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