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/test/browser_with_test_window_test.h" | 8 #include "chrome/test/browser_with_test_window_test.h" |
9 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
10 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 EXPECT_EQ(preview_tab_2_index, browser()->active_index()); | 104 EXPECT_EQ(preview_tab_2_index, browser()->active_index()); |
105 | 105 |
106 // Activate |tab_contents_1| tab. | 106 // Activate |tab_contents_1| tab. |
107 tab_contents_1->Activate(); | 107 tab_contents_1->Activate(); |
108 | 108 |
109 // When we get the preview tab for |tab_contents_1|, | 109 // When we get the preview tab for |tab_contents_1|, |
110 // |preview_tab_1| is activated and focused. | 110 // |preview_tab_1| is activated and focused. |
111 tab_controller->GetOrCreatePreviewTab(tab_contents_1); | 111 tab_controller->GetOrCreatePreviewTab(tab_contents_1); |
112 EXPECT_EQ(preview_tab_1_index, browser()->active_index()); | 112 EXPECT_EQ(preview_tab_1_index, browser()->active_index()); |
113 } | 113 } |
| 114 |
| 115 // Clear the initiator tab details associated with preview tab. |
| 116 TEST_F(PrintPreviewTabControllerTest, ClearInitiatorTabDetails) { |
| 117 ASSERT_TRUE(browser()); |
| 118 BrowserList::SetLastActive(browser()); |
| 119 ASSERT_TRUE(BrowserList::GetLastActive()); |
| 120 |
| 121 // Lets start with one window with one tab. |
| 122 EXPECT_EQ(1u, BrowserList::size()); |
| 123 EXPECT_EQ(0, browser()->tab_count()); |
| 124 browser()->NewTab(); |
| 125 EXPECT_EQ(1, browser()->tab_count()); |
| 126 |
| 127 // Create a reference to initiator tab contents. |
| 128 TabContents* initiator_tab = browser()->GetSelectedTabContents(); |
| 129 |
| 130 scoped_refptr<printing::PrintPreviewTabController> |
| 131 tab_controller(new printing::PrintPreviewTabController()); |
| 132 ASSERT_TRUE(tab_controller); |
| 133 |
| 134 // Get the preview tab for initiator tab. |
| 135 TabContents* preview_tab = |
| 136 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
| 137 |
| 138 // New print preview tab is created. Current focus is on preview tab. |
| 139 EXPECT_EQ(2, browser()->tab_count()); |
| 140 EXPECT_NE(initiator_tab, preview_tab); |
| 141 |
| 142 // Clear the initiator tab details associated with the preview tab. |
| 143 tab_controller->EraseInitiatorTabInfo(preview_tab); |
| 144 |
| 145 // Activate initiator_tab. |
| 146 initiator_tab->Activate(); |
| 147 |
| 148 // Get the print preview tab for initiator tab. |
| 149 TabContents* new_preview_tab = |
| 150 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
| 151 |
| 152 // New preview tab is created. |
| 153 EXPECT_EQ(3, browser()->tab_count()); |
| 154 EXPECT_NE(new_preview_tab, preview_tab); |
| 155 } |
OLD | NEW |