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

Unified Diff: chrome/test/base/in_process_browser_test.cc

Issue 16174003: Make all tests use GetActiveDesktop() instead of hardcoding HOST_DESKTOP_TYPE_NATIVE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/in_process_browser_test.cc
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 293c4c8bbd9ada11bd10a41f00021704be8b97ba..29c5c1829a2773f8e70d5164cfbf3aec81756637 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -195,6 +195,10 @@ void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) {
if (command_line->HasSwitch(switches::kAshBrowserTests)) {
command_line->AppendSwitchNative(switches::kViewerLaunchViaAppId,
win8::test::kDefaultTestAppUserModelId);
+ // Ash already launches with a single browser opened, add kSilentLaunch to
+ // make sure StartupBrowserCreator doesn't attempt to launch a browser on
+ // the native desktop on startup.
+ command_line->AppendSwitch(switches::kSilentLaunch);
}
#endif
@@ -275,7 +279,7 @@ bool InProcessBrowserTest::SetUpUserDataDirectory() {
// finish loading and shows the browser.
Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
Browser* browser = new Browser(
- Browser::CreateParams(profile, chrome::HOST_DESKTOP_TYPE_NATIVE));
+ Browser::CreateParams(profile, chrome::GetActiveDesktop()));
AddBlankTabAndShow(browser);
return browser;
}
@@ -284,7 +288,7 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser() {
// Create a new browser with using the incognito profile.
Browser* incognito = new Browser(
Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile(),
- chrome::HOST_DESKTOP_TYPE_NATIVE));
+ chrome::GetActiveDesktop()));
AddBlankTabAndShow(incognito);
return incognito;
}
@@ -292,7 +296,7 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser() {
Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
Browser* browser =
new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile,
- chrome::HOST_DESKTOP_TYPE_NATIVE));
+ chrome::GetActiveDesktop()));
AddBlankTabAndShow(browser);
return browser;
}
@@ -303,7 +307,7 @@ Browser* InProcessBrowserTest::CreateBrowserForApp(
Browser* browser = new Browser(
Browser::CreateParams::CreateForApp(
Browser::TYPE_POPUP, app_name, gfx::Rect(), profile,
- chrome::HOST_DESKTOP_TYPE_NATIVE));
+ chrome::GetActiveDesktop()));
AddBlankTabAndShow(browser);
return browser;
}
@@ -359,11 +363,10 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
autorelease_pool_->Recycle();
#endif
- // Browser tests do not support multi-desktop for now.
- const BrowserList* native_browser_list =
- BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
- if (!native_browser_list->empty()) {
- browser_ = native_browser_list->get(0);
+ const BrowserList* active_browser_list =
+ BrowserList::GetInstance(chrome::GetActiveDesktop());
+ if (!active_browser_list->empty()) {
+ browser_ = active_browser_list->get(0);
#if defined(USE_ASH)
// There are cases where windows get created maximized by default.
if (browser_->window()->IsMaximized())
@@ -402,13 +405,24 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
content::RunAllPendingInMessageLoop();
QuitBrowsers();
- CHECK(native_browser_list->empty());
+ CHECK(active_browser_list->empty());
}
void InProcessBrowserTest::QuitBrowsers() {
if (chrome::GetTotalBrowserCount() == 0)
return;
+ // Browser tests only run on one desktop at a time and no action should result
+ // in browsers being created on any other desktop than the active desktop for
+ // this test.
+ chrome::HostDesktopType active_desktop_type = chrome::GetActiveDesktop();
+ for (chrome::HostDesktopType t = chrome::HOST_DESKTOP_TYPE_FIRST;
+ t < chrome::HOST_DESKTOP_TYPE_COUNT;
+ t = static_cast<chrome::HostDesktopType>(t + 1)) {
+ if (t != active_desktop_type)
+ CHECK(BrowserList::GetInstance(t)->empty()) << t;
+ }
+
// Invoke AttemptExit on a running message loop.
// AttemptExit exits the message loop after everything has been
// shut down properly.
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698