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

Side by Side Diff: chrome/browser/sessions/session_restore_browsertest_chromeos.cc

Issue 1228723002: Extract duplicated code in browser_tests for closing a browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/WithoutWaiting/Asynchronously Created 5 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
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 <list> 5 #include <list>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 iter != browser_list_.end(); ++iter) { 47 iter != browser_list_.end(); ++iter) {
48 if (*iter == browser) { 48 if (*iter == browser) {
49 CloseBrowserSynchronously(*iter); 49 CloseBrowserSynchronously(*iter);
50 browser_list_.erase(iter); 50 browser_list_.erase(iter);
51 return true; 51 return true;
52 } 52 }
53 } 53 }
54 return false; 54 return false;
55 } 55 }
56 56
57 void CloseBrowserSynchronously(Browser* browser) {
58 content::WindowedNotificationObserver observer(
59 chrome::NOTIFICATION_BROWSER_CLOSED,
60 content::NotificationService::AllSources());
61 browser->window()->Close();
62 observer.Wait();
63 }
64
65 Browser::CreateParams CreateParamsForApp(const std::string name, 57 Browser::CreateParams CreateParamsForApp(const std::string name,
66 bool trusted) { 58 bool trusted) {
67 return Browser::CreateParams::CreateForApp( 59 return Browser::CreateParams::CreateForApp(
68 name, trusted, gfx::Rect(), profile(), chrome::GetActiveDesktop()); 60 name, trusted, gfx::Rect(), profile(), chrome::GetActiveDesktop());
69 } 61 }
70 62
71 // Turn on session restore before we restart. 63 // Turn on session restore before we restart.
72 void TurnOnSessionRestore() { 64 void TurnOnSessionRestore() {
73 SessionStartupPref::SetStartupPref( 65 SessionStartupPref::SetStartupPref(
74 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); 66 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 size_t total_count = 0; 154 size_t total_count = 0;
163 size_t maximized_count = 0; 155 size_t maximized_count = 0;
164 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 156 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
165 ++total_count; 157 ++total_count;
166 if (it->window()->IsMaximized()) 158 if (it->window()->IsMaximized())
167 ++maximized_count; 159 ++maximized_count;
168 } 160 }
169 EXPECT_EQ(4u, total_count); 161 EXPECT_EQ(4u, total_count);
170 EXPECT_EQ(2u, maximized_count); 162 EXPECT_EQ(2u, maximized_count);
171 } 163 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest.cc ('k') | chrome/browser/ui/settings_window_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698