NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / printing / cloud_print / test / cloud_print_policy_browsertest.cc
blob344fcf42bbdc90743b8b0ed781cd4f4204dd9b48
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.
5 #include "base/command_line.h"
6 #include "base/path_service.h"
7 #include "base/process/kill.h"
8 #include "base/process/launch.h"
9 #include "base/test/test_timeouts.h"
10 #include "chrome/browser/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/test_switches.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/notification_service.h"
17 #include "content/public/common/result_codes.h"
19 // These tests don't apply to the Mac version; see GetCommandLineForRelaunch
20 // for details.
21 #if defined(OS_MACOSX)
22 #error This test file should not be part of the Mac build.
23 #endif
25 namespace {
27 class CloudPrintPolicyTest : public InProcessBrowserTest {
28 public:
29 CloudPrintPolicyTest() {}
32 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, NormalPassedFlag) {
33 #if defined(OS_WIN) && defined(USE_ASH)
34 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
35 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
36 return;
37 #endif
39 base::FilePath test_file_path = ui_test_utils::GetTestFilePath(
40 base::FilePath(), base::FilePath().AppendASCII("empty.html"));
41 CommandLine new_command_line(GetCommandLineForRelaunch());
42 new_command_line.AppendArgPath(test_file_path);
44 content::WindowedNotificationObserver observer(
45 chrome::NOTIFICATION_TAB_ADDED,
46 content::NotificationService::AllSources());
48 base::ProcessHandle handle;
49 bool launched =
50 base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle);
51 EXPECT_TRUE(launched);
53 observer.Wait();
55 int exit_code = -100;
56 bool exited =
57 base::WaitForExitCodeWithTimeout(handle, &exit_code,
58 TestTimeouts::action_timeout());
60 EXPECT_TRUE(exited);
61 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code);
62 base::CloseProcessHandle(handle);
65 // Disabled due to http://crbug.com/144393.
66 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, DISABLED_CloudPrintPolicyFlag) {
67 CommandLine new_command_line(GetCommandLineForRelaunch());
68 new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy);
70 base::ProcessHandle handle;
71 bool launched =
72 base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle);
73 EXPECT_TRUE(launched);
75 int exit_code = -100;
76 bool exited =
77 base::WaitForExitCodeWithTimeout(handle, &exit_code,
78 TestTimeouts::action_timeout());
80 EXPECT_TRUE(exited);
81 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code);
82 base::CloseProcessHandle(handle);
85 } // namespace