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

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

Issue 2685653002: Remove TabModel -replaceWebState: method. (Closed)
Patch Set: Fix indentation in the initializer. Created 3 years, 10 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/tab.mm ('k') | ios/chrome/browser/tabs/tab_private.h » ('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/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"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 12 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h"
14 #include "ios/chrome/browser/chrome_url_constants.h" 14 #include "ios/chrome/browser/chrome_url_constants.h"
15 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" 15 #include "ios/chrome/browser/infobars/infobar_manager_impl.h"
16 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h"
16 #import "ios/chrome/browser/sessions/session_window.h" 17 #import "ios/chrome/browser/sessions/session_window.h"
17 #import "ios/chrome/browser/sessions/test_session_service.h" 18 #import "ios/chrome/browser/sessions/test_session_service.h"
18 #import "ios/chrome/browser/tabs/tab.h" 19 #import "ios/chrome/browser/tabs/tab.h"
19 #import "ios/chrome/browser/tabs/tab_model.h" 20 #import "ios/chrome/browser/tabs/tab_model.h"
20 #import "ios/chrome/browser/tabs/tab_model_observer.h" 21 #import "ios/chrome/browser/tabs/tab_model_observer.h"
21 #import "ios/chrome/browser/tabs/tab_private.h" 22 #import "ios/chrome/browser/tabs/tab_private.h"
22 #import "ios/chrome/browser/web/chrome_web_client.h" 23 #import "ios/chrome/browser/web/chrome_web_client.h"
23 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager .h" 24 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager .h"
24 #import "ios/web/navigation/crw_session_controller.h" 25 #import "ios/web/navigation/crw_session_controller.h"
25 #import "ios/web/navigation/navigation_manager_impl.h" 26 #import "ios/web/navigation/navigation_manager_impl.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 browserState:(ios::ChromeBrowserState*)browserState 58 browserState:(ios::ChromeBrowserState*)browserState
58 tabModel:(TabModel*)tabModel; 59 tabModel:(TabModel*)tabModel;
59 @end 60 @end
60 61
61 @implementation TabTest 62 @implementation TabTest
62 63
63 - (instancetype)initWithWindowName:(NSString*)windowName 64 - (instancetype)initWithWindowName:(NSString*)windowName
64 lastVisitedTimestamp:(double)lastVisitedTimestamp 65 lastVisitedTimestamp:(double)lastVisitedTimestamp
65 browserState:(ios::ChromeBrowserState*)browserState 66 browserState:(ios::ChromeBrowserState*)browserState
66 tabModel:(TabModel*)tabModel { 67 tabModel:(TabModel*)tabModel {
67 self = [super initWithWindowName:windowName 68 id webControllerMock =
68 opener:nil 69 [OCMockObject niceMockForClass:[CRWWebController class]];
69 openedByDOM:NO
70 model:tabModel
71 browserState:browserState];
72 if (self) {
73 id webControllerMock =
74 [OCMockObject niceMockForClass:[CRWWebController class]];
75 70
76 auto webStateImpl = base::MakeUnique<WebStateImpl>(browserState); 71 auto webStateImpl = base::MakeUnique<WebStateImpl>(browserState);
77 webStateImpl->SetWebController(webControllerMock); 72 webStateImpl->SetWebController(webControllerMock);
78 webStateImpl->GetNavigationManagerImpl().InitializeSession( 73 webStateImpl->GetNavigationManagerImpl().InitializeSession(windowName,
79 windowName, @"opener", NO, -1); 74 @"opener", NO, -1);
80 [webStateImpl->GetNavigationManagerImpl().GetSessionController() 75 [webStateImpl->GetNavigationManagerImpl().GetSessionController()
81 setLastVisitedTimestamp:lastVisitedTimestamp]; 76 setLastVisitedTimestamp:lastVisitedTimestamp];
82 77
83 WebStateImpl* webStateImplPtr = webStateImpl.get(); 78 WebStateImpl* webStateImplPtr = webStateImpl.get();
84 [[[webControllerMock stub] andReturnValue:OCMOCK_VALUE(webStateImplPtr)] 79 [[[webControllerMock stub] andReturnValue:OCMOCK_VALUE(webStateImplPtr)]
85 webStateImpl]; 80 webStateImpl];
86 BOOL yes = YES; 81 BOOL yes = YES;
87 [[[webControllerMock stub] andReturnValue:OCMOCK_VALUE(yes)] isViewAlive]; 82 [[[webControllerMock stub] andReturnValue:OCMOCK_VALUE(yes)] isViewAlive];
88 83
89 [self replaceWebState:std::move(webStateImpl)]; 84 if ((self = [super initWithWebState:std::move(webStateImpl)
85 model:tabModel
86 attachTabHelpers:NO])) {
87 IOSChromeSessionTabHelper::CreateForWebState(self.webState);
90 } 88 }
91 return self; 89 return self;
92 } 90 }
93 91
94 @end 92 @end
95 93
96 @interface TabModel (VisibleForTesting) 94 @interface TabModel (VisibleForTesting)
97 - (SessionWindowIOS*)windowForSavingSession; 95 - (SessionWindowIOS*)windowForSavingSession;
98 @end 96 @end
99 97
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // Restoring TabModel session sends asynchronous tasks to IO thread, wait 882 // Restoring TabModel session sends asynchronous tasks to IO thread, wait
885 // for them to complete after destroying the TabModel. 883 // for them to complete after destroying the TabModel.
886 base::RunLoop().RunUntilIdle(); 884 base::RunLoop().RunUntilIdle();
887 885
888 // Clean up. 886 // Clean up.
889 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath 887 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath
890 error:nullptr]); 888 error:nullptr]);
891 } 889 }
892 890
893 } // anonymous namespace 891 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/tabs/tab_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698