Chromium Code Reviews| Index: chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc |
| diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9c05718176cd008e66b2b57ef0e79f60843771a0 |
| --- /dev/null |
| +++ b/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/command_line.h" |
| +#include "base/file_util.h" |
| +#include "base/path_service.h" |
| +#include "base/process_util.h" |
| +#include "base/test/test_timeouts.h" |
| +#include "chrome/common/chrome_notification_types.h" |
| +#include "chrome/common/chrome_result_codes.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "content/public/browser/notification_service.h" |
| +#include "content/public/common/result_codes.h" |
| + |
| +// These tests don't apply to the Mac version; see GetCommandLineForRelaunch |
| +// for details. |
| +#if !defined(OS_MACOSX) |
|
Lei Zhang
2012/07/09 22:40:04
Can we just exclude this file on Mac in the .gypi
Scott Byer
2012/07/10 16:23:12
Done.
|
| + |
| +namespace { |
| + |
| +class CloudPrintPolicyTest : public InProcessBrowserTest { |
| + public: |
| + CloudPrintPolicyTest() {} |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, NormalPassedFlag) { |
| + FilePath test_file_path = ui_test_utils::GetTestFilePath( |
| + FilePath(), FilePath().AppendASCII("empty.html")); |
| + CommandLine new_command_line(GetCommandLineForRelaunch()); |
| + new_command_line.AppendArgPath(test_file_path); |
| + |
| + ui_test_utils::WindowedNotificationObserver observer( |
| + chrome::NOTIFICATION_TAB_ADDED, |
| + content::NotificationService::AllSources()); |
| + |
| + base::ProcessHandle handle; |
| + bool launched = |
| + base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle); |
| + EXPECT_TRUE(launched); |
| + |
| + observer.Wait(); |
| + |
| + int exit_code = -100; |
| + bool exited = |
| + base::WaitForExitCodeWithTimeout(handle, &exit_code, |
| + TestTimeouts::action_timeout_ms()); |
|
Albert Bodenhamer
2012/07/09 04:09:40
Do we need action_timeout_ms or action_timeout her
Scott Byer
2012/07/10 16:23:12
action_timeout_ms. I don't like integer (sec/tick/
|
| + |
| + EXPECT_TRUE(exited); |
| + EXPECT_EQ(exit_code, chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED); |
| + base::CloseProcessHandle(handle); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, CloudPrintPolicyFlag) { |
| + CommandLine new_command_line(GetCommandLineForRelaunch()); |
| + new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
| + |
| + base::ProcessHandle handle; |
| + bool launched = |
| + base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle); |
| + EXPECT_TRUE(launched); |
| + |
| + int exit_code = -100; |
| + bool exited = |
| + base::WaitForExitCodeWithTimeout(handle, &exit_code, |
| + TestTimeouts::action_timeout_ms()); |
| + |
| + EXPECT_TRUE(exited); |
| + EXPECT_EQ(exit_code, content::RESULT_CODE_NORMAL_EXIT); |
| + base::CloseProcessHandle(handle); |
| +} |
| + |
| +} // namespace |
| + |
| +#endif // !OS_MACOSX |