| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import <objc/runtime.h> | 5 #import <objc/runtime.h> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 inBackground:YES]; | 625 inBackground:YES]; |
| 626 EXPECT_EQ([tab_model_ indexOfTab:tab4], [tab_model_ indexOfTab:tab3] + 1); | 626 EXPECT_EQ([tab_model_ indexOfTab:tab4], [tab_model_ indexOfTab:tab3] + 1); |
| 627 } | 627 } |
| 628 | 628 |
| 629 TEST_F(TabModelTest, AddWithOrderControllerAndGrouping) { | 629 TEST_F(TabModelTest, AddWithOrderControllerAndGrouping) { |
| 630 // Create a few tabs with the controller at the front. | 630 // Create a few tabs with the controller at the front. |
| 631 Tab* parent = | 631 Tab* parent = |
| 632 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 632 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 633 // Force the history to update, as it is used to determine grouping. | 633 // Force the history to update, as it is used to determine grouping. |
| 634 ASSERT_TRUE([parent navigationManager]); | 634 ASSERT_TRUE([parent navigationManager]); |
| 635 [[parent navigationManager]->GetSessionController() commitPendingEntry]; | 635 [[parent navigationManager]->GetSessionController() commitPendingItem]; |
| 636 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 636 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 637 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 637 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 638 | 638 |
| 639 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); | 639 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); |
| 640 | 640 |
| 641 // Add a new tab, it should be added behind the parent. | 641 // Add a new tab, it should be added behind the parent. |
| 642 Tab* child1 = [tab_model_ | 642 Tab* child1 = [tab_model_ |
| 643 insertOrUpdateTabWithURL:kURL | 643 insertOrUpdateTabWithURL:kURL |
| 644 referrer:kEmptyReferrer | 644 referrer:kEmptyReferrer |
| 645 transition:ui::PAGE_TRANSITION_LINK | 645 transition:ui::PAGE_TRANSITION_LINK |
| (...skipping 17 matching lines...) Expand all Loading... |
| 663 atIndex:TabModelConstants::kTabPositionAutomatically | 663 atIndex:TabModelConstants::kTabPositionAutomatically |
| 664 inBackground:YES]; | 664 inBackground:YES]; |
| 665 EXPECT_EQ([tab_model_ indexOfTab:child2], 2U); | 665 EXPECT_EQ([tab_model_ indexOfTab:child2], 2U); |
| 666 | 666 |
| 667 // Navigate the parent tab to a new URL. It should not change any ordering. | 667 // Navigate the parent tab to a new URL. It should not change any ordering. |
| 668 web::NavigationManager::WebLoadParams parent_params( | 668 web::NavigationManager::WebLoadParams parent_params( |
| 669 GURL("http://www.espn.com")); | 669 GURL("http://www.espn.com")); |
| 670 parent_params.transition_type = ui::PAGE_TRANSITION_TYPED; | 670 parent_params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| 671 [[parent webController] loadWithParams:parent_params]; | 671 [[parent webController] loadWithParams:parent_params]; |
| 672 ASSERT_TRUE([parent navigationManager]); | 672 ASSERT_TRUE([parent navigationManager]); |
| 673 [[parent navigationManager]->GetSessionController() commitPendingEntry]; | 673 [[parent navigationManager]->GetSessionController() commitPendingItem]; |
| 674 EXPECT_EQ([tab_model_ indexOfTab:parent], 0U); | 674 EXPECT_EQ([tab_model_ indexOfTab:parent], 0U); |
| 675 | 675 |
| 676 // Add a new tab. It should be added behind the parent. It should not be added | 676 // Add a new tab. It should be added behind the parent. It should not be added |
| 677 // after the previous two children. | 677 // after the previous two children. |
| 678 Tab* child3 = [tab_model_ | 678 Tab* child3 = [tab_model_ |
| 679 insertOrUpdateTabWithURL:kURL | 679 insertOrUpdateTabWithURL:kURL |
| 680 referrer:kEmptyReferrer | 680 referrer:kEmptyReferrer |
| 681 transition:ui::PAGE_TRANSITION_LINK | 681 transition:ui::PAGE_TRANSITION_LINK |
| 682 windowName:nil | 682 windowName:nil |
| 683 opener:parent | 683 opener:parent |
| (...skipping 24 matching lines...) Expand all Loading... |
| 708 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 708 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 709 EXPECT_EQ([tab_model_ indexOfTab:nonChild], [tab_model_ count] - 1); | 709 EXPECT_EQ([tab_model_ indexOfTab:nonChild], [tab_model_ count] - 1); |
| 710 } | 710 } |
| 711 | 711 |
| 712 TEST_F(TabModelTest, AddWithLinkTransitionAndIndex) { | 712 TEST_F(TabModelTest, AddWithLinkTransitionAndIndex) { |
| 713 // Create a few tabs with the controller at the front. | 713 // Create a few tabs with the controller at the front. |
| 714 Tab* parent = | 714 Tab* parent = |
| 715 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 715 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 716 // Force the history to update, as it is used to determine grouping. | 716 // Force the history to update, as it is used to determine grouping. |
| 717 ASSERT_TRUE([parent navigationManager]); | 717 ASSERT_TRUE([parent navigationManager]); |
| 718 [[parent navigationManager]->GetSessionController() commitPendingEntry]; | 718 [[parent navigationManager]->GetSessionController() commitPendingItem]; |
| 719 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 719 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 720 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; | 720 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer windowName:nil]; |
| 721 | 721 |
| 722 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); | 722 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); |
| 723 | 723 |
| 724 // Add a new tab, it should be added before the parent since the index | 724 // Add a new tab, it should be added before the parent since the index |
| 725 // parameter has been specified with a valid value. | 725 // parameter has been specified with a valid value. |
| 726 Tab* child1 = [tab_model_ insertOrUpdateTabWithURL:kURL | 726 Tab* child1 = [tab_model_ insertOrUpdateTabWithURL:kURL |
| 727 referrer:kEmptyReferrer | 727 referrer:kEmptyReferrer |
| 728 transition:ui::PAGE_TRANSITION_LINK | 728 transition:ui::PAGE_TRANSITION_LINK |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 browserState:chrome_browser_state.get()]); | 876 browserState:chrome_browser_state.get()]); |
| 877 EXPECT_EQ(model.get().currentTab, [model tabAtIndex:1]); | 877 EXPECT_EQ(model.get().currentTab, [model tabAtIndex:1]); |
| 878 [model browserStateDestroyed]; | 878 [model browserStateDestroyed]; |
| 879 | 879 |
| 880 // Clean up. | 880 // Clean up. |
| 881 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath | 881 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath |
| 882 error:nullptr]); | 882 error:nullptr]); |
| 883 } | 883 } |
| 884 | 884 |
| 885 } // anonymous namespace | 885 } // anonymous namespace |
| OLD | NEW |