| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "chrome/browser/dock_info.h" | 7 #include "chrome/browser/dock_info.h" |
| 8 #include "chrome/browser/dom_ui/new_tab_ui.h" | 8 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/profile_manager.h" | 10 #include "chrome/browser/profile_manager.h" |
| 11 #include "chrome/browser/tab_contents/navigation_controller.h" | 11 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 12 #include "chrome/browser/tab_contents/navigation_entry.h" | 12 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents_factory.h" | 14 #include "chrome/browser/tab_contents/tab_contents_factory.h" |
| 15 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
| 16 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" | 16 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/common/stl_util-inl.h" | 18 #include "chrome/common/stl_util-inl.h" |
| 19 #include "chrome/common/url_constants.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 const TabContentsType kHTTPTabContentsType = | 22 const TabContentsType kHTTPTabContentsType = |
| 22 static_cast<TabContentsType>(TAB_CONTENTS_NUM_TYPES + 1); | 23 static_cast<TabContentsType>(TAB_CONTENTS_NUM_TYPES + 1); |
| 23 const TabContentsType kReplacementContentsType = | 24 const TabContentsType kReplacementContentsType = |
| 24 static_cast<TabContentsType>(kHTTPTabContentsType + 1); | 25 static_cast<TabContentsType>(kHTTPTabContentsType + 1); |
| 25 | 26 |
| 26 class TabStripDummyDelegate : public TabStripModelDelegate { | 27 class TabStripDummyDelegate : public TabStripModelDelegate { |
| 27 public: | 28 public: |
| 28 explicit TabStripDummyDelegate(TabContents* dummy) | 29 explicit TabStripDummyDelegate(TabContents* dummy) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 | 77 |
| 77 // This constructs our fake TabContents. | 78 // This constructs our fake TabContents. |
| 78 class TabStripModelTestTabContentsFactory : public TabContentsFactory { | 79 class TabStripModelTestTabContentsFactory : public TabContentsFactory { |
| 79 public: | 80 public: |
| 80 virtual TabContents* CreateInstance() { | 81 virtual TabContents* CreateInstance() { |
| 81 return new TabStripModelTestTabContents(kHTTPTabContentsType); | 82 return new TabStripModelTestTabContents(kHTTPTabContentsType); |
| 82 } | 83 } |
| 83 | 84 |
| 84 virtual bool CanHandleURL(const GURL& url) { | 85 virtual bool CanHandleURL(const GURL& url) { |
| 85 return url.scheme() == "http"; | 86 return url.SchemeIs(chrome::kHttpScheme); |
| 86 } | 87 } |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 TabStripModelTestTabContentsFactory factory; | 90 TabStripModelTestTabContentsFactory factory; |
| 90 | 91 |
| 91 class TabStripModelTest : public testing::Test { | 92 class TabStripModelTest : public testing::Test { |
| 92 public: | 93 public: |
| 93 // Overridden from testing::Test | 94 // Overridden from testing::Test |
| 94 virtual void SetUp() { | 95 virtual void SetUp() { |
| 95 TabContents::RegisterFactory(kHTTPTabContentsType, &factory); | 96 TabContents::RegisterFactory(kHTTPTabContentsType, &factory); |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 // Now select the last tab. | 1283 // Now select the last tab. |
| 1283 strip.SelectTabContentsAt(strip.count() - 1, true); | 1284 strip.SelectTabContentsAt(strip.count() - 1, true); |
| 1284 | 1285 |
| 1285 // Now close the last tab. The next adjacent should be selected. | 1286 // Now close the last tab. The next adjacent should be selected. |
| 1286 strip.CloseTabContentsAt(strip.count() - 1); | 1287 strip.CloseTabContentsAt(strip.count() - 1); |
| 1287 EXPECT_EQ(page_d_contents, strip.GetTabContentsAt(strip.selected_index())); | 1288 EXPECT_EQ(page_d_contents, strip.GetTabContentsAt(strip.selected_index())); |
| 1288 | 1289 |
| 1289 strip.CloseAllTabs(); | 1290 strip.CloseAllTabs(); |
| 1290 } | 1291 } |
| 1291 | 1292 |
| OLD | NEW |