OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" |
| 8 #include "base/process_util.h" |
| 9 #include "base/test/test_timeouts.h" |
| 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/chrome_result_codes.h" |
| 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/common/result_codes.h" |
| 17 |
| 18 // These tests don't apply to the Mac version; see GetCommandLineForRelaunch |
| 19 // for details. |
| 20 #if defined(OS_MACOSX) |
| 21 #error This test file should not be part of the Mac build. |
| 22 #endif |
| 23 |
| 24 namespace { |
| 25 |
| 26 class CloudPrintPolicyTest : public InProcessBrowserTest { |
| 27 public: |
| 28 CloudPrintPolicyTest() {} |
| 29 }; |
| 30 |
| 31 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, NormalPassedFlag) { |
| 32 FilePath test_file_path = ui_test_utils::GetTestFilePath( |
| 33 FilePath(), FilePath().AppendASCII("empty.html")); |
| 34 CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 35 new_command_line.AppendArgPath(test_file_path); |
| 36 |
| 37 ui_test_utils::WindowedNotificationObserver observer( |
| 38 chrome::NOTIFICATION_TAB_ADDED, |
| 39 content::NotificationService::AllSources()); |
| 40 |
| 41 base::ProcessHandle handle; |
| 42 bool launched = |
| 43 base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle); |
| 44 EXPECT_TRUE(launched); |
| 45 |
| 46 observer.Wait(); |
| 47 |
| 48 int exit_code = -100; |
| 49 bool exited = |
| 50 base::WaitForExitCodeWithTimeout(handle, &exit_code, |
| 51 TestTimeouts::action_timeout_ms()); |
| 52 |
| 53 EXPECT_TRUE(exited); |
| 54 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code); |
| 55 base::CloseProcessHandle(handle); |
| 56 } |
| 57 |
| 58 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, CloudPrintPolicyFlag) { |
| 59 CommandLine new_command_line(GetCommandLineForRelaunch()); |
| 60 new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
| 61 |
| 62 base::ProcessHandle handle; |
| 63 bool launched = |
| 64 base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle); |
| 65 EXPECT_TRUE(launched); |
| 66 |
| 67 int exit_code = -100; |
| 68 bool exited = |
| 69 base::WaitForExitCodeWithTimeout(handle, &exit_code, |
| 70 TestTimeouts::action_timeout_ms()); |
| 71 |
| 72 EXPECT_TRUE(exited); |
| 73 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code); |
| 74 base::CloseProcessHandle(handle); |
| 75 } |
| 76 |
| 77 } // namespace |
OLD | NEW |