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

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

Issue 857283002: Makes a couple of tests reset state appropriately (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak Created 5 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 "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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 profile_ = profile_manager_->CreateTestingProfile(kTestAccountId); 101 profile_ = profile_manager_->CreateTestingProfile(kTestAccountId);
102 102
103 TestingBrowserProcess::GetGlobal(); 103 TestingBrowserProcess::GetGlobal();
104 AshTestBase::SetUp(); 104 AshTestBase::SetUp();
105 105
106 // Set up a desktop screen for Windows to hold native widgets, used when 106 // Set up a desktop screen for Windows to hold native widgets, used when
107 // adding desktop widgets (i.e., message center notifications). 107 // adding desktop widgets (i.e., message center notifications).
108 #if defined(OS_WIN) 108 #if defined(OS_WIN)
109 test_screen_.reset(aura::TestScreen::Create(gfx::Size())); 109 test_screen_.reset(aura::TestScreen::Create(gfx::Size()));
110 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); 110 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
111 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop); 111 gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_);
112 #endif 112 #endif
113 113
114 service_.reset(new NiceMock<ProfileSyncServiceMock>(profile_)); 114 service_.reset(new NiceMock<ProfileSyncServiceMock>(profile_));
115 115
116 FakeLoginUIService* login_ui_service = static_cast<FakeLoginUIService*>( 116 FakeLoginUIService* login_ui_service = static_cast<FakeLoginUIService*>(
117 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( 117 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse(
118 profile_, BuildMockLoginUIService)); 118 profile_, BuildMockLoginUIService));
119 login_ui_service->SetLoginUI(&login_ui_); 119 login_ui_service->SetLoginUI(&login_ui_);
120 120
121 error_controller_.reset(new SyncErrorController(service_.get())); 121 error_controller_.reset(new SyncErrorController(service_.get()));
122 error_notifier_.reset(new SyncErrorNotifier(error_controller_.get(), 122 error_notifier_.reset(new SyncErrorNotifier(error_controller_.get(),
123 profile_)); 123 profile_));
124 124
125 notification_ui_manager_ = g_browser_process->notification_ui_manager(); 125 notification_ui_manager_ = g_browser_process->notification_ui_manager();
126 } 126 }
127 127
128 void TearDown() override { 128 void TearDown() override {
129 error_notifier_->Shutdown(); 129 error_notifier_->Shutdown();
130 service_.reset(); 130 service_.reset();
131 #if defined(OS_WIN) 131 #if defined(OS_WIN)
132 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
133 gfx::Screen::SetScreenTypeDelegate(nullptr);
132 test_screen_.reset(); 134 test_screen_.reset();
133 #endif 135 #endif
134 profile_manager_.reset(); 136 profile_manager_.reset();
135 137
136 AshTestBase::TearDown(); 138 AshTestBase::TearDown();
137 } 139 }
138 140
139 protected: 141 protected:
140 // Utility function to test that SyncErrorNotifier behaves correctly for the 142 // Utility function to test that SyncErrorNotifier behaves correctly for the
141 // given error condition. 143 // given error condition.
(...skipping 17 matching lines...) Expand all
159 ASSERT_TRUE(notification); 161 ASSERT_TRUE(notification);
160 ASSERT_FALSE(notification->title().empty()); 162 ASSERT_FALSE(notification->title().empty());
161 ASSERT_FALSE(notification->title().empty()); 163 ASSERT_FALSE(notification->title().empty());
162 ASSERT_EQ((size_t)1, notification->buttons().size()); 164 ASSERT_EQ((size_t)1, notification->buttons().size());
163 } else { 165 } else {
164 ASSERT_FALSE(notification); 166 ASSERT_FALSE(notification);
165 } 167 }
166 } 168 }
167 169
168 #if defined(OS_WIN) 170 #if defined(OS_WIN)
171 ScreenTypeDelegateDesktop screen_type_delegate_;
169 scoped_ptr<gfx::Screen> test_screen_; 172 scoped_ptr<gfx::Screen> test_screen_;
170 #endif 173 #endif
171 scoped_ptr<TestingProfileManager> profile_manager_; 174 scoped_ptr<TestingProfileManager> profile_manager_;
172 scoped_ptr<SyncErrorController> error_controller_; 175 scoped_ptr<SyncErrorController> error_controller_;
173 scoped_ptr<SyncErrorNotifier> error_notifier_; 176 scoped_ptr<SyncErrorNotifier> error_notifier_;
174 scoped_ptr<NiceMock<ProfileSyncServiceMock> > service_; 177 scoped_ptr<NiceMock<ProfileSyncServiceMock> > service_;
175 TestingProfile* profile_; 178 TestingProfile* profile_;
176 FakeLoginUI login_ui_; 179 FakeLoginUI login_ui_;
177 NotificationUIManager* notification_ui_manager_; 180 NotificationUIManager* notification_ui_manager_;
178 181
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 SCOPED_TRACE("Not expecting notification since sync setup is incomplete"); 232 SCOPED_TRACE("Not expecting notification since sync setup is incomplete");
230 VerifySyncErrorNotifierResult( 233 VerifySyncErrorNotifierResult(
231 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, 234 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS,
232 false /* not signed in */, 235 false /* not signed in */,
233 false /* no error */); 236 false /* no error */);
234 } 237 }
235 } 238 }
236 239
237 } // namespace test 240 } // namespace test
238 } // namespace ash 241 } // namespace ash
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_error_notifier_ash_unittest.cc ('k') | chrome/test/base/view_event_test_platform_part_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698