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

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

Issue 187443008: Elim Browser::AppType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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
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 "chrome/browser/ui/browser_navigator_browsertest.h" 5 #include "chrome/browser/ui/browser_navigator_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, 111 Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type,
112 Profile* profile) { 112 Profile* profile) {
113 Browser* browser = new Browser( 113 Browser* browser = new Browser(
114 Browser::CreateParams(type, profile, chrome::GetActiveDesktop())); 114 Browser::CreateParams(type, profile, chrome::GetActiveDesktop()));
115 chrome::AddTabAt(browser, GURL(), -1, true); 115 chrome::AddTabAt(browser, GURL(), -1, true);
116 return browser; 116 return browser;
117 } 117 }
118 118
119 Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, 119 Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Profile* profile) {
120 Profile* profile) {
121 Browser* browser = new Browser( 120 Browser* browser = new Browser(
122 Browser::CreateParams::CreateForApp( 121 Browser::CreateParams::CreateForApp(
123 Browser::TYPE_POPUP, "Test", gfx::Rect(), profile, 122 Browser::TYPE_POPUP, "Test", gfx::Rect(), profile,
124 chrome::GetActiveDesktop())); 123 chrome::GetActiveDesktop()));
125 chrome::AddTabAt(browser, GURL(), -1, true); 124 chrome::AddTabAt(browser, GURL(), -1, true);
126 return browser; 125 return browser;
127 } 126 }
128 127
129 WebContents* BrowserNavigatorTest::CreateWebContents() { 128 WebContents* BrowserNavigatorTest::CreateWebContents() {
130 content::WebContents::CreateParams create_params(browser()->profile()); 129 content::WebContents::CreateParams create_params(browser()->profile());
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 504
506 // We should have three windows, the browser() provided by the framework, 505 // We should have three windows, the browser() provided by the framework,
507 // the first popup window, and the second popup window. 506 // the first popup window, and the second popup window.
508 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); 507 EXPECT_EQ(3u, chrome::GetTotalBrowserCount());
509 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 508 EXPECT_EQ(1, browser()->tab_strip_model()->count());
510 EXPECT_EQ(1, p1.browser->tab_strip_model()->count()); 509 EXPECT_EQ(1, p1.browser->tab_strip_model()->count());
511 EXPECT_EQ(1, p2.browser->tab_strip_model()->count()); 510 EXPECT_EQ(1, p2.browser->tab_strip_model()->count());
512 } 511 }
513 512
514 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 513 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
515 // from an app frame results in a new Browser with TYPE_APP_POPUP. 514 // from an app frame results in a new Browser with TYPE_POPUP.
516 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 515 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
517 Disposition_NewPopupFromAppWindow) { 516 Disposition_NewPopupFromAppWindow) {
518 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, 517 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile());
519 browser()->profile());
520 chrome::NavigateParams p(MakeNavigateParams(app_browser)); 518 chrome::NavigateParams p(MakeNavigateParams(app_browser));
521 p.disposition = NEW_POPUP; 519 p.disposition = NEW_POPUP;
522 p.window_bounds = gfx::Rect(0, 0, 200, 200); 520 p.window_bounds = gfx::Rect(0, 0, 200, 200);
523 chrome::Navigate(&p); 521 chrome::Navigate(&p);
524 522
525 // Navigate() should have opened a new popup app window. 523 // Navigate() should have opened a new popup app window.
526 EXPECT_NE(app_browser, p.browser); 524 EXPECT_NE(app_browser, p.browser);
527 EXPECT_NE(browser(), p.browser); 525 EXPECT_NE(browser(), p.browser);
528 EXPECT_TRUE(p.browser->is_type_popup()); 526 EXPECT_TRUE(p.browser->is_type_popup());
529 EXPECT_TRUE(p.browser->is_app()); 527 EXPECT_TRUE(p.browser->is_app());
530 528
531 // We should now have three windows, the app window, the app popup it created, 529 // We should now have three windows, the app window, the app popup it created,
532 // and the original browser() provided by the framework. 530 // and the original browser() provided by the framework.
533 EXPECT_EQ(3u, chrome::GetTotalBrowserCount()); 531 EXPECT_EQ(3u, chrome::GetTotalBrowserCount());
534 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 532 EXPECT_EQ(1, browser()->tab_strip_model()->count());
535 EXPECT_EQ(1, app_browser->tab_strip_model()->count()); 533 EXPECT_EQ(1, app_browser->tab_strip_model()->count());
536 EXPECT_EQ(1, p.browser->tab_strip_model()->count()); 534 EXPECT_EQ(1, p.browser->tab_strip_model()->count());
537 } 535 }
538 536
539 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 537 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
540 // from an app popup results in a new Browser also of TYPE_APP_POPUP. 538 // from an app popup results in a new Browser also of TYPE_POPUP.
541 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 539 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
542 Disposition_NewPopupFromAppPopup) { 540 Disposition_NewPopupFromAppPopup) {
543 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, 541 Browser* app_browser = CreateEmptyBrowserForApp(browser()->profile());
544 browser()->profile());
545 // Open an app popup. 542 // Open an app popup.
546 chrome::NavigateParams p1(MakeNavigateParams(app_browser)); 543 chrome::NavigateParams p1(MakeNavigateParams(app_browser));
547 p1.disposition = NEW_POPUP; 544 p1.disposition = NEW_POPUP;
548 p1.window_bounds = gfx::Rect(0, 0, 200, 200); 545 p1.window_bounds = gfx::Rect(0, 0, 200, 200);
549 chrome::Navigate(&p1); 546 chrome::Navigate(&p1);
550 // Now open another app popup. 547 // Now open another app popup.
551 chrome::NavigateParams p2(MakeNavigateParams(p1.browser)); 548 chrome::NavigateParams p2(MakeNavigateParams(p1.browser));
552 p2.disposition = NEW_POPUP; 549 p2.disposition = NEW_POPUP;
553 p2.window_bounds = gfx::Rect(0, 0, 200, 200); 550 p2.window_bounds = gfx::Rect(0, 0, 200, 200);
554 chrome::Navigate(&p2); 551 chrome::Navigate(&p2);
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 // Open a renderer initiated POST request in new foreground tab. 1346 // Open a renderer initiated POST request in new foreground tab.
1350 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); 1347 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle));
1351 std::string post_data = kExpectedTitle; 1348 std::string post_data = kExpectedTitle;
1352 base::string16 title; 1349 base::string16 title;
1353 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( 1350 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle(
1354 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title)); 1351 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title));
1355 EXPECT_NE(expected_title, title); 1352 EXPECT_NE(expected_title, title);
1356 } 1353 }
1357 1354
1358 } // namespace 1355 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698