Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: chrome/browser/ui/browser_list_unittest.cc

Issue 7574002: Be able to print items that do window.print(); window.close() (airline tix e.g.) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Lei's comments. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 TestingBrowserProcess* browser_process = testing_browser_process_.get(); 174 TestingBrowserProcess* browser_process = testing_browser_process_.get();
175 printing::BackgroundPrintingManager* bg_print_manager = 175 printing::BackgroundPrintingManager* bg_print_manager =
176 browser_process->background_printing_manager(); 176 browser_process->background_printing_manager();
177 177
178 // Grab a tab and give ownership to BackgroundPrintingManager. 178 // Grab a tab and give ownership to BackgroundPrintingManager.
179 TabContentsIterator tab_iterator; 179 TabContentsIterator tab_iterator;
180 TabContentsWrapper* tab = *tab_iterator; 180 TabContentsWrapper* tab = *tab_iterator;
181 int page_id = 1; 181 int page_id = 1;
182 NavigateToPrintUrl(tab, page_id++); 182 NavigateToPrintUrl(tab, page_id++);
183 183
184 bg_print_manager->OwnTabContents(tab); 184 bg_print_manager->OwnPreviewTabContents(tab);
185 185
186 EXPECT_EQ(4U, CountAllTabs()); 186 EXPECT_EQ(4U, CountAllTabs());
187 187
188 // Close remaining tabs. 188 // Close remaining tabs.
189 browser2->CloseAllTabs(); 189 browser2->CloseAllTabs();
190 browser3->CloseAllTabs(); 190 browser3->CloseAllTabs();
191 191
192 EXPECT_EQ(1U, CountAllTabs()); 192 EXPECT_EQ(1U, CountAllTabs());
193 193
194 // Delete the last remaining tab. 194 // Delete the last remaining tab.
(...skipping 12 matching lines...) Expand all
207 // Tell BackgroundPrintingManager to take ownership of all tabs. 207 // Tell BackgroundPrintingManager to take ownership of all tabs.
208 // Save the tabs in |owned_tabs| because manipulating tabs in the middle of 208 // Save the tabs in |owned_tabs| because manipulating tabs in the middle of
209 // TabContentsIterator is a bad idea. 209 // TabContentsIterator is a bad idea.
210 std::vector<TabContentsWrapper*> owned_tabs; 210 std::vector<TabContentsWrapper*> owned_tabs;
211 for (TabContentsIterator iterator; !iterator.done(); ++iterator) { 211 for (TabContentsIterator iterator; !iterator.done(); ++iterator) {
212 NavigateToPrintUrl(*iterator, page_id++); 212 NavigateToPrintUrl(*iterator, page_id++);
213 owned_tabs.push_back(*iterator); 213 owned_tabs.push_back(*iterator);
214 } 214 }
215 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin(); 215 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin();
216 it != owned_tabs.end(); ++it) { 216 it != owned_tabs.end(); ++it) {
217 bg_print_manager->OwnTabContents(*it); 217 bg_print_manager->OwnPreviewTabContents(*it);
218 } 218 }
219 219
220 EXPECT_EQ(6U, CountAllTabs()); 220 EXPECT_EQ(6U, CountAllTabs());
221 221
222 // Delete all tabs to clean up. 222 // Delete all tabs to clean up.
223 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin(); 223 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin();
224 it != owned_tabs.end(); ++it) { 224 it != owned_tabs.end(); ++it) {
225 delete *it; 225 delete *it;
226 } 226 }
227 227
228 EXPECT_EQ(0U, CountAllTabs()); 228 EXPECT_EQ(0U, CountAllTabs());
229 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698