| Index: chrome/browser/browser_unittest.cc
|
| diff --git a/chrome/browser/browser_unittest.cc b/chrome/browser/browser_unittest.cc
|
| index d388eb0fb2078a28d10d1d508be3f7b2a362a57e..eeb019f23c26531aa787732ab149b4aa85e5e35d 100644
|
| --- a/chrome/browser/browser_unittest.cc
|
| +++ b/chrome/browser/browser_unittest.cc
|
| @@ -1,89 +1,102 @@
|
| -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
|
| +// Copyright (c) 2010 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/common/url_constants.h"
|
| -#include "chrome/test/in_process_browser_test.h"
|
| -#include "net/base/mock_host_resolver.h"
|
| -
|
| -class BrowserTest : public InProcessBrowserTest {
|
| - public:
|
| - BrowserTest() {
|
| - host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL);
|
| - // Avoid making external DNS lookups. In this test we don't need this
|
| - // to succeed.
|
| - host_resolver_proc_->AddSimulatedFailure("*.google.com");
|
| - scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
|
| - }
|
| -
|
| - private:
|
| - scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_proc_;
|
| - net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_;
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace {
|
| +
|
| +const struct NavigationScenario {
|
| + bool pinned;
|
| + const char* url;
|
| + const char* referrer;
|
| + PageTransition::Type transition;
|
| + WindowOpenDisposition original_disposition;
|
| + WindowOpenDisposition result_disposition;
|
| +} kNavigationScenarios[] = {
|
| + // Disposition changes to new foreground.
|
| + { true,
|
| + "http://www.example.com",
|
| + "http://www.google.com",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + NEW_FOREGROUND_TAB },
|
| + // Also works with AUTO_BOOKMARK.
|
| + { true,
|
| + "http://www.example.com",
|
| + "http://www.google.com",
|
| + PageTransition::AUTO_BOOKMARK,
|
| + CURRENT_TAB,
|
| + NEW_FOREGROUND_TAB },
|
| + // Also happens if the schemes differ.
|
| + { true,
|
| + "ftp://www.example.com",
|
| + "http://www.example.com",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + NEW_FOREGROUND_TAB },
|
| + // Don't choke on an empty referrer.
|
| + { true,
|
| + "ftp://www.example.com",
|
| + "",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + NEW_FOREGROUND_TAB },
|
| + // Unpinned tab - no change.
|
| + { false,
|
| + "http://www.example.com",
|
| + "http://www.google.com",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + CURRENT_TAB },
|
| + // Original disposition is not CURRENT_TAB - no change.
|
| + { true,
|
| + "http://www.example.com",
|
| + "http://www.google.com",
|
| + PageTransition::LINK,
|
| + NEW_BACKGROUND_TAB,
|
| + NEW_BACKGROUND_TAB },
|
| + // Other PageTransition type - no change.
|
| + { true,
|
| + "http://www.example.com",
|
| + "http://www.google.com",
|
| + PageTransition::TYPED,
|
| + CURRENT_TAB,
|
| + CURRENT_TAB },
|
| + // Same domain and scheme - no change.
|
| + { true,
|
| + "http://www.google.com/reader",
|
| + "http://www.google.com",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + CURRENT_TAB },
|
| + // Switching between http and https - no change.
|
| + { true,
|
| + "https://www.example.com",
|
| + "http://www.example.com",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + CURRENT_TAB },
|
| + // Switching between https and http - no change.
|
| + { true,
|
| + "http://www.example.com",
|
| + "https://www.example.com",
|
| + PageTransition::LINK,
|
| + CURRENT_TAB,
|
| + CURRENT_TAB },
|
| };
|
|
|
| -/*
|
| -// 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(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
|
| - Browser::ADD_SELECTED, NULL, std::string());
|
| -
|
| - // 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(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
|
| - Browser::ADD_SELECTED, NULL, std::string());
|
| -
|
| - // 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(chrome::kAboutBlankURL), GURL(), PageTransition::TYPED, -1,
|
| - Browser::ADD_SELECTED, NULL, std::string());
|
| -
|
| - // 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();
|
| +} // namespace
|
| +
|
| +TEST(BrowserTest, PinnedTabDisposition) {
|
| + for (size_t i = 0; i < arraysize(kNavigationScenarios); ++i) {
|
| + EXPECT_EQ(kNavigationScenarios[i].result_disposition,
|
| + Browser::AdjustWindowOpenDispositionForTab(
|
| + kNavigationScenarios[i].pinned,
|
| + GURL(kNavigationScenarios[i].url),
|
| + GURL(kNavigationScenarios[i].referrer),
|
| + kNavigationScenarios[i].transition,
|
| + kNavigationScenarios[i].original_disposition)) << i;
|
| + }
|
| }
|
| -*/
|
|
|