OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/printing/print_preview_tab_controller.h" | 5 #include "chrome/browser/printing/print_preview_tab_controller.h" |
6 #include "chrome/browser/printing/print_view_manager.h" | 6 #include "chrome/browser/printing/print_view_manager.h" |
7 #include "chrome/browser/tabs/tab_strip_model.h" | 7 #include "chrome/browser/tabs/tab_strip_model.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
10 #include "chrome/browser/ui/webui/print_preview_ui.h" | 10 #include "chrome/browser/ui/webui/print_preview_ui.h" |
11 #include "chrome/test/base/browser_with_test_window_test.h" | 11 #include "chrome/test/base/browser_with_test_window_test.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "content/browser/tab_contents/navigation_entry.h" | 13 #include "content/browser/tab_contents/navigation_entry.h" |
14 #include "content/browser/tab_contents/navigation_details.h" | 14 #include "content/browser/tab_contents/navigation_details.h" |
15 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
19 | 19 |
| 20 // Test crashes on Aura due to initiator tab's native view having no parent. |
| 21 // http://crbug.com/104284 |
| 22 #if defined(USE_AURA) |
| 23 #define MAYBE_GetOrCreatePreviewTab DISABLED_GetOrCreatePreviewTab |
| 24 #define MAYBE_MultiplePreviewTabs DISABLED_MultiplePreviewTabs |
| 25 #define MAYBE_ClearInitiatorTabDetails DISABLED_ClearInitiatorTabDetails |
| 26 #else |
| 27 #define MAYBE_GetOrCreatePreviewTab GetOrCreatePreviewTab |
| 28 #define MAYBE_MultiplePreviewTabs MultiplePreviewTabs |
| 29 #define MAYBE_ClearInitiatorTabDetails ClearInitiatorTabDetails |
| 30 #endif |
| 31 |
20 typedef BrowserWithTestWindowTest PrintPreviewTabControllerUnitTest; | 32 typedef BrowserWithTestWindowTest PrintPreviewTabControllerUnitTest; |
21 | 33 |
22 // Test crashs on TouchUI due to initiator tab's native view having no parent. | |
23 // http://crbug.com/104284 | |
24 // Crashes on Aura due to no FocusManager. | |
25 // http://crbug.com/105186 | |
26 #if defined(TOUCH_UI) || defined(USE_AURA) | |
27 #define MAYBE_GetOrCreatePreviewTab DISABLED_GetOrCreatePreviewTab | |
28 #else | |
29 #define MAYBE_GetOrCreatePreviewTab GetOrCreatePreviewTab | |
30 #endif | |
31 // Create/Get a preview tab for initiator tab. | 34 // Create/Get a preview tab for initiator tab. |
32 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { | 35 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { |
33 ASSERT_TRUE(browser()); | 36 ASSERT_TRUE(browser()); |
34 BrowserList::SetLastActive(browser()); | 37 BrowserList::SetLastActive(browser()); |
35 ASSERT_TRUE(BrowserList::GetLastActive()); | 38 ASSERT_TRUE(BrowserList::GetLastActive()); |
36 | 39 |
37 // Lets start with one window with one tab. | 40 // Lets start with one window with one tab. |
38 EXPECT_EQ(1u, BrowserList::size()); | 41 EXPECT_EQ(1u, BrowserList::size()); |
39 EXPECT_EQ(0, browser()->tab_count()); | 42 EXPECT_EQ(0, browser()->tab_count()); |
40 browser()->NewTab(); | 43 browser()->NewTab(); |
(...skipping 20 matching lines...) Expand all Loading... |
61 TabContentsWrapper* new_preview_tab = | 64 TabContentsWrapper* new_preview_tab = |
62 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 65 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
63 | 66 |
64 // Preview tab already exists. Tab count remains the same. | 67 // Preview tab already exists. Tab count remains the same. |
65 EXPECT_EQ(1, browser()->tab_count()); | 68 EXPECT_EQ(1, browser()->tab_count()); |
66 | 69 |
67 // 1:1 relationship between initiator and preview tab. | 70 // 1:1 relationship between initiator and preview tab. |
68 EXPECT_EQ(new_preview_tab, preview_tab); | 71 EXPECT_EQ(new_preview_tab, preview_tab); |
69 } | 72 } |
70 | 73 |
71 // http://crbug.com/104284 | |
72 // http://crbug.com/105186 | |
73 #if defined(TOUCH_UI) || defined(USE_AURA) | |
74 #define MAYBE_MultiplePreviewTabs DISABLED_MultiplePreviewTabs | |
75 #else | |
76 #define MAYBE_MultiplePreviewTabs MultiplePreviewTabs | |
77 #endif | |
78 // To show multiple print preview tabs exist in the same browser for | 74 // To show multiple print preview tabs exist in the same browser for |
79 // different initiator tabs. If preview tab already exists for an initiator, it | 75 // different initiator tabs. If preview tab already exists for an initiator, it |
80 // gets focused. | 76 // gets focused. |
81 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_MultiplePreviewTabs) { | 77 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_MultiplePreviewTabs) { |
82 ASSERT_TRUE(browser()); | 78 ASSERT_TRUE(browser()); |
83 BrowserList::SetLastActive(browser()); | 79 BrowserList::SetLastActive(browser()); |
84 ASSERT_TRUE(BrowserList::GetLastActive()); | 80 ASSERT_TRUE(BrowserList::GetLastActive()); |
85 | 81 |
86 // Lets start with one window and two tabs. | 82 // Lets start with one window and two tabs. |
87 EXPECT_EQ(1u, BrowserList::size()); | 83 EXPECT_EQ(1u, BrowserList::size()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 EXPECT_EQ(-1, preview_tab_1_index); | 127 EXPECT_EQ(-1, preview_tab_1_index); |
132 EXPECT_EQ(-1, preview_tab_2_index); | 128 EXPECT_EQ(-1, preview_tab_2_index); |
133 EXPECT_EQ(tab_2_index, browser()->active_index()); | 129 EXPECT_EQ(tab_2_index, browser()->active_index()); |
134 | 130 |
135 // When we get the preview tab for |tab_contents_1|, | 131 // When we get the preview tab for |tab_contents_1|, |
136 // |preview_tab_1| is activated and focused. | 132 // |preview_tab_1| is activated and focused. |
137 tab_controller->GetOrCreatePreviewTab(tab_contents_1); | 133 tab_controller->GetOrCreatePreviewTab(tab_contents_1); |
138 EXPECT_EQ(tab_1_index, browser()->active_index()); | 134 EXPECT_EQ(tab_1_index, browser()->active_index()); |
139 } | 135 } |
140 | 136 |
141 // http://crbug.com/104284 | |
142 // http://crbug.com/105186 | |
143 #if defined(TOUCH_UI) || defined(USE_AURA) | |
144 #define MAYBE_ClearInitiatorTabDetails DISABLED_ClearInitiatorTabDetails | |
145 #else | |
146 #define MAYBE_ClearInitiatorTabDetails ClearInitiatorTabDetails | |
147 #endif | |
148 // Clear the initiator tab details associated with preview tab. | 137 // Clear the initiator tab details associated with preview tab. |
149 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_ClearInitiatorTabDetails) { | 138 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_ClearInitiatorTabDetails) { |
150 ASSERT_TRUE(browser()); | 139 ASSERT_TRUE(browser()); |
151 BrowserList::SetLastActive(browser()); | 140 BrowserList::SetLastActive(browser()); |
152 ASSERT_TRUE(BrowserList::GetLastActive()); | 141 ASSERT_TRUE(BrowserList::GetLastActive()); |
153 | 142 |
154 // Lets start with one window with one tab. | 143 // Lets start with one window with one tab. |
155 EXPECT_EQ(1u, BrowserList::size()); | 144 EXPECT_EQ(1u, BrowserList::size()); |
156 EXPECT_EQ(0, browser()->tab_count()); | 145 EXPECT_EQ(0, browser()->tab_count()); |
157 browser()->NewTab(); | 146 browser()->NewTab(); |
(...skipping 20 matching lines...) Expand all Loading... |
178 tab_controller->EraseInitiatorTabInfo(preview_tab); | 167 tab_controller->EraseInitiatorTabInfo(preview_tab); |
179 | 168 |
180 // Get the print preview tab for initiator tab. | 169 // Get the print preview tab for initiator tab. |
181 TabContentsWrapper* new_preview_tab = | 170 TabContentsWrapper* new_preview_tab = |
182 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 171 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
183 | 172 |
184 // New preview tab is created. | 173 // New preview tab is created. |
185 EXPECT_EQ(1, browser()->tab_count()); | 174 EXPECT_EQ(1, browser()->tab_count()); |
186 EXPECT_NE(new_preview_tab, preview_tab); | 175 EXPECT_NE(new_preview_tab, preview_tab); |
187 } | 176 } |
OLD | NEW |