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/sync/sync_error_notifier_ash.h" | 5 #include "chrome/browser/sync/sync_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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Notification ID corresponding to kProfileSyncNotificationId + kTestAccountId. | 44 // Notification ID corresponding to kProfileSyncNotificationId + kTestAccountId. |
45 static const std::string kNotificationId = | 45 static const std::string kNotificationId = |
46 "chrome://settings/sync/testuser@test.com"; | 46 "chrome://settings/sync/testuser@test.com"; |
47 | 47 |
48 #if defined(OS_WIN) | 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 ~ScreenTypeDelegateDesktop() {} | 52 virtual ~ScreenTypeDelegateDesktop() {} |
53 virtual gfx::ScreenType GetScreenTypeForNativeView( | 53 virtual gfx::ScreenType GetScreenTypeForNativeView( |
54 gfx::NativeView view) OVERRIDE { | 54 gfx::NativeView view) override { |
55 return chrome::IsNativeViewInAsh(view) ? | 55 return chrome::IsNativeViewInAsh(view) ? |
56 gfx::SCREEN_TYPE_ALTERNATE : | 56 gfx::SCREEN_TYPE_ALTERNATE : |
57 gfx::SCREEN_TYPE_NATIVE; | 57 gfx::SCREEN_TYPE_NATIVE; |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop); | 61 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop); |
62 }; | 62 }; |
63 #endif | 63 #endif |
64 | 64 |
65 class FakeLoginUIService: public LoginUIService { | 65 class FakeLoginUIService: public LoginUIService { |
66 public: | 66 public: |
67 FakeLoginUIService() : LoginUIService(NULL) {} | 67 FakeLoginUIService() : LoginUIService(NULL) {} |
68 virtual ~FakeLoginUIService() {} | 68 virtual ~FakeLoginUIService() {} |
69 }; | 69 }; |
70 | 70 |
71 class FakeLoginUI : public LoginUIService::LoginUI { | 71 class FakeLoginUI : public LoginUIService::LoginUI { |
72 public: | 72 public: |
73 FakeLoginUI() : focus_ui_call_count_(0) {} | 73 FakeLoginUI() : focus_ui_call_count_(0) {} |
74 | 74 |
75 virtual ~FakeLoginUI() {} | 75 virtual ~FakeLoginUI() {} |
76 | 76 |
77 int focus_ui_call_count() const { return focus_ui_call_count_; } | 77 int focus_ui_call_count() const { return focus_ui_call_count_; } |
78 | 78 |
79 private: | 79 private: |
80 // LoginUIService::LoginUI: | 80 // LoginUIService::LoginUI: |
81 virtual void FocusUI() OVERRIDE { | 81 virtual void FocusUI() override { |
82 ++focus_ui_call_count_; | 82 ++focus_ui_call_count_; |
83 } | 83 } |
84 virtual void CloseUI() OVERRIDE {} | 84 virtual void CloseUI() override {} |
85 | 85 |
86 int focus_ui_call_count_; | 86 int focus_ui_call_count_; |
87 }; | 87 }; |
88 | 88 |
89 KeyedService* BuildMockLoginUIService( | 89 KeyedService* BuildMockLoginUIService( |
90 content::BrowserContext* profile) { | 90 content::BrowserContext* profile) { |
91 return new FakeLoginUIService(); | 91 return new FakeLoginUIService(); |
92 } | 92 } |
93 | 93 |
94 class SyncErrorNotifierTest : public AshTestBase { | 94 class SyncErrorNotifierTest : public AshTestBase { |
95 public: | 95 public: |
96 SyncErrorNotifierTest() {} | 96 SyncErrorNotifierTest() {} |
97 virtual ~SyncErrorNotifierTest() {} | 97 virtual ~SyncErrorNotifierTest() {} |
98 | 98 |
99 virtual void SetUp() OVERRIDE { | 99 virtual void SetUp() override { |
100 profile_manager_.reset( | 100 profile_manager_.reset( |
101 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 101 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
102 ASSERT_TRUE(profile_manager_->SetUp()); | 102 ASSERT_TRUE(profile_manager_->SetUp()); |
103 | 103 |
104 profile_ = profile_manager_->CreateTestingProfile(kTestAccountId); | 104 profile_ = profile_manager_->CreateTestingProfile(kTestAccountId); |
105 | 105 |
106 TestingBrowserProcess::GetGlobal(); | 106 TestingBrowserProcess::GetGlobal(); |
107 AshTestBase::SetUp(); | 107 AshTestBase::SetUp(); |
108 | 108 |
109 // Set up a desktop screen for Windows to hold native widgets, used when | 109 // Set up a desktop screen for Windows to hold native widgets, used when |
(...skipping 11 matching lines...) Expand all Loading... |
121 profile_, BuildMockLoginUIService)); | 121 profile_, BuildMockLoginUIService)); |
122 login_ui_service->SetLoginUI(&login_ui_); | 122 login_ui_service->SetLoginUI(&login_ui_); |
123 | 123 |
124 error_controller_.reset(new SyncErrorController(service_.get())); | 124 error_controller_.reset(new SyncErrorController(service_.get())); |
125 error_notifier_.reset(new SyncErrorNotifier(error_controller_.get(), | 125 error_notifier_.reset(new SyncErrorNotifier(error_controller_.get(), |
126 profile_)); | 126 profile_)); |
127 | 127 |
128 notification_ui_manager_ = g_browser_process->notification_ui_manager(); | 128 notification_ui_manager_ = g_browser_process->notification_ui_manager(); |
129 } | 129 } |
130 | 130 |
131 virtual void TearDown() OVERRIDE { | 131 virtual void TearDown() override { |
132 error_notifier_->Shutdown(); | 132 error_notifier_->Shutdown(); |
133 service_.reset(); | 133 service_.reset(); |
134 #if defined(OS_WIN) | 134 #if defined(OS_WIN) |
135 test_screen_.reset(); | 135 test_screen_.reset(); |
136 #endif | 136 #endif |
137 profile_manager_.reset(); | 137 profile_manager_.reset(); |
138 | 138 |
139 AshTestBase::TearDown(); | 139 AshTestBase::TearDown(); |
140 } | 140 } |
141 | 141 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 SCOPED_TRACE("Not expecting notification since sync setup is incomplete"); | 232 SCOPED_TRACE("Not expecting notification since sync setup is incomplete"); |
233 VerifySyncErrorNotifierResult( | 233 VerifySyncErrorNotifierResult( |
234 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, | 234 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
235 false /* not signed in */, | 235 false /* not signed in */, |
236 false /* no error */); | 236 false /* no error */); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 } // namespace test | 240 } // namespace test |
241 } // namespace ash | 241 } // namespace ash |
OLD | NEW |