| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/service_process_util.h" | 5 #include "chrome/common/service_process_util.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 base::ScopedTempDir temp_dir_; | 291 base::ScopedTempDir temp_dir_; |
| 292 base::MessageLoopForUI loop_; | 292 base::MessageLoopForUI loop_; |
| 293 base::Thread io_thread_; | 293 base::Thread io_thread_; |
| 294 base::FilePath executable_path_, bundle_path_; | 294 base::FilePath executable_path_, bundle_path_; |
| 295 scoped_ptr<MockLaunchd> mock_launchd_; | 295 scoped_ptr<MockLaunchd> mock_launchd_; |
| 296 scoped_ptr<Launchd::ScopedInstance> scoped_launchd_instance_; | 296 scoped_ptr<Launchd::ScopedInstance> scoped_launchd_instance_; |
| 297 ServiceProcessState service_process_state_; | 297 ServiceProcessState service_process_state_; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 void DeleteFunc(const base::FilePath& file) { | 300 void DeleteFunc(const base::FilePath& file) { |
| 301 EXPECT_TRUE(base::Delete(file, true)); | 301 EXPECT_TRUE(base::DeleteFile(file, true)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void MoveFunc(const base::FilePath& from, const base::FilePath& to) { | 304 void MoveFunc(const base::FilePath& from, const base::FilePath& to) { |
| 305 EXPECT_TRUE(base::Move(from, to)); | 305 EXPECT_TRUE(base::Move(from, to)); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void ChangeAttr(const base::FilePath& from, int mode) { | 308 void ChangeAttr(const base::FilePath& from, int mode) { |
| 309 EXPECT_EQ(chmod(from.value().c_str(), mode), 0); | 309 EXPECT_EQ(chmod(from.value().c_str(), mode), 0); |
| 310 } | 310 } |
| 311 | 311 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 FSRef bundle_ref; | 394 FSRef bundle_ref; |
| 395 ASSERT_TRUE(base::mac::FSRefFromPath(bundle_path().value(), &bundle_ref)); | 395 ASSERT_TRUE(base::mac::FSRefFromPath(bundle_path().value(), &bundle_ref)); |
| 396 GetIOMessageLoopProxy()->PostTask( | 396 GetIOMessageLoopProxy()->PostTask( |
| 397 FROM_HERE, | 397 FROM_HERE, |
| 398 base::Bind(&TrashFunc, bundle_path())); | 398 base::Bind(&TrashFunc, bundle_path())); |
| 399 Run(); | 399 Run(); |
| 400 ASSERT_TRUE(mock_launchd()->remove_called()); | 400 ASSERT_TRUE(mock_launchd()->remove_called()); |
| 401 ASSERT_TRUE(mock_launchd()->delete_called()); | 401 ASSERT_TRUE(mock_launchd()->delete_called()); |
| 402 std::string path(base::mac::PathFromFSRef(bundle_ref)); | 402 std::string path(base::mac::PathFromFSRef(bundle_ref)); |
| 403 base::FilePath file_path(path); | 403 base::FilePath file_path(path); |
| 404 ASSERT_TRUE(base::Delete(file_path, true)); | 404 ASSERT_TRUE(base::DeleteFile(file_path, true)); |
| 405 } | 405 } |
| 406 | 406 |
| 407 TEST_F(ServiceProcessStateFileManipulationTest, ChangeAttr) { | 407 TEST_F(ServiceProcessStateFileManipulationTest, ChangeAttr) { |
| 408 ScopedAttributesRestorer restorer(bundle_path(), 0777); | 408 ScopedAttributesRestorer restorer(bundle_path(), 0777); |
| 409 GetIOMessageLoopProxy()->PostTask( | 409 GetIOMessageLoopProxy()->PostTask( |
| 410 FROM_HERE, | 410 FROM_HERE, |
| 411 base::Bind(&ChangeAttr, bundle_path(), 0222)); | 411 base::Bind(&ChangeAttr, bundle_path(), 0222)); |
| 412 Run(); | 412 Run(); |
| 413 ASSERT_TRUE(mock_launchd()->remove_called()); | 413 ASSERT_TRUE(mock_launchd()->remove_called()); |
| 414 ASSERT_TRUE(mock_launchd()->delete_called()); | 414 ASSERT_TRUE(mock_launchd()->delete_called()); |
| 415 } | 415 } |
| 416 | 416 |
| 417 #endif // !OS_MACOSX | 417 #endif // !OS_MACOSX |
| OLD | NEW |