| 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/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 | 12 |
| 13 #if !defined(OS_MACOSX) | 13 #if !defined(OS_MACOSX) |
| 14 #include "base/at_exit.h" | 14 #include "base/at_exit.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/test/multiprocess_test.h" | 17 #include "base/test/multiprocess_test.h" |
| 18 #include "base/test/test_timeouts.h" | 18 #include "base/test/test_timeouts.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/chrome_version_info.h" | 22 #include "chrome/common/chrome_version_info.h" |
| 23 #include "testing/multiprocess_func_list.h" | 23 #include "testing/multiprocess_func_list.h" |
| 24 | 24 |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 26 #include "base/win/win_util.h" | 26 #include "base/win/win_util.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 #if defined(OS_POSIX) | 29 #if defined(OS_POSIX) |
| 30 #include <glib.h> |
| 30 #include "chrome/common/auto_start_linux.h" | 31 #include "chrome/common/auto_start_linux.h" |
| 31 #include <glib.h> | |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 #if defined(USE_AURA) | 34 #if defined(USE_AURA) |
| 35 // This test fails http://crbug.com/84854, and is very flaky on CrOS and | 35 // This test fails http://crbug.com/84854, and is very flaky on CrOS and |
| 36 // somewhat flaky on other Linux. | 36 // somewhat flaky on other Linux. |
| 37 #define MAYBE_ForceShutdown DISABLED_ForceShutdown | 37 #define MAYBE_ForceShutdown DISABLED_ForceShutdown |
| 38 #else | 38 #else |
| 39 #if defined(OS_LINUX) || defined(OS_WIN) | 39 #if defined(OS_LINUX) || defined(OS_WIN) |
| 40 #define MAYBE_ForceShutdown DISABLED_ForceShutdown | 40 #define MAYBE_ForceShutdown DISABLED_ForceShutdown |
| 41 #else | 41 #else |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 EXPECT_TRUE(g_good_shutdown); | 234 EXPECT_TRUE(g_good_shutdown); |
| 235 return 0; | 235 return 0; |
| 236 } | 236 } |
| 237 | 237 |
| 238 #else // !OS_MACOSX | 238 #else // !OS_MACOSX |
| 239 | 239 |
| 240 #include <CoreFoundation/CoreFoundation.h> | 240 #include <CoreFoundation/CoreFoundation.h> |
| 241 | 241 |
| 242 #include "base/file_path.h" | 242 #include "base/file_path.h" |
| 243 #include "base/file_util.h" | 243 #include "base/file_util.h" |
| 244 #include "base/files/scoped_temp_dir.h" |
| 244 #include "base/mac/mac_util.h" | 245 #include "base/mac/mac_util.h" |
| 245 #include "base/scoped_temp_dir.h" | |
| 246 #include "base/test/test_timeouts.h" | 246 #include "base/test/test_timeouts.h" |
| 247 #include "base/threading/thread.h" | 247 #include "base/threading/thread.h" |
| 248 #include "chrome/common/mac/launchd.h" | 248 #include "chrome/common/mac/launchd.h" |
| 249 #include "chrome/common/mac/mock_launchd.h" | 249 #include "chrome/common/mac/mock_launchd.h" |
| 250 #include "testing/gtest/include/gtest/gtest.h" | 250 #include "testing/gtest/include/gtest/gtest.h" |
| 251 | 251 |
| 252 class ServiceProcessStateFileManipulationTest : public ::testing::Test { | 252 class ServiceProcessStateFileManipulationTest : public ::testing::Test { |
| 253 protected: | 253 protected: |
| 254 ServiceProcessStateFileManipulationTest() | 254 ServiceProcessStateFileManipulationTest() |
| 255 : io_thread_("ServiceProcessStateFileManipulationTest_IO") { | 255 : io_thread_("ServiceProcessStateFileManipulationTest_IO") { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 282 const FilePath& executable_path() const { return executable_path_; } | 282 const FilePath& executable_path() const { return executable_path_; } |
| 283 const FilePath& bundle_path() const { return bundle_path_; } | 283 const FilePath& bundle_path() const { return bundle_path_; } |
| 284 const FilePath& GetTempDirPath() const { return temp_dir_.path(); } | 284 const FilePath& GetTempDirPath() const { return temp_dir_.path(); } |
| 285 | 285 |
| 286 base::MessageLoopProxy* GetIOMessageLoopProxy() { | 286 base::MessageLoopProxy* GetIOMessageLoopProxy() { |
| 287 return io_thread_.message_loop_proxy().get(); | 287 return io_thread_.message_loop_proxy().get(); |
| 288 } | 288 } |
| 289 void Run() { loop_.Run(); } | 289 void Run() { loop_.Run(); } |
| 290 | 290 |
| 291 private: | 291 private: |
| 292 ScopedTempDir temp_dir_; | 292 base::ScopedTempDir temp_dir_; |
| 293 MessageLoopForUI loop_; | 293 MessageLoopForUI loop_; |
| 294 base::Thread io_thread_; | 294 base::Thread io_thread_; |
| 295 FilePath executable_path_, bundle_path_; | 295 FilePath executable_path_, bundle_path_; |
| 296 scoped_ptr<MockLaunchd> mock_launchd_; | 296 scoped_ptr<MockLaunchd> mock_launchd_; |
| 297 scoped_ptr<Launchd::ScopedInstance> scoped_launchd_instance_; | 297 scoped_ptr<Launchd::ScopedInstance> scoped_launchd_instance_; |
| 298 ServiceProcessState service_process_state_; | 298 ServiceProcessState service_process_state_; |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 void DeleteFunc(const FilePath& file) { | 301 void DeleteFunc(const FilePath& file) { |
| 302 EXPECT_TRUE(file_util::Delete(file, true)); | 302 EXPECT_TRUE(file_util::Delete(file, true)); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 ScopedAttributesRestorer restorer(bundle_path(), 0777); | 409 ScopedAttributesRestorer restorer(bundle_path(), 0777); |
| 410 GetIOMessageLoopProxy()->PostTask( | 410 GetIOMessageLoopProxy()->PostTask( |
| 411 FROM_HERE, | 411 FROM_HERE, |
| 412 base::Bind(&ChangeAttr, bundle_path(), 0222)); | 412 base::Bind(&ChangeAttr, bundle_path(), 0222)); |
| 413 Run(); | 413 Run(); |
| 414 ASSERT_TRUE(mock_launchd()->remove_called()); | 414 ASSERT_TRUE(mock_launchd()->remove_called()); |
| 415 ASSERT_TRUE(mock_launchd()->delete_called()); | 415 ASSERT_TRUE(mock_launchd()->delete_called()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 #endif // !OS_MACOSX | 418 #endif // !OS_MACOSX |
| OLD | NEW |