Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: ios/chrome/browser/tabs/tab_model_unittest.mm

Issue 2921063002: Clean up CRWSessionController usage in TabTest and TabModelTest. (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/tabs/DEPS ('k') | ios/chrome/browser/tabs/tab_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 11 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" 12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h"
13 #include "ios/chrome/browser/chrome_url_constants.h" 13 #include "ios/chrome/browser/chrome_url_constants.h"
14 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" 14 #include "ios/chrome/browser/infobars/infobar_manager_impl.h"
15 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" 15 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h"
16 #import "ios/chrome/browser/sessions/session_ios.h" 16 #import "ios/chrome/browser/sessions/session_ios.h"
17 #import "ios/chrome/browser/sessions/session_window_ios.h" 17 #import "ios/chrome/browser/sessions/session_window_ios.h"
18 #import "ios/chrome/browser/sessions/test_session_service.h" 18 #import "ios/chrome/browser/sessions/test_session_service.h"
19 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" 19 #import "ios/chrome/browser/tabs/legacy_tab_helper.h"
20 #import "ios/chrome/browser/tabs/tab.h" 20 #import "ios/chrome/browser/tabs/tab.h"
21 #import "ios/chrome/browser/tabs/tab_helper_util.h" 21 #import "ios/chrome/browser/tabs/tab_helper_util.h"
22 #import "ios/chrome/browser/tabs/tab_model.h" 22 #import "ios/chrome/browser/tabs/tab_model.h"
23 #import "ios/chrome/browser/tabs/tab_model_observer.h" 23 #import "ios/chrome/browser/tabs/tab_model_observer.h"
24 #import "ios/chrome/browser/tabs/tab_private.h" 24 #import "ios/chrome/browser/tabs/tab_private.h"
25 #import "ios/chrome/browser/web/chrome_web_client.h" 25 #import "ios/chrome/browser/web/chrome_web_client.h"
26 #import "ios/chrome/browser/web_state_list/web_state_list.h" 26 #import "ios/chrome/browser/web_state_list/web_state_list.h"
27 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager .h" 27 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager .h"
28 #import "ios/web/navigation/crw_session_controller.h"
29 #import "ios/web/navigation/navigation_manager_impl.h" 28 #import "ios/web/navigation/navigation_manager_impl.h"
30 #import "ios/web/public/crw_session_storage.h" 29 #import "ios/web/public/crw_session_storage.h"
31 #import "ios/web/public/navigation_manager.h" 30 #import "ios/web/public/navigation_manager.h"
32 #include "ios/web/public/referrer.h" 31 #include "ios/web/public/referrer.h"
33 #import "ios/web/public/serializable_user_data_manager.h" 32 #import "ios/web/public/serializable_user_data_manager.h"
34 #include "ios/web/public/test/scoped_testing_web_client.h" 33 #include "ios/web/public/test/scoped_testing_web_client.h"
35 #include "ios/web/public/test/test_web_thread_bundle.h" 34 #include "ios/web/public/test/test_web_thread_bundle.h"
36 #include "ios/web/public/web_thread.h" 35 #include "ios/web/public/web_thread.h"
37 #import "ios/web/web_state/ui/crw_web_controller.h" 36 #import "ios/web/web_state/ui/crw_web_controller.h"
38 #import "ios/web/web_state/web_state_impl.h" 37 #import "ios/web/web_state/web_state_impl.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 // Create a few tabs with the controller at the front. 838 // Create a few tabs with the controller at the front.
840 Tab* parent = [tab_model_ insertTabWithURL:GURL(kURL1) 839 Tab* parent = [tab_model_ insertTabWithURL:GURL(kURL1)
841 referrer:web::Referrer() 840 referrer:web::Referrer()
842 transition:ui::PAGE_TRANSITION_TYPED 841 transition:ui::PAGE_TRANSITION_TYPED
843 opener:nil 842 opener:nil
844 openedByDOM:NO 843 openedByDOM:NO
845 atIndex:[tab_model_ count] 844 atIndex:[tab_model_ count]
846 inBackground:NO]; 845 inBackground:NO];
847 // Force the history to update, as it is used to determine grouping. 846 // Force the history to update, as it is used to determine grouping.
848 ASSERT_TRUE([parent navigationManagerImpl]); 847 ASSERT_TRUE([parent navigationManagerImpl]);
849 [[parent navigationManagerImpl]->GetSessionController() commitPendingItem]; 848 [parent navigationManagerImpl]->CommitPendingItem();
850 [tab_model_ insertTabWithURL:GURL(kURL1) 849 [tab_model_ insertTabWithURL:GURL(kURL1)
851 referrer:web::Referrer() 850 referrer:web::Referrer()
852 transition:ui::PAGE_TRANSITION_TYPED 851 transition:ui::PAGE_TRANSITION_TYPED
853 opener:nil 852 opener:nil
854 openedByDOM:NO 853 openedByDOM:NO
855 atIndex:[tab_model_ count] 854 atIndex:[tab_model_ count]
856 inBackground:NO]; 855 inBackground:NO];
857 [tab_model_ insertTabWithURL:GURL(kURL1) 856 [tab_model_ insertTabWithURL:GURL(kURL1)
858 referrer:web::Referrer() 857 referrer:web::Referrer()
859 transition:ui::PAGE_TRANSITION_TYPED 858 transition:ui::PAGE_TRANSITION_TYPED
(...skipping 27 matching lines...) Expand all
887 atIndex:TabModelConstants::kTabPositionAutomatically 886 atIndex:TabModelConstants::kTabPositionAutomatically
888 inBackground:NO]; 887 inBackground:NO];
889 EXPECT_EQ([tab_model_ indexOfTab:child2], 2U); 888 EXPECT_EQ([tab_model_ indexOfTab:child2], 2U);
890 889
891 // Navigate the parent tab to a new URL. It should not change any ordering. 890 // Navigate the parent tab to a new URL. It should not change any ordering.
892 web::NavigationManager::WebLoadParams parent_params( 891 web::NavigationManager::WebLoadParams parent_params(
893 GURL("http://www.espn.com")); 892 GURL("http://www.espn.com"));
894 parent_params.transition_type = ui::PAGE_TRANSITION_TYPED; 893 parent_params.transition_type = ui::PAGE_TRANSITION_TYPED;
895 [parent navigationManager]->LoadURLWithParams(parent_params); 894 [parent navigationManager]->LoadURLWithParams(parent_params);
896 ASSERT_TRUE([parent navigationManagerImpl]); 895 ASSERT_TRUE([parent navigationManagerImpl]);
897 [[parent navigationManagerImpl]->GetSessionController() commitPendingItem]; 896 [parent navigationManagerImpl]->CommitPendingItem();
898 EXPECT_EQ([tab_model_ indexOfTab:parent], 0U); 897 EXPECT_EQ([tab_model_ indexOfTab:parent], 0U);
899 898
900 // Add a new tab. It should be added behind the parent. It should not be added 899 // Add a new tab. It should be added behind the parent. It should not be added
901 // after the previous two children. 900 // after the previous two children.
902 Tab* child3 = 901 Tab* child3 =
903 [tab_model_ insertTabWithURL:GURL(kURL1) 902 [tab_model_ insertTabWithURL:GURL(kURL1)
904 referrer:web::Referrer() 903 referrer:web::Referrer()
905 transition:ui::PAGE_TRANSITION_LINK 904 transition:ui::PAGE_TRANSITION_LINK
906 opener:parent 905 opener:parent
907 openedByDOM:NO 906 openedByDOM:NO
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // Create a few tabs with the controller at the front. 939 // Create a few tabs with the controller at the front.
941 Tab* parent = [tab_model_ insertTabWithURL:GURL(kURL1) 940 Tab* parent = [tab_model_ insertTabWithURL:GURL(kURL1)
942 referrer:web::Referrer() 941 referrer:web::Referrer()
943 transition:ui::PAGE_TRANSITION_TYPED 942 transition:ui::PAGE_TRANSITION_TYPED
944 opener:nil 943 opener:nil
945 openedByDOM:NO 944 openedByDOM:NO
946 atIndex:[tab_model_ count] 945 atIndex:[tab_model_ count]
947 inBackground:NO]; 946 inBackground:NO];
948 // Force the history to update, as it is used to determine grouping. 947 // Force the history to update, as it is used to determine grouping.
949 ASSERT_TRUE([parent navigationManagerImpl]); 948 ASSERT_TRUE([parent navigationManagerImpl]);
950 [[parent navigationManagerImpl]->GetSessionController() commitPendingItem]; 949 [parent navigationManagerImpl]->CommitPendingItem();
951 [tab_model_ insertTabWithURL:GURL(kURL1) 950 [tab_model_ insertTabWithURL:GURL(kURL1)
952 referrer:web::Referrer() 951 referrer:web::Referrer()
953 transition:ui::PAGE_TRANSITION_TYPED 952 transition:ui::PAGE_TRANSITION_TYPED
954 opener:nil 953 opener:nil
955 openedByDOM:NO 954 openedByDOM:NO
956 atIndex:[tab_model_ count] 955 atIndex:[tab_model_ count]
957 inBackground:NO]; 956 inBackground:NO];
958 [tab_model_ insertTabWithURL:GURL(kURL1) 957 [tab_model_ insertTabWithURL:GURL(kURL1)
959 referrer:web::Referrer() 958 referrer:web::Referrer()
960 transition:ui::PAGE_TRANSITION_TYPED 959 transition:ui::PAGE_TRANSITION_TYPED
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]); 1175 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]);
1177 EXPECT_EQ([tab_model_ tabAtIndex:2], 1176 EXPECT_EQ([tab_model_ tabAtIndex:2],
1178 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); 1177 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]);
1179 1178
1180 // Clean up. 1179 // Clean up.
1181 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath 1180 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath
1182 error:nullptr]); 1181 error:nullptr]);
1183 } 1182 }
1184 1183
1185 } // anonymous namespace 1184 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/DEPS ('k') | ios/chrome/browser/tabs/tab_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698