Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/browser/signin/signin_error_notifier_ash_unittest.cc

Issue 1962463002: Revert of GetAccountIdFromProfile() should not return an empty account id if a valid profile is provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/signin/signin_error_notifier_ash.h" 5 #include "chrome/browser/signin/signin_error_notifier_ash.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "content/public/test/test_browser_thread_bundle.h" 27 #include "content/public/test/test_browser_thread_bundle.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "ui/message_center/notification.h" 29 #include "ui/message_center/notification.h"
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include "chrome/browser/ui/ash/ash_util.h" 32 #include "chrome/browser/ui/ash/ash_util.h"
33 #include "ui/aura/test/test_screen.h" 33 #include "ui/aura/test/test_screen.h"
34 #include "ui/display/screen.h" 34 #include "ui/display/screen.h"
35 #endif 35 #endif
36 36
37 #if defined(OS_CHROMEOS)
38 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
39 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
40 #endif
41
42 namespace ash { 37 namespace ash {
43 namespace test { 38 namespace test {
44 39
45 namespace { 40 namespace {
46 41
47 static const char kTestAccountId[] = "testuser@test.com"; 42 static const char kTestAccountId[] = "testuser@test.com";
48 43
49 // Notification ID corresponding to kProfileSigninNotificationId + 44 // Notification ID corresponding to kProfileSigninNotificationId +
50 // kTestAccountId. 45 // kTestAccountId.
51 static const std::string kNotificationId = 46 static const std::string kNotificationId =
52 "chrome://settings/signin/testuser@test.com"; 47 "chrome://settings/signin/testuser@test.com";
53 } 48 }
54 49
55 class SigninErrorNotifierTest : public AshTestBase { 50 class SigninErrorNotifierTest : public AshTestBase {
56 public: 51 public:
57 void SetUp() override { 52 void SetUp() override {
58 // Create a signed-in profile. 53 // Create a signed-in profile.
59 TestingProfile::Builder builder; 54 TestingProfile::Builder builder;
60 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), 55 builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
61 BuildFakeSigninManagerBase); 56 BuildFakeSigninManagerBase);
62 profile_ = builder.Build(); 57 profile_ = builder.Build();
63 profile_->set_profile_name(kTestAccountId); 58 profile_->set_profile_name(kTestAccountId);
64 59
65 profile_manager_.reset( 60 profile_manager_.reset(
66 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 61 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
67 ASSERT_TRUE(profile_manager_->SetUp()); 62 ASSERT_TRUE(profile_manager_->SetUp());
68 63
69 #if defined(OS_CHROMEOS)
70 mock_user_manager_ = new chromeos::MockUserManager();
71 user_manager_enabler_.reset(
72 new chromeos::ScopedUserManagerEnabler(mock_user_manager_));
73 #endif
74
75 TestingBrowserProcess::GetGlobal(); 64 TestingBrowserProcess::GetGlobal();
76 AshTestBase::SetUp(); 65 AshTestBase::SetUp();
77 66
78 // Set up screen for Windows. 67 // Set up screen for Windows.
79 #if defined(OS_WIN) 68 #if defined(OS_WIN)
80 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); 69 test_screen_.reset(aura::TestScreen::Create(gfx::Size()));
81 display::Screen::SetScreenInstance(test_screen_.get()); 70 display::Screen::SetScreenInstance(test_screen_.get());
82 #endif 71 #endif
83 72
84 error_controller_ = SigninErrorControllerFactory::GetForProfile( 73 error_controller_ = SigninErrorControllerFactory::GetForProfile(
(...skipping 22 matching lines...) Expand all
107 *message = notification->message(); 96 *message = notification->message();
108 } 97 }
109 98
110 #if defined(OS_WIN) 99 #if defined(OS_WIN)
111 std::unique_ptr<display::Screen> test_screen_; 100 std::unique_ptr<display::Screen> test_screen_;
112 #endif 101 #endif
113 std::unique_ptr<TestingProfileManager> profile_manager_; 102 std::unique_ptr<TestingProfileManager> profile_manager_;
114 std::unique_ptr<TestingProfile> profile_; 103 std::unique_ptr<TestingProfile> profile_;
115 SigninErrorController* error_controller_; 104 SigninErrorController* error_controller_;
116 NotificationUIManager* notification_ui_manager_; 105 NotificationUIManager* notification_ui_manager_;
117 #if defined(OS_CHROMEOS)
118 chromeos::MockUserManager* mock_user_manager_; // Not owned.
119 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
120 #endif
121 }; 106 };
122 107
123 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { 108 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) {
124 ASSERT_FALSE(notification_ui_manager_->FindById( 109 ASSERT_FALSE(notification_ui_manager_->FindById(
125 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 110 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
126 { 111 {
127 // Add a provider (removes itself on exiting this scope). 112 // Add a provider (removes itself on exiting this scope).
128 FakeAuthStatusProvider provider(error_controller_); 113 FakeAuthStatusProvider provider(error_controller_);
129 ASSERT_FALSE(notification_ui_manager_->FindById( 114 ASSERT_FALSE(notification_ui_manager_->FindById(
130 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); 115 kNotificationId, NotificationUIManager::GetProfileID(profile_.get())));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 EXPECT_FALSE(notification->title().empty()); 232 EXPECT_FALSE(notification->title().empty());
248 EXPECT_FALSE(notification->message().empty()); 233 EXPECT_FALSE(notification->message().empty());
249 EXPECT_EQ((size_t)1, notification->buttons().size()); 234 EXPECT_EQ((size_t)1, notification->buttons().size());
250 } 235 }
251 } 236 }
252 } 237 }
253 #endif 238 #endif
254 239
255 } // namespace test 240 } // namespace test
256 } // namespace ash 241 } // namespace ash
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/profiles/profile_helper.h ('k') | chrome/browser/sync/sync_error_notifier_ash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698