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

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

Issue 4145013: DOMUI: Use ShowSingletonTab to open the settings tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test typo. Created 10 years, 1 month 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 "chrome/browser/browser_list.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/browser_window.h"
7 #include "chrome/browser/profile.h" 6 #include "chrome/browser/profile.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 7 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/browser/tab_contents/tab_contents_view.h" 8 #include "chrome/browser/tab_contents/tab_contents_view.h"
10 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
11 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/browser_navigator.h" 12 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/in_process_browser_test.h" 15 #include "chrome/test/in_process_browser_test.h"
14 #include "chrome/test/ui_test_utils.h" 16 #include "chrome/test/ui_test_utils.h"
15 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
16 18
17 namespace { 19 namespace {
18 20
19 class BrowserNavigatorTest : public InProcessBrowserTest { 21 class BrowserNavigatorTest : public InProcessBrowserTest {
20 protected: 22 protected:
21 GURL GetGoogleURL() const { 23 GURL GetGoogleURL() const {
22 return GURL("http://www.google.com/"); 24 return GURL("http://www.google.com/");
(...skipping 27 matching lines...) Expand all
50 GURL old_url = browser()->GetSelectedTabContents()->GetURL(); 52 GURL old_url = browser()->GetSelectedTabContents()->GetURL();
51 browser::NavigateParams p(MakeNavigateParams()); 53 browser::NavigateParams p(MakeNavigateParams());
52 p.disposition = disposition; 54 p.disposition = disposition;
53 browser::Navigate(&p); 55 browser::Navigate(&p);
54 56
55 // Nothing should have happened as a result of Navigate(); 57 // Nothing should have happened as a result of Navigate();
56 EXPECT_EQ(1, browser()->tab_count()); 58 EXPECT_EQ(1, browser()->tab_count());
57 EXPECT_EQ(1u, BrowserList::size()); 59 EXPECT_EQ(1u, BrowserList::size());
58 EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL()); 60 EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL());
59 } 61 }
62
63 // TODO(jhawkins): Remove once tabbed options are enabled by default.
64 virtual void SetUpCommandLine(CommandLine* command_line) {
65 command_line->AppendSwitch(switches::kEnableTabbedOptions);
66 }
60 }; 67 };
61 68
62 // This test verifies that when a navigation occurs within a tab, the tab count 69 // This test verifies that when a navigation occurs within a tab, the tab count
63 // of the Browser remains the same and the current tab bears the loaded URL. 70 // of the Browser remains the same and the current tab bears the loaded URL.
64 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { 71 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) {
65 browser::NavigateParams p(MakeNavigateParams()); 72 browser::NavigateParams p(MakeNavigateParams());
66 browser::Navigate(&p); 73 browser::Navigate(&p);
67 ui_test_utils::WaitForNavigationInCurrentTab(browser()); 74 ui_test_utils::WaitForNavigationInCurrentTab(browser());
68 EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedTabContents()->GetURL()); 75 EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedTabContents()->GetURL());
69 // We should have one window with one tab. 76 // We should have one window with one tab.
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 EXPECT_NE(browser(), p.browser); 463 EXPECT_NE(browser(), p.browser);
457 EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type()); 464 EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type());
458 465
459 // We should now have two windows, the browser() provided by the framework and 466 // We should now have two windows, the browser() provided by the framework and
460 // the new normal window. 467 // the new normal window.
461 EXPECT_EQ(2u, BrowserList::size()); 468 EXPECT_EQ(2u, BrowserList::size());
462 EXPECT_EQ(1, browser()->tab_count()); 469 EXPECT_EQ(1, browser()->tab_count());
463 EXPECT_EQ(1, p.browser->tab_count()); 470 EXPECT_EQ(1, p.browser->tab_count());
464 } 471 }
465 472
473 // This test verifies that constructing params with disposition = SINGLETON_TAB
474 // and |ignore_tabs| = true opens a new tab navigated to the specified URL if no
csilv 2010/11/17 01:31:57 I think you mean "ignore_path". Same on lines 503
James Hawkins 2010/11/17 01:48:21 Done.
475 // previous tab with that URL (minus the path) exists.
476 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
477 Disposition_SingletonTabNew_IgnorePath) {
478 GURL url("http://www.google.com/");
479 browser()->AddSelectedTabWithURL(url, PageTransition::LINK);
480
481 // We should have one browser with 2 tabs, the 2nd selected.
csilv 2010/11/17 01:31:57 minor nit, the comment states that we should have
James Hawkins 2010/11/17 01:48:21 Done.
482 EXPECT_EQ(1u, BrowserList::size());
483 EXPECT_EQ(1, browser()->selected_index());
484
485 // Navigate to a new singleton tab with a sub-page.
486 browser::NavigateParams p(MakeNavigateParams());
487 p.disposition = SINGLETON_TAB;
488 p.url = GURL("chrome://settings/advanced");
489 p.show_window = true;
490 p.ignore_path = true;
491 browser::Navigate(&p);
492
493 // The last tab should now be selected and navigated to the sub-page of the
494 // URL.
495 EXPECT_EQ(browser(), p.browser);
496 EXPECT_EQ(3, browser()->tab_count());
497 EXPECT_EQ(2, browser()->selected_index());
498 EXPECT_EQ(GURL("chrome://settings/advanced"),
499 browser()->GetSelectedTabContents()->GetURL());
500 }
501
502 // This test verifies that constructing params with disposition = SINGLETON_TAB
503 // and |ignore_tabs| = true opens an existing tab with the matching URL (minus
504 // the path) which is navigated to the specified URL.
505 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
506 Disposition_SingletonTabExisting_IgnorePath) {
507 GURL singleton_url1("chrome://settings");
508 GURL url("http://www.google.com/");
509 browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK);
510 browser()->AddSelectedTabWithURL(url, PageTransition::LINK);
511
512 // We should have one browser with 3 tabs, the 3rd selected.
513 EXPECT_EQ(1u, BrowserList::size());
514 EXPECT_EQ(2, browser()->selected_index());
515
516 // Navigate to singleton_url1.
517 browser::NavigateParams p(MakeNavigateParams());
518 p.disposition = SINGLETON_TAB;
519 p.url = GURL("chrome://settings/advanced");
520 p.show_window = true;
521 p.ignore_path = true;
522 browser::Navigate(&p);
523
524 // The middle tab should now be selected and navigated to the sub-page of the
525 // URL.
526 EXPECT_EQ(browser(), p.browser);
527 EXPECT_EQ(3, browser()->tab_count());
528 EXPECT_EQ(1, browser()->selected_index());
529 EXPECT_EQ(GURL("chrome://settings/advanced"),
530 browser()->GetSelectedTabContents()->GetURL());
531 }
532
533 // This test verifies that constructing params with disposition = SINGLETON_TAB
534 // and |ignore_tabs| = true opens an existing tab with the matching URL (minus
535 // the path) which is navigated to the specified URL.
536 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
537 Disposition_SingletonTabExistingSubPath_IgnorePath) {
538 GURL singleton_url1("chrome://settings/advanced");
539 GURL url("http://www.google.com/");
540 browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK);
541 browser()->AddSelectedTabWithURL(url, PageTransition::LINK);
542
543 // We should have one browser with 3 tabs, the 3rd selected.
544 EXPECT_EQ(1u, BrowserList::size());
545 EXPECT_EQ(2, browser()->selected_index());
546
547 // Navigate to singleton_url1.
548 browser::NavigateParams p(MakeNavigateParams());
549 p.disposition = SINGLETON_TAB;
550 p.url = GURL("chrome://settings/personal");
551 p.show_window = true;
552 p.ignore_path = true;
553 browser::Navigate(&p);
554
555 // The middle tab should now be selected and navigated to the sub-page of the
556 // URL.
557 EXPECT_EQ(browser(), p.browser);
558 EXPECT_EQ(3, browser()->tab_count());
559 EXPECT_EQ(1, browser()->selected_index());
560 EXPECT_EQ(GURL("chrome://settings/personal"),
561 browser()->GetSelectedTabContents()->GetURL());
562 }
466 563
467 } // namespace 564 } // 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