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

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

Issue 8916006: Revert 114441 - Follow-up changes to http://codereview.chromium.org/8937001 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/ui/browser_init_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser_process.h"
6 #include "chrome/browser/browser_shutdown.h"
7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/printing/background_printing_manager.h" 5 #include "chrome/browser/printing/background_printing_manager.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_list.h" 6 #include "chrome/browser/ui/browser_list.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/browser_with_test_window_test.h" 9 #include "chrome/test/base/browser_with_test_window_test.h"
15 #include "chrome/test/base/testing_browser_process.h" 10 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_pref_service.h"
17 #include "chrome/test/base/testing_profile_manager.h"
18 #include "content/browser/tab_contents/tab_contents.h" 11 #include "content/browser/tab_contents/tab_contents.h"
19 12
20 typedef BrowserWithTestWindowTest BrowserListTest; 13 typedef BrowserWithTestWindowTest BrowserListTest;
21 14
22 namespace { 15 namespace {
23 16
24 // Helper function to iterate and count all the tabs. 17 // Helper function to iterate and count all the tabs.
25 size_t CountAllTabs() { 18 size_t CountAllTabs() {
26 size_t count = 0; 19 size_t count = 0;
27 for (TabContentsIterator iterator; !iterator.done(); ++iterator) 20 for (TabContentsIterator iterator; !iterator.done(); ++iterator)
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 225
233 // Delete all tabs to clean up. 226 // Delete all tabs to clean up.
234 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin(); 227 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin();
235 it != owned_tabs.end(); ++it) { 228 it != owned_tabs.end(); ++it) {
236 delete *it; 229 delete *it;
237 } 230 }
238 231
239 EXPECT_EQ(0U, CountAllTabs()); 232 EXPECT_EQ(0U, CountAllTabs());
240 } 233 }
241 #endif 234 #endif
242
243 TEST_F(BrowserListTest, AttemptRestart) {
244 ASSERT_TRUE(g_browser_process);
245 TestingPrefService testing_pref_service;
246 testing_pref_service.RegisterBooleanPref(prefs::kWasRestarted, false);
247 testing_pref_service.RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown,
248 false);
249
250 TestingBrowserProcess* testing_browser_process =
251 static_cast<TestingBrowserProcess*>(g_browser_process);
252 testing_browser_process->SetLocalState(&testing_pref_service);
253 ASSERT_TRUE(g_browser_process->local_state());
254 ProfileManager* profile_manager = new ProfileManager(FilePath());
255 testing_browser_process->SetProfileManager(profile_manager);
256
257 BrowserList::AttemptRestart();
258 // Cancel the effects of us calling BrowserList::AttemptRestart. Otherwise
259 // tests ran after this one will fail.
260 browser_shutdown::SetTryingToQuit(false);
261
262 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted));
263 testing_browser_process->SetLocalState(NULL);
264 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698