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" |
11 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
12 #include "chrome/browser/signin/fake_signin_manager.h" | 12 #include "chrome/browser/signin/fake_signin_manager.h" |
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
14 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" | 14 #include "chrome/browser/signin/signin_error_notifier_factory_ash.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "chrome/test/base/testing_profile_manager.h" | 18 #include "chrome/test/base/testing_profile_manager.h" |
19 #include "components/signin/core/browser/fake_auth_status_provider.h" | 19 #include "components/signin/core/browser/fake_auth_status_provider.h" |
20 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 20 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
21 #include "components/signin/core/browser/signin_error_controller.h" | 21 #include "components/signin/core/browser/signin_error_controller.h" |
22 #include "components/signin/core/browser/signin_manager.h" | 22 #include "components/signin/core/browser/signin_manager.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/message_center/notification.h" | 25 #include "ui/message_center/notification.h" |
26 | 26 |
27 #if !defined(OS_CHROMEOS) | 27 #if defined(OS_WIN) |
28 #include "chrome/browser/ui/ash/ash_util.h" | 28 #include "chrome/browser/ui/ash/ash_util.h" |
29 #include "ui/aura/test/test_screen.h" | 29 #include "ui/aura/test/test_screen.h" |
30 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
31 #include "ui/gfx/screen_type_delegate.h" | 31 #include "ui/gfx/screen_type_delegate.h" |
32 #endif | 32 #endif |
33 | 33 |
34 namespace ash { | 34 namespace ash { |
35 namespace test { | 35 namespace test { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 static const char kTestAccountId[] = "testuser@test.com"; | 39 static const char kTestAccountId[] = "testuser@test.com"; |
40 static const char kTestUsername[] = "testuser@test.com"; | 40 static const char kTestUsername[] = "testuser@test.com"; |
41 | 41 |
42 // Notification ID corresponding to kProfileSigninNotificationId + | 42 // Notification ID corresponding to kProfileSigninNotificationId + |
43 // kTestAccountId. | 43 // kTestAccountId. |
44 static const std::string kNotificationId = | 44 static const std::string kNotificationId = |
45 "chrome://settings/signin/testuser@test.com"; | 45 "chrome://settings/signin/testuser@test.com"; |
46 } | 46 } |
47 | 47 |
48 #if !defined(OS_CHROMEOS) | 48 #if defined(OS_WIN) |
49 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { | 49 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { |
50 public: | 50 public: |
51 ScreenTypeDelegateDesktop() {} | 51 ScreenTypeDelegateDesktop() {} |
52 virtual gfx::ScreenType GetScreenTypeForNativeView( | 52 virtual gfx::ScreenType GetScreenTypeForNativeView( |
53 gfx::NativeView view) OVERRIDE { | 53 gfx::NativeView view) OVERRIDE { |
54 return chrome::IsNativeViewInAsh(view) ? | 54 return chrome::IsNativeViewInAsh(view) ? |
55 gfx::SCREEN_TYPE_ALTERNATE : | 55 gfx::SCREEN_TYPE_ALTERNATE : |
56 gfx::SCREEN_TYPE_NATIVE; | 56 gfx::SCREEN_TYPE_NATIVE; |
57 } | 57 } |
58 private: | 58 private: |
(...skipping 13 matching lines...) Expand all Loading... |
72 | 72 |
73 profile_manager_.reset( | 73 profile_manager_.reset( |
74 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 74 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
75 ASSERT_TRUE(profile_manager_->SetUp()); | 75 ASSERT_TRUE(profile_manager_->SetUp()); |
76 | 76 |
77 TestingBrowserProcess::GetGlobal(); | 77 TestingBrowserProcess::GetGlobal(); |
78 AshTestBase::SetUp(); | 78 AshTestBase::SetUp(); |
79 | 79 |
80 // Set up screen for Windows. | 80 // Set up screen for Windows. |
81 #if defined(OS_WIN) | 81 #if defined(OS_WIN) |
82 aura::TestScreen* test_screen = aura::TestScreen::Create(gfx::Size()); | 82 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); |
83 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen); | 83 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
84 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop); | 84 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop); |
85 #endif | 85 #endif |
86 | 86 |
87 error_controller_ = | 87 error_controller_ = |
88 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())-> | 88 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())-> |
89 signin_error_controller(); | 89 signin_error_controller(); |
90 SigninErrorNotifierFactory::GetForProfile(profile_.get()); | 90 SigninErrorNotifierFactory::GetForProfile(profile_.get()); |
91 notification_ui_manager_ = g_browser_process->notification_ui_manager(); | 91 notification_ui_manager_ = g_browser_process->notification_ui_manager(); |
92 } | 92 } |
93 | 93 |
94 virtual void TearDown() OVERRIDE { | 94 virtual void TearDown() OVERRIDE { |
| 95 #if defined(OS_WIN) |
| 96 test_screen_.reset(); |
| 97 #endif |
95 profile_manager_.reset(); | 98 profile_manager_.reset(); |
96 | 99 |
97 AshTestBase::TearDown(); | 100 AshTestBase::TearDown(); |
98 } | 101 } |
99 | 102 |
100 protected: | 103 protected: |
101 void GetMessage(base::string16* message) { | 104 void GetMessage(base::string16* message) { |
102 const Notification* notification = | 105 const Notification* notification = |
103 g_browser_process->notification_ui_manager()->FindById(kNotificationId); | 106 g_browser_process->notification_ui_manager()->FindById(kNotificationId); |
104 ASSERT_FALSE(notification == NULL); | 107 ASSERT_FALSE(notification == NULL); |
105 *message = notification->message(); | 108 *message = notification->message(); |
106 } | 109 } |
107 | 110 |
| 111 #if defined(OS_WIN) |
| 112 scoped_ptr<gfx::Screen> test_screen_; |
| 113 #endif |
108 scoped_ptr<TestingProfileManager> profile_manager_; | 114 scoped_ptr<TestingProfileManager> profile_manager_; |
109 scoped_ptr<TestingProfile> profile_; | 115 scoped_ptr<TestingProfile> profile_; |
110 SigninErrorController* error_controller_; | 116 SigninErrorController* error_controller_; |
111 NotificationUIManager* notification_ui_manager_; | 117 NotificationUIManager* notification_ui_manager_; |
112 }; | 118 }; |
113 | 119 |
114 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { | 120 TEST_F(SigninErrorNotifierTest, NoErrorAuthStatusProviders) { |
115 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); | 121 ASSERT_FALSE(notification_ui_manager_->FindById(kNotificationId)); |
116 { | 122 { |
117 // Add a provider (removes itself on exiting this scope). | 123 // Add a provider (removes itself on exiting this scope). |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 EXPECT_FALSE(notification->title().empty()); | 237 EXPECT_FALSE(notification->title().empty()); |
232 EXPECT_FALSE(notification->message().empty()); | 238 EXPECT_FALSE(notification->message().empty()); |
233 EXPECT_EQ((size_t)1, notification->buttons().size()); | 239 EXPECT_EQ((size_t)1, notification->buttons().size()); |
234 } | 240 } |
235 } | 241 } |
236 } | 242 } |
237 #endif | 243 #endif |
238 | 244 |
239 } // namespace test | 245 } // namespace test |
240 } // namespace ash | 246 } // namespace ash |
OLD | NEW |