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

Side by Side Diff: chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc

Issue 10692195: Consolidate Browser Creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/tab_contents/tab_contents_iterator.h" 5 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/browser_shutdown.h" 8 #include "chrome/browser/browser_shutdown.h"
9 #include "chrome/browser/lifetime/application_lifetime.h" 9 #include "chrome/browser/lifetime/application_lifetime.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/printing/background_printing_manager.h" 11 #include "chrome/browser/printing/background_printing_manager.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
14 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/browser_with_test_window_test.h" 18 #include "chrome/test/base/browser_with_test_window_test.h"
19 #include "chrome/test/base/test_browser_window.h"
19 #include "chrome/test/base/testing_browser_process.h" 20 #include "chrome/test/base/testing_browser_process.h"
20 #include "chrome/test/base/testing_pref_service.h" 21 #include "chrome/test/base/testing_pref_service.h"
21 #include "chrome/test/base/testing_profile_manager.h" 22 #include "chrome/test/base/testing_profile_manager.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "content/public/test/test_renderer_host.h" 24 #include "content/public/test/test_renderer_host.h"
24 25
25 typedef BrowserWithTestWindowTest BrowserListTest; 26 typedef BrowserWithTestWindowTest BrowserListTest;
26 27
27 namespace { 28 namespace {
28 29
(...skipping 14 matching lines...) Expand all
43 44
44 } // namespace 45 } // namespace
45 46
46 TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { 47 TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) {
47 // Make sure we have 1 window to start with. 48 // Make sure we have 1 window to start with.
48 EXPECT_EQ(1U, BrowserList::size()); 49 EXPECT_EQ(1U, BrowserList::size());
49 50
50 EXPECT_EQ(0U, CountAllTabs()); 51 EXPECT_EQ(0U, CountAllTabs());
51 52
52 // Create more browsers/windows. 53 // Create more browsers/windows.
53 scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile())); 54 scoped_ptr<Browser> browser2(
54 scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile())); 55 chrome::CreateBrowserWithTestWindowForProfile(profile()));
55 scoped_ptr<Browser> browser4(new Browser(Browser::TYPE_TABBED, profile())); 56 scoped_ptr<Browser> browser3(
56 57 chrome::CreateBrowserWithTestWindowForProfile(profile()));
57 scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get())); 58 scoped_ptr<Browser> browser4(
58 scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get())); 59 chrome::CreateBrowserWithTestWindowForProfile(profile()));
59 scoped_ptr<TestBrowserWindow> window4(new TestBrowserWindow(browser4.get()));
60
61 browser2->SetWindowForTesting(window2.get());
62 browser3->SetWindowForTesting(window3.get());
63 browser4->SetWindowForTesting(window4.get());
64 60
65 // Sanity checks. 61 // Sanity checks.
66 EXPECT_EQ(4U, BrowserList::size()); 62 EXPECT_EQ(4U, BrowserList::size());
67 EXPECT_EQ(0, browser()->tab_count()); 63 EXPECT_EQ(0, browser()->tab_count());
68 EXPECT_EQ(0, browser2->tab_count()); 64 EXPECT_EQ(0, browser2->tab_count());
69 EXPECT_EQ(0, browser3->tab_count()); 65 EXPECT_EQ(0, browser3->tab_count());
70 EXPECT_EQ(0, browser4->tab_count()); 66 EXPECT_EQ(0, browser4->tab_count());
71 67
72 EXPECT_EQ(0U, CountAllTabs()); 68 EXPECT_EQ(0U, CountAllTabs());
73 69
(...skipping 16 matching lines...) Expand all
90 EXPECT_EQ(42U, CountAllTabs()); 86 EXPECT_EQ(42U, CountAllTabs());
91 // Close all remaining tabs to keep all the destructors happy. 87 // Close all remaining tabs to keep all the destructors happy.
92 chrome::CloseAllTabs(browser3.get()); 88 chrome::CloseAllTabs(browser3.get());
93 } 89 }
94 90
95 TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) { 91 TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) {
96 // Make sure we have 1 window to start with. 92 // Make sure we have 1 window to start with.
97 EXPECT_EQ(1U, BrowserList::size()); 93 EXPECT_EQ(1U, BrowserList::size());
98 94
99 // Create more browsers/windows. 95 // Create more browsers/windows.
100 scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile())); 96 scoped_ptr<Browser> browser2(
101 scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile())); 97 chrome::CreateBrowserWithTestWindowForProfile(profile()));
102 98 scoped_ptr<Browser> browser3(
103 scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get())); 99 chrome::CreateBrowserWithTestWindowForProfile(profile()));
104 scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get()));
105
106 browser2->SetWindowForTesting(window2.get());
107 browser3->SetWindowForTesting(window3.get());
108 100
109 // Sanity checks. 101 // Sanity checks.
110 EXPECT_EQ(3U, BrowserList::size()); 102 EXPECT_EQ(3U, BrowserList::size());
111 EXPECT_EQ(0, browser()->tab_count()); 103 EXPECT_EQ(0, browser()->tab_count());
112 EXPECT_EQ(0, browser2->tab_count()); 104 EXPECT_EQ(0, browser2->tab_count());
113 EXPECT_EQ(0, browser3->tab_count()); 105 EXPECT_EQ(0, browser3->tab_count());
114 106
115 EXPECT_EQ(0U, CountAllTabs()); 107 EXPECT_EQ(0U, CountAllTabs());
116 108
117 // Add some tabs. 109 // Add some tabs.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 chrome::CloseAllTabs(browser3.get()); 153 chrome::CloseAllTabs(browser3.get());
162 } 154 }
163 155
164 #if 0 156 #if 0
165 // TODO(thestig) Fix or remove this test. http://crbug.com/100309 157 // TODO(thestig) Fix or remove this test. http://crbug.com/100309
166 TEST_F(BrowserListTest, TabContentsIteratorBackgroundPrinting) { 158 TEST_F(BrowserListTest, TabContentsIteratorBackgroundPrinting) {
167 // Make sure we have 1 window to start with. 159 // Make sure we have 1 window to start with.
168 EXPECT_EQ(1U, BrowserList::size()); 160 EXPECT_EQ(1U, BrowserList::size());
169 161
170 // Create more browsers/windows. 162 // Create more browsers/windows.
171 scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile())); 163 scoped_ptr<Browser> browser2(
172 scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile())); 164 chrome::CreateBrowserWithTestWindowForProfile(profile()));
173 165 scoped_ptr<Browser> browser3(
174 scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get())); 166 chrome::CreateBrowserWithTestWindowForProfile(profile()));
175 scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get()));
176
177 browser2->SetWindowForTesting(window2.get());
178 browser3->SetWindowForTesting(window3.get());
179 167
180 EXPECT_EQ(0U, CountAllTabs()); 168 EXPECT_EQ(0U, CountAllTabs());
181 169
182 // Add some tabs. 170 // Add some tabs.
183 for (size_t i = 0; i < 3; ++i) 171 for (size_t i = 0; i < 3; ++i)
184 chrome::NewTab(browser2); 172 chrome::NewTab(browser2);
185 chrome::NewTab(browser3); 173 chrome::NewTab(browser3);
186 174
187 EXPECT_EQ(4U, CountAllTabs()); 175 EXPECT_EQ(4U, CountAllTabs());
188 176
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 testing_browser_process->SetProfileManager(profile_manager); 255 testing_browser_process->SetProfileManager(profile_manager);
268 256
269 browser::AttemptRestart(); 257 browser::AttemptRestart();
270 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests 258 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests
271 // ran after this one will fail. 259 // ran after this one will fail.
272 browser_shutdown::SetTryingToQuit(false); 260 browser_shutdown::SetTryingToQuit(false);
273 261
274 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); 262 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted));
275 testing_browser_process->SetLocalState(NULL); 263 testing_browser_process->SetLocalState(NULL);
276 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_impl.cc ('k') | chrome/browser/ui/tabs/pinned_tab_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698