| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 |
| 37 namespace ash { | 42 namespace ash { |
| 38 namespace test { | 43 namespace test { |
| 39 | 44 |
| 40 namespace { | 45 namespace { |
| 41 | 46 |
| 42 static const char kTestAccountId[] = "testuser@test.com"; | 47 static const char kTestAccountId[] = "testuser@test.com"; |
| 43 | 48 |
| 44 // Notification ID corresponding to kProfileSigninNotificationId + | 49 // Notification ID corresponding to kProfileSigninNotificationId + |
| 45 // kTestAccountId. | 50 // kTestAccountId. |
| 46 static const std::string kNotificationId = | 51 static const std::string kNotificationId = |
| 47 "chrome://settings/signin/testuser@test.com"; | 52 "chrome://settings/signin/testuser@test.com"; |
| 48 } | 53 } |
| 49 | 54 |
| 50 class SigninErrorNotifierTest : public AshTestBase { | 55 class SigninErrorNotifierTest : public AshTestBase { |
| 51 public: | 56 public: |
| 52 void SetUp() override { | 57 void SetUp() override { |
| 53 // Create a signed-in profile. | 58 // Create a signed-in profile. |
| 54 TestingProfile::Builder builder; | 59 TestingProfile::Builder builder; |
| 55 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 60 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
| 56 BuildFakeSigninManagerBase); | 61 BuildFakeSigninManagerBase); |
| 57 profile_ = builder.Build(); | 62 profile_ = builder.Build(); |
| 58 profile_->set_profile_name(kTestAccountId); | 63 profile_->set_profile_name(kTestAccountId); |
| 59 | 64 |
| 60 profile_manager_.reset( | 65 profile_manager_.reset( |
| 61 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 66 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 62 ASSERT_TRUE(profile_manager_->SetUp()); | 67 ASSERT_TRUE(profile_manager_->SetUp()); |
| 63 | 68 |
| 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 |
| 64 TestingBrowserProcess::GetGlobal(); | 75 TestingBrowserProcess::GetGlobal(); |
| 65 AshTestBase::SetUp(); | 76 AshTestBase::SetUp(); |
| 66 | 77 |
| 67 // Set up screen for Windows. | 78 // Set up screen for Windows. |
| 68 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
| 69 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); | 80 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); |
| 70 display::Screen::SetScreenInstance(test_screen_.get()); | 81 display::Screen::SetScreenInstance(test_screen_.get()); |
| 71 #endif | 82 #endif |
| 72 | 83 |
| 73 error_controller_ = SigninErrorControllerFactory::GetForProfile( | 84 error_controller_ = SigninErrorControllerFactory::GetForProfile( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 *message = notification->message(); | 107 *message = notification->message(); |
| 97 } | 108 } |
| 98 | 109 |
| 99 #if defined(OS_WIN) | 110 #if defined(OS_WIN) |
| 100 std::unique_ptr<display::Screen> test_screen_; | 111 std::unique_ptr<display::Screen> test_screen_; |
| 101 #endif | 112 #endif |
| 102 std::unique_ptr<TestingProfileManager> profile_manager_; | 113 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 103 std::unique_ptr<TestingProfile> profile_; | 114 std::unique_ptr<TestingProfile> profile_; |
| 104 SigninErrorController* error_controller_; | 115 SigninErrorController* error_controller_; |
| 105 NotificationUIManager* notification_ui_manager_; | 116 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 |
| 106 }; | 121 }; |
| 107 | 122 |
| 108 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { | 123 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { |
| 109 ASSERT_FALSE(notification_ui_manager_->FindById( | 124 ASSERT_FALSE(notification_ui_manager_->FindById( |
| 110 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); | 125 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); |
| 111 { | 126 { |
| 112 // Add a provider (removes itself on exiting this scope). | 127 // Add a provider (removes itself on exiting this scope). |
| 113 FakeAuthStatusProvider provider(error_controller_); | 128 FakeAuthStatusProvider provider(error_controller_); |
| 114 ASSERT_FALSE(notification_ui_manager_->FindById( | 129 ASSERT_FALSE(notification_ui_manager_->FindById( |
| 115 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); | 130 kNotificationId, NotificationUIManager::GetProfileID(profile_.get()))); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 EXPECT_FALSE(notification->title().empty()); | 247 EXPECT_FALSE(notification->title().empty()); |
| 233 EXPECT_FALSE(notification->message().empty()); | 248 EXPECT_FALSE(notification->message().empty()); |
| 234 EXPECT_EQ((size_t)1, notification->buttons().size()); | 249 EXPECT_EQ((size_t)1, notification->buttons().size()); |
| 235 } | 250 } |
| 236 } | 251 } |
| 237 } | 252 } |
| 238 #endif | 253 #endif |
| 239 | 254 |
| 240 } // namespace test | 255 } // namespace test |
| 241 } // namespace ash | 256 } // namespace ash |
| OLD | NEW |