Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/apps/app_browsertest.cc

Issue 23054002: Added basic browser test for window.print() from Chrome apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added print preview auto-cancel to avoid test timeouts Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/launcher.h" 5 #include "apps/launcher.h"
6 #include "apps/native_app_window.h" 6 #include "apps/native_app_window.h"
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/extensions/component_loader.h" 24 #include "chrome/browser/extensions/component_loader.h"
25 #include "chrome/browser/extensions/event_router.h" 25 #include "chrome/browser/extensions/event_router.h"
26 #include "chrome/browser/extensions/extension_browsertest.h" 26 #include "chrome/browser/extensions/extension_browsertest.h"
27 #include "chrome/browser/extensions/extension_service.h" 27 #include "chrome/browser/extensions/extension_service.h"
28 #include "chrome/browser/extensions/extension_system.h" 28 #include "chrome/browser/extensions/extension_system.h"
29 #include "chrome/browser/extensions/extension_test_message_listener.h" 29 #include "chrome/browser/extensions/extension_test_message_listener.h"
30 #include "chrome/browser/tab_contents/render_view_context_menu.h" 30 #include "chrome/browser/tab_contents/render_view_context_menu.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/extensions/application_launch.h" 32 #include "chrome/browser/ui/extensions/application_launch.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 33 #include "chrome/browser/ui/tabs/tab_strip_model.h"
34 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
34 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/extensions/api/app_runtime.h" 36 #include "chrome/common/extensions/api/app_runtime.h"
36 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
37 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
38 #include "chrome/test/base/test_switches.h" 39 #include "chrome/test/base/test_switches.h"
39 #include "chrome/test/base/ui_test_utils.h" 40 #include "chrome/test/base/ui_test_utils.h"
40 #include "components/user_prefs/pref_registry_syncable.h" 41 #include "components/user_prefs/pref_registry_syncable.h"
41 #include "components/web_modal/web_contents_modal_dialog_manager.h" 42 #include "components/web_modal/web_contents_modal_dialog_manager.h"
42 #include "content/public/browser/devtools_agent_host.h" 43 #include "content/public/browser/devtools_agent_host.h"
43 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 LoadAndLaunchPlatformApp("minimal"); 1019 LoadAndLaunchPlatformApp("minimal");
1019 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 1020 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
1020 1021
1021 EXPECT_EQ(1LU, GetShellWindowCount()); 1022 EXPECT_EQ(1LU, GetShellWindowCount());
1022 ShellWindowRegistry::ShellWindowList shell_windows = ShellWindowRegistry::Get( 1023 ShellWindowRegistry::ShellWindowList shell_windows = ShellWindowRegistry::Get(
1023 browser()->profile())->shell_windows(); 1024 browser()->profile())->shell_windows();
1024 EXPECT_TRUE((*shell_windows.begin())->web_contents()-> 1025 EXPECT_TRUE((*shell_windows.begin())->web_contents()->
1025 GetRenderWidgetHostView()->HasFocus()); 1026 GetRenderWidgetHostView()->HasFocus());
1026 } 1027 }
1027 1028
1029 class PlatformAppPrintBrowserTest : public PlatformAppBrowserTest {
1030 public:
1031 PlatformAppPrintBrowserTest() {}
1032
1033 #if !defined(GOOGLE_CHROME_BUILD)
Vitaly Buka (NO REVIEWS) 2013/08/28 01:20:26 ifdef could be removed
dharcourt 2013/08/28 23:23:57 Done.
1034 // Ensures print tests use the print preview panel even for non-Chrome
1035 // Chromium builds (Chrome branded builds always use this panel).
1036 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1037 command_line->AppendSwitch(switches::kEnablePrintPreview);
1038 PlatformAppBrowserTest::SetUpCommandLine(command_line);
1039 }
1040 #endif
1041 };
1042
1043 // Currently this test doesn't work on OS X and only works if the PDF preview
1044 // plug-in is available. This plug-in will only be available in Chrome release
1045 // builds or if it has been manually copied from a Chrome release build. To run
1046 // this test when the plug-in has been manually copied, manually comment out the
1047 // GOOGLE_CHROME_BUILD part of the next line.
1048 #if defined(OS_MACOSX) || !defined(GOOGLE_CHROME_BUILD)
1049 #define MAYBE_WindowDotPrintWorks DISABLED_WindowDotPrintWorks
1050 #else
1051 #define MAYBE_WindowDotPrintWorks WindowDotPrintWorks
1052 #endif
1053
1054 IN_PROC_BROWSER_TEST_F(PlatformAppPrintBrowserTest, MAYBE_WindowDotPrintWorks) {
1055 PrintPreviewUI::SetAutoCancelForTesting(true);
1056 ASSERT_TRUE(RunPlatformAppTest("platform_apps/print_api")) << message_;
Vitaly Buka (NO REVIEWS) 2013/08/28 01:20:26 without auto close, where exactly tests timeouts?
dharcourt 2013/08/28 23:23:57 Inside RunPlatformAppTest, which never returns if
1057 PrintPreviewUI::SetAutoCancelForTesting(false);
Vitaly Buka (NO REVIEWS) 2013/08/28 01:20:26 Probably you can avoid static methods using if you
dharcourt 2013/08/28 23:23:57 Unfortunately I don't think I can use the same met
1058 }
1059
1028 1060
1029 #if defined(OS_CHROMEOS) 1061 #if defined(OS_CHROMEOS)
1030 1062
1031 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest, 1063 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest,
1032 public ShellWindowRegistry::Observer { 1064 public ShellWindowRegistry::Observer {
1033 public: 1065 public:
1034 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1066 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1035 // Tell chromeos to launch in Guest mode, aka incognito. 1067 // Tell chromeos to launch in Guest mode, aka incognito.
1036 command_line->AppendSwitch(switches::kIncognito); 1068 command_line->AppendSwitch(switches::kIncognito);
1037 PlatformAppBrowserTest::SetUpCommandLine(command_line); 1069 PlatformAppBrowserTest::SetUpCommandLine(command_line);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1113
1082 while (!ContainsKey(opener_app_ids_, file_manager->id())) { 1114 while (!ContainsKey(opener_app_ids_, file_manager->id())) {
1083 content::RunAllPendingInMessageLoop(); 1115 content::RunAllPendingInMessageLoop();
1084 } 1116 }
1085 } 1117 }
1086 1118
1087 #endif // defined(OS_CHROMEOS) 1119 #endif // defined(OS_CHROMEOS)
1088 1120
1089 1121
1090 } // namespace extensions 1122 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698