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 "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 73 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
74 ASSERT_TRUE(profile_manager_->SetUp()); | 74 ASSERT_TRUE(profile_manager_->SetUp()); |
75 | 75 |
76 TestingBrowserProcess::GetGlobal(); | 76 TestingBrowserProcess::GetGlobal(); |
77 AshTestBase::SetUp(); | 77 AshTestBase::SetUp(); |
78 | 78 |
79 // Set up screen for Windows. | 79 // Set up screen for Windows. |
80 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
81 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); | 81 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); |
82 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 82 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
83 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop); | 83 gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_); |
84 #endif | 84 #endif |
85 | 85 |
86 error_controller_ = SigninErrorControllerFactory::GetForProfile( | 86 error_controller_ = SigninErrorControllerFactory::GetForProfile( |
87 profile_.get()); | 87 profile_.get()); |
88 SigninErrorNotifierFactory::GetForProfile(profile_.get()); | 88 SigninErrorNotifierFactory::GetForProfile(profile_.get()); |
89 notification_ui_manager_ = g_browser_process->notification_ui_manager(); | 89 notification_ui_manager_ = g_browser_process->notification_ui_manager(); |
90 } | 90 } |
91 | 91 |
92 void TearDown() override { | 92 void TearDown() override { |
93 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 94 gfx::Screen::SetScreenTypeDelegate(nullptr); |
| 95 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); |
94 test_screen_.reset(); | 96 test_screen_.reset(); |
95 #endif | 97 #endif |
96 profile_manager_.reset(); | 98 profile_manager_.reset(); |
97 | 99 |
98 AshTestBase::TearDown(); | 100 AshTestBase::TearDown(); |
99 } | 101 } |
100 | 102 |
101 protected: | 103 protected: |
102 void GetMessage(base::string16* message) { | 104 void GetMessage(base::string16* message) { |
103 const Notification* notification = | 105 const Notification* notification = |
104 g_browser_process->notification_ui_manager()->FindById( | 106 g_browser_process->notification_ui_manager()->FindById( |
105 kNotificationId, | 107 kNotificationId, |
106 NotificationUIManager::GetProfileID(profile_.get())); | 108 NotificationUIManager::GetProfileID(profile_.get())); |
107 ASSERT_FALSE(notification == NULL); | 109 ASSERT_FALSE(notification == NULL); |
108 *message = notification->message(); | 110 *message = notification->message(); |
109 } | 111 } |
110 | 112 |
111 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
| 114 ScreenTypeDelegateDesktop screen_type_delegate_; |
112 scoped_ptr<gfx::Screen> test_screen_; | 115 scoped_ptr<gfx::Screen> test_screen_; |
113 #endif | 116 #endif |
114 scoped_ptr<TestingProfileManager> profile_manager_; | 117 scoped_ptr<TestingProfileManager> profile_manager_; |
115 scoped_ptr<TestingProfile> profile_; | 118 scoped_ptr<TestingProfile> profile_; |
116 SigninErrorController* error_controller_; | 119 SigninErrorController* error_controller_; |
117 NotificationUIManager* notification_ui_manager_; | 120 NotificationUIManager* notification_ui_manager_; |
118 }; | 121 }; |
119 | 122 |
120 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { | 123 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { |
121 ASSERT_FALSE(notification_ui_manager_->FindById( | 124 ASSERT_FALSE(notification_ui_manager_->FindById( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 EXPECT_FALSE(notification->title().empty()); | 252 EXPECT_FALSE(notification->title().empty()); |
250 EXPECT_FALSE(notification->message().empty()); | 253 EXPECT_FALSE(notification->message().empty()); |
251 EXPECT_EQ((size_t)1, notification->buttons().size()); | 254 EXPECT_EQ((size_t)1, notification->buttons().size()); |
252 } | 255 } |
253 } | 256 } |
254 } | 257 } |
255 #endif | 258 #endif |
256 | 259 |
257 } // namespace test | 260 } // namespace test |
258 } // namespace ash | 261 } // namespace ash |
OLD | NEW |