| Index: chrome/browser/ui/browser_list_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/ui/browser_list_unittest.cc (revision 84344)
|
| +++ chrome/browser/ui/browser_list_unittest.cc (working copy)
|
| @@ -2,7 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/printing/background_printing_manager.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| #include "chrome/test/browser_with_test_window_test.h"
|
|
|
| typedef BrowserWithTestWindowTest BrowserListTest;
|
| @@ -137,3 +139,77 @@
|
| browser2->CloseAllTabs();
|
| browser3->CloseAllTabs();
|
| }
|
| +
|
| +TEST_F(BrowserListTest, TabContentsIteratorBackgroundPrinting) {
|
| + // Make sure we have 1 window to start with.
|
| + EXPECT_EQ(1U, BrowserList::size());
|
| +
|
| + // Create more browsers/windows.
|
| + scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile()));
|
| + scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile()));
|
| +
|
| + scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get()));
|
| + scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get()));
|
| +
|
| + browser2->set_window(window2.get());
|
| + browser3->set_window(window3.get());
|
| +
|
| + EXPECT_EQ(0U, CountAllTabs());
|
| +
|
| + // Add some tabs.
|
| + for (size_t i = 0; i < 3; ++i)
|
| + browser2->NewTab();
|
| + browser3->NewTab();
|
| +
|
| + EXPECT_EQ(4U, CountAllTabs());
|
| +
|
| + TestingBrowserProcess* browser_process = testing_browser_process_.get();
|
| + printing::BackgroundPrintingManager* bg_print_manager =
|
| + browser_process->background_printing_manager();
|
| +
|
| + // Grab a tab and hide it.
|
| + TabContentsIterator tab_iterator;
|
| + TabContentsWrapper* tab = *tab_iterator;
|
| + bg_print_manager->HideTabContents(tab);
|
| +
|
| + EXPECT_EQ(4U, CountAllTabs());
|
| +
|
| + // Close remaining tabs.
|
| + browser2->CloseAllTabs();
|
| + browser3->CloseAllTabs();
|
| +
|
| + EXPECT_EQ(1U, CountAllTabs());
|
| +
|
| + // Delete the last remaining tab.
|
| + delete tab;
|
| +
|
| + EXPECT_EQ(0U, CountAllTabs());
|
| +
|
| + // Add some tabs.
|
| + for (size_t i = 0; i < 3; ++i) {
|
| + browser2->NewTab();
|
| + browser3->NewTab();
|
| + }
|
| +
|
| + EXPECT_EQ(6U, CountAllTabs());
|
| +
|
| + // Hide all tabs. Save the tabs in |hidden_tabs| because manipulating
|
| + // tabs in the middle of TabContentsIterator is a bad idea.
|
| + std::vector<TabContentsWrapper*> hidden_tabs;
|
| + for (TabContentsIterator iterator; !iterator.done(); ++iterator)
|
| + hidden_tabs.push_back(*iterator);
|
| + for (std::vector<TabContentsWrapper*>::iterator it = hidden_tabs.begin();
|
| + it != hidden_tabs.end(); ++it) {
|
| + bg_print_manager->HideTabContents(*it);
|
| + }
|
| +
|
| + EXPECT_EQ(6U, CountAllTabs());
|
| +
|
| + // Delete all tabs to clean up.
|
| + for (std::vector<TabContentsWrapper*>::iterator it = hidden_tabs.begin();
|
| + it != hidden_tabs.end(); ++it) {
|
| + delete *it;
|
| + }
|
| +
|
| + EXPECT_EQ(0U, CountAllTabs());
|
| +}
|
|
|