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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_browsertest.cc

Issue 2685333005: ash: fix regression where ctrl+n put new window on wrong desktop (Closed)
Patch Set: Rebase to ToT Created 3 years, 10 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 // Note that in our testing we do not ever query the BrowserList for the "last 223 // Note that in our testing we do not ever query the BrowserList for the "last
224 // active" browser. That's because the browsers are set as "active" by 224 // active" browser. That's because the browsers are set as "active" by
225 // platform UI toolkit messages, and those messages are not sent during unit 225 // platform UI toolkit messages, and those messages are not sent during unit
226 // testing sessions. 226 // testing sessions.
227 227
228 OpenURLsPopupObserver observer; 228 OpenURLsPopupObserver observer;
229 BrowserList::AddObserver(&observer); 229 BrowserList::AddObserver(&observer);
230 230
231 Browser* popup = new Browser( 231 Browser* popup = new Browser(
232 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); 232 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile(), true));
233 ASSERT_TRUE(popup->is_type_popup()); 233 ASSERT_TRUE(popup->is_type_popup());
234 ASSERT_EQ(popup, observer.added_browser_); 234 ASSERT_EQ(popup, observer.added_browser_);
235 235
236 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 236 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
237 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 237 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
238 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 238 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
239 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 239 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
240 // This should create a new window, but re-use the profile from |popup|. If 240 // This should create a new window, but re-use the profile from |popup|. If
241 // it used a NULL or invalid profile, it would crash. 241 // it used a NULL or invalid profile, it would crash.
242 launch.OpenURLsInBrowser(popup, false, urls); 242 launch.OpenURLsInBrowser(popup, false, urls);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 Profile* profile1 = profile_manager->GetProfile( 519 Profile* profile1 = profile_manager->GetProfile(
520 dest_path.Append(FILE_PATH_LITERAL("New Profile 1"))); 520 dest_path.Append(FILE_PATH_LITERAL("New Profile 1")));
521 ASSERT_TRUE(profile1); 521 ASSERT_TRUE(profile1);
522 522
523 Profile* profile2 = profile_manager->GetProfile( 523 Profile* profile2 = profile_manager->GetProfile(
524 dest_path.Append(FILE_PATH_LITERAL("New Profile 2"))); 524 dest_path.Append(FILE_PATH_LITERAL("New Profile 2")));
525 ASSERT_TRUE(profile2); 525 ASSERT_TRUE(profile2);
526 526
527 // Open some urls with the browsers, and close them. 527 // Open some urls with the browsers, and close them.
528 Browser* browser1 = 528 Browser* browser1 =
529 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile1)); 529 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile1, true));
530 chrome::NewTab(browser1); 530 chrome::NewTab(browser1);
531 ui_test_utils::NavigateToURL(browser1, 531 ui_test_utils::NavigateToURL(browser1,
532 embedded_test_server()->GetURL("/empty.html")); 532 embedded_test_server()->GetURL("/empty.html"));
533 CloseBrowserSynchronously(browser1); 533 CloseBrowserSynchronously(browser1);
534 534
535 Browser* browser2 = new Browser( 535 Browser* browser2 =
536 Browser::CreateParams(Browser::TYPE_TABBED, profile2)); 536 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile2, true));
537 chrome::NewTab(browser2); 537 chrome::NewTab(browser2);
538 ui_test_utils::NavigateToURL(browser2, 538 ui_test_utils::NavigateToURL(browser2,
539 embedded_test_server()->GetURL("/form.html")); 539 embedded_test_server()->GetURL("/form.html"));
540 CloseBrowserSynchronously(browser2); 540 CloseBrowserSynchronously(browser2);
541 541
542 // Set different startup preferences for the 2 profiles. 542 // Set different startup preferences for the 2 profiles.
543 std::vector<GURL> urls1; 543 std::vector<GURL> urls1;
544 urls1.push_back(ui_test_utils::GetTestUrl( 544 urls1.push_back(ui_test_utils::GetTestUrl(
545 base::FilePath(base::FilePath::kCurrentDirectory), 545 base::FilePath(base::FilePath::kCurrentDirectory),
546 base::FilePath(FILE_PATH_LITERAL("title1.html")))); 546 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 urls.push_back(ui_test_utils::GetTestUrl( 660 urls.push_back(ui_test_utils::GetTestUrl(
661 base::FilePath(base::FilePath::kCurrentDirectory), 661 base::FilePath(base::FilePath::kCurrentDirectory),
662 base::FilePath(FILE_PATH_LITERAL("title1.html")))); 662 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
663 663
664 SessionStartupPref pref_urls(SessionStartupPref::URLS); 664 SessionStartupPref pref_urls(SessionStartupPref::URLS);
665 pref_urls.urls = urls; 665 pref_urls.urls = urls;
666 SessionStartupPref::SetStartupPref(profile_urls, pref_urls); 666 SessionStartupPref::SetStartupPref(profile_urls, pref_urls);
667 667
668 // Open a page with profile_last. 668 // Open a page with profile_last.
669 Browser* browser_last = new Browser( 669 Browser* browser_last = new Browser(
670 Browser::CreateParams(Browser::TYPE_TABBED, profile_last)); 670 Browser::CreateParams(Browser::TYPE_TABBED, profile_last, true));
671 chrome::NewTab(browser_last); 671 chrome::NewTab(browser_last);
672 ui_test_utils::NavigateToURL(browser_last, 672 ui_test_utils::NavigateToURL(browser_last,
673 embedded_test_server()->GetURL("/empty.html")); 673 embedded_test_server()->GetURL("/empty.html"));
674 CloseBrowserAsynchronously(browser_last); 674 CloseBrowserAsynchronously(browser_last);
675 675
676 // Close the main browser. 676 // Close the main browser.
677 CloseBrowserAsynchronously(browser()); 677 CloseBrowserAsynchronously(browser());
678 678
679 // Do a simple non-process-startup browser launch. 679 // Do a simple non-process-startup browser launch.
680 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 680 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 ASSERT_TRUE(browser); 1088 ASSERT_TRUE(browser);
1089 tab_strip = browser->tab_strip_model(); 1089 tab_strip = browser->tab_strip_model();
1090 1090
1091 // Ensure that the new tab page appears on subsequent runs. 1091 // Ensure that the new tab page appears on subsequent runs.
1092 ASSERT_EQ(1, tab_strip->count()); 1092 ASSERT_EQ(1, tab_strip->count());
1093 EXPECT_EQ("chrome://newtab/", 1093 EXPECT_EQ("chrome://newtab/",
1094 tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); 1094 tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec());
1095 } 1095 }
1096 1096
1097 #endif // !defined(OS_CHROMEOS) 1097 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698