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/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 10 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
13 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/test/browser_test_utils.h" | 21 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/test_navigation_observer.h" | 22 #include "content/public/test/test_navigation_observer.h" |
23 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
| 24 #include "url/url_constants.h" |
24 | 25 |
25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
26 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
27 #include "ui/aura/window_tree_host.h" | 28 #include "ui/aura/window_tree_host.h" |
28 #endif | 29 #endif |
29 | 30 |
30 using task_manager::browsertest_util::MatchAboutBlankTab; | 31 using task_manager::browsertest_util::MatchAboutBlankTab; |
31 using task_manager::browsertest_util::MatchAnyPrint; | 32 using task_manager::browsertest_util::MatchAnyPrint; |
32 using task_manager::browsertest_util::MatchAnyTab; | 33 using task_manager::browsertest_util::MatchAnyTab; |
33 using task_manager::browsertest_util::MatchPrint; | 34 using task_manager::browsertest_util::MatchPrint; |
34 using task_manager::browsertest_util::WaitForTaskManagerRows; | 35 using task_manager::browsertest_util::WaitForTaskManagerRows; |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 class PrintPreviewTest : public InProcessBrowserTest { | 39 class PrintPreviewTest : public InProcessBrowserTest { |
39 public: | 40 public: |
40 PrintPreviewTest() {} | 41 PrintPreviewTest() {} |
41 | 42 |
42 void Print() { | 43 void Print() { |
43 content::TestNavigationObserver nav_observer(NULL); | 44 content::TestNavigationObserver nav_observer(NULL); |
44 nav_observer.StartWatchingNewWebContents(); | 45 nav_observer.StartWatchingNewWebContents(); |
45 chrome::ExecuteCommand(browser(), IDC_PRINT); | 46 chrome::ExecuteCommand(browser(), IDC_PRINT); |
46 nav_observer.Wait(); | 47 nav_observer.Wait(); |
47 nav_observer.StopWatchingNewWebContents(); | 48 nav_observer.StopWatchingNewWebContents(); |
48 } | 49 } |
49 }; | 50 }; |
50 | 51 |
51 // The two tests below are failing on Linux LSAN | |
52 // crbug.com/382523 | |
53 #if !defined(ADDRESS_SANITIZER) | |
54 | |
55 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, PrintCommands) { | 52 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, PrintCommands) { |
56 // We start off at about:blank page. | 53 // We start off at about:blank page. |
57 // Make sure there is 1 tab and print is enabled. | 54 // Make sure there is 1 tab and print is enabled. |
58 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 55 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
59 | 56 |
60 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT)); | 57 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT)); |
61 | 58 |
62 // Make sure advanced print command (Ctrl+Shift+p) is enabled. | 59 // Make sure advanced print command (Ctrl+Shift+p) is enabled. |
63 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ADVANCED_PRINT)); | 60 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ADVANCED_PRINT)); |
64 | 61 |
(...skipping 29 matching lines...) Expand all Loading... |
94 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 91 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
95 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 92 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
96 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyPrint())); | 93 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyPrint())); |
97 | 94 |
98 // Create the print preview dialog. | 95 // Create the print preview dialog. |
99 Print(); | 96 Print(); |
100 | 97 |
101 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 98 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
102 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 99 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
103 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); | 100 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); |
104 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchPrint("about:blank"))); | 101 ASSERT_NO_FATAL_FAILURE( |
| 102 WaitForTaskManagerRows(1, MatchPrint(url::kAboutBlankURL))); |
105 } | 103 } |
106 | 104 |
107 #endif | |
108 | |
109 // Disable the test for mac as it started being flaky, see http://crbug/367665. | 105 // Disable the test for mac as it started being flaky, see http://crbug/367665. |
110 #if defined(OS_MACOSX) && !defined(OS_IOS) | 106 #if defined(OS_MACOSX) && !defined(OS_IOS) |
111 #define MAYBE_TaskManagerExistingPrintPreview DISABLED_TaskManagerExistingPrintP
review | 107 #define MAYBE_TaskManagerExistingPrintPreview DISABLED_TaskManagerExistingPrintP
review |
112 // Disable the test for Linux LSAN, see http://crbug.com/382764. | |
113 #elif defined(OS_LINUX) && defined(ADDRESS_SANITIZER) | |
114 #define MAYBE_TaskManagerExistingPrintPreview DISABLED_TaskManagerExistingPrintP
review | |
115 #else | 108 #else |
116 #define MAYBE_TaskManagerExistingPrintPreview TaskManagerExistingPrintPreview | 109 #define MAYBE_TaskManagerExistingPrintPreview TaskManagerExistingPrintPreview |
117 #endif | 110 #endif |
118 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, | 111 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, |
119 MAYBE_TaskManagerExistingPrintPreview) { | 112 MAYBE_TaskManagerExistingPrintPreview) { |
120 // Create the print preview dialog. | 113 // Create the print preview dialog. |
121 Print(); | 114 Print(); |
122 | 115 |
123 chrome::ShowTaskManager(browser()); // Show task manager AFTER print dialog. | 116 chrome::ShowTaskManager(browser()); // Show task manager AFTER print dialog. |
124 | 117 |
125 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 118 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
126 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 119 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
127 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); | 120 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyPrint())); |
128 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchPrint("about:blank"))); | 121 ASSERT_NO_FATAL_FAILURE( |
| 122 WaitForTaskManagerRows(1, MatchPrint(url::kAboutBlankURL))); |
129 } | 123 } |
130 | 124 |
131 #if defined(OS_WIN) | 125 #if defined(OS_WIN) |
132 | |
133 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) { | 126 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) { |
134 HWND* child = reinterpret_cast<HWND*>(l_param); | 127 HWND* child = reinterpret_cast<HWND*>(l_param); |
135 *child = hwnd; | 128 *child = hwnd; |
136 // The first child window is the plugin, then its children. So stop | 129 // The first child window is the plugin, then its children. So stop |
137 // enumerating after the first callback. | 130 // enumerating after the first callback. |
138 return FALSE; | 131 return FALSE; |
139 } | 132 } |
140 | 133 |
141 // This test verifies that constrained windows aren't covered by windowed NPAPI | 134 // This test verifies that constrained windows aren't covered by windowed NPAPI |
142 // plugins. The code which fixes this is in WebContentsViewAura::WindowObserver. | 135 // plugins. The code which fixes this is in WebContentsViewAura::WindowObserver. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 browser(), GURL("about:blank"), NEW_FOREGROUND_TAB, | 191 browser(), GURL("about:blank"), NEW_FOREGROUND_TAB, |
199 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 192 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
200 | 193 |
201 browser()->tab_strip_model()->ActivateTabAt(0, true); | 194 browser()->tab_strip_model()->ActivateTabAt(0, true); |
202 | 195 |
203 // Navigate main tab to hide print preview. | 196 // Navigate main tab to hide print preview. |
204 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 197 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
205 | 198 |
206 browser()->tab_strip_model()->ActivateTabAt(1, true); | 199 browser()->tab_strip_model()->ActivateTabAt(1, true); |
207 } | 200 } |
208 #endif | 201 #endif // defined(OS_WIN) |
209 | 202 |
210 } // namespace | 203 } // namespace |
OLD | NEW |