| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. |
| 4 |
| 5 #include "chrome/browser/browser.h" |
| 6 #include "chrome/test/in_process_browser_test.h" |
| 7 #include "net/base/host_resolver_unittest.h" |
| 8 |
| 9 class BrowserTest : public InProcessBrowserTest { |
| 10 public: |
| 11 BrowserTest() { |
| 12 host_mapper_ = new net::RuleBasedHostMapper(); |
| 13 // Avoid making external DNS lookups. In this test we don't need this |
| 14 // to succeed. |
| 15 host_mapper_->AddSimulatedFailure("*.google.com"); |
| 16 scoped_host_mapper_.Init(host_mapper_.get()); |
| 17 } |
| 18 |
| 19 private: |
| 20 scoped_refptr<net::RuleBasedHostMapper> host_mapper_; |
| 21 net::ScopedHostMapper scoped_host_mapper_; |
| 22 }; |
| 23 |
| 24 // This tests that windows without tabstrips can't have new tabs opened in |
| 25 // them. |
| 26 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTabsInPopups) { |
| 27 Browser::RegisterAppPrefs(L"Test"); |
| 28 |
| 29 // We start with a normal browser with one tab. |
| 30 EXPECT_EQ(1, browser()->tab_count()); |
| 31 |
| 32 // Open a popup browser with a single blank foreground tab. |
| 33 Browser* popup_browser = browser()->CreateForPopup(browser()->profile()); |
| 34 popup_browser->AddBlankTab(true); |
| 35 EXPECT_EQ(1, popup_browser->tab_count()); |
| 36 |
| 37 // Now try opening another tab in the popup browser. |
| 38 popup_browser->AddTabWithURL(GURL("about:blank"), GURL(), |
| 39 PageTransition::TYPED, true, NULL); |
| 40 |
| 41 // The popup should still only have one tab. |
| 42 EXPECT_EQ(1, popup_browser->tab_count()); |
| 43 |
| 44 // The normal browser should now have two. |
| 45 EXPECT_EQ(2, browser()->tab_count()); |
| 46 |
| 47 // Open an app frame browser with a single blank foreground tab. |
| 48 Browser* app_browser = |
| 49 browser()->CreateForApp(L"Test", browser()->profile(), false); |
| 50 app_browser->AddBlankTab(true); |
| 51 EXPECT_EQ(1, app_browser->tab_count()); |
| 52 |
| 53 // Now try opening another tab in the app browser. |
| 54 app_browser->AddTabWithURL(GURL("about:blank"), GURL(), |
| 55 PageTransition::TYPED, true, NULL); |
| 56 |
| 57 // The popup should still only have one tab. |
| 58 EXPECT_EQ(1, app_browser->tab_count()); |
| 59 |
| 60 // The normal browser should now have three. |
| 61 EXPECT_EQ(3, browser()->tab_count()); |
| 62 |
| 63 // Open an app frame popup browser with a single blank foreground tab. |
| 64 Browser* app_popup_browser = |
| 65 browser()->CreateForApp(L"Test", browser()->profile(), false); |
| 66 app_popup_browser->AddBlankTab(true); |
| 67 EXPECT_EQ(1, app_popup_browser->tab_count()); |
| 68 |
| 69 // Now try opening another tab in the app popup browser. |
| 70 app_popup_browser->AddTabWithURL(GURL("about:blank"), GURL(), |
| 71 PageTransition::TYPED, true, NULL); |
| 72 |
| 73 // The popup should still only have one tab. |
| 74 EXPECT_EQ(1, app_popup_browser->tab_count()); |
| 75 |
| 76 // The normal browser should now have four. |
| 77 EXPECT_EQ(4, browser()->tab_count()); |
| 78 |
| 79 // Close the additional browsers. |
| 80 popup_browser->CloseAllTabs(); |
| 81 app_browser->CloseAllTabs(); |
| 82 app_popup_browser->CloseAllTabs(); |
| 83 } |
| OLD | NEW |