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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 atIndex:TabModelConstants::kTabPositionAutomatically | 571 atIndex:TabModelConstants::kTabPositionAutomatically |
572 inBackground:YES]; | 572 inBackground:YES]; |
573 EXPECT_EQ([tab_model_ indexOfTab:tab4], [tab_model_ indexOfTab:tab3] + 1); | 573 EXPECT_EQ([tab_model_ indexOfTab:tab4], [tab_model_ indexOfTab:tab3] + 1); |
574 } | 574 } |
575 | 575 |
576 TEST_F(TabModelTest, AddWithOrderControllerAndGrouping) { | 576 TEST_F(TabModelTest, AddWithOrderControllerAndGrouping) { |
577 // Create a few tabs with the controller at the front. | 577 // Create a few tabs with the controller at the front. |
578 Tab* parent = [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 578 Tab* parent = [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
579 // Force the history to update, as it is used to determine grouping. | 579 // Force the history to update, as it is used to determine grouping. |
580 ASSERT_TRUE([parent navigationManager]); | 580 ASSERT_TRUE([parent navigationManager]); |
581 [[parent navigationManager]->GetSessionController() commitPendingItem]; | 581 [[parent navigationManagerImpl]->GetSessionController() commitPendingItem]; |
582 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 582 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
583 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 583 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
584 | 584 |
585 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); | 585 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); |
586 | 586 |
587 // Add a new tab, it should be added behind the parent. | 587 // Add a new tab, it should be added behind the parent. |
588 Tab* child1 = | 588 Tab* child1 = |
589 [tab_model_ insertTabWithURL:kURL | 589 [tab_model_ insertTabWithURL:kURL |
590 referrer:kEmptyReferrer | 590 referrer:kEmptyReferrer |
591 transition:ui::PAGE_TRANSITION_LINK | 591 transition:ui::PAGE_TRANSITION_LINK |
(...skipping 15 matching lines...) Expand all Loading... |
607 atIndex:TabModelConstants::kTabPositionAutomatically | 607 atIndex:TabModelConstants::kTabPositionAutomatically |
608 inBackground:YES]; | 608 inBackground:YES]; |
609 EXPECT_EQ([tab_model_ indexOfTab:child2], 2U); | 609 EXPECT_EQ([tab_model_ indexOfTab:child2], 2U); |
610 | 610 |
611 // Navigate the parent tab to a new URL. It should not change any ordering. | 611 // Navigate the parent tab to a new URL. It should not change any ordering. |
612 web::NavigationManager::WebLoadParams parent_params( | 612 web::NavigationManager::WebLoadParams parent_params( |
613 GURL("http://www.espn.com")); | 613 GURL("http://www.espn.com")); |
614 parent_params.transition_type = ui::PAGE_TRANSITION_TYPED; | 614 parent_params.transition_type = ui::PAGE_TRANSITION_TYPED; |
615 [[parent webController] loadWithParams:parent_params]; | 615 [[parent webController] loadWithParams:parent_params]; |
616 ASSERT_TRUE([parent navigationManager]); | 616 ASSERT_TRUE([parent navigationManager]); |
617 [[parent navigationManager]->GetSessionController() commitPendingItem]; | 617 [[parent navigationManagerImpl]->GetSessionController() commitPendingItem]; |
618 EXPECT_EQ([tab_model_ indexOfTab:parent], 0U); | 618 EXPECT_EQ([tab_model_ indexOfTab:parent], 0U); |
619 | 619 |
620 // Add a new tab. It should be added behind the parent. It should not be added | 620 // Add a new tab. It should be added behind the parent. It should not be added |
621 // after the previous two children. | 621 // after the previous two children. |
622 Tab* child3 = | 622 Tab* child3 = |
623 [tab_model_ insertTabWithURL:kURL | 623 [tab_model_ insertTabWithURL:kURL |
624 referrer:kEmptyReferrer | 624 referrer:kEmptyReferrer |
625 transition:ui::PAGE_TRANSITION_LINK | 625 transition:ui::PAGE_TRANSITION_LINK |
626 opener:parent | 626 opener:parent |
627 openedByDOM:NO | 627 openedByDOM:NO |
(...skipping 20 matching lines...) Expand all Loading... |
648 // Now add a non-owned tab and make sure it is added at the end. | 648 // Now add a non-owned tab and make sure it is added at the end. |
649 Tab* nonChild = [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 649 Tab* nonChild = [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
650 EXPECT_EQ([tab_model_ indexOfTab:nonChild], [tab_model_ count] - 1); | 650 EXPECT_EQ([tab_model_ indexOfTab:nonChild], [tab_model_ count] - 1); |
651 } | 651 } |
652 | 652 |
653 TEST_F(TabModelTest, AddWithLinkTransitionAndIndex) { | 653 TEST_F(TabModelTest, AddWithLinkTransitionAndIndex) { |
654 // Create a few tabs with the controller at the front. | 654 // Create a few tabs with the controller at the front. |
655 Tab* parent = [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 655 Tab* parent = [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
656 // Force the history to update, as it is used to determine grouping. | 656 // Force the history to update, as it is used to determine grouping. |
657 ASSERT_TRUE([parent navigationManager]); | 657 ASSERT_TRUE([parent navigationManager]); |
658 [[parent navigationManager]->GetSessionController() commitPendingItem]; | 658 [[parent navigationManagerImpl]->GetSessionController() commitPendingItem]; |
659 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 659 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
660 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; | 660 [tab_model_ addTabWithURL:kURL referrer:kEmptyReferrer]; |
661 | 661 |
662 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); | 662 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); |
663 | 663 |
664 // Add a new tab, it should be added before the parent since the index | 664 // Add a new tab, it should be added before the parent since the index |
665 // parameter has been specified with a valid value. | 665 // parameter has been specified with a valid value. |
666 Tab* child1 = [tab_model_ insertTabWithURL:kURL | 666 Tab* child1 = [tab_model_ insertTabWithURL:kURL |
667 referrer:kEmptyReferrer | 667 referrer:kEmptyReferrer |
668 transition:ui::PAGE_TRANSITION_LINK | 668 transition:ui::PAGE_TRANSITION_LINK |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 // Restoring TabModel session sends asynchronous tasks to IO thread, wait | 845 // Restoring TabModel session sends asynchronous tasks to IO thread, wait |
846 // for them to complete after destroying the TabModel. | 846 // for them to complete after destroying the TabModel. |
847 base::RunLoop().RunUntilIdle(); | 847 base::RunLoop().RunUntilIdle(); |
848 | 848 |
849 // Clean up. | 849 // Clean up. |
850 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath | 850 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath |
851 error:nullptr]); | 851 error:nullptr]); |
852 } | 852 } |
853 | 853 |
854 } // anonymous namespace | 854 } // anonymous namespace |
OLD | NEW |