| 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 "chrome/browser/back_forward_menu_model.h" | 5 #include "chrome/browser/back_forward_menu_model.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.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_factory.h" | 13 #include "chrome/browser/tab_contents/tab_contents_factory.h" |
| 14 #include "chrome/common/url_constants.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 17 // TODO(port): port this header. | 18 // TODO(port): port this header. |
| 18 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 19 #elif defined(OS_POSIX) | 20 #elif defined(OS_POSIX) |
| 20 #include "chrome/common/temp_scaffolding_stubs.h" | 21 #include "chrome/common/temp_scaffolding_stubs.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 const TabContentsType kHTTPTabContentsType = | 24 const TabContentsType kHTTPTabContentsType = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 // This constructs our fake TabContents. | 51 // This constructs our fake TabContents. |
| 51 class BackFwdMenuModelTestTabContentsFactory : public TabContentsFactory { | 52 class BackFwdMenuModelTestTabContentsFactory : public TabContentsFactory { |
| 52 public: | 53 public: |
| 53 virtual TabContents* CreateInstance() { | 54 virtual TabContents* CreateInstance() { |
| 54 return new BackFwdMenuModelTestTabContents; | 55 return new BackFwdMenuModelTestTabContents; |
| 55 } | 56 } |
| 56 | 57 |
| 57 virtual bool CanHandleURL(const GURL& url) { | 58 virtual bool CanHandleURL(const GURL& url) { |
| 58 return url.scheme() == "http"; | 59 return url.SchemeIs(chrome::kHttpScheme); |
| 59 } | 60 } |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 BackFwdMenuModelTestTabContentsFactory factory; | 63 BackFwdMenuModelTestTabContentsFactory factory; |
| 63 | 64 |
| 64 class BackFwdMenuModelTest : public testing::Test { | 65 class BackFwdMenuModelTest : public testing::Test { |
| 65 public: | 66 public: |
| 66 | 67 |
| 67 // Overridden from testing::Test | 68 // Overridden from testing::Test |
| 68 virtual void SetUp() { | 69 virtual void SetUp() { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 EXPECT_EQ(4, back_model->GetIndexOfNextChapterStop(3, true)); | 487 EXPECT_EQ(4, back_model->GetIndexOfNextChapterStop(3, true)); |
| 487 // And try backwards as well. | 488 // And try backwards as well. |
| 488 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(4, false)); | 489 EXPECT_EQ(3, back_model->GetIndexOfNextChapterStop(4, false)); |
| 489 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(3, false)); | 490 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(3, false)); |
| 490 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(2, false)); | 491 EXPECT_EQ(1, back_model->GetIndexOfNextChapterStop(2, false)); |
| 491 EXPECT_EQ(-1, back_model->GetIndexOfNextChapterStop(1, false)); | 492 EXPECT_EQ(-1, back_model->GetIndexOfNextChapterStop(1, false)); |
| 492 } | 493 } |
| 493 contents->CloseContents(); | 494 contents->CloseContents(); |
| 494 } | 495 } |
| 495 | 496 |
| OLD | NEW |