OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | |
10 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
12 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
17 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
18 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
19 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/test_navigation_observer.h" | 21 #include "content/public/test/test_navigation_observer.h" |
23 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
24 #include "url/url_constants.h" | 23 #include "url/url_constants.h" |
25 | 24 |
25 #if defined(OS_MACOSX) | |
26 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | |
27 #endif // defined(OS_MACOSX) | |
28 | |
26 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
27 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
28 #include "ui/aura/window_tree_host.h" | 31 #include "ui/aura/window_tree_host.h" |
29 #endif | 32 #endif |
30 | 33 |
31 using task_manager::browsertest_util::MatchAboutBlankTab; | |
32 using task_manager::browsertest_util::MatchAnyPrint; | |
33 using task_manager::browsertest_util::MatchAnyTab; | |
34 using task_manager::browsertest_util::MatchPrint; | |
35 using task_manager::browsertest_util::WaitForTaskManagerRows; | |
36 | |
37 namespace { | 34 namespace { |
38 | 35 |
39 class PrintPreviewTest : public InProcessBrowserTest { | 36 class PrintPreviewTest : public InProcessBrowserTest { |
40 public: | 37 public: |
41 PrintPreviewTest() {} | 38 PrintPreviewTest() {} |
42 | 39 |
43 void Print() { | 40 void Print() { |
44 content::TestNavigationObserver nav_observer(NULL); | 41 content::TestNavigationObserver nav_observer(NULL); |
45 nav_observer.StartWatchingNewWebContents(); | 42 nav_observer.StartWatchingNewWebContents(); |
46 chrome::ExecuteCommand(browser(), IDC_PRINT); | 43 chrome::ExecuteCommand(browser(), IDC_PRINT); |
(...skipping 30 matching lines...) Expand all Loading... | |
77 browser()->tab_strip_model()->GetActiveWebContents()); | 74 browser()->tab_strip_model()->GetActiveWebContents()); |
78 chrome::Reload(browser(), CURRENT_TAB); | 75 chrome::Reload(browser(), CURRENT_TAB); |
79 reload_observer.Wait(); | 76 reload_observer.Wait(); |
80 | 77 |
81 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT)); | 78 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT)); |
82 | 79 |
83 ASSERT_EQ(is_basic_print_expected, | 80 ASSERT_EQ(is_basic_print_expected, |
84 chrome::IsCommandEnabled(browser(), IDC_BASIC_PRINT)); | 81 chrome::IsCommandEnabled(browser(), IDC_BASIC_PRINT)); |
85 } | 82 } |
86 | 83 |
84 // Old task manager browser tests should only run on Mac. | |
85 #if defined(OS_MACOSX) | |
86 using task_manager::browsertest_util::MatchAboutBlankTab; | |
87 using task_manager::browsertest_util::MatchAnyPrint; | |
88 using task_manager::browsertest_util::MatchAnyTab; | |
89 using task_manager::browsertest_util::MatchPrint; | |
90 using task_manager::browsertest_util::WaitForTaskManagerRows; | |
91 | |
87 // Disable the test for mac, see http://crbug/367665. | 92 // Disable the test for mac, see http://crbug/367665. |
88 #if defined(OS_MACOSX) || defined(OS_LINUX) | 93 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, DISABLED_TaskManagerNewPrintPreview) { |
89 #define MAYBE_TaskManagerNewPrintPreview DISABLED_TaskManagerNewPrintPreview | |
90 #else | |
91 #define MAYBE_TaskManagerNewPrintPreview TaskManagerNewPrintPreview | |
92 #endif | |
93 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, MAYBE_TaskManagerNewPrintPreview) { | |
94 // This test is for the old implementation of the task manager. We must | |
95 // explicitly disable the new one. | |
96 task_manager::browsertest_util::EnableOldTaskManager(); | |
97 | |
98 chrome::ShowTaskManager(browser()); // Show task manager BEFORE print dialog. | 94 chrome::ShowTaskManager(browser()); // Show task manager BEFORE print dialog. |
99 | 95 |
100 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 96 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
101 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 97 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
102 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyPrint())); | 98 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyPrint())); |
ncarter (slow)
2016/04/22 21:47:20
Let's not put these tests on a path to deletion. F
afakhry
2016/04/22 22:51:18
We do have printing coverage for the new task mana
| |
103 | 99 |
104 // Create the print preview dialog. | 100 // Create the print preview dialog. |
105 Print(); | 101 Print(); |
106 | 102 |
107 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 103 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
108 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 104 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
109 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); | 105 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); |
110 ASSERT_NO_FATAL_FAILURE( | 106 ASSERT_NO_FATAL_FAILURE( |
111 WaitForTaskManagerRows(1, MatchPrint(url::kAboutBlankURL))); | 107 WaitForTaskManagerRows(1, MatchPrint(url::kAboutBlankURL))); |
112 } | 108 } |
113 | 109 |
114 // http://crbug/367665. | 110 // http://crbug/367665. |
115 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, | 111 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, |
116 DISABLED_TaskManagerExistingPrintPreview) { | 112 DISABLED_TaskManagerExistingPrintPreview) { |
117 // This test is for the old implementation of the task manager. We must | |
118 // explicitly disable the new one. | |
119 task_manager::browsertest_util::EnableOldTaskManager(); | |
120 | |
121 // Create the print preview dialog. | 113 // Create the print preview dialog. |
122 Print(); | 114 Print(); |
123 | 115 |
124 chrome::ShowTaskManager(browser()); // Show task manager AFTER print dialog. | 116 chrome::ShowTaskManager(browser()); // Show task manager AFTER print dialog. |
125 | 117 |
126 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 118 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
127 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 119 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
128 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); | 120 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); |
129 ASSERT_NO_FATAL_FAILURE( | 121 ASSERT_NO_FATAL_FAILURE( |
130 WaitForTaskManagerRows(1, MatchPrint(url::kAboutBlankURL))); | 122 WaitForTaskManagerRows(1, MatchPrint(url::kAboutBlankURL))); |
131 } | 123 } |
124 #endif // defined(OS_MACOSX) | |
132 | 125 |
133 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
134 // http://crbug.com/396360 | 127 // http://crbug.com/396360 |
135 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, DISABLED_NoCrashOnCloseWithOtherTabs) { | 128 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, DISABLED_NoCrashOnCloseWithOtherTabs) { |
136 // Now print preview. | 129 // Now print preview. |
137 Print(); | 130 Print(); |
138 | 131 |
139 ui_test_utils::NavigateToURLWithDisposition( | 132 ui_test_utils::NavigateToURLWithDisposition( |
140 browser(), GURL("about:blank"), NEW_FOREGROUND_TAB, | 133 browser(), GURL("about:blank"), NEW_FOREGROUND_TAB, |
141 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 134 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
142 | 135 |
143 browser()->tab_strip_model()->ActivateTabAt(0, true); | 136 browser()->tab_strip_model()->ActivateTabAt(0, true); |
144 | 137 |
145 // Navigate main tab to hide print preview. | 138 // Navigate main tab to hide print preview. |
146 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 139 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
147 | 140 |
148 browser()->tab_strip_model()->ActivateTabAt(1, true); | 141 browser()->tab_strip_model()->ActivateTabAt(1, true); |
149 } | 142 } |
150 #endif // defined(OS_WIN) | 143 #endif // defined(OS_WIN) |
151 | 144 |
152 } // namespace | 145 } // namespace |
OLD | NEW |