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

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

Issue 8929027: 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
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/prefs/pref_service.h"
5 #include "chrome/browser/printing/background_printing_manager.h" 7 #include "chrome/browser/printing/background_printing_manager.h"
8 #include "chrome/browser/profiles/profile_manager.h"
6 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
11 #include "chrome/common/pref_names.h"
8 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
9 #include "chrome/test/base/browser_with_test_window_test.h" 13 #include "chrome/test/base/browser_with_test_window_test.h"
10 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
15 #include "chrome/test/base/testing_pref_service.h"
16 #include "chrome/test/base/testing_profile_manager.h"
11 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
12 18
13 typedef BrowserWithTestWindowTest BrowserListTest; 19 typedef BrowserWithTestWindowTest BrowserListTest;
14 20
15 namespace { 21 namespace {
16 22
17 // Helper function to iterate and count all the tabs. 23 // Helper function to iterate and count all the tabs.
18 size_t CountAllTabs() { 24 size_t CountAllTabs() {
19 size_t count = 0; 25 size_t count = 0;
20 for (TabContentsIterator iterator; !iterator.done(); ++iterator) 26 for (TabContentsIterator iterator; !iterator.done(); ++iterator)
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 231
226 // Delete all tabs to clean up. 232 // Delete all tabs to clean up.
227 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin(); 233 for (std::vector<TabContentsWrapper*>::iterator it = owned_tabs.begin();
228 it != owned_tabs.end(); ++it) { 234 it != owned_tabs.end(); ++it) {
229 delete *it; 235 delete *it;
230 } 236 }
231 237
232 EXPECT_EQ(0U, CountAllTabs()); 238 EXPECT_EQ(0U, CountAllTabs());
233 } 239 }
234 #endif 240 #endif
241
242 TEST_F(BrowserListTest, AttemptRestart) {
243 ASSERT_TRUE(g_browser_process);
244 TestingPrefService testing_pref_service;
245 testing_pref_service.RegisterBooleanPref(prefs::kWasRestarted, false);
246 testing_pref_service.RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown,
247 false);
248
249 TestingBrowserProcess* testing_browser_process =
250 static_cast<TestingBrowserProcess*>(g_browser_process);
251 testing_browser_process->SetLocalState(&testing_pref_service);
252 ASSERT_TRUE(g_browser_process->local_state());
253 ProfileManager* profile_manager = new ProfileManager(FilePath());
254 testing_browser_process->SetProfileManager(profile_manager);
255
256 BrowserList::AttemptRestart();
257 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted));
258 testing_browser_process->SetLocalState(NULL);
259 }
OLDNEW
« chrome/browser/ui/browser_init.cc ('K') | « 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