| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/browser.h" | |
| 6 #include "testing/gtest/include/gtest/gtest.h" | |
| 7 | |
| 8 namespace { | |
| 9 | |
| 10 const struct NavigationScenario { | |
| 11 bool pinned; | |
| 12 const char* url; | |
| 13 const char* referrer; | |
| 14 PageTransition::Type transition; | |
| 15 WindowOpenDisposition original_disposition; | |
| 16 WindowOpenDisposition result_disposition; | |
| 17 } kNavigationScenarios[] = { | |
| 18 // Disposition changes to new foreground. | |
| 19 { true, | |
| 20 "http://www.example.com", | |
| 21 "http://www.google.com", | |
| 22 PageTransition::LINK, | |
| 23 CURRENT_TAB, | |
| 24 NEW_FOREGROUND_TAB }, | |
| 25 // Also works with AUTO_BOOKMARK. | |
| 26 { true, | |
| 27 "http://www.example.com", | |
| 28 "http://www.google.com", | |
| 29 PageTransition::AUTO_BOOKMARK, | |
| 30 CURRENT_TAB, | |
| 31 NEW_FOREGROUND_TAB }, | |
| 32 // Also works with TYPED. | |
| 33 { true, | |
| 34 "http://www.example.com", | |
| 35 "http://www.google.com", | |
| 36 PageTransition::TYPED, | |
| 37 CURRENT_TAB, | |
| 38 NEW_FOREGROUND_TAB }, | |
| 39 // Also happens if the schemes differ. | |
| 40 { true, | |
| 41 "ftp://www.example.com", | |
| 42 "http://www.example.com", | |
| 43 PageTransition::LINK, | |
| 44 CURRENT_TAB, | |
| 45 NEW_FOREGROUND_TAB }, | |
| 46 // Don't choke on an empty referrer. | |
| 47 { true, | |
| 48 "ftp://www.example.com", | |
| 49 "", | |
| 50 PageTransition::LINK, | |
| 51 CURRENT_TAB, | |
| 52 NEW_FOREGROUND_TAB }, | |
| 53 // Unpinned tab - no change. | |
| 54 { false, | |
| 55 "http://www.example.com", | |
| 56 "http://www.google.com", | |
| 57 PageTransition::LINK, | |
| 58 CURRENT_TAB, | |
| 59 CURRENT_TAB }, | |
| 60 // Original disposition is not CURRENT_TAB - no change. | |
| 61 { true, | |
| 62 "http://www.example.com", | |
| 63 "http://www.google.com", | |
| 64 PageTransition::LINK, | |
| 65 NEW_BACKGROUND_TAB, | |
| 66 NEW_BACKGROUND_TAB }, | |
| 67 // Other PageTransition type - no change. | |
| 68 { true, | |
| 69 "http://www.example.com", | |
| 70 "http://www.google.com", | |
| 71 PageTransition::RELOAD, | |
| 72 CURRENT_TAB, | |
| 73 CURRENT_TAB }, | |
| 74 // Same domain and scheme - no change. | |
| 75 { true, | |
| 76 "http://www.google.com/reader", | |
| 77 "http://www.google.com", | |
| 78 PageTransition::LINK, | |
| 79 CURRENT_TAB, | |
| 80 CURRENT_TAB }, | |
| 81 // Switching between http and https - no change. | |
| 82 { true, | |
| 83 "https://www.example.com", | |
| 84 "http://www.example.com", | |
| 85 PageTransition::LINK, | |
| 86 CURRENT_TAB, | |
| 87 CURRENT_TAB }, | |
| 88 // Switching between https and http - no change. | |
| 89 { true, | |
| 90 "http://www.example.com", | |
| 91 "https://www.example.com", | |
| 92 PageTransition::LINK, | |
| 93 CURRENT_TAB, | |
| 94 CURRENT_TAB }, | |
| 95 }; | |
| 96 | |
| 97 } // namespace | |
| 98 | |
| 99 TEST(BrowserTest, PinnedTabDisposition) { | |
| 100 for (size_t i = 0; i < arraysize(kNavigationScenarios); ++i) { | |
| 101 EXPECT_EQ(kNavigationScenarios[i].result_disposition, | |
| 102 Browser::AdjustWindowOpenDispositionForTab( | |
| 103 kNavigationScenarios[i].pinned, | |
| 104 GURL(kNavigationScenarios[i].url), | |
| 105 GURL(kNavigationScenarios[i].referrer), | |
| 106 kNavigationScenarios[i].transition, | |
| 107 kNavigationScenarios[i].original_disposition)) << i; | |
| 108 } | |
| 109 } | |
| OLD | NEW |