| 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 13 matching lines...) Expand all Loading... |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class CloudPrintPolicyTest : public InProcessBrowserTest { | 26 class CloudPrintPolicyTest : public InProcessBrowserTest { |
| 27 public: | 27 public: |
| 28 CloudPrintPolicyTest() {} | 28 CloudPrintPolicyTest() {} |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, NormalPassedFlag) { | 31 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, NormalPassedFlag) { |
| 32 #if defined(OS_WIN) && defined(USE_ASH) | 32 #if defined(OS_WIN) && defined(USE_ASH) |
| 33 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 33 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 34 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 34 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 35 switches::kAshBrowserTests)) |
| 35 return; | 36 return; |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( | 39 base::FilePath test_file_path = ui_test_utils::GetTestFilePath( |
| 39 base::FilePath(), base::FilePath().AppendASCII("empty.html")); | 40 base::FilePath(), base::FilePath().AppendASCII("empty.html")); |
| 40 CommandLine new_command_line(GetCommandLineForRelaunch()); | 41 base::CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 41 new_command_line.AppendArgPath(test_file_path); | 42 new_command_line.AppendArgPath(test_file_path); |
| 42 | 43 |
| 43 content::WindowedNotificationObserver observer( | 44 content::WindowedNotificationObserver observer( |
| 44 chrome::NOTIFICATION_TAB_ADDED, | 45 chrome::NOTIFICATION_TAB_ADDED, |
| 45 content::NotificationService::AllSources()); | 46 content::NotificationService::AllSources()); |
| 46 | 47 |
| 47 base::Process process = | 48 base::Process process = |
| 48 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest()); | 49 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest()); |
| 49 EXPECT_TRUE(process.IsValid()); | 50 EXPECT_TRUE(process.IsValid()); |
| 50 | 51 |
| 51 observer.Wait(); | 52 observer.Wait(); |
| 52 | 53 |
| 53 int exit_code = -100; | 54 int exit_code = -100; |
| 54 bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), | 55 bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), |
| 55 &exit_code); | 56 &exit_code); |
| 56 EXPECT_TRUE(exited); | 57 EXPECT_TRUE(exited); |
| 57 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code); | 58 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code); |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Disabled due to http://crbug.com/144393. | 61 // Disabled due to http://crbug.com/144393. |
| 61 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, DISABLED_CloudPrintPolicyFlag) { | 62 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, DISABLED_CloudPrintPolicyFlag) { |
| 62 CommandLine new_command_line(GetCommandLineForRelaunch()); | 63 base::CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 63 new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); | 64 new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
| 64 // This is important for the test as the way the browser process is launched | 65 // This is important for the test as the way the browser process is launched |
| 65 // here causes the predictor databases to be initialized multiple times. This | 66 // here causes the predictor databases to be initialized multiple times. This |
| 66 // is not an issue for production where the process is launched as a service | 67 // is not an issue for production where the process is launched as a service |
| 67 // and a Profile is not created. See http://crbug.com/140466 for more details. | 68 // and a Profile is not created. See http://crbug.com/140466 for more details. |
| 68 new_command_line.AppendSwitchASCII( | 69 new_command_line.AppendSwitchASCII( |
| 69 switches::kSpeculativeResourcePrefetching, | 70 switches::kSpeculativeResourcePrefetching, |
| 70 switches::kSpeculativeResourcePrefetchingDisabled); | 71 switches::kSpeculativeResourcePrefetchingDisabled); |
| 71 | 72 |
| 72 base::Process process = | 73 base::Process process = |
| 73 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest()); | 74 base::LaunchProcess(new_command_line, base::LaunchOptionsForTest()); |
| 74 EXPECT_TRUE(process.IsValid()); | 75 EXPECT_TRUE(process.IsValid()); |
| 75 | 76 |
| 76 int exit_code = -100; | 77 int exit_code = -100; |
| 77 bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), | 78 bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), |
| 78 &exit_code); | 79 &exit_code); |
| 79 EXPECT_TRUE(exited); | 80 EXPECT_TRUE(exited); |
| 80 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code); | 81 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code); |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace | 84 } // namespace |
| OLD | NEW |