| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 TEST_F(ServiceProcessStateTest, AutoRun) { | 121 TEST_F(ServiceProcessStateTest, AutoRun) { |
| 122 ServiceProcessState state; | 122 ServiceProcessState state; |
| 123 ASSERT_TRUE(state.AddToAutoRun()); | 123 ASSERT_TRUE(state.AddToAutoRun()); |
| 124 scoped_ptr<CommandLine> autorun_command_line; | 124 scoped_ptr<CommandLine> autorun_command_line; |
| 125 #if defined(OS_WIN) | 125 #if defined(OS_WIN) |
| 126 std::string value_name = GetServiceProcessScopedName("_service_run"); | 126 std::string value_name = GetServiceProcessScopedName("_service_run"); |
| 127 base::string16 value; | 127 base::string16 value; |
| 128 EXPECT_TRUE(base::win::ReadCommandFromAutoRun(HKEY_CURRENT_USER, | 128 EXPECT_TRUE(base::win::ReadCommandFromAutoRun(HKEY_CURRENT_USER, |
| 129 UTF8ToWide(value_name), | 129 base::UTF8ToWide(value_name), |
| 130 &value)); | 130 &value)); |
| 131 autorun_command_line.reset(new CommandLine(CommandLine::FromString(value))); | 131 autorun_command_line.reset(new CommandLine(CommandLine::FromString(value))); |
| 132 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 132 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| 133 #if defined(GOOGLE_CHROME_BUILD) | 133 #if defined(GOOGLE_CHROME_BUILD) |
| 134 std::string base_desktop_name = "google-chrome-service.desktop"; | 134 std::string base_desktop_name = "google-chrome-service.desktop"; |
| 135 #else // CHROMIUM_BUILD | 135 #else // CHROMIUM_BUILD |
| 136 std::string base_desktop_name = "chromium-service.desktop"; | 136 std::string base_desktop_name = "chromium-service.desktop"; |
| 137 #endif | 137 #endif |
| 138 std::string exec_value; | 138 std::string exec_value; |
| 139 EXPECT_TRUE(AutoStart::GetAutostartFileValue( | 139 EXPECT_TRUE(AutoStart::GetAutostartFileValue( |
| 140 GetServiceProcessScopedName(base_desktop_name), "Exec", &exec_value)); | 140 GetServiceProcessScopedName(base_desktop_name), "Exec", &exec_value)); |
| 141 GError *error = NULL; | 141 GError *error = NULL; |
| 142 gchar **argv = NULL; | 142 gchar **argv = NULL; |
| 143 gint argc = 0; | 143 gint argc = 0; |
| 144 if (g_shell_parse_argv(exec_value.c_str(), &argc, &argv, &error)) { | 144 if (g_shell_parse_argv(exec_value.c_str(), &argc, &argv, &error)) { |
| 145 autorun_command_line.reset(new CommandLine(argc, argv)); | 145 autorun_command_line.reset(new CommandLine(argc, argv)); |
| 146 g_strfreev(argv); | 146 g_strfreev(argv); |
| 147 } else { | 147 } else { |
| 148 ADD_FAILURE(); | 148 ADD_FAILURE(); |
| 149 g_error_free(error); | 149 g_error_free(error); |
| 150 } | 150 } |
| 151 #endif // defined(OS_WIN) | 151 #endif // defined(OS_WIN) |
| 152 if (autorun_command_line.get()) { | 152 if (autorun_command_line.get()) { |
| 153 EXPECT_EQ(autorun_command_line->GetSwitchValueASCII(switches::kProcessType), | 153 EXPECT_EQ(autorun_command_line->GetSwitchValueASCII(switches::kProcessType), |
| 154 std::string(switches::kServiceProcess)); | 154 std::string(switches::kServiceProcess)); |
| 155 } | 155 } |
| 156 ASSERT_TRUE(state.RemoveFromAutoRun()); | 156 ASSERT_TRUE(state.RemoveFromAutoRun()); |
| 157 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
| 158 EXPECT_FALSE(base::win::ReadCommandFromAutoRun(HKEY_CURRENT_USER, | 158 EXPECT_FALSE(base::win::ReadCommandFromAutoRun(HKEY_CURRENT_USER, |
| 159 UTF8ToWide(value_name), | 159 base::UTF8ToWide(value_name), |
| 160 &value)); | 160 &value)); |
| 161 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 161 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| 162 EXPECT_FALSE(AutoStart::GetAutostartFileValue( | 162 EXPECT_FALSE(AutoStart::GetAutostartFileValue( |
| 163 GetServiceProcessScopedName(base_desktop_name), "Exec", &exec_value)); | 163 GetServiceProcessScopedName(base_desktop_name), "Exec", &exec_value)); |
| 164 #endif // defined(OS_WIN) | 164 #endif // defined(OS_WIN) |
| 165 } | 165 } |
| 166 | 166 |
| 167 TEST_F(ServiceProcessStateTest, SharedMem) { | 167 TEST_F(ServiceProcessStateTest, SharedMem) { |
| 168 std::string version; | 168 std::string version; |
| 169 base::ProcessId pid; | 169 base::ProcessId pid; |
| (...skipping 239 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 |