summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_unittest.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-02 21:30:36 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-02 21:30:36 +0000
commitbe403765cb6f437aff8f71dfd380b0645a238dda (patch)
tree4d23e60ddee3ccb222ca499c0c2e33fac09f467c /chrome/browser/browser_unittest.cc
parent191a718d183e7ef0247079d2d5cf99a96841f702 (diff)
downloadchromium_src-be403765cb6f437aff8f71dfd380b0645a238dda.zip
chromium_src-be403765cb6f437aff8f71dfd380b0645a238dda.tar.gz
chromium_src-be403765cb6f437aff8f71dfd380b0645a238dda.tar.bz2
Fix a case where non-tabbed browser windows could open tabs. Also includes UI test for this.
http://crbug.com/8472 Review URL: http://codereview.chromium.org/56094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_unittest.cc')
-rw-r--r--chrome/browser/browser_unittest.cc83
1 files changed, 83 insertions, 0 deletions
diff --git a/chrome/browser/browser_unittest.cc b/chrome/browser/browser_unittest.cc
new file mode 100644
index 0000000..73a49cd
--- /dev/null
+++ b/chrome/browser/browser_unittest.cc
@@ -0,0 +1,83 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "chrome/browser/browser.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "net/base/host_resolver_unittest.h"
+
+class BrowserTest : public InProcessBrowserTest {
+ public:
+ BrowserTest() {
+ host_mapper_ = new net::RuleBasedHostMapper();
+ // Avoid making external DNS lookups. In this test we don't need this
+ // to succeed.
+ host_mapper_->AddSimulatedFailure("*.google.com");
+ scoped_host_mapper_.Init(host_mapper_.get());
+ }
+
+ private:
+ scoped_refptr<net::RuleBasedHostMapper> host_mapper_;
+ net::ScopedHostMapper scoped_host_mapper_;
+};
+
+// This tests that windows without tabstrips can't have new tabs opened in
+// them.
+IN_PROC_BROWSER_TEST_F(BrowserTest, NoTabsInPopups) {
+ Browser::RegisterAppPrefs(L"Test");
+
+ // We start with a normal browser with one tab.
+ EXPECT_EQ(1, browser()->tab_count());
+
+ // Open a popup browser with a single blank foreground tab.
+ Browser* popup_browser = browser()->CreateForPopup(browser()->profile());
+ popup_browser->AddBlankTab(true);
+ EXPECT_EQ(1, popup_browser->tab_count());
+
+ // Now try opening another tab in the popup browser.
+ popup_browser->AddTabWithURL(GURL("about:blank"), GURL(),
+ PageTransition::TYPED, true, NULL);
+
+ // The popup should still only have one tab.
+ EXPECT_EQ(1, popup_browser->tab_count());
+
+ // The normal browser should now have two.
+ EXPECT_EQ(2, browser()->tab_count());
+
+ // Open an app frame browser with a single blank foreground tab.
+ Browser* app_browser =
+ browser()->CreateForApp(L"Test", browser()->profile(), false);
+ app_browser->AddBlankTab(true);
+ EXPECT_EQ(1, app_browser->tab_count());
+
+ // Now try opening another tab in the app browser.
+ app_browser->AddTabWithURL(GURL("about:blank"), GURL(),
+ PageTransition::TYPED, true, NULL);
+
+ // The popup should still only have one tab.
+ EXPECT_EQ(1, app_browser->tab_count());
+
+ // The normal browser should now have three.
+ EXPECT_EQ(3, browser()->tab_count());
+
+ // Open an app frame popup browser with a single blank foreground tab.
+ Browser* app_popup_browser =
+ browser()->CreateForApp(L"Test", browser()->profile(), false);
+ app_popup_browser->AddBlankTab(true);
+ EXPECT_EQ(1, app_popup_browser->tab_count());
+
+ // Now try opening another tab in the app popup browser.
+ app_popup_browser->AddTabWithURL(GURL("about:blank"), GURL(),
+ PageTransition::TYPED, true, NULL);
+
+ // The popup should still only have one tab.
+ EXPECT_EQ(1, app_popup_browser->tab_count());
+
+ // The normal browser should now have four.
+ EXPECT_EQ(4, browser()->tab_count());
+
+ // Close the additional browsers.
+ popup_browser->CloseAllTabs();
+ app_browser->CloseAllTabs();
+ app_popup_browser->CloseAllTabs();
+}