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

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

Issue 2643493002: Added -[Tab webState:didCommitNavigationWithDetails:]. (Closed)
Patch Set: Cleaned up tests Created 3 years, 11 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') | 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 typedef BOOL (^openURLBlockType)(const GURL&, BOOL); 108 typedef BOOL (^openURLBlockType)(const GURL&, BOOL);
109 109
110 - (BOOL)openURL:(const GURL&)url linkClicked:(BOOL)linkClicked { 110 - (BOOL)openURL:(const GURL&)url linkClicked:(BOOL)linkClicked {
111 return static_cast<openURLBlockType>([self blockForSelector:_cmd])( 111 return static_cast<openURLBlockType>([self blockForSelector:_cmd])(
112 url, linkClicked); 112 url, linkClicked);
113 } 113 }
114 @end 114 @end
115 115
116 namespace { 116 namespace {
117 117
118 const web::LoadPhase kLoadRequested = web::LOAD_REQUESTED;
119 const web::LoadPhase kPageLoading = web::PAGE_LOADING; 118 const web::LoadPhase kPageLoading = web::PAGE_LOADING;
120 const web::LoadPhase kPageLoaded = web::PAGE_LOADED; 119 const web::LoadPhase kPageLoaded = web::PAGE_LOADED;
121 120
122 // Observer of a QueryHistory request. 121 // Observer of a QueryHistory request.
123 class HistoryQueryResultsObserver 122 class HistoryQueryResultsObserver
124 : public base::RefCountedThreadSafe<HistoryQueryResultsObserver> { 123 : public base::RefCountedThreadSafe<HistoryQueryResultsObserver> {
125 public: 124 public:
126 HistoryQueryResultsObserver(base::RunLoop* run_loop) : run_loop_(run_loop) {} 125 HistoryQueryResultsObserver(base::RunLoop* run_loop) : run_loop_(run_loop) {}
127 126
128 // Stores |results| and stops the current message loop. 127 // Stores |results| and stops the current message loop.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 [tab_ replaceExternalAppLauncher:mock_external_app_launcher_]; 221 [tab_ replaceExternalAppLauncher:mock_external_app_launcher_];
223 } 222 }
224 223
225 void TearDown() override { 224 void TearDown() override {
226 [tab_ close]; 225 [tab_ close];
227 226
228 BlockCleanupTest::TearDown(); 227 BlockCleanupTest::TearDown();
229 } 228 }
230 229
231 void BrowseTo(const GURL& userUrl, const GURL& redirectUrl, NSString* title) { 230 void BrowseTo(const GURL& userUrl, const GURL& redirectUrl, NSString* title) {
232 [[[(id)mock_web_controller_ expect]
233 andReturnValue:OCMOCK_VALUE(kLoadRequested)] loadPhase];
234 web::Referrer empty_referrer; 231 web::Referrer empty_referrer;
235 [tab_ webWillAddPendingURL:userUrl transition:ui::PAGE_TRANSITION_TYPED]; 232 [tab_ webWillAddPendingURL:userUrl transition:ui::PAGE_TRANSITION_TYPED];
236 [tab_ webStateImpl]->OnProvisionalNavigationStarted(userUrl); 233 [tab_ webStateImpl]->OnProvisionalNavigationStarted(userUrl);
237 [tab_ webWillAddPendingURL:redirectUrl 234 [tab_ webWillAddPendingURL:redirectUrl
238 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT]; 235 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT];
239 [[tab_ navigationManager]->GetSessionController() 236 [[tab_ navigationManager]->GetSessionController()
240 addPendingEntry:redirectUrl 237 addPendingEntry:redirectUrl
241 referrer:empty_referrer 238 referrer:empty_referrer
242 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT 239 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT
243 rendererInitiated:YES]; 240 rendererInitiated:YES];
244 [tab_ webStateImpl]->OnProvisionalNavigationStarted(redirectUrl); 241 [tab_ webStateImpl]->OnProvisionalNavigationStarted(redirectUrl);
245 [[[(id)mock_web_controller_ expect]
246 andReturnValue:OCMOCK_VALUE(kPageLoading)] loadPhase];
247 [[tab_ navigationManager]->GetSessionController() commitPendingEntry]; 242 [[tab_ navigationManager]->GetSessionController() commitPendingEntry];
248 [[tab_ webController] webStateImpl]->OnNavigationCommitted(redirectUrl); 243 [[tab_ webController] webStateImpl]->OnNavigationCommitted(redirectUrl);
249 [tab_ webDidStartLoadingURL:redirectUrl shouldUpdateHistory:YES]; 244 [tab_ webDidStartLoadingURL:redirectUrl shouldUpdateHistory:YES];
250 [tab_ webController:mock_web_controller_ titleDidChange:title]; 245 [tab_ webController:mock_web_controller_ titleDidChange:title];
251 [[[(id)mock_web_controller_ expect] 246 [[[(id)mock_web_controller_ expect]
252 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; 247 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase];
253 [tab_ webStateImpl]->OnPageLoaded(redirectUrl, true); 248 [tab_ webStateImpl]->OnPageLoaded(redirectUrl, true);
254 } 249 }
255 250
256 void BrowseToNewTab() { 251 void BrowseToNewTab() {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 [[FakeNativeAppMetadata alloc] init]); 545 [[FakeNativeAppMetadata alloc] init]);
551 546
552 // Turn auto open on. 547 // Turn auto open on.
553 [metadata setShouldAutoOpenLinks:YES]; 548 [metadata setShouldAutoOpenLinks:YES];
554 int expectedCallCount = 2; 549 int expectedCallCount = 2;
555 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 550 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
556 EXPECT_FALSE([metadata shouldAutoOpenLinks]); 551 EXPECT_FALSE([metadata shouldAutoOpenLinks]);
557 } 552 }
558 553
559 } // namespace 554 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698