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
21 #if defined(OS_MACOSX)
22 #error This test file should not be part of the Mac build.
27 class CloudPrintPolicyTest
: public InProcessBrowserTest
{
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
))
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
;
50 base::LaunchProcess(new_command_line
, base::LaunchOptionsForTest(),
52 EXPECT_TRUE(launched
);
58 base::WaitForExitCodeWithTimeout(handle
, &exit_code
,
59 TestTimeouts::action_timeout());
62 EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED
, exit_code
);
63 base::CloseProcessHandle(handle
);
66 // Disabled due to http://crbug.com/144393.
67 IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest
, DISABLED_CloudPrintPolicyFlag
) {
68 CommandLine
new_command_line(GetCommandLineForRelaunch());
69 new_command_line
.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy
);
71 base::ProcessHandle handle
;
73 base::LaunchProcess(new_command_line
, base::LaunchOptionsForTest(),
75 EXPECT_TRUE(launched
);
79 base::WaitForExitCodeWithTimeout(handle
, &exit_code
,
80 TestTimeouts::action_timeout());
83 EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT
, exit_code
);
84 base::CloseProcessHandle(handle
);