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

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

Issue 14307023: chrome: Use base::MessageLoop. (Part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_focus_uitest.cc » ('j') | 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) 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 // Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser. 196 // Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser.
197 void CloseWindowCallback(Browser* browser) { 197 void CloseWindowCallback(Browser* browser) {
198 chrome::CloseWindow(browser); 198 chrome::CloseWindow(browser);
199 } 199 }
200 200
201 // Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app 201 // Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app
202 // menu. 202 // menu.
203 void RunCloseWithAppMenuCallback(Browser* browser) { 203 void RunCloseWithAppMenuCallback(Browser* browser) {
204 // ShowAppMenu is modal under views. Schedule a task that closes the window. 204 // ShowAppMenu is modal under views. Schedule a task that closes the window.
205 MessageLoop::current()->PostTask( 205 base::MessageLoop::current()->PostTask(
206 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); 206 FROM_HERE, base::Bind(&CloseWindowCallback, browser));
207 chrome::ShowAppMenu(browser); 207 chrome::ShowAppMenu(browser);
208 } 208 }
209 209
210 // Displays "INTERSTITIAL" while the interstitial is attached. 210 // Displays "INTERSTITIAL" while the interstitial is attached.
211 // (InterstitialPage can be used in a test directly, but there would be no way 211 // (InterstitialPage can be used in a test directly, but there would be no way
212 // to visually tell if it is showing or not.) 212 // to visually tell if it is showing or not.)
213 class TestInterstitialPage : public content::InterstitialPageDelegate { 213 class TestInterstitialPage : public content::InterstitialPageDelegate {
214 public: 214 public:
215 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { 215 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // ensures that it happens through the single IDC_EXIT of the test. 530 // ensures that it happens through the single IDC_EXIT of the test.
531 virtual void CleanUpOnMainThread() OVERRIDE { 531 virtual void CleanUpOnMainThread() OVERRIDE {
532 // Cycle both the MessageLoop and the Cocoa runloop twice to flush out any 532 // Cycle both the MessageLoop and the Cocoa runloop twice to flush out any
533 // Chrome work that generates Cocoa work. Do this twice since there are two 533 // Chrome work that generates Cocoa work. Do this twice since there are two
534 // Browsers that must be closed. 534 // Browsers that must be closed.
535 CycleRunLoops(); 535 CycleRunLoops();
536 CycleRunLoops(); 536 CycleRunLoops();
537 537
538 // Run the application event loop to completion, which will cycle the 538 // Run the application event loop to completion, which will cycle the
539 // native MessagePump on all platforms. 539 // native MessagePump on all platforms.
540 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 540 base::MessageLoop::current()->PostTask(FROM_HERE,
541 MessageLoop::current()->Run(); 541 base::MessageLoop::QuitClosure());
542 base::MessageLoop::current()->Run();
542 543
543 // Take care of any remaining Cocoa work. 544 // Take care of any remaining Cocoa work.
544 CycleRunLoops(); 545 CycleRunLoops();
545 546
546 // At this point, quit should be for real now. 547 // At this point, quit should be for real now.
547 ASSERT_EQ(0u, chrome::GetTotalBrowserCount()); 548 ASSERT_EQ(0u, chrome::GetTotalBrowserCount());
548 } 549 }
549 550
550 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run 551 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run
551 // loop. It also drains the NSAutoreleasePool. 552 // loop. It also drains the NSAutoreleasePool.
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 1165 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
1165 #define MAYBE_CloseWithAppMenuOpen DISABLED_CloseWithAppMenuOpen 1166 #define MAYBE_CloseWithAppMenuOpen DISABLED_CloseWithAppMenuOpen
1166 #else 1167 #else
1167 #define MAYBE_CloseWithAppMenuOpen CloseWithAppMenuOpen 1168 #define MAYBE_CloseWithAppMenuOpen CloseWithAppMenuOpen
1168 #endif 1169 #endif
1169 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_CloseWithAppMenuOpen) { 1170 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_CloseWithAppMenuOpen) {
1170 if (browser_defaults::kBrowserAliveWithNoWindows) 1171 if (browser_defaults::kBrowserAliveWithNoWindows)
1171 return; 1172 return;
1172 1173
1173 // We need a message loop running for menus on windows. 1174 // We need a message loop running for menus on windows.
1174 MessageLoop::current()->PostTask( 1175 base::MessageLoop::current()->PostTask(
1175 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser())); 1176 FROM_HERE, base::Bind(&RunCloseWithAppMenuCallback, browser()));
1176 } 1177 }
1177 1178
1178 #if !defined(OS_MACOSX) 1179 #if !defined(OS_MACOSX)
1179 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { 1180 IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) {
1180 ASSERT_TRUE(test_server()->Start()); 1181 ASSERT_TRUE(test_server()->Start());
1181 1182
1182 // Load an app 1183 // Load an app
1183 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1184 host_resolver()->AddRule("www.example.com", "127.0.0.1");
1184 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 1185 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2153 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2153 } 2154 }
2154 2155
2155 // Shift-middle-clicks open in a foreground tab. 2156 // Shift-middle-clicks open in a foreground tab.
2156 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { 2157 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) {
2157 int modifiers = WebKit::WebInputEvent::ShiftKey; 2158 int modifiers = WebKit::WebInputEvent::ShiftKey;
2158 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; 2159 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle;
2159 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2160 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2160 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2161 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2161 } 2162 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_focus_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698