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