OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 3397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3408 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)); | 3408 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)); |
3409 EXPECT_EQ(instance1, instance2); | 3409 EXPECT_EQ(instance1, instance2); |
3410 EXPECT_EQ(0, controller.GetEntryAtIndex(0)->GetPageID()); | 3410 EXPECT_EQ(0, controller.GetEntryAtIndex(0)->GetPageID()); |
3411 EXPECT_EQ(1, controller.GetEntryAtIndex(1)->GetPageID()); | 3411 EXPECT_EQ(1, controller.GetEntryAtIndex(1)->GetPageID()); |
3412 EXPECT_EQ(1, contents()->GetMaxPageIDForSiteInstance(instance1)); | 3412 EXPECT_EQ(1, contents()->GetMaxPageIDForSiteInstance(instance1)); |
3413 | 3413 |
3414 scoped_ptr<TestWebContents> other_contents( | 3414 scoped_ptr<TestWebContents> other_contents( |
3415 static_cast<TestWebContents*>(CreateTestWebContents())); | 3415 static_cast<TestWebContents*>(CreateTestWebContents())); |
3416 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3416 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3417 other_contents->NavigateAndCommit(url3); | 3417 other_contents->NavigateAndCommit(url3); |
3418 other_contents->ExpectSetHistoryLengthAndPrune( | 3418 other_contents->ExpectSetHistoryOffsetAndLength(2, 3); |
Charlie Reis
2014/12/03 23:48:07
So much nicer!
| |
3419 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | |
3420 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3421 other_controller.CopyStateFromAndPrune(&controller, false); | 3419 other_controller.CopyStateFromAndPrune(&controller, false); |
3422 | 3420 |
3423 // other_controller should now contain the 3 urls: url1, url2 and url3. | 3421 // other_controller should now contain the 3 urls: url1, url2 and url3. |
3424 | 3422 |
3425 ASSERT_EQ(3, other_controller.GetEntryCount()); | 3423 ASSERT_EQ(3, other_controller.GetEntryCount()); |
3426 | 3424 |
3427 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); | 3425 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); |
3428 | 3426 |
3429 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3427 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3430 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); | 3428 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); |
(...skipping 25 matching lines...) Expand all Loading... | |
3456 | 3454 |
3457 NavigateAndCommit(url1); | 3455 NavigateAndCommit(url1); |
3458 NavigateAndCommit(url2); | 3456 NavigateAndCommit(url2); |
3459 controller.GoBack(); | 3457 controller.GoBack(); |
3460 contents()->CommitPendingNavigation(); | 3458 contents()->CommitPendingNavigation(); |
3461 | 3459 |
3462 scoped_ptr<TestWebContents> other_contents( | 3460 scoped_ptr<TestWebContents> other_contents( |
3463 static_cast<TestWebContents*>(CreateTestWebContents())); | 3461 static_cast<TestWebContents*>(CreateTestWebContents())); |
3464 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3462 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3465 other_contents->NavigateAndCommit(url3); | 3463 other_contents->NavigateAndCommit(url3); |
3466 other_contents->ExpectSetHistoryLengthAndPrune( | 3464 other_contents->ExpectSetHistoryOffsetAndLength(1, 2); |
3467 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, | |
3468 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3469 other_controller.CopyStateFromAndPrune(&controller, false); | 3465 other_controller.CopyStateFromAndPrune(&controller, false); |
3470 | 3466 |
3471 // other_controller should now contain: url1, url3 | 3467 // other_controller should now contain: url1, url3 |
3472 | 3468 |
3473 ASSERT_EQ(2, other_controller.GetEntryCount()); | 3469 ASSERT_EQ(2, other_controller.GetEntryCount()); |
3474 ASSERT_EQ(1, other_controller.GetCurrentEntryIndex()); | 3470 ASSERT_EQ(1, other_controller.GetCurrentEntryIndex()); |
3475 | 3471 |
3476 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3472 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3477 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); | 3473 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); |
3478 EXPECT_EQ(0, other_controller.GetEntryAtIndex(1)->GetPageID()); | 3474 EXPECT_EQ(0, other_controller.GetEntryAtIndex(1)->GetPageID()); |
(...skipping 15 matching lines...) Expand all Loading... | |
3494 const GURL url4("http://foo4"); | 3490 const GURL url4("http://foo4"); |
3495 | 3491 |
3496 NavigateAndCommit(url1); | 3492 NavigateAndCommit(url1); |
3497 NavigateAndCommit(url2); | 3493 NavigateAndCommit(url2); |
3498 | 3494 |
3499 scoped_ptr<TestWebContents> other_contents( | 3495 scoped_ptr<TestWebContents> other_contents( |
3500 static_cast<TestWebContents*>(CreateTestWebContents())); | 3496 static_cast<TestWebContents*>(CreateTestWebContents())); |
3501 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3497 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3502 other_contents->NavigateAndCommit(url3); | 3498 other_contents->NavigateAndCommit(url3); |
3503 other_contents->NavigateAndCommit(url4); | 3499 other_contents->NavigateAndCommit(url4); |
3504 other_contents->ExpectSetHistoryLengthAndPrune( | 3500 other_contents->ExpectSetHistoryOffsetAndLength(2, 3); |
3505 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(1)), 2, | |
3506 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3507 other_controller.CopyStateFromAndPrune(&controller, false); | 3501 other_controller.CopyStateFromAndPrune(&controller, false); |
3508 | 3502 |
3509 // other_controller should now contain: url1, url2, url4 | 3503 // other_controller should now contain: url1, url2, url4 |
3510 | 3504 |
3511 ASSERT_EQ(3, other_controller.GetEntryCount()); | 3505 ASSERT_EQ(3, other_controller.GetEntryCount()); |
3512 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); | 3506 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); |
3513 | 3507 |
3514 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3508 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3515 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); | 3509 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); |
3516 EXPECT_EQ(url4, other_controller.GetEntryAtIndex(2)->GetURL()); | 3510 EXPECT_EQ(url4, other_controller.GetEntryAtIndex(2)->GetURL()); |
(...skipping 17 matching lines...) Expand all Loading... | |
3534 NavigateAndCommit(url1); | 3528 NavigateAndCommit(url1); |
3535 NavigateAndCommit(url2); | 3529 NavigateAndCommit(url2); |
3536 | 3530 |
3537 scoped_ptr<TestWebContents> other_contents( | 3531 scoped_ptr<TestWebContents> other_contents( |
3538 static_cast<TestWebContents*>(CreateTestWebContents())); | 3532 static_cast<TestWebContents*>(CreateTestWebContents())); |
3539 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3533 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3540 other_contents->NavigateAndCommit(url3); | 3534 other_contents->NavigateAndCommit(url3); |
3541 other_contents->NavigateAndCommit(url4); | 3535 other_contents->NavigateAndCommit(url4); |
3542 other_controller.GoBack(); | 3536 other_controller.GoBack(); |
3543 other_contents->CommitPendingNavigation(); | 3537 other_contents->CommitPendingNavigation(); |
3544 other_contents->ExpectSetHistoryLengthAndPrune( | 3538 other_contents->ExpectSetHistoryOffsetAndLength(2, 3); |
3545 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | |
3546 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3547 other_controller.CopyStateFromAndPrune(&controller, false); | 3539 other_controller.CopyStateFromAndPrune(&controller, false); |
3548 | 3540 |
3549 // other_controller should now contain: url1, url2, url3 | 3541 // other_controller should now contain: url1, url2, url3 |
3550 | 3542 |
3551 ASSERT_EQ(3, other_controller.GetEntryCount()); | 3543 ASSERT_EQ(3, other_controller.GetEntryCount()); |
3552 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); | 3544 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); |
3553 | 3545 |
3554 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3546 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3555 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); | 3547 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); |
3556 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->GetURL()); | 3548 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->GetURL()); |
(...skipping 18 matching lines...) Expand all Loading... | |
3575 NavigateAndCommit(url2); | 3567 NavigateAndCommit(url2); |
3576 controller.GoBack(); | 3568 controller.GoBack(); |
3577 contents()->CommitPendingNavigation(); | 3569 contents()->CommitPendingNavigation(); |
3578 | 3570 |
3579 scoped_ptr<TestWebContents> other_contents( | 3571 scoped_ptr<TestWebContents> other_contents( |
3580 static_cast<TestWebContents*>(CreateTestWebContents())); | 3572 static_cast<TestWebContents*>(CreateTestWebContents())); |
3581 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3573 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3582 other_contents->NavigateAndCommit(url3); | 3574 other_contents->NavigateAndCommit(url3); |
3583 other_controller.LoadURL( | 3575 other_controller.LoadURL( |
3584 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3576 url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
3585 other_contents->ExpectSetHistoryLengthAndPrune( | 3577 other_contents->ExpectSetHistoryOffsetAndLength(1, 2); |
3586 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, | |
3587 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3588 other_controller.CopyStateFromAndPrune(&controller, false); | 3578 other_controller.CopyStateFromAndPrune(&controller, false); |
3589 | 3579 |
3590 // other_controller should now contain url1, url3, and a pending entry | 3580 // other_controller should now contain url1, url3, and a pending entry |
3591 // for url4. | 3581 // for url4. |
3592 | 3582 |
3593 ASSERT_EQ(2, other_controller.GetEntryCount()); | 3583 ASSERT_EQ(2, other_controller.GetEntryCount()); |
3594 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); | 3584 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); |
3595 | 3585 |
3596 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3586 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3597 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); | 3587 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); |
(...skipping 24 matching lines...) Expand all Loading... | |
3622 scoped_ptr<TestWebContents> other_contents( | 3612 scoped_ptr<TestWebContents> other_contents( |
3623 static_cast<TestWebContents*>(CreateTestWebContents())); | 3613 static_cast<TestWebContents*>(CreateTestWebContents())); |
3624 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3614 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3625 other_contents->NavigateAndCommit(url2a); | 3615 other_contents->NavigateAndCommit(url2a); |
3626 // Simulate a client redirect, which has the same page ID as entry 2a. | 3616 // Simulate a client redirect, which has the same page ID as entry 2a. |
3627 other_controller.LoadURL( | 3617 other_controller.LoadURL( |
3628 url2b, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 3618 url2b, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
3629 other_controller.GetPendingEntry()->SetPageID( | 3619 other_controller.GetPendingEntry()->SetPageID( |
3630 other_controller.GetLastCommittedEntry()->GetPageID()); | 3620 other_controller.GetLastCommittedEntry()->GetPageID()); |
3631 | 3621 |
3632 other_contents->ExpectSetHistoryLengthAndPrune( | 3622 other_contents->ExpectSetHistoryOffsetAndLength(1, 2); |
3633 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, | |
3634 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3635 other_controller.CopyStateFromAndPrune(&controller, false); | 3623 other_controller.CopyStateFromAndPrune(&controller, false); |
3636 | 3624 |
3637 // other_controller should now contain url1, url2a, and a pending entry | 3625 // other_controller should now contain url1, url2a, and a pending entry |
3638 // for url2b. | 3626 // for url2b. |
3639 | 3627 |
3640 ASSERT_EQ(2, other_controller.GetEntryCount()); | 3628 ASSERT_EQ(2, other_controller.GetEntryCount()); |
3641 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); | 3629 EXPECT_EQ(1, other_controller.GetCurrentEntryIndex()); |
3642 | 3630 |
3643 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3631 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3644 EXPECT_EQ(url2a, other_controller.GetEntryAtIndex(1)->GetURL()); | 3632 EXPECT_EQ(url2a, other_controller.GetEntryAtIndex(1)->GetURL()); |
(...skipping 21 matching lines...) Expand all Loading... | |
3666 const GURL url3("http://foo3"); | 3654 const GURL url3("http://foo3"); |
3667 | 3655 |
3668 NavigateAndCommit(url1); | 3656 NavigateAndCommit(url1); |
3669 NavigateAndCommit(url2); | 3657 NavigateAndCommit(url2); |
3670 controller.GoBack(); | 3658 controller.GoBack(); |
3671 | 3659 |
3672 scoped_ptr<TestWebContents> other_contents( | 3660 scoped_ptr<TestWebContents> other_contents( |
3673 static_cast<TestWebContents*>(CreateTestWebContents())); | 3661 static_cast<TestWebContents*>(CreateTestWebContents())); |
3674 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3662 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3675 other_contents->NavigateAndCommit(url3); | 3663 other_contents->NavigateAndCommit(url3); |
3676 other_contents->ExpectSetHistoryLengthAndPrune( | 3664 other_contents->ExpectSetHistoryOffsetAndLength(2, 3); |
3677 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | |
3678 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3679 other_controller.CopyStateFromAndPrune(&controller, false); | 3665 other_controller.CopyStateFromAndPrune(&controller, false); |
3680 | 3666 |
3681 // other_controller should now contain: url1, url2, url3 | 3667 // other_controller should now contain: url1, url2, url3 |
3682 | 3668 |
3683 ASSERT_EQ(3, other_controller.GetEntryCount()); | 3669 ASSERT_EQ(3, other_controller.GetEntryCount()); |
3684 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); | 3670 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); |
3685 | 3671 |
3686 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3672 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3687 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); | 3673 EXPECT_EQ(url2, other_controller.GetEntryAtIndex(1)->GetURL()); |
3688 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->GetURL()); | 3674 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(2)->GetURL()); |
(...skipping 24 matching lines...) Expand all Loading... | |
3713 PrunedListener listener(&controller); | 3699 PrunedListener listener(&controller); |
3714 | 3700 |
3715 NavigateAndCommit(url1); | 3701 NavigateAndCommit(url1); |
3716 NavigateAndCommit(url2); | 3702 NavigateAndCommit(url2); |
3717 NavigateAndCommit(url3); | 3703 NavigateAndCommit(url3); |
3718 | 3704 |
3719 scoped_ptr<TestWebContents> other_contents( | 3705 scoped_ptr<TestWebContents> other_contents( |
3720 static_cast<TestWebContents*>(CreateTestWebContents())); | 3706 static_cast<TestWebContents*>(CreateTestWebContents())); |
3721 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3707 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3722 other_contents->NavigateAndCommit(url4); | 3708 other_contents->NavigateAndCommit(url4); |
3723 other_contents->ExpectSetHistoryLengthAndPrune( | 3709 other_contents->ExpectSetHistoryOffsetAndLength(2, 3); |
3724 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | |
3725 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3726 other_controller.CopyStateFromAndPrune(&controller, false); | 3710 other_controller.CopyStateFromAndPrune(&controller, false); |
3727 | 3711 |
3728 // We should have received a pruned notification. | 3712 // We should have received a pruned notification. |
3729 EXPECT_EQ(1, listener.notification_count_); | 3713 EXPECT_EQ(1, listener.notification_count_); |
3730 EXPECT_TRUE(listener.details_.from_front); | 3714 EXPECT_TRUE(listener.details_.from_front); |
3731 EXPECT_EQ(1, listener.details_.count); | 3715 EXPECT_EQ(1, listener.details_.count); |
3732 | 3716 |
3733 // other_controller should now contain only 3 urls: url2, url3 and url4. | 3717 // other_controller should now contain only 3 urls: url2, url3 and url4. |
3734 | 3718 |
3735 ASSERT_EQ(3, other_controller.GetEntryCount()); | 3719 ASSERT_EQ(3, other_controller.GetEntryCount()); |
(...skipping 28 matching lines...) Expand all Loading... | |
3764 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)); | 3748 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)); |
3765 EXPECT_EQ(instance1, instance2); | 3749 EXPECT_EQ(instance1, instance2); |
3766 EXPECT_EQ(0, controller.GetEntryAtIndex(0)->GetPageID()); | 3750 EXPECT_EQ(0, controller.GetEntryAtIndex(0)->GetPageID()); |
3767 EXPECT_EQ(1, controller.GetEntryAtIndex(1)->GetPageID()); | 3751 EXPECT_EQ(1, controller.GetEntryAtIndex(1)->GetPageID()); |
3768 EXPECT_EQ(1, contents()->GetMaxPageIDForSiteInstance(instance1)); | 3752 EXPECT_EQ(1, contents()->GetMaxPageIDForSiteInstance(instance1)); |
3769 | 3753 |
3770 scoped_ptr<TestWebContents> other_contents( | 3754 scoped_ptr<TestWebContents> other_contents( |
3771 static_cast<TestWebContents*>(CreateTestWebContents())); | 3755 static_cast<TestWebContents*>(CreateTestWebContents())); |
3772 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3756 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3773 other_contents->NavigateAndCommit(url3); | 3757 other_contents->NavigateAndCommit(url3); |
3774 other_contents->ExpectSetHistoryLengthAndPrune( | 3758 other_contents->ExpectSetHistoryOffsetAndLength(1, 2); |
3775 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 1, | |
3776 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3777 other_controller.CopyStateFromAndPrune(&controller, true); | 3759 other_controller.CopyStateFromAndPrune(&controller, true); |
3778 | 3760 |
3779 // other_controller should now contain the 2 urls: url1 and url3. | 3761 // other_controller should now contain the 2 urls: url1 and url3. |
3780 | 3762 |
3781 ASSERT_EQ(2, other_controller.GetEntryCount()); | 3763 ASSERT_EQ(2, other_controller.GetEntryCount()); |
3782 | 3764 |
3783 ASSERT_EQ(1, other_controller.GetCurrentEntryIndex()); | 3765 ASSERT_EQ(1, other_controller.GetCurrentEntryIndex()); |
3784 | 3766 |
3785 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); | 3767 EXPECT_EQ(url1, other_controller.GetEntryAtIndex(0)->GetURL()); |
3786 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); | 3768 EXPECT_EQ(url3, other_controller.GetEntryAtIndex(1)->GetURL()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3818 PrunedListener listener(&controller); | 3800 PrunedListener listener(&controller); |
3819 | 3801 |
3820 NavigateAndCommit(url1); | 3802 NavigateAndCommit(url1); |
3821 NavigateAndCommit(url2); | 3803 NavigateAndCommit(url2); |
3822 NavigateAndCommit(url3); | 3804 NavigateAndCommit(url3); |
3823 | 3805 |
3824 scoped_ptr<TestWebContents> other_contents( | 3806 scoped_ptr<TestWebContents> other_contents( |
3825 static_cast<TestWebContents*>(CreateTestWebContents())); | 3807 static_cast<TestWebContents*>(CreateTestWebContents())); |
3826 NavigationControllerImpl& other_controller = other_contents->GetController(); | 3808 NavigationControllerImpl& other_controller = other_contents->GetController(); |
3827 other_contents->NavigateAndCommit(url4); | 3809 other_contents->NavigateAndCommit(url4); |
3828 other_contents->ExpectSetHistoryLengthAndPrune( | 3810 other_contents->ExpectSetHistoryOffsetAndLength(2, 3); |
3829 GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2, | |
3830 other_controller.GetEntryAtIndex(0)->GetPageID()); | |
3831 other_controller.CopyStateFromAndPrune(&controller, true); | 3811 other_controller.CopyStateFromAndPrune(&controller, true); |
3832 | 3812 |
3833 // We should have received no pruned notification. | 3813 // We should have received no pruned notification. |
3834 EXPECT_EQ(0, listener.notification_count_); | 3814 EXPECT_EQ(0, listener.notification_count_); |
3835 | 3815 |
3836 // other_controller should now contain only 3 urls: url1, url2 and url4. | 3816 // other_controller should now contain only 3 urls: url1, url2 and url4. |
3837 | 3817 |
3838 ASSERT_EQ(3, other_controller.GetEntryCount()); | 3818 ASSERT_EQ(3, other_controller.GetEntryCount()); |
3839 | 3819 |
3840 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); | 3820 ASSERT_EQ(2, other_controller.GetCurrentEntryIndex()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3875 source_controller.Restore( | 3855 source_controller.Restore( |
3876 entries.size() - 1, | 3856 entries.size() - 1, |
3877 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 3857 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
3878 &entries); | 3858 &entries); |
3879 ASSERT_EQ(0u, entries.size()); | 3859 ASSERT_EQ(0u, entries.size()); |
3880 source_controller.LoadIfNecessary(); | 3860 source_controller.LoadIfNecessary(); |
3881 source_contents->CommitPendingNavigation(); | 3861 source_contents->CommitPendingNavigation(); |
3882 | 3862 |
3883 // Load a page, then copy state from |source_contents|. | 3863 // Load a page, then copy state from |source_contents|. |
3884 NavigateAndCommit(kInitialUrl); | 3864 NavigateAndCommit(kInitialUrl); |
3885 contents()->ExpectSetHistoryLengthAndPrune( | 3865 contents()->ExpectSetHistoryOffsetAndLength(2, 3); |
3886 GetSiteInstanceFromEntry(controller_impl().GetEntryAtIndex(0)), 2, | |
3887 controller_impl().GetEntryAtIndex(0)->GetPageID()); | |
3888 controller_impl().CopyStateFromAndPrune(&source_controller, false); | 3866 controller_impl().CopyStateFromAndPrune(&source_controller, false); |
3889 ASSERT_EQ(3, controller_impl().GetEntryCount()); | 3867 ASSERT_EQ(3, controller_impl().GetEntryCount()); |
3890 | 3868 |
3891 // Go back to the first entry one at a time and | 3869 // Go back to the first entry one at a time and |
3892 // verify that it works as expected. | 3870 // verify that it works as expected. |
3893 EXPECT_EQ(2, controller_impl().GetCurrentEntryIndex()); | 3871 EXPECT_EQ(2, controller_impl().GetCurrentEntryIndex()); |
3894 EXPECT_EQ(kInitialUrl, controller_impl().GetActiveEntry()->GetURL()); | 3872 EXPECT_EQ(kInitialUrl, controller_impl().GetActiveEntry()->GetURL()); |
3895 | 3873 |
3896 controller_impl().GoBack(); | 3874 controller_impl().GoBack(); |
3897 contents()->CommitPendingNavigation(); | 3875 contents()->CommitPendingNavigation(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3953 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); | 3931 message = process()->sink().GetFirstMessageMatching(FrameMsg_Navigate::ID); |
3954 EXPECT_TRUE(message == NULL); | 3932 EXPECT_TRUE(message == NULL); |
3955 } | 3933 } |
3956 | 3934 |
3957 // Test call to PruneAllButLastCommitted for the only entry. | 3935 // Test call to PruneAllButLastCommitted for the only entry. |
3958 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { | 3936 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { |
3959 NavigationControllerImpl& controller = controller_impl(); | 3937 NavigationControllerImpl& controller = controller_impl(); |
3960 const GURL url1("http://foo1"); | 3938 const GURL url1("http://foo1"); |
3961 NavigateAndCommit(url1); | 3939 NavigateAndCommit(url1); |
3962 | 3940 |
3963 contents()->ExpectSetHistoryLengthAndPrune( | 3941 contents()->ExpectSetHistoryOffsetAndLength(0, 1); |
3964 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(0)), 0, | |
3965 controller.GetEntryAtIndex(0)->GetPageID()); | |
3966 | 3942 |
3967 controller.PruneAllButLastCommitted(); | 3943 controller.PruneAllButLastCommitted(); |
3968 | 3944 |
3969 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 3945 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
3970 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url1); | 3946 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url1); |
3971 } | 3947 } |
3972 | 3948 |
3973 // Test call to PruneAllButLastCommitted for first entry. | 3949 // Test call to PruneAllButLastCommitted for first entry. |
3974 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForFirst) { | 3950 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForFirst) { |
3975 NavigationControllerImpl& controller = controller_impl(); | 3951 NavigationControllerImpl& controller = controller_impl(); |
3976 const GURL url1("http://foo/1"); | 3952 const GURL url1("http://foo/1"); |
3977 const GURL url2("http://foo/2"); | 3953 const GURL url2("http://foo/2"); |
3978 const GURL url3("http://foo/3"); | 3954 const GURL url3("http://foo/3"); |
3979 | 3955 |
3980 NavigateAndCommit(url1); | 3956 NavigateAndCommit(url1); |
3981 NavigateAndCommit(url2); | 3957 NavigateAndCommit(url2); |
3982 NavigateAndCommit(url3); | 3958 NavigateAndCommit(url3); |
3983 controller.GoBack(); | 3959 controller.GoBack(); |
3984 controller.GoBack(); | 3960 controller.GoBack(); |
3985 contents()->CommitPendingNavigation(); | 3961 contents()->CommitPendingNavigation(); |
3986 | 3962 |
3987 contents()->ExpectSetHistoryLengthAndPrune( | 3963 contents()->ExpectSetHistoryOffsetAndLength(0, 1); |
3988 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(0)), 0, | |
3989 controller.GetEntryAtIndex(0)->GetPageID()); | |
3990 | 3964 |
3991 controller.PruneAllButLastCommitted(); | 3965 controller.PruneAllButLastCommitted(); |
3992 | 3966 |
3993 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 3967 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
3994 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url1); | 3968 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url1); |
3995 } | 3969 } |
3996 | 3970 |
3997 // Test call to PruneAllButLastCommitted for intermediate entry. | 3971 // Test call to PruneAllButLastCommitted for intermediate entry. |
3998 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForIntermediate) { | 3972 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForIntermediate) { |
3999 NavigationControllerImpl& controller = controller_impl(); | 3973 NavigationControllerImpl& controller = controller_impl(); |
4000 const GURL url1("http://foo/1"); | 3974 const GURL url1("http://foo/1"); |
4001 const GURL url2("http://foo/2"); | 3975 const GURL url2("http://foo/2"); |
4002 const GURL url3("http://foo/3"); | 3976 const GURL url3("http://foo/3"); |
4003 | 3977 |
4004 NavigateAndCommit(url1); | 3978 NavigateAndCommit(url1); |
4005 NavigateAndCommit(url2); | 3979 NavigateAndCommit(url2); |
4006 NavigateAndCommit(url3); | 3980 NavigateAndCommit(url3); |
4007 controller.GoBack(); | 3981 controller.GoBack(); |
4008 contents()->CommitPendingNavigation(); | 3982 contents()->CommitPendingNavigation(); |
4009 | 3983 |
4010 contents()->ExpectSetHistoryLengthAndPrune( | 3984 contents()->ExpectSetHistoryOffsetAndLength(0, 1); |
4011 GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)), 0, | |
4012 controller.GetEntryAtIndex(1)->GetPageID()); | |
4013 | 3985 |
4014 controller.PruneAllButLastCommitted(); | 3986 controller.PruneAllButLastCommitted(); |
4015 | 3987 |
4016 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 3988 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
4017 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url2); | 3989 EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url2); |
4018 } | 3990 } |
4019 | 3991 |
4020 // Test call to PruneAllButLastCommitted for a pending entry that is not yet in | 3992 // Test call to PruneAllButLastCommitted for a pending entry that is not yet in |
4021 // the list of entries. | 3993 // the list of entries. |
4022 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) { | 3994 TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) { |
4023 NavigationControllerImpl& controller = controller_impl(); | 3995 NavigationControllerImpl& controller = controller_impl(); |
4024 const GURL url1("http://foo/1"); | 3996 const GURL url1("http://foo/1"); |
4025 const GURL url2("http://foo/2"); | 3997 const GURL url2("http://foo/2"); |
4026 const GURL url3("http://foo/3"); | 3998 const GURL url3("http://foo/3"); |
4027 | 3999 |
4028 NavigateAndCommit(url1); | 4000 NavigateAndCommit(url1); |
4029 NavigateAndCommit(url2); | 4001 NavigateAndCommit(url2); |
4030 | 4002 |
4031 // Create a pending entry that is not in the entry list. | 4003 // Create a pending entry that is not in the entry list. |
4032 controller.LoadURL( | 4004 controller.LoadURL( |
4033 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 4005 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
4034 EXPECT_TRUE(controller.GetPendingEntry()); | 4006 EXPECT_TRUE(controller.GetPendingEntry()); |
4035 EXPECT_EQ(2, controller.GetEntryCount()); | 4007 EXPECT_EQ(2, controller.GetEntryCount()); |
4036 | 4008 |
4037 contents()->ExpectSetHistoryLengthAndPrune( | 4009 contents()->ExpectSetHistoryOffsetAndLength(0, 1); |
4038 NULL, 0, controller.GetPendingEntry()->GetPageID()); | |
4039 controller.PruneAllButLastCommitted(); | 4010 controller.PruneAllButLastCommitted(); |
4040 | 4011 |
4041 // We should only have the last committed and pending entries at this point, | 4012 // We should only have the last committed and pending entries at this point, |
4042 // and the pending entry should still not be in the entry list. | 4013 // and the pending entry should still not be in the entry list. |
4043 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 4014 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
4044 EXPECT_EQ(url2, controller.GetEntryAtIndex(0)->GetURL()); | 4015 EXPECT_EQ(url2, controller.GetEntryAtIndex(0)->GetURL()); |
4045 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 4016 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
4046 EXPECT_TRUE(controller.GetPendingEntry()); | 4017 EXPECT_TRUE(controller.GetPendingEntry()); |
4047 EXPECT_EQ(1, controller.GetEntryCount()); | 4018 EXPECT_EQ(1, controller.GetEntryCount()); |
4048 | 4019 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4389 params.post_id = -1; | 4360 params.post_id = -1; |
4390 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 4361 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
4391 | 4362 |
4392 // Now reload. replaceState overrides the POST, so we should not show a | 4363 // Now reload. replaceState overrides the POST, so we should not show a |
4393 // repost warning dialog. | 4364 // repost warning dialog. |
4394 controller_impl().Reload(true); | 4365 controller_impl().Reload(true); |
4395 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4366 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
4396 } | 4367 } |
4397 | 4368 |
4398 } // namespace content | 4369 } // namespace content |
OLD | NEW |