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

Side by Side Diff: chrome/browser/chromeos/shutdown_policy_browsertest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <memory>
5 #include <string> 6 #include <string>
6 7
7 #include "ash/shell.h" 8 #include "ash/shell.h"
8 #include "ash/strings/grit/ash_strings.h" 9 #include "ash/strings/grit/ash_strings.h"
9 #include "ash/system/date/date_default_view.h" 10 #include "ash/system/date/date_default_view.h"
10 #include "ash/system/date/tray_date.h" 11 #include "ash/system/date/tray_date.h"
11 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
12 #include "ash/system/tray/tray_popup_header_button.h" 13 #include "ash/system/tray/tray_popup_header_button.h"
13 #include "ash/system/user/login_status.h" 14 #include "ash/system/user/login_status.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 22 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
23 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" 23 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h"
24 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" 24 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
25 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 25 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
26 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" 26 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
27 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 27 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void WaitUntilOobeUIIsReady(OobeUI* oobe_ui) { 128 void WaitUntilOobeUIIsReady(OobeUI* oobe_ui) {
129 ASSERT_TRUE(oobe_ui); 129 ASSERT_TRUE(oobe_ui);
130 base::RunLoop run_loop; 130 base::RunLoop run_loop;
131 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure()); 131 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure());
132 if (!oobe_ui_ready) 132 if (!oobe_ui_ready)
133 run_loop.Run(); 133 run_loop.Run();
134 } 134 }
135 135
136 content::WebContents* contents_; 136 content::WebContents* contents_;
137 bool result_; 137 bool result_;
138 scoped_ptr<base::RunLoop> run_loop_; 138 std::unique_ptr<base::RunLoop> run_loop_;
139 }; 139 };
140 140
141 class ShutdownPolicyInSessionTest 141 class ShutdownPolicyInSessionTest
142 : public ShutdownPolicyBaseTest { 142 : public ShutdownPolicyBaseTest {
143 protected: 143 protected:
144 ShutdownPolicyInSessionTest() {} 144 ShutdownPolicyInSessionTest() {}
145 ~ShutdownPolicyInSessionTest() override {} 145 ~ShutdownPolicyInSessionTest() override {}
146 146
147 void SetUpOnMainThread() override { 147 void SetUpOnMainThread() override {
148 ShutdownPolicyBaseTest::SetUpOnMainThread(); 148 ShutdownPolicyBaseTest::SetUpOnMainThread();
(...skipping 19 matching lines...) Expand all
168 } 168 }
169 169
170 bool HasButtonTooltipText(const ash::TrayPopupHeaderButton* button, 170 bool HasButtonTooltipText(const ash::TrayPopupHeaderButton* button,
171 int message_id) const { 171 int message_id) const {
172 base::string16 actual_tooltip; 172 base::string16 actual_tooltip;
173 button->GetTooltipText(gfx::Point(), &actual_tooltip); 173 button->GetTooltipText(gfx::Point(), &actual_tooltip);
174 return l10n_util::GetStringUTF16(message_id) == actual_tooltip; 174 return l10n_util::GetStringUTF16(message_id) == actual_tooltip;
175 } 175 }
176 176
177 private: 177 private:
178 scoped_ptr<ash::DateDefaultView> date_default_view_; 178 std::unique_ptr<ash::DateDefaultView> date_default_view_;
179 179
180 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyInSessionTest); 180 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyInSessionTest);
181 }; 181 };
182 182
183 IN_PROC_BROWSER_TEST_F(ShutdownPolicyInSessionTest, TestBasic) { 183 IN_PROC_BROWSER_TEST_F(ShutdownPolicyInSessionTest, TestBasic) {
184 const ash::TrayPopupHeaderButton *shutdown_button = GetShutdownButton(); 184 const ash::TrayPopupHeaderButton *shutdown_button = GetShutdownButton();
185 EXPECT_TRUE( 185 EXPECT_TRUE(
186 HasButtonTooltipText(shutdown_button, IDS_ASH_STATUS_TRAY_SHUTDOWN)); 186 HasButtonTooltipText(shutdown_button, IDS_ASH_STATUS_TRAY_SHUTDOWN));
187 } 187 }
188 188
(...skipping 12 matching lines...) Expand all
201 } 201 }
202 202
203 class ShutdownPolicyLockerTest : public ShutdownPolicyBaseTest { 203 class ShutdownPolicyLockerTest : public ShutdownPolicyBaseTest {
204 protected: 204 protected:
205 ShutdownPolicyLockerTest() : fake_session_manager_client_(nullptr) {} 205 ShutdownPolicyLockerTest() : fake_session_manager_client_(nullptr) {}
206 ~ShutdownPolicyLockerTest() override {} 206 ~ShutdownPolicyLockerTest() override {}
207 207
208 void SetUpInProcessBrowserTestFixture() override { 208 void SetUpInProcessBrowserTestFixture() override {
209 fake_session_manager_client_ = new FakeSessionManagerClient; 209 fake_session_manager_client_ = new FakeSessionManagerClient;
210 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( 210 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
211 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); 211 std::unique_ptr<SessionManagerClient>(fake_session_manager_client_));
212 212
213 ShutdownPolicyBaseTest::SetUpInProcessBrowserTestFixture(); 213 ShutdownPolicyBaseTest::SetUpInProcessBrowserTestFixture();
214 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( 214 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
215 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); 215 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
216 InstallOwnerKey(); 216 InstallOwnerKey();
217 MarkAsEnterpriseOwned(); 217 MarkAsEnterpriseOwned();
218 } 218 }
219 219
220 void SetUpOnMainThread() override { 220 void SetUpOnMainThread() override {
221 ShutdownPolicyBaseTest::SetUpOnMainThread(); 221 ShutdownPolicyBaseTest::SetUpOnMainThread();
222 222
223 // Bring up the locker screen. 223 // Bring up the locker screen.
224 ScreenLocker::Show(); 224 ScreenLocker::Show();
225 scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester()); 225 std::unique_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
226 tester->EmulateWindowManagerReady(); 226 tester->EmulateWindowManagerReady();
227 content::WindowedNotificationObserver lock_state_observer( 227 content::WindowedNotificationObserver lock_state_observer(
228 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 228 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
229 content::NotificationService::AllSources()); 229 content::NotificationService::AllSources());
230 if (!tester->IsLocked()) 230 if (!tester->IsLocked())
231 lock_state_observer.Wait(); 231 lock_state_observer.Wait();
232 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker(); 232 ScreenLocker* screen_locker = ScreenLocker::default_screen_locker();
233 WebUIScreenLocker* web_ui_screen_locker = 233 WebUIScreenLocker* web_ui_screen_locker =
234 static_cast<WebUIScreenLocker*>(screen_locker->delegate()); 234 static_cast<WebUIScreenLocker*>(screen_locker->delegate());
235 ASSERT_TRUE(web_ui_screen_locker); 235 ASSERT_TRUE(web_ui_screen_locker);
236 content::WebUI* web_ui = web_ui_screen_locker->GetWebUI(); 236 content::WebUI* web_ui = web_ui_screen_locker->GetWebUI();
237 ASSERT_TRUE(web_ui); 237 ASSERT_TRUE(web_ui);
238 contents_ = web_ui->GetWebContents(); 238 contents_ = web_ui->GetWebContents();
239 ASSERT_TRUE(contents_); 239 ASSERT_TRUE(contents_);
240 240
241 // Wait for the login UI to be ready. 241 // Wait for the login UI to be ready.
242 WaitUntilOobeUIIsReady( 242 WaitUntilOobeUIIsReady(
243 static_cast<OobeUI*>(web_ui->GetController())); 243 static_cast<OobeUI*>(web_ui->GetController()));
244 } 244 }
245 245
246 private: 246 private:
247 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; 247 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
248 FakeSessionManagerClient* fake_session_manager_client_; 248 FakeSessionManagerClient* fake_session_manager_client_;
249 249
250 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyLockerTest); 250 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyLockerTest);
251 }; 251 };
252 252
253 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLockerTest, TestBasic) { 253 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLockerTest, TestBasic) {
254 PrepareAndRunScript("restart-header-bar-item", true); 254 PrepareAndRunScript("restart-header-bar-item", true);
255 PrepareAndRunScript("shutdown-header-bar-item", false); 255 PrepareAndRunScript("shutdown-header-bar-item", false);
256 } 256 }
257 257
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 PrepareAndRunScript("restart-header-bar-item", false); 327 PrepareAndRunScript("restart-header-bar-item", false);
328 PrepareAndRunScript("shutdown-header-bar-item", true); 328 PrepareAndRunScript("shutdown-header-bar-item", true);
329 329
330 UpdateRebootOnShutdownPolicy(false); 330 UpdateRebootOnShutdownPolicy(false);
331 RefreshDevicePolicy(); 331 RefreshDevicePolicy();
332 PrepareAndRunScript("restart-header-bar-item", true); 332 PrepareAndRunScript("restart-header-bar-item", true);
333 PrepareAndRunScript("shutdown-header-bar-item", false); 333 PrepareAndRunScript("shutdown-header-bar-item", false);
334 } 334 }
335 335
336 } // namespace chromeos 336 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/token_encryptor.h ('k') | chrome/browser/chromeos/status/data_promo_notification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698