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

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

Issue 6296011: Fix for regression: Any window of type APP should create APP_POPUP windows. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add BrowserNavigatorTest.Disposition_NewPopupFromAppPopup Created 9 years, 11 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_navigator.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/profiles/profile.h" 6 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/tab_contents/tab_contents.h" 7 #include "chrome/browser/tab_contents/tab_contents.h"
8 #include "chrome/browser/tab_contents/tab_contents_view.h" 8 #include "chrome/browser/tab_contents/tab_contents_view.h"
9 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); 254 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
255 255
256 // We should have two windows, the browser() provided by the framework and the 256 // We should have two windows, the browser() provided by the framework and the
257 // new popup window. 257 // new popup window.
258 EXPECT_EQ(2u, BrowserList::size()); 258 EXPECT_EQ(2u, BrowserList::size());
259 EXPECT_EQ(1, browser()->tab_count()); 259 EXPECT_EQ(1, browser()->tab_count());
260 EXPECT_EQ(1, p.browser->tab_count()); 260 EXPECT_EQ(1, p.browser->tab_count());
261 } 261 }
262 262
263 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 263 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
264 // from a normal popup results in a new Browser with TYPE_POPUP.
265 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
266 // Open a popup.
267 browser::NavigateParams p1(MakeNavigateParams());
268 p1.disposition = NEW_POPUP;
269 browser::Navigate(&p1);
270 // Open another popup.
271 browser::NavigateParams p2(MakeNavigateParams(p1.browser));
272 p2.disposition = NEW_POPUP;
273 browser::Navigate(&p2);
274
275 // Navigate() should have opened a new normal popup window.
276 EXPECT_NE(p1.browser, p2.browser);
277 EXPECT_EQ(Browser::TYPE_POPUP, p2.browser->type());
278
279 // We should have three windows, the browser() provided by the framework,
280 // the first popup window, and the second popup window.
281 EXPECT_EQ(3u, BrowserList::size());
282 EXPECT_EQ(1, browser()->tab_count());
283 EXPECT_EQ(1, p1.browser->tab_count());
284 EXPECT_EQ(1, p2.browser->tab_count());
285 }
286
287 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
264 // from an app frame results in a new Browser with TYPE_APP_POPUP. 288 // from an app frame results in a new Browser with TYPE_APP_POPUP.
265 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 289 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
266 Disposition_NewPopupFromAppWindow) { 290 Disposition_NewPopupFromAppWindow) {
267 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP, 291 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP,
268 browser()->profile()); 292 browser()->profile());
269 browser::NavigateParams p(MakeNavigateParams(app_browser)); 293 browser::NavigateParams p(MakeNavigateParams(app_browser));
270 p.disposition = NEW_POPUP; 294 p.disposition = NEW_POPUP;
271 browser::Navigate(&p); 295 browser::Navigate(&p);
272 296
273 // Navigate() should have opened a new popup app window. 297 // Navigate() should have opened a new popup app window.
274 EXPECT_NE(app_browser, p.browser); 298 EXPECT_NE(app_browser, p.browser);
275 EXPECT_NE(browser(), p.browser); 299 EXPECT_NE(browser(), p.browser);
276 EXPECT_EQ(Browser::TYPE_APP_POPUP, p.browser->type()); 300 EXPECT_EQ(Browser::TYPE_APP_POPUP, p.browser->type());
277 301
278 // We should now have three windows, the app window, the app popup it created, 302 // We should now have three windows, the app window, the app popup it created,
279 // and the original browser() provided by the framework. 303 // and the original browser() provided by the framework.
280 EXPECT_EQ(3u, BrowserList::size()); 304 EXPECT_EQ(3u, BrowserList::size());
281 EXPECT_EQ(1, browser()->tab_count()); 305 EXPECT_EQ(1, browser()->tab_count());
282 EXPECT_EQ(1, app_browser->tab_count()); 306 EXPECT_EQ(1, app_browser->tab_count());
283 EXPECT_EQ(1, p.browser->tab_count()); 307 EXPECT_EQ(1, p.browser->tab_count());
284 } 308 }
285 309
286 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 310 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
311 // from an app popup results in a new Browser also of TYPE_APP_POPUP.
312 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
313 Disposition_NewPopupFromAppPopup) {
314 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP,
315 browser()->profile());
316 // Open an app popup.
317 browser::NavigateParams p1(MakeNavigateParams(app_browser));
318 p1.disposition = NEW_POPUP;
319 browser::Navigate(&p1);
320 // Now open another app popup.
321 browser::NavigateParams p2(MakeNavigateParams(p1.browser));
322 p2.disposition = NEW_POPUP;
323 browser::Navigate(&p2);
324
325 // Navigate() should have opened a new popup app window.
326 EXPECT_NE(browser(), p1.browser);
327 EXPECT_NE(p1.browser, p2.browser);
328 EXPECT_EQ(Browser::TYPE_APP_POPUP, p2.browser->type());
329
330 // We should now have four windows, the app window, the first app popup,
331 // the second app popup, and the original browser() provided by the framework.
332 EXPECT_EQ(4u, BrowserList::size());
333 EXPECT_EQ(1, browser()->tab_count());
334 EXPECT_EQ(1, app_browser->tab_count());
335 EXPECT_EQ(1, p1.browser->tab_count());
336 EXPECT_EQ(1, p2.browser->tab_count());
337 }
338
339 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
287 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. 340 // from an extension app tab results in a new Browser with TYPE_APP_POPUP.
288 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 341 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
289 Disposition_NewPopupFromExtensionApp) { 342 Disposition_NewPopupFromExtensionApp) {
290 // TODO(beng): TBD. 343 // TODO(beng): TBD.
291 } 344 }
292 345
293 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW 346 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW
294 // always opens a new window. 347 // always opens a new window.
295 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { 348 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) {
296 browser::NavigateParams p(MakeNavigateParams()); 349 browser::NavigateParams p(MakeNavigateParams());
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 675
623 // The second tab should still be selected, but navigated to the new path. 676 // The second tab should still be selected, but navigated to the new path.
624 EXPECT_EQ(browser(), p.browser); 677 EXPECT_EQ(browser(), p.browser);
625 EXPECT_EQ(2, browser()->tab_count()); 678 EXPECT_EQ(2, browser()->tab_count());
626 EXPECT_EQ(1, browser()->selected_index()); 679 EXPECT_EQ(1, browser()->selected_index());
627 EXPECT_EQ(singleton_url_target, 680 EXPECT_EQ(singleton_url_target,
628 browser()->GetSelectedTabContents()->GetURL()); 681 browser()->GetSelectedTabContents()->GetURL());
629 } 682 }
630 683
631 } // namespace 684 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698