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/background_printing_manager.h" | 5 #include "chrome/browser/printing/background_printing_manager.h" |
6 #include "chrome/browser/ui/browser_list.h" | 6 #include "chrome/browser/ui/browser_list.h" |
7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome/test/base/browser_with_test_window_test.h" | 9 #include "chrome/test/base/browser_with_test_window_test.h" |
| 10 #include "chrome/test/base/testing_browser_process.h" |
10 | 11 |
11 typedef BrowserWithTestWindowTest BrowserListTest; | 12 typedef BrowserWithTestWindowTest BrowserListTest; |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // Helper function to iterate and count all the tabs. | 16 // Helper function to iterate and count all the tabs. |
16 size_t CountAllTabs() { | 17 size_t CountAllTabs() { |
17 size_t count = 0; | 18 size_t count = 0; |
18 for (TabContentsIterator iterator; !iterator.done(); ++iterator) | 19 for (TabContentsIterator iterator; !iterator.done(); ++iterator) |
19 ++count; | 20 ++count; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 165 |
165 EXPECT_EQ(0U, CountAllTabs()); | 166 EXPECT_EQ(0U, CountAllTabs()); |
166 | 167 |
167 // Add some tabs. | 168 // Add some tabs. |
168 for (size_t i = 0; i < 3; ++i) | 169 for (size_t i = 0; i < 3; ++i) |
169 browser2->NewTab(); | 170 browser2->NewTab(); |
170 browser3->NewTab(); | 171 browser3->NewTab(); |
171 | 172 |
172 EXPECT_EQ(4U, CountAllTabs()); | 173 EXPECT_EQ(4U, CountAllTabs()); |
173 | 174 |
174 TestingBrowserProcess* browser_process = testing_browser_process_.get(); | 175 TestingBrowserProcess* browser_process = |
| 176 static_cast<TestingBrowserProcess*>(g_browser_process); |
175 printing::BackgroundPrintingManager* bg_print_manager = | 177 printing::BackgroundPrintingManager* bg_print_manager = |
176 browser_process->background_printing_manager(); | 178 browser_process->background_printing_manager(); |
177 | 179 |
178 // Grab a tab and give ownership to BackgroundPrintingManager. | 180 // Grab a tab and give ownership to BackgroundPrintingManager. |
179 TabContentsIterator tab_iterator; | 181 TabContentsIterator tab_iterator; |
180 TabContentsWrapper* tab = *tab_iterator; | 182 TabContentsWrapper* tab = *tab_iterator; |
181 int page_id = 1; | 183 int page_id = 1; |
182 NavigateToPrintUrl(tab, page_id++); | 184 NavigateToPrintUrl(tab, page_id++); |
183 | 185 |
184 bg_print_manager->OwnTabContents(tab); | 186 bg_print_manager->OwnTabContents(tab); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 EXPECT_EQ(6U, CountAllTabs()); | 222 EXPECT_EQ(6U, CountAllTabs()); |
221 | 223 |
222 // Delete all tabs to clean up. | 224 // Delete all tabs to clean up. |
223 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin(); | 225 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin(); |
224 it != owned_tabs.end(); ++it) { | 226 it != owned_tabs.end(); ++it) { |
225 delete *it; | 227 delete *it; |
226 } | 228 } |
227 | 229 |
228 EXPECT_EQ(0U, CountAllTabs()); | 230 EXPECT_EQ(0U, CountAllTabs()); |
229 } | 231 } |
OLD | NEW |