Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: chrome/browser/sync/sync_error_notifier_ash_unittest.cc

Issue 1608733002: Remove ui/gfx/screen_type_delegate.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-4
Patch Set: and another rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <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 12 matching lines...) Expand all
23 #include "components/browser_sync/browser/profile_sync_service_mock.h" 23 #include "components/browser_sync/browser/profile_sync_service_mock.h"
24 #include "components/sync_driver/sync_error_controller.h" 24 #include "components/sync_driver/sync_error_controller.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/message_center/notification.h" 27 #include "ui/message_center/notification.h"
28 28
29 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 #include "chrome/browser/ui/ash/ash_util.h" 30 #include "chrome/browser/ui/ash/ash_util.h"
31 #include "ui/aura/test/test_screen.h" 31 #include "ui/aura/test/test_screen.h"
32 #include "ui/gfx/screen.h" 32 #include "ui/gfx/screen.h"
33 #include "ui/gfx/screen_type_delegate.h"
34 #endif 33 #endif
35 34
36 using ::testing::NiceMock; 35 using ::testing::NiceMock;
37 using ::testing::Return; 36 using ::testing::Return;
38 using ::testing::ReturnRef; 37 using ::testing::ReturnRef;
39 using ::testing::_; 38 using ::testing::_;
40 39
41 namespace ash { 40 namespace ash {
42 namespace test { 41 namespace test {
43 42
44 namespace { 43 namespace {
45 44
46 static const char kTestAccountId[] = "testuser@test.com"; 45 static const char kTestAccountId[] = "testuser@test.com";
47 46
48 // Notification ID corresponding to kProfileSyncNotificationId + kTestAccountId. 47 // Notification ID corresponding to kProfileSyncNotificationId + kTestAccountId.
49 static const std::string kNotificationId = 48 static const std::string kNotificationId =
50 "chrome://settings/sync/testuser@test.com"; 49 "chrome://settings/sync/testuser@test.com";
51 50
52 #if defined(OS_WIN)
53 class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate {
54 public:
55 ScreenTypeDelegateDesktop() {}
56 ~ScreenTypeDelegateDesktop() override {}
57 gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override {
58 return chrome::IsNativeViewInAsh(view) ?
59 gfx::SCREEN_TYPE_ALTERNATE :
60 gfx::SCREEN_TYPE_NATIVE;
61 }
62
63 private:
64 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop);
65 };
66 #endif
67
68 class FakeLoginUIService: public LoginUIService { 51 class FakeLoginUIService: public LoginUIService {
69 public: 52 public:
70 FakeLoginUIService() : LoginUIService(NULL) {} 53 FakeLoginUIService() : LoginUIService(NULL) {}
71 ~FakeLoginUIService() override {} 54 ~FakeLoginUIService() override {}
72 }; 55 };
73 56
74 class FakeLoginUI : public LoginUIService::LoginUI { 57 class FakeLoginUI : public LoginUIService::LoginUI {
75 public: 58 public:
76 FakeLoginUI() : focus_ui_call_count_(0) {} 59 FakeLoginUI() : focus_ui_call_count_(0) {}
77 60
(...skipping 19 matching lines...) Expand all
97 SyncErrorNotifierTest() {} 80 SyncErrorNotifierTest() {}
98 ~SyncErrorNotifierTest() override {} 81 ~SyncErrorNotifierTest() override {}
99 82
100 void SetUp() override { 83 void SetUp() override {
101 DCHECK(TestingBrowserProcess::GetGlobal()); 84 DCHECK(TestingBrowserProcess::GetGlobal());
102 85
103 // Set up a desktop screen for Windows to hold native widgets, used when 86 // Set up a desktop screen for Windows to hold native widgets, used when
104 // adding desktop widgets (i.e., message center notifications). 87 // adding desktop widgets (i.e., message center notifications).
105 #if defined(OS_WIN) 88 #if defined(OS_WIN)
106 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); 89 test_screen_.reset(aura::TestScreen::Create(gfx::Size()));
107 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); 90 gfx::Screen::SetScreenInstance(test_screen_.get());
108 gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_);
109 #endif 91 #endif
110 92
111 AshTestBase::SetUp(); 93 AshTestBase::SetUp();
112 94
113 profile_manager_.reset( 95 profile_manager_.reset(
114 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 96 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
115 ASSERT_TRUE(profile_manager_->SetUp()); 97 ASSERT_TRUE(profile_manager_->SetUp());
116 98
117 profile_ = profile_manager_->CreateTestingProfile(kTestAccountId); 99 profile_ = profile_manager_->CreateTestingProfile(kTestAccountId);
118 100
(...skipping 13 matching lines...) Expand all
132 } 114 }
133 115
134 void TearDown() override { 116 void TearDown() override {
135 error_notifier_->Shutdown(); 117 error_notifier_->Shutdown();
136 service_.reset(); 118 service_.reset();
137 profile_manager_.reset(); 119 profile_manager_.reset();
138 120
139 AshTestBase::TearDown(); 121 AshTestBase::TearDown();
140 122
141 #if defined(OS_WIN) 123 #if defined(OS_WIN)
142 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); 124 gfx::Screen::SetScreenInstance(nullptr);
143 gfx::Screen::SetScreenTypeDelegate(nullptr);
144 test_screen_.reset(); 125 test_screen_.reset();
145 #endif 126 #endif
146 127
147 } 128 }
148 129
149 protected: 130 protected:
150 // Utility function to test that SyncErrorNotifier behaves correctly for the 131 // Utility function to test that SyncErrorNotifier behaves correctly for the
151 // given error condition. 132 // given error condition.
152 void VerifySyncErrorNotifierResult(GoogleServiceAuthError::State error_state, 133 void VerifySyncErrorNotifierResult(GoogleServiceAuthError::State error_state,
153 bool is_signed_in, 134 bool is_signed_in,
(...skipping 15 matching lines...) Expand all
169 ASSERT_TRUE(notification); 150 ASSERT_TRUE(notification);
170 ASSERT_FALSE(notification->title().empty()); 151 ASSERT_FALSE(notification->title().empty());
171 ASSERT_FALSE(notification->title().empty()); 152 ASSERT_FALSE(notification->title().empty());
172 ASSERT_EQ((size_t)1, notification->buttons().size()); 153 ASSERT_EQ((size_t)1, notification->buttons().size());
173 } else { 154 } else {
174 ASSERT_FALSE(notification); 155 ASSERT_FALSE(notification);
175 } 156 }
176 } 157 }
177 158
178 #if defined(OS_WIN) 159 #if defined(OS_WIN)
179 ScreenTypeDelegateDesktop screen_type_delegate_;
180 scoped_ptr<gfx::Screen> test_screen_; 160 scoped_ptr<gfx::Screen> test_screen_;
181 #endif 161 #endif
182 scoped_ptr<TestingProfileManager> profile_manager_; 162 scoped_ptr<TestingProfileManager> profile_manager_;
183 scoped_ptr<SyncErrorController> error_controller_; 163 scoped_ptr<SyncErrorController> error_controller_;
184 scoped_ptr<SyncErrorNotifier> error_notifier_; 164 scoped_ptr<SyncErrorNotifier> error_notifier_;
185 scoped_ptr<ProfileSyncServiceMock> service_; 165 scoped_ptr<ProfileSyncServiceMock> service_;
186 TestingProfile* profile_; 166 TestingProfile* profile_;
187 FakeLoginUI login_ui_; 167 FakeLoginUI login_ui_;
188 NotificationUIManager* notification_ui_manager_; 168 NotificationUIManager* notification_ui_manager_;
189 169
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 SCOPED_TRACE("Not expecting notification since sync setup is incomplete"); 221 SCOPED_TRACE("Not expecting notification since sync setup is incomplete");
242 VerifySyncErrorNotifierResult( 222 VerifySyncErrorNotifierResult(
243 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, 223 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS,
244 false /* not signed in */, 224 false /* not signed in */,
245 false /* no error */); 225 false /* no error */);
246 } 226 }
247 } 227 }
248 228
249 } // namespace test 229 } // namespace test
250 } // namespace ash 230 } // namespace ash
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_error_notifier_ash_unittest.cc ('k') | chrome/browser/ui/app_list/app_list_service_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698