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

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

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 #include <utility> 8 #include <utility>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 virtual ~AutomaticRebootManagerTest(); 205 virtual ~AutomaticRebootManagerTest();
206 }; 206 };
207 207
208 void SaveUptimeToFile(const base::FilePath& path, 208 void SaveUptimeToFile(const base::FilePath& path,
209 const base::TimeDelta& uptime) { 209 const base::TimeDelta& uptime) {
210 if (path.empty() || uptime == base::TimeDelta()) 210 if (path.empty() || uptime == base::TimeDelta())
211 return; 211 return;
212 212
213 const std::string uptime_seconds = base::DoubleToString(uptime.InSecondsF()); 213 const std::string uptime_seconds = base::DoubleToString(uptime.InSecondsF());
214 ASSERT_EQ(static_cast<int>(uptime_seconds.size()), 214 ASSERT_EQ(static_cast<int>(uptime_seconds.size()),
215 file_util::WriteFile(path, 215 base::WriteFile(path, uptime_seconds.c_str(),
216 uptime_seconds.c_str(), 216 uptime_seconds.size()));
217 uptime_seconds.size()));
218 } 217 }
219 218
220 MockTimeSingleThreadTaskRunner::MockTimeSingleThreadTaskRunner() { 219 MockTimeSingleThreadTaskRunner::MockTimeSingleThreadTaskRunner() {
221 } 220 }
222 221
223 bool MockTimeSingleThreadTaskRunner::RunsTasksOnCurrentThread() const { 222 bool MockTimeSingleThreadTaskRunner::RunsTasksOnCurrentThread() const {
224 return true; 223 return true;
225 } 224 }
226 225
227 bool MockTimeSingleThreadTaskRunner::PostDelayedTask( 226 bool MockTimeSingleThreadTaskRunner::PostDelayedTask(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 339 }
341 340
342 AutomaticRebootManagerBasicTest::~AutomaticRebootManagerBasicTest() { 341 AutomaticRebootManagerBasicTest::~AutomaticRebootManagerBasicTest() {
343 } 342 }
344 343
345 void AutomaticRebootManagerBasicTest::SetUp() { 344 void AutomaticRebootManagerBasicTest::SetUp() {
346 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 345 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
347 const base::FilePath& temp_dir = temp_dir_.path(); 346 const base::FilePath& temp_dir = temp_dir_.path();
348 const base::FilePath uptime_file = temp_dir.Append("uptime"); 347 const base::FilePath uptime_file = temp_dir.Append("uptime");
349 task_runner_->SetUptimeFile(uptime_file); 348 task_runner_->SetUptimeFile(uptime_file);
350 ASSERT_FALSE(file_util::WriteFile(uptime_file, NULL, 0)); 349 ASSERT_FALSE(base::WriteFile(uptime_file, NULL, 0));
351 update_reboot_needed_uptime_file_ = 350 update_reboot_needed_uptime_file_ =
352 temp_dir.Append("update_reboot_needed_uptime"); 351 temp_dir.Append("update_reboot_needed_uptime");
353 ASSERT_FALSE(file_util::WriteFile( 352 ASSERT_FALSE(base::WriteFile(update_reboot_needed_uptime_file_, NULL, 0));
354 update_reboot_needed_uptime_file_, NULL, 0));
355 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPTIME, uptime_file)); 353 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPTIME, uptime_file));
356 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME, 354 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME,
357 update_reboot_needed_uptime_file_)); 355 update_reboot_needed_uptime_file_));
358 356
359 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); 357 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
360 AutomaticRebootManager::RegisterPrefs(local_state_.registry()); 358 AutomaticRebootManager::RegisterPrefs(local_state_.registry());
361 359
362 FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; 360 FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager;
363 power_manager_client_ = new FakePowerManagerClient; 361 power_manager_client_ = new FakePowerManagerClient;
364 dbus_manager->SetPowerManagerClient( 362 dbus_manager->SetPowerManagerClient(
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 INSTANTIATE_TEST_CASE_P( 2054 INSTANTIATE_TEST_CASE_P(
2057 AutomaticRebootManagerTestInstance, 2055 AutomaticRebootManagerTestInstance,
2058 AutomaticRebootManagerTest, 2056 AutomaticRebootManagerTest,
2059 ::testing::Values( 2057 ::testing::Values(
2060 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, 2058 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN,
2061 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, 2059 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION,
2062 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); 2060 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION));
2063 2061
2064 } // namespace system 2062 } // namespace system
2065 } // namespace chromeos 2063 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/automatic_reboot_manager.cc ('k') | chrome/browser/component_updater/component_unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698