Chromium Code Reviews| 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" |
| 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 Loading... | |
| 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 opener:nil | |
| 69 openedByDOM:NO | |
| 70 model:tabModel | |
| 71 browserState:browserState]; | |
| 72 if (self) { | |
| 73 id webControllerMock = | 68 id webControllerMock = |
| 74 [OCMockObject niceMockForClass:[CRWWebController class]]; | 69 [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( |
| 79 windowName, @"opener", NO, -1); | 74 windowName, @"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) |
|
marq (ping after 24h)
2017/02/07 18:39:04
Prefer to keep the superclass init at the top of t
sdefresne
2017/02/08 09:28:57
There's a good reason: I need to create and WebSta
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |