Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "ui/message_center/notification.h" | 28 #include "ui/message_center/notification.h" |
| 29 | 29 |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 #include "chrome/browser/ui/ash/ash_util.h" | 31 #include "chrome/browser/ui/ash/ash_util.h" |
| 32 #include "ui/aura/test/test_screen.h" | 32 #include "ui/aura/test/test_screen.h" |
| 33 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if defined(OS_CHROMEOS) | |
| 37 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | |
| 38 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | |
| 39 #endif | |
| 40 | |
| 36 namespace ash { | 41 namespace ash { |
| 37 namespace test { | 42 namespace test { |
| 38 | 43 |
| 39 namespace { | 44 namespace { |
| 40 | 45 |
| 41 static const char kTestAccountId[] = "testuser@test.com"; | 46 static const char kTestAccountId[] = "testuser@test.com"; |
| 42 | 47 |
| 43 // Notification ID corresponding to kProfileSigninNotificationId + | 48 // Notification ID corresponding to kProfileSigninNotificationId + |
| 44 // kTestAccountId. | 49 // kTestAccountId. |
| 45 static const std::string kNotificationId = | 50 static const std::string kNotificationId = |
| 46 "chrome://settings/signin/testuser@test.com"; | 51 "chrome://settings/signin/testuser@test.com"; |
| 47 } | 52 } |
| 48 | 53 |
| 49 class SigninErrorNotifierTest : public AshTestBase { | 54 class SigninErrorNotifierTest : public AshTestBase { |
| 50 public: | 55 public: |
| 51 void SetUp() override { | 56 void SetUp() override { |
| 52 // Create a signed-in profile. | 57 // Create a signed-in profile. |
| 53 TestingProfile::Builder builder; | 58 TestingProfile::Builder builder; |
| 54 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 59 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
| 55 BuildFakeSigninManagerBase); | 60 BuildFakeSigninManagerBase); |
| 56 profile_ = builder.Build(); | 61 profile_ = builder.Build(); |
| 57 profile_->set_profile_name(kTestAccountId); | 62 profile_->set_profile_name(kTestAccountId); |
| 58 | 63 |
| 59 profile_manager_.reset( | 64 profile_manager_.reset( |
| 60 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 65 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 61 ASSERT_TRUE(profile_manager_->SetUp()); | 66 ASSERT_TRUE(profile_manager_->SetUp()); |
| 62 | 67 |
| 68 #if defined(OS_CHROMEOS) | |
| 69 mock_user_manager_ = new chromeos::MockUserManager(); | |
| 70 user_manager_enabler_.reset( | |
| 71 new chromeos::ScopedUserManagerEnabler(mock_user_manager_)); | |
| 72 #endif | |
| 73 | |
| 63 TestingBrowserProcess::GetGlobal(); | 74 TestingBrowserProcess::GetGlobal(); |
| 64 AshTestBase::SetUp(); | 75 AshTestBase::SetUp(); |
| 65 | 76 |
| 66 // Set up screen for Windows. | 77 // Set up screen for Windows. |
| 67 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
| 68 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); | 79 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); |
| 69 gfx::Screen::SetScreenInstance(test_screen_.get()); | 80 gfx::Screen::SetScreenInstance(test_screen_.get()); |
| 70 #endif | 81 #endif |
| 71 | 82 |
| 72 error_controller_ = SigninErrorControllerFactory::GetForProfile( | 83 error_controller_ = SigninErrorControllerFactory::GetForProfile( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 95 *message = notification->message(); | 106 *message = notification->message(); |
| 96 } | 107 } |
| 97 | 108 |
| 98 #if defined(OS_WIN) | 109 #if defined(OS_WIN) |
| 99 scoped_ptr<gfx::Screen> test_screen_; | 110 scoped_ptr<gfx::Screen> test_screen_; |
| 100 #endif | 111 #endif |
| 101 scoped_ptr<TestingProfileManager> profile_manager_; | 112 scoped_ptr<TestingProfileManager> profile_manager_; |
| 102 scoped_ptr<TestingProfile> profile_; | 113 scoped_ptr<TestingProfile> profile_; |
| 103 SigninErrorController* error_controller_; | 114 SigninErrorController* error_controller_; |
| 104 NotificationUIManager* notification_ui_manager_; | 115 NotificationUIManager* notification_ui_manager_; |
| 116 #if defined(OS_CHROMEOS) | |
| 117 chromeos::MockUserManager* mock_user_manager_; | |
|
Mr4D (OOO till 08-26)
2016/04/14 17:44:25
You might want to add a comment that this is owned
| |
| 118 scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; | |
| 119 #endif | |
| 105 }; | 120 }; |
| 106 | 121 |
| 107 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { | 122 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { |
| 108 ASSERT_FALSE(notification_ui_manager_->FindById( | 123 ASSERT_FALSE(notification_ui_manager_->FindById( |
| 109 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); | 124 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); |
| 110 { | 125 { |
| 111 // Add a provider (removes itself on exiting this scope). | 126 // Add a provider (removes itself on exiting this scope). |
| 112 FakeAuthStatusProvider provider(error_controller_); | 127 FakeAuthStatusProvider provider(error_controller_); |
| 113 ASSERT_FALSE(notification_ui_manager_->FindById( | 128 ASSERT_FALSE(notification_ui_manager_->FindById( |
| 114 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); | 129 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 EXPECT_FALSE(notification->title().empty()); | 246 EXPECT_FALSE(notification->title().empty()); |
| 232 EXPECT_FALSE(notification->message().empty()); | 247 EXPECT_FALSE(notification->message().empty()); |
| 233 EXPECT_EQ((size_t)1, notification->buttons().size()); | 248 EXPECT_EQ((size_t)1, notification->buttons().size()); |
| 234 } | 249 } |
| 235 } | 250 } |
| 236 } | 251 } |
| 237 #endif | 252 #endif |
| 238 | 253 |
| 239 } // namespace test | 254 } // namespace test |
| 240 } // namespace ash | 255 } // namespace ash |
| OLD | NEW |