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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/process/kill.h" | 6 #include "base/process/kill.h" |
7 #include "base/process/launch.h" | 7 #include "base/process/launch.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/common/chrome_result_codes.h" | 10 #include "chrome/common/chrome_result_codes.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( | 38 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( |
39 base::FilePath(), base::FilePath().AppendASCII("empty.html")); | 39 base::FilePath(), base::FilePath().AppendASCII("empty.html")); |
40 CommandLine new_command_line(GetCommandLineForRelaunch()); | 40 CommandLine new_command_line(GetCommandLineForRelaunch()); |
41 new_command_line.AppendArgPath(test_file_path); | 41 new_command_line.AppendArgPath(test_file_path); |
42 | 42 |
43 content::WindowedNotificationObserver observer( | 43 content::WindowedNotificationObserver observer( |
44 chrome::NOTIFICATION_TAB_ADDED, | 44 chrome::NOTIFICATION_TAB_ADDED, |
45 content::NotificationService::AllSources()); | 45 content::NotificationService::AllSources()); |
46 | 46 |
47 base::ProcessHandle handle; | 47 base::Process process = |
48 bool launched = | 48 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest()); |
49 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest(), | 49 EXPECT_TRUE(process.IsValid()); |
50 &handle); | |
51 EXPECT_TRUE(launched); | |
52 | 50 |
53 observer.Wait(); | 51 observer.Wait(); |
54 | 52 |
55 int exit_code = -100; | 53 int exit_code = -100; |
56 bool exited = | 54 bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), |
57 base::WaitForExitCodeWithTimeout(handle, &exit_code, | 55 &exit_code); |
58 TestTimeouts::action_timeout()); | |
59 | |
60 EXPECT_TRUE(exited); | 56 EXPECT_TRUE(exited); |
61 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code); | 57 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code); |
62 base::CloseProcessHandle(handle); | |
63 } | 58 } |
64 | 59 |
65 // Disabled due to http://crbug.com/144393. | 60 // Disabled due to http://crbug.com/144393. |
66 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, DISABLED_CloudPrintPolicyFlag) { | 61 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, DISABLED_CloudPrintPolicyFlag) { |
67 CommandLine new_command_line(GetCommandLineForRelaunch()); | 62 CommandLine new_command_line(GetCommandLineForRelaunch()); |
68 new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); | 63 new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
69 // This is important for the test as the way the browser process is launched | 64 // This is important for the test as the way the browser process is launched |
70 // here causes the predictor databases to be initialized multiple times. This | 65 // here causes the predictor databases to be initialized multiple times. This |
71 // is not an issue for production where the process is launched as a service | 66 // is not an issue for production where the process is launched as a service |
72 // and a Profile is not created. See http://crbug.com/140466 for more details. | 67 // and a Profile is not created. See http://crbug.com/140466 for more details. |
73 new_command_line.AppendSwitchASCII( | 68 new_command_line.AppendSwitchASCII( |
74 switches::kSpeculativeResourcePrefetching, | 69 switches::kSpeculativeResourcePrefetching, |
75 switches::kSpeculativeResourcePrefetchingDisabled); | 70 switches::kSpeculativeResourcePrefetchingDisabled); |
76 | 71 |
77 base::ProcessHandle handle; | 72 base::Process process = |
78 bool launched = | 73 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest()); |
79 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest(), | 74 EXPECT_TRUE(process.IsValid()); |
80 &handle); | |
81 EXPECT_TRUE(launched); | |
82 | 75 |
83 int exit_code = -100; | 76 int exit_code = -100; |
84 bool exited = | 77 bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), |
85 base::WaitForExitCodeWithTimeout(handle, &exit_code, | 78 &exit_code); |
86 TestTimeouts::action_timeout()); | |
87 | |
88 EXPECT_TRUE(exited); | 79 EXPECT_TRUE(exited); |
89 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code); | 80 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code); |
90 base::CloseProcessHandle(handle); | |
91 } | 81 } |
92 | 82 |
93 } // namespace | 83 } // namespace |
OLD | NEW |