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

Side by Side Diff: chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc

Issue 2770783002: Use TaskScheduler instead of blocking pool in automatic_reboot_manager.cc. (Closed)
Patch Set: add-include Created 3 years, 7 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
« no previous file with comments | « chrome/browser/chromeos/system/automatic_reboot_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/message_loop/message_loop.h"
15 #include "base/path_service.h" 14 #include "base/path_service.h"
16 #include "base/run_loop.h"
17 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/task_scheduler/task_scheduler.h"
17 #include "base/test/scoped_async_task_scheduler.h"
18 #include "base/test/simple_test_tick_clock.h" 18 #include "base/test/simple_test_tick_clock.h"
19 #include "base/test/test_mock_time_task_runner.h" 19 #include "base/test/test_mock_time_task_runner.h"
20 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
21 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
22 #include "base/time/tick_clock.h" 22 #include "base/time/tick_clock.h"
23 #include "base/values.h" 23 #include "base/values.h"
24 #include "chrome/browser/chrome_notification_types.h" 24 #include "chrome/browser/chrome_notification_types.h"
25 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 25 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
27 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h" 27 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "chrome/test/base/testing_browser_process.h" 29 #include "chrome/test/base/testing_browser_process.h"
30 #include "chromeos/chromeos_paths.h" 30 #include "chromeos/chromeos_paths.h"
31 #include "chromeos/dbus/dbus_thread_manager.h" 31 #include "chromeos/dbus/dbus_thread_manager.h"
32 #include "chromeos/dbus/fake_power_manager_client.h" 32 #include "chromeos/dbus/fake_power_manager_client.h"
33 #include "chromeos/dbus/fake_update_engine_client.h" 33 #include "chromeos/dbus/fake_update_engine_client.h"
34 #include "components/prefs/pref_registry_simple.h" 34 #include "components/prefs/pref_registry_simple.h"
35 #include "components/prefs/testing_pref_service.h" 35 #include "components/prefs/testing_pref_service.h"
36 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/notification_details.h" 37 #include "content/public/browser/notification_details.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
40 #include "content/public/test/test_browser_thread.h"
41 #include "testing/gmock/include/gmock/gmock.h" 40 #include "testing/gmock/include/gmock/gmock.h"
42 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
43 #include "ui/message_center/message_center.h" 42 #include "ui/message_center/message_center.h"
44 43
45 using ::testing::_; 44 using ::testing::_;
46 using ::testing::Invoke; 45 using ::testing::Invoke;
47 using ::testing::Mock; 46 using ::testing::Mock;
48 using ::testing::ReturnPointee; 47 using ::testing::ReturnPointee;
49 48
50 namespace chromeos { 49 namespace chromeos {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 void VerifyTimerIsRunning(const base::OneShotTimer* timer, 194 void VerifyTimerIsRunning(const base::OneShotTimer* timer,
196 const base::TimeDelta& delay) const; 195 const base::TimeDelta& delay) const;
197 void VerifyLoginScreenIdleTimerIsRunning() const; 196 void VerifyLoginScreenIdleTimerIsRunning() const;
198 197
199 base::ScopedTempDir temp_dir_; 198 base::ScopedTempDir temp_dir_;
200 base::FilePath update_reboot_needed_uptime_file_; 199 base::FilePath update_reboot_needed_uptime_file_;
201 200
202 bool reboot_after_update_ = false; 201 bool reboot_after_update_ = false;
203 202
204 base::ThreadTaskRunnerHandle ui_thread_task_runner_handle_; 203 base::ThreadTaskRunnerHandle ui_thread_task_runner_handle_;
204 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler_;
205 205
206 TestingPrefServiceSimple local_state_; 206 TestingPrefServiceSimple local_state_;
207 MockUserManager* mock_user_manager_; // Not owned. 207 MockUserManager* mock_user_manager_; // Not owned.
208 ScopedUserManagerEnabler user_manager_enabler_; 208 ScopedUserManagerEnabler user_manager_enabler_;
209 209
210 FakePowerManagerClient* power_manager_client_ = nullptr; // Not owned. 210 FakePowerManagerClient* power_manager_client_ = nullptr; // Not owned.
211 FakeUpdateEngineClient* update_engine_client_ = nullptr; // Not owned. 211 FakeUpdateEngineClient* update_engine_client_ = nullptr; // Not owned.
212 }; 212 };
213 213
214 enum AutomaticRebootManagerTestScenario { 214 enum AutomaticRebootManagerTestScenario {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 TestAutomaticRebootManagerTaskRunner::TestAutomaticRebootManagerTaskRunner() 259 TestAutomaticRebootManagerTaskRunner::TestAutomaticRebootManagerTaskRunner()
260 : uptime_provider_(new MockUptimeProvider(this)) { 260 : uptime_provider_(new MockUptimeProvider(this)) {
261 } 261 }
262 262
263 TestAutomaticRebootManagerTaskRunner::~TestAutomaticRebootManagerTaskRunner() { 263 TestAutomaticRebootManagerTaskRunner::~TestAutomaticRebootManagerTaskRunner() {
264 } 264 }
265 265
266 void TestAutomaticRebootManagerTaskRunner::OnBeforeSelectingTask() { 266 void TestAutomaticRebootManagerTaskRunner::OnBeforeSelectingTask() {
267 base::SequencedWorkerPool* blocking_pool = 267 content::BrowserThread::GetBlockingPool()->FlushForTesting();
268 content::BrowserThread::GetBlockingPool(); 268 base::TaskScheduler::GetInstance()->FlushForTesting();
269 blocking_pool->FlushForTesting();
270 } 269 }
271 270
272 void TestAutomaticRebootManagerTaskRunner::OnAfterTimePassed() { 271 void TestAutomaticRebootManagerTaskRunner::OnAfterTimePassed() {
273 uptime_provider_->WriteUptimeToFile(); 272 uptime_provider_->WriteUptimeToFile();
274 } 273 }
275 274
276 void TestAutomaticRebootManagerTaskRunner::OnAfterTaskRun() { 275 void TestAutomaticRebootManagerTaskRunner::OnAfterTaskRun() {
277 base::SequencedWorkerPool* blocking_pool = 276 content::BrowserThread::GetBlockingPool()->FlushForTesting();
278 content::BrowserThread::GetBlockingPool(); 277 base::TaskScheduler::GetInstance()->FlushForTesting();
279 blocking_pool->FlushForTesting();
280 } 278 }
281 279
282 MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver() 280 MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver()
283 : automatic_reboot_manger_(nullptr) { 281 : automatic_reboot_manger_(nullptr) {
284 ON_CALL(*this, WillDestroyAutomaticRebootManager()) 282 ON_CALL(*this, WillDestroyAutomaticRebootManager())
285 .WillByDefault( 283 .WillByDefault(
286 Invoke(this, 284 Invoke(this,
287 &MockAutomaticRebootManagerObserver::StopObserving)); 285 &MockAutomaticRebootManagerObserver::StopObserving));
288 } 286 }
289 287
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 AutomaticRebootManagerTestInstance, 2258 AutomaticRebootManagerTestInstance,
2261 AutomaticRebootManagerTest, 2259 AutomaticRebootManagerTest,
2262 ::testing::Values( 2260 ::testing::Values(
2263 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, 2261 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN,
2264 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, 2262 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION,
2265 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_ARC_KIOSK_APP_SESSION, 2263 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_ARC_KIOSK_APP_SESSION,
2266 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); 2264 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION));
2267 2265
2268 } // namespace system 2266 } // namespace system
2269 } // namespace chromeos 2267 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/automatic_reboot_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698