| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3586 EXPECT_EQ(i, controller.GetCurrentEntryIndex()); | 3586 EXPECT_EQ(i, controller.GetCurrentEntryIndex()); |
| 3587 } | 3587 } |
| 3588 | 3588 |
| 3589 MockScreenshotManager* screenshot_manager = | 3589 MockScreenshotManager* screenshot_manager = |
| 3590 new MockScreenshotManager(&controller); | 3590 new MockScreenshotManager(&controller); |
| 3591 controller.SetScreenshotManager(screenshot_manager); | 3591 controller.SetScreenshotManager(screenshot_manager); |
| 3592 for (int i = 0; i < controller.GetEntryCount(); ++i) { | 3592 for (int i = 0; i < controller.GetEntryCount(); ++i) { |
| 3593 entry = NavigationEntryImpl::FromNavigationEntry( | 3593 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3594 controller.GetEntryAtIndex(i)); | 3594 controller.GetEntryAtIndex(i)); |
| 3595 screenshot_manager->TakeScreenshotFor(entry); | 3595 screenshot_manager->TakeScreenshotFor(entry); |
| 3596 EXPECT_TRUE(entry->screenshot()); | 3596 EXPECT_TRUE(entry->screenshot().get()); |
| 3597 } | 3597 } |
| 3598 | 3598 |
| 3599 NavigateAndCommit(GURL("https://foo/")); | 3599 NavigateAndCommit(GURL("https://foo/")); |
| 3600 EXPECT_EQ(13, controller.GetEntryCount()); | 3600 EXPECT_EQ(13, controller.GetEntryCount()); |
| 3601 entry = NavigationEntryImpl::FromNavigationEntry( | 3601 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3602 controller.GetEntryAtIndex(11)); | 3602 controller.GetEntryAtIndex(11)); |
| 3603 screenshot_manager->TakeScreenshotFor(entry); | 3603 screenshot_manager->TakeScreenshotFor(entry); |
| 3604 | 3604 |
| 3605 for (int i = 0; i < 2; ++i) { | 3605 for (int i = 0; i < 2; ++i) { |
| 3606 entry = NavigationEntryImpl::FromNavigationEntry( | 3606 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3607 controller.GetEntryAtIndex(i)); | 3607 controller.GetEntryAtIndex(i)); |
| 3608 EXPECT_FALSE(entry->screenshot()) << "Screenshot " << i << " not purged"; | 3608 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i |
| 3609 << " not purged"; |
| 3609 } | 3610 } |
| 3610 | 3611 |
| 3611 for (int i = 2; i < controller.GetEntryCount() - 1; ++i) { | 3612 for (int i = 2; i < controller.GetEntryCount() - 1; ++i) { |
| 3612 entry = NavigationEntryImpl::FromNavigationEntry( | 3613 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3613 controller.GetEntryAtIndex(i)); | 3614 controller.GetEntryAtIndex(i)); |
| 3614 EXPECT_TRUE(entry->screenshot()) << "Screenshot not found for " << i; | 3615 EXPECT_TRUE(entry->screenshot().get()) << "Screenshot not found for " << i; |
| 3615 } | 3616 } |
| 3616 | 3617 |
| 3617 // Navigate to index 5 and then try to assign screenshot to all entries. | 3618 // Navigate to index 5 and then try to assign screenshot to all entries. |
| 3618 controller.GoToIndex(5); | 3619 controller.GoToIndex(5); |
| 3619 contents()->CommitPendingNavigation(); | 3620 contents()->CommitPendingNavigation(); |
| 3620 EXPECT_EQ(5, controller.GetCurrentEntryIndex()); | 3621 EXPECT_EQ(5, controller.GetCurrentEntryIndex()); |
| 3621 for (int i = 0; i < controller.GetEntryCount() - 1; ++i) { | 3622 for (int i = 0; i < controller.GetEntryCount() - 1; ++i) { |
| 3622 entry = NavigationEntryImpl::FromNavigationEntry( | 3623 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3623 controller.GetEntryAtIndex(i)); | 3624 controller.GetEntryAtIndex(i)); |
| 3624 screenshot_manager->TakeScreenshotFor(entry); | 3625 screenshot_manager->TakeScreenshotFor(entry); |
| 3625 } | 3626 } |
| 3626 | 3627 |
| 3627 for (int i = 10; i <= 12; ++i) { | 3628 for (int i = 10; i <= 12; ++i) { |
| 3628 entry = NavigationEntryImpl::FromNavigationEntry( | 3629 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3629 controller.GetEntryAtIndex(i)); | 3630 controller.GetEntryAtIndex(i)); |
| 3630 EXPECT_FALSE(entry->screenshot()) << "Screenshot " << i << " not purged"; | 3631 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i |
| 3632 << " not purged"; |
| 3631 screenshot_manager->TakeScreenshotFor(entry); | 3633 screenshot_manager->TakeScreenshotFor(entry); |
| 3632 } | 3634 } |
| 3633 | 3635 |
| 3634 // Navigate to index 7 and assign screenshot to all entries. | 3636 // Navigate to index 7 and assign screenshot to all entries. |
| 3635 controller.GoToIndex(7); | 3637 controller.GoToIndex(7); |
| 3636 contents()->CommitPendingNavigation(); | 3638 contents()->CommitPendingNavigation(); |
| 3637 EXPECT_EQ(7, controller.GetCurrentEntryIndex()); | 3639 EXPECT_EQ(7, controller.GetCurrentEntryIndex()); |
| 3638 for (int i = 0; i < controller.GetEntryCount() - 1; ++i) { | 3640 for (int i = 0; i < controller.GetEntryCount() - 1; ++i) { |
| 3639 entry = NavigationEntryImpl::FromNavigationEntry( | 3641 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3640 controller.GetEntryAtIndex(i)); | 3642 controller.GetEntryAtIndex(i)); |
| 3641 screenshot_manager->TakeScreenshotFor(entry); | 3643 screenshot_manager->TakeScreenshotFor(entry); |
| 3642 } | 3644 } |
| 3643 | 3645 |
| 3644 for (int i = 0; i < 2; ++i) { | 3646 for (int i = 0; i < 2; ++i) { |
| 3645 entry = NavigationEntryImpl::FromNavigationEntry( | 3647 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3646 controller.GetEntryAtIndex(i)); | 3648 controller.GetEntryAtIndex(i)); |
| 3647 EXPECT_FALSE(entry->screenshot()) << "Screenshot " << i << " not purged"; | 3649 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i |
| 3650 << " not purged"; |
| 3648 } | 3651 } |
| 3649 | 3652 |
| 3650 // Clear all screenshots. | 3653 // Clear all screenshots. |
| 3651 EXPECT_EQ(13, controller.GetEntryCount()); | 3654 EXPECT_EQ(13, controller.GetEntryCount()); |
| 3652 EXPECT_EQ(10, screenshot_manager->GetScreenshotCount()); | 3655 EXPECT_EQ(10, screenshot_manager->GetScreenshotCount()); |
| 3653 controller.ClearAllScreenshots(); | 3656 controller.ClearAllScreenshots(); |
| 3654 EXPECT_EQ(0, screenshot_manager->GetScreenshotCount()); | 3657 EXPECT_EQ(0, screenshot_manager->GetScreenshotCount()); |
| 3655 for (int i = 0; i < controller.GetEntryCount(); ++i) { | 3658 for (int i = 0; i < controller.GetEntryCount(); ++i) { |
| 3656 entry = NavigationEntryImpl::FromNavigationEntry( | 3659 entry = NavigationEntryImpl::FromNavigationEntry( |
| 3657 controller.GetEntryAtIndex(i)); | 3660 controller.GetEntryAtIndex(i)); |
| 3658 EXPECT_FALSE(entry->screenshot()) << "Screenshot " << i << " not cleared"; | 3661 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i |
| 3662 << " not cleared"; |
| 3659 } | 3663 } |
| 3660 } | 3664 } |
| 3661 | 3665 |
| 3662 // Test that the navigation controller clears its session history when a | 3666 // Test that the navigation controller clears its session history when a |
| 3663 // navigation commits with the clear history list flag set. | 3667 // navigation commits with the clear history list flag set. |
| 3664 TEST_F(NavigationControllerTest, ClearHistoryList) { | 3668 TEST_F(NavigationControllerTest, ClearHistoryList) { |
| 3665 const GURL url1("http://foo1"); | 3669 const GURL url1("http://foo1"); |
| 3666 const GURL url2("http://foo2"); | 3670 const GURL url2("http://foo2"); |
| 3667 const GURL url3("http://foo3"); | 3671 const GURL url3("http://foo3"); |
| 3668 const GURL url4("http://foo4"); | 3672 const GURL url4("http://foo4"); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 PAGE_TRANSITION_LINK); | 3884 PAGE_TRANSITION_LINK); |
| 3881 session_helper_.AssertNavigationEquals(nav, | 3885 session_helper_.AssertNavigationEquals(nav, |
| 3882 windows_[0]->tabs[0]->navigations[0]); | 3886 windows_[0]->tabs[0]->navigations[0]); |
| 3883 nav.set_url(url2); | 3887 nav.set_url(url2); |
| 3884 session_helper_.AssertNavigationEquals(nav, | 3888 session_helper_.AssertNavigationEquals(nav, |
| 3885 windows_[0]->tabs[0]->navigations[1]); | 3889 windows_[0]->tabs[0]->navigations[1]); |
| 3886 } | 3890 } |
| 3887 */ | 3891 */ |
| 3888 | 3892 |
| 3889 } // namespace content | 3893 } // namespace content |
| OLD | NEW |