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

Side by Side Diff: ios/chrome/browser/tabs/tab_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_private.h ('k') | no next file » | 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 <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true)); 187 ASSERT_TRUE(chrome_browser_state_->CreateHistoryService(true));
188 history_service_ = ios::HistoryServiceFactory::GetForBrowserState( 188 history_service_ = ios::HistoryServiceFactory::GetForBrowserState(
189 chrome_browser_state_.get(), ServiceAccessType::EXPLICIT_ACCESS); 189 chrome_browser_state_.get(), ServiceAccessType::EXPLICIT_ACCESS);
190 190
191 ios::ChromeBrowserState* browser_state = chrome_browser_state_.get(); 191 ios::ChromeBrowserState* browser_state = chrome_browser_state_.get();
192 if (UseOffTheRecordBrowserState()) 192 if (UseOffTheRecordBrowserState())
193 browser_state = browser_state->GetOffTheRecordChromeBrowserState(); 193 browser_state = browser_state->GetOffTheRecordChromeBrowserState();
194 194
195 mock_web_controller_ = 195 mock_web_controller_ =
196 [OCMockObject niceMockForClass:[CRWWebController class]]; 196 [OCMockObject niceMockForClass:[CRWWebController class]];
197 std::unique_ptr<WebStateImpl> web_state_impl; 197 auto web_state_impl = base::MakeUnique<WebStateImpl>(browser_state);
198 web_state_impl.reset(new WebStateImpl(browser_state));
199 web_state_impl->SetWebController(mock_web_controller_); 198 web_state_impl->SetWebController(mock_web_controller_);
200 web_state_impl->GetNavigationManagerImpl().InitializeSession( 199 web_state_impl->GetNavigationManagerImpl().InitializeSession(
201 @"window1", @"opener", NO, 0); 200 @"window1", @"opener", NO, 0);
202 web_state_impl_ = web_state_impl.get(); 201 web_state_impl_ = web_state_impl.get();
203 [[[(OCMockObject*)mock_web_controller_ stub] 202 [[[static_cast<OCMockObject*>(mock_web_controller_) stub]
204 andReturnValue:OCMOCK_VALUE(web_state_impl_)] webStateImpl]; 203 andReturnValue:OCMOCK_VALUE(web_state_impl_)] webStateImpl];
205 web_controller_view_.reset([[UIView alloc] init]); 204 web_controller_view_.reset([[UIView alloc] init]);
206 [[[(OCMockObject*)mock_web_controller_ stub] 205 [[[static_cast<OCMockObject*>(mock_web_controller_) stub]
207 andReturn:web_controller_view_.get()] view]; 206 andReturn:web_controller_view_.get()] view];
208 tab_.reset([[Tab alloc] initWithWindowName:nil 207 tab_.reset([[Tab alloc] initWithWebState:std::move(web_state_impl)
209 opener:nullptr 208 model:nil
210 openedByDOM:NO 209 attachTabHelpers:NO]);
211 model:nil
212 browserState:browser_state]);
213 web::NavigationManager::WebLoadParams params(GURL("chrome://version/")); 210 web::NavigationManager::WebLoadParams params(GURL("chrome://version/"));
214 [[tab_ webController] loadWithParams:params]; 211 [[tab_ webController] loadWithParams:params];
215 [tab_ replaceWebState:std::move(web_state_impl)];
216 212
217 // There should be no entries in the history at this point. 213 // There should be no entries in the history at this point.
218 history::QueryResults results; 214 history::QueryResults results;
219 QueryAllHistory(&results); 215 QueryAllHistory(&results);
220 EXPECT_EQ(0UL, results.size()); 216 EXPECT_EQ(0UL, results.size());
221 mock_external_app_launcher_.reset([[ExternalAppLauncherMock alloc] 217 mock_external_app_launcher_.reset([[ExternalAppLauncherMock alloc]
222 initWithRepresentedObject: 218 initWithRepresentedObject:
223 [OCMockObject mockForClass:[ExternalAppLauncher class]]]); 219 [OCMockObject mockForClass:[ExternalAppLauncher class]]]);
224 [tab_ replaceExternalAppLauncher:mock_external_app_launcher_]; 220 [tab_ replaceExternalAppLauncher:mock_external_app_launcher_];
225 } 221 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 [[FakeNativeAppMetadata alloc] init]); 547 [[FakeNativeAppMetadata alloc] init]);
552 548
553 // Turn auto open on. 549 // Turn auto open on.
554 [metadata setShouldAutoOpenLinks:YES]; 550 [metadata setShouldAutoOpenLinks:YES];
555 int expectedCallCount = 2; 551 int expectedCallCount = 2;
556 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 552 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
557 EXPECT_FALSE([metadata shouldAutoOpenLinks]); 553 EXPECT_FALSE([metadata shouldAutoOpenLinks]);
558 } 554 }
559 555
560 } // namespace 556 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_private.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698