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

Side by Side Diff: chrome/browser/chromeos/system/automatic_reboot_manager_unittest.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/system/automatic_reboot_manager.h" 5 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/test_shell_delegate.h" 10 #include "ash/test/test_shell_delegate.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 private: 101 private:
102 ~TestAutomaticRebootManagerTaskRunner() override; 102 ~TestAutomaticRebootManagerTaskRunner() override;
103 103
104 // base::TestMockTimeTaskRunner: 104 // base::TestMockTimeTaskRunner:
105 void OnBeforeSelectingTask() override; 105 void OnBeforeSelectingTask() override;
106 void OnAfterTimePassed() override; 106 void OnAfterTimePassed() override;
107 void OnAfterTaskRun() override; 107 void OnAfterTaskRun() override;
108 108
109 scoped_ptr<MockUptimeProvider> uptime_provider_; 109 std::unique_ptr<MockUptimeProvider> uptime_provider_;
110 110
111 DISALLOW_COPY_AND_ASSIGN(TestAutomaticRebootManagerTaskRunner); 111 DISALLOW_COPY_AND_ASSIGN(TestAutomaticRebootManagerTaskRunner);
112 }; 112 };
113 113
114 class MockAutomaticRebootManagerObserver 114 class MockAutomaticRebootManagerObserver
115 : public AutomaticRebootManagerObserver { 115 : public AutomaticRebootManagerObserver {
116 public: 116 public:
117 MockAutomaticRebootManagerObserver(); 117 MockAutomaticRebootManagerObserver();
118 ~MockAutomaticRebootManagerObserver() override; 118 ~MockAutomaticRebootManagerObserver() override;
119 119
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // has increased by a small offset already. The offset is calculated and 179 // has increased by a small offset already. The offset is calculated and
180 // stored in |uptime_processing_delay_| so that tests can accurately determine 180 // stored in |uptime_processing_delay_| so that tests can accurately determine
181 // the uptime seen by the UI thread. 181 // the uptime seen by the UI thread.
182 base::TimeDelta uptime_processing_delay_; 182 base::TimeDelta uptime_processing_delay_;
183 base::TimeDelta update_reboot_needed_uptime_; 183 base::TimeDelta update_reboot_needed_uptime_;
184 base::TimeDelta uptime_limit_; 184 base::TimeDelta uptime_limit_;
185 185
186 scoped_refptr<TestAutomaticRebootManagerTaskRunner> task_runner_; 186 scoped_refptr<TestAutomaticRebootManagerTaskRunner> task_runner_;
187 187
188 MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_; 188 MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_;
189 scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_; 189 std::unique_ptr<AutomaticRebootManager> automatic_reboot_manager_;
190 190
191 private: 191 private:
192 void VerifyTimerIsStopped(const base::OneShotTimer* timer) const; 192 void VerifyTimerIsStopped(const base::OneShotTimer* timer) const;
193 void VerifyTimerIsRunning(const base::OneShotTimer* timer, 193 void VerifyTimerIsRunning(const base::OneShotTimer* timer,
194 const base::TimeDelta& delay) const; 194 const base::TimeDelta& delay) const;
195 void VerifyLoginScreenIdleTimerIsRunning() const; 195 void VerifyLoginScreenIdleTimerIsRunning() const;
196 196
197 base::ScopedTempDir temp_dir_; 197 base::ScopedTempDir temp_dir_;
198 base::FilePath update_reboot_needed_uptime_file_; 198 base::FilePath update_reboot_needed_uptime_file_;
199 199
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 update_reboot_needed_uptime_file_ = 326 update_reboot_needed_uptime_file_ =
327 temp_dir.Append("update_reboot_needed_uptime"); 327 temp_dir.Append("update_reboot_needed_uptime");
328 ASSERT_FALSE(base::WriteFile(update_reboot_needed_uptime_file_, NULL, 0)); 328 ASSERT_FALSE(base::WriteFile(update_reboot_needed_uptime_file_, NULL, 0));
329 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPTIME, uptime_file)); 329 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPTIME, uptime_file));
330 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME, 330 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME,
331 update_reboot_needed_uptime_file_)); 331 update_reboot_needed_uptime_file_));
332 332
333 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); 333 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
334 AutomaticRebootManager::RegisterPrefs(local_state_.registry()); 334 AutomaticRebootManager::RegisterPrefs(local_state_.registry());
335 335
336 scoped_ptr<DBusThreadManagerSetter> dbus_setter = 336 std::unique_ptr<DBusThreadManagerSetter> dbus_setter =
337 chromeos::DBusThreadManager::GetSetterForTesting(); 337 chromeos::DBusThreadManager::GetSetterForTesting();
338 power_manager_client_ = new FakePowerManagerClient; 338 power_manager_client_ = new FakePowerManagerClient;
339 dbus_setter->SetPowerManagerClient( 339 dbus_setter->SetPowerManagerClient(
340 scoped_ptr<PowerManagerClient>(power_manager_client_)); 340 std::unique_ptr<PowerManagerClient>(power_manager_client_));
341 update_engine_client_ = new FakeUpdateEngineClient; 341 update_engine_client_ = new FakeUpdateEngineClient;
342 dbus_setter->SetUpdateEngineClient( 342 dbus_setter->SetUpdateEngineClient(
343 scoped_ptr<UpdateEngineClient>(update_engine_client_)); 343 std::unique_ptr<UpdateEngineClient>(update_engine_client_));
344 344
345 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) 345 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn())
346 .WillRepeatedly(ReturnPointee(&is_user_logged_in_)); 346 .WillRepeatedly(ReturnPointee(&is_user_logged_in_));
347 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsKioskApp()) 347 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsKioskApp())
348 .WillRepeatedly(ReturnPointee(&is_logged_in_as_kiosk_app_)); 348 .WillRepeatedly(ReturnPointee(&is_logged_in_as_kiosk_app_));
349 } 349 }
350 350
351 void AutomaticRebootManagerBasicTest::TearDown() { 351 void AutomaticRebootManagerBasicTest::TearDown() {
352 if (automatic_reboot_manager_) { 352 if (automatic_reboot_manager_) {
353 Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_); 353 Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_); 453 Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_);
454 EXPECT_CALL(automatic_reboot_manager_observer_, 454 EXPECT_CALL(automatic_reboot_manager_observer_,
455 WillDestroyAutomaticRebootManager()).Times(0); 455 WillDestroyAutomaticRebootManager()).Times(0);
456 EXPECT_CALL(automatic_reboot_manager_observer_, 456 EXPECT_CALL(automatic_reboot_manager_observer_,
457 OnRebootRequested(_)).Times(0); 457 OnRebootRequested(_)).Times(0);
458 } 458 }
459 459
460 void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager( 460 void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager(
461 bool expect_reboot) { 461 bool expect_reboot) {
462 automatic_reboot_manager_.reset(new AutomaticRebootManager( 462 automatic_reboot_manager_.reset(new AutomaticRebootManager(
463 scoped_ptr<base::TickClock>(task_runner_->GetMockTickClock()))); 463 std::unique_ptr<base::TickClock>(task_runner_->GetMockTickClock())));
464 automatic_reboot_manager_observer_.Init(automatic_reboot_manager_.get()); 464 automatic_reboot_manager_observer_.Init(automatic_reboot_manager_.get());
465 task_runner_->RunUntilIdle(); 465 task_runner_->RunUntilIdle();
466 EXPECT_EQ(expect_reboot ? 1 : 0, 466 EXPECT_EQ(expect_reboot ? 1 : 0,
467 power_manager_client_->num_request_restart_calls()); 467 power_manager_client_->num_request_restart_calls());
468 468
469 uptime_processing_delay_ = 469 uptime_processing_delay_ =
470 base::TimeTicks() - automatic_reboot_manager_->boot_time_ - 470 base::TimeTicks() - automatic_reboot_manager_->boot_time_ -
471 uptime_provider()->uptime(); 471 uptime_provider()->uptime();
472 EXPECT_GE(uptime_processing_delay_, base::TimeDelta()); 472 EXPECT_GE(uptime_processing_delay_, base::TimeDelta());
473 EXPECT_LE(uptime_processing_delay_, base::TimeDelta::FromSeconds(1)); 473 EXPECT_LE(uptime_processing_delay_, base::TimeDelta::FromSeconds(1));
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 INSTANTIATE_TEST_CASE_P( 2280 INSTANTIATE_TEST_CASE_P(
2281 AutomaticRebootManagerTestInstance, 2281 AutomaticRebootManagerTestInstance,
2282 AutomaticRebootManagerTest, 2282 AutomaticRebootManagerTest,
2283 ::testing::Values( 2283 ::testing::Values(
2284 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, 2284 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN,
2285 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, 2285 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION,
2286 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); 2286 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION));
2287 2287
2288 } // namespace system 2288 } // namespace system
2289 } // namespace chromeos 2289 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/automatic_reboot_manager.cc ('k') | chrome/browser/chromeos/system/device_change_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698