| 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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Lets start with one window with one tab. | 34 // Lets start with one window with one tab. |
| 35 EXPECT_EQ(1u, BrowserList::size()); | 35 EXPECT_EQ(1u, BrowserList::size()); |
| 36 EXPECT_EQ(0, browser()->tab_count()); | 36 EXPECT_EQ(0, browser()->tab_count()); |
| 37 browser()->NewTab(); | 37 browser()->NewTab(); |
| 38 EXPECT_EQ(1, browser()->tab_count()); | 38 EXPECT_EQ(1, browser()->tab_count()); |
| 39 | 39 |
| 40 // Create a reference to initiator tab contents. | 40 // Create a reference to initiator tab contents. |
| 41 TabContentsWrapper* initiator_tab = | 41 TabContentsWrapper* initiator_tab = |
| 42 browser()->GetSelectedTabContentsWrapper(); | 42 browser()->GetSelectedTabContentsWrapper(); |
| 43 | 43 |
| 44 scoped_refptr<printing::PrintPreviewTabController> | 44 printing::PrintPreviewTabController* tab_controller = |
| 45 tab_controller(new printing::PrintPreviewTabController()); | 45 printing::PrintPreviewTabController::GetInstance(); |
| 46 ASSERT_TRUE(tab_controller); | 46 ASSERT_TRUE(tab_controller); |
| 47 | 47 |
| 48 // Get the preview tab for initiator tab. | 48 // Get the preview tab for initiator tab. |
| 49 TabContentsWrapper* preview_tab = | 49 TabContentsWrapper* preview_tab = |
| 50 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 50 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
| 51 | 51 |
| 52 // New print preview tab is created. | 52 // New print preview tab is created. |
| 53 EXPECT_EQ(1, browser()->tab_count()); | 53 EXPECT_EQ(1, browser()->tab_count()); |
| 54 EXPECT_NE(initiator_tab, preview_tab); | 54 EXPECT_NE(initiator_tab, preview_tab); |
| 55 | 55 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 TabContentsWrapper* tab_contents_1 = | 86 TabContentsWrapper* tab_contents_1 = |
| 87 browser()->GetSelectedTabContentsWrapper(); | 87 browser()->GetSelectedTabContentsWrapper(); |
| 88 ASSERT_TRUE(tab_contents_1); | 88 ASSERT_TRUE(tab_contents_1); |
| 89 | 89 |
| 90 browser()->NewTab(); | 90 browser()->NewTab(); |
| 91 TabContentsWrapper* tab_contents_2 = | 91 TabContentsWrapper* tab_contents_2 = |
| 92 browser()->GetSelectedTabContentsWrapper(); | 92 browser()->GetSelectedTabContentsWrapper(); |
| 93 ASSERT_TRUE(tab_contents_2); | 93 ASSERT_TRUE(tab_contents_2); |
| 94 EXPECT_EQ(2, browser()->tab_count()); | 94 EXPECT_EQ(2, browser()->tab_count()); |
| 95 | 95 |
| 96 scoped_refptr<printing::PrintPreviewTabController> | 96 printing::PrintPreviewTabController* tab_controller = |
| 97 tab_controller(new printing::PrintPreviewTabController()); | 97 printing::PrintPreviewTabController::GetInstance(); |
| 98 ASSERT_TRUE(tab_controller); | 98 ASSERT_TRUE(tab_controller); |
| 99 | 99 |
| 100 // Create preview tab for |tab_contents_1| | 100 // Create preview tab for |tab_contents_1| |
| 101 TabContentsWrapper* preview_tab_1 = | 101 TabContentsWrapper* preview_tab_1 = |
| 102 tab_controller->GetOrCreatePreviewTab(tab_contents_1); | 102 tab_controller->GetOrCreatePreviewTab(tab_contents_1); |
| 103 | 103 |
| 104 EXPECT_NE(tab_contents_1, preview_tab_1); | 104 EXPECT_NE(tab_contents_1, preview_tab_1); |
| 105 EXPECT_EQ(2, browser()->tab_count()); | 105 EXPECT_EQ(2, browser()->tab_count()); |
| 106 | 106 |
| 107 // Create preview tab for |tab_contents_2| | 107 // Create preview tab for |tab_contents_2| |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // Lets start with one window with one tab. | 146 // Lets start with one window with one tab. |
| 147 EXPECT_EQ(1u, BrowserList::size()); | 147 EXPECT_EQ(1u, BrowserList::size()); |
| 148 EXPECT_EQ(0, browser()->tab_count()); | 148 EXPECT_EQ(0, browser()->tab_count()); |
| 149 browser()->NewTab(); | 149 browser()->NewTab(); |
| 150 EXPECT_EQ(1, browser()->tab_count()); | 150 EXPECT_EQ(1, browser()->tab_count()); |
| 151 | 151 |
| 152 // Create a reference to initiator tab contents. | 152 // Create a reference to initiator tab contents. |
| 153 TabContentsWrapper* initiator_tab = | 153 TabContentsWrapper* initiator_tab = |
| 154 browser()->GetSelectedTabContentsWrapper(); | 154 browser()->GetSelectedTabContentsWrapper(); |
| 155 | 155 |
| 156 scoped_refptr<printing::PrintPreviewTabController> | 156 printing::PrintPreviewTabController* tab_controller = |
| 157 tab_controller(new printing::PrintPreviewTabController()); | 157 printing::PrintPreviewTabController::GetInstance(); |
| 158 ASSERT_TRUE(tab_controller); | 158 ASSERT_TRUE(tab_controller); |
| 159 | 159 |
| 160 // Get the preview tab for initiator tab. | 160 // Get the preview tab for initiator tab. |
| 161 TabContentsWrapper* preview_tab = | 161 TabContentsWrapper* preview_tab = |
| 162 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 162 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
| 163 | 163 |
| 164 // New print preview tab is created. Current focus is on preview tab. | 164 // New print preview tab is created. Current focus is on preview tab. |
| 165 EXPECT_EQ(1, browser()->tab_count()); | 165 EXPECT_EQ(1, browser()->tab_count()); |
| 166 EXPECT_NE(initiator_tab, preview_tab); | 166 EXPECT_NE(initiator_tab, preview_tab); |
| 167 | 167 |
| 168 // Clear the initiator tab details associated with the preview tab. | 168 // Clear the initiator tab details associated with the preview tab. |
| 169 tab_controller->EraseInitiatorTabInfo(preview_tab); | 169 tab_controller->EraseInitiatorTabInfo(preview_tab); |
| 170 | 170 |
| 171 // Get the print preview tab for initiator tab. | 171 // Get the print preview tab for initiator tab. |
| 172 TabContentsWrapper* new_preview_tab = | 172 TabContentsWrapper* new_preview_tab = |
| 173 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 173 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
| 174 | 174 |
| 175 // New preview tab is created. | 175 // New preview tab is created. |
| 176 EXPECT_EQ(1, browser()->tab_count()); | 176 EXPECT_EQ(1, browser()->tab_count()); |
| 177 EXPECT_NE(new_preview_tab, preview_tab); | 177 EXPECT_NE(new_preview_tab, preview_tab); |
| 178 } | 178 } |
| OLD | NEW |