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

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

Issue 2823623002: Remove usage of Tab's |url| property from TabModel. (Closed)
Patch Set: test + formatting fixes 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/tab_model.mm ('k') | ios/web/navigation/navigation_manager_impl.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/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"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 343
344 TEST_F(TabModelTest, RestoreSessionOnNTPTest) { 344 TEST_F(TabModelTest, RestoreSessionOnNTPTest) {
345 Tab* tab = [tab_model_ insertTabWithURL:GURL(kChromeUINewTabURL) 345 Tab* tab = [tab_model_ insertTabWithURL:GURL(kChromeUINewTabURL)
346 referrer:web::Referrer() 346 referrer:web::Referrer()
347 transition:ui::PAGE_TRANSITION_TYPED 347 transition:ui::PAGE_TRANSITION_TYPED
348 opener:nil 348 opener:nil
349 openedByDOM:NO 349 openedByDOM:NO
350 atIndex:0 350 atIndex:0
351 inBackground:NO]; 351 inBackground:NO];
352 web::WebStateImpl* web_state = static_cast<web::WebStateImpl*>(tab.webState);
353 web_state->GetNavigationManagerImpl().CommitPendingItem();
352 354
353 SessionWindowIOS* window(CreateSessionWindow()); 355 SessionWindowIOS* window(CreateSessionWindow());
354 [tab_model_ restoreSessionWindow:window]; 356 [tab_model_ restoreSessionWindow:window];
355 357
356 ASSERT_EQ(3U, [tab_model_ count]); 358 ASSERT_EQ(3U, [tab_model_ count]);
357 EXPECT_NSEQ([tab_model_ tabAtIndex:1], [tab_model_ currentTab]); 359 EXPECT_NSEQ([tab_model_ tabAtIndex:1], [tab_model_ currentTab]);
358 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:0]); 360 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:0]);
359 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:1]); 361 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:1]);
360 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:2]); 362 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:2]);
361 } 363 }
362 364
363 TEST_F(TabModelTest, RestoreSessionOn2NtpTest) { 365 TEST_F(TabModelTest, RestoreSessionOn2NtpTest) {
364 Tab* tab0 = [tab_model_ insertTabWithURL:GURL(kChromeUINewTabURL) 366 Tab* tab0 = [tab_model_ insertTabWithURL:GURL(kChromeUINewTabURL)
365 referrer:web::Referrer() 367 referrer:web::Referrer()
366 transition:ui::PAGE_TRANSITION_TYPED 368 transition:ui::PAGE_TRANSITION_TYPED
367 opener:nil 369 opener:nil
368 openedByDOM:NO 370 openedByDOM:NO
369 atIndex:0 371 atIndex:0
370 inBackground:NO]; 372 inBackground:NO];
373 web::WebStateImpl* web_state = static_cast<web::WebStateImpl*>(tab0.webState);
374 web_state->GetNavigationManagerImpl().CommitPendingItem();
371 Tab* tab1 = [tab_model_ insertTabWithURL:GURL(kChromeUINewTabURL) 375 Tab* tab1 = [tab_model_ insertTabWithURL:GURL(kChromeUINewTabURL)
372 referrer:web::Referrer() 376 referrer:web::Referrer()
373 transition:ui::PAGE_TRANSITION_TYPED 377 transition:ui::PAGE_TRANSITION_TYPED
374 opener:nil 378 opener:nil
375 openedByDOM:NO 379 openedByDOM:NO
376 atIndex:1 380 atIndex:1
377 inBackground:NO]; 381 inBackground:NO];
382 web_state = static_cast<web::WebStateImpl*>(tab1.webState);
383 web_state->GetNavigationManagerImpl().CommitPendingItem();
378 384
379 SessionWindowIOS* window(CreateSessionWindow()); 385 SessionWindowIOS* window(CreateSessionWindow());
380 [tab_model_ restoreSessionWindow:window]; 386 [tab_model_ restoreSessionWindow:window];
381 387
382 ASSERT_EQ(5U, [tab_model_ count]); 388 ASSERT_EQ(5U, [tab_model_ count]);
383 EXPECT_NSEQ([tab_model_ tabAtIndex:3], [tab_model_ currentTab]); 389 EXPECT_NSEQ([tab_model_ tabAtIndex:3], [tab_model_ currentTab]);
384 EXPECT_NSEQ(tab0, [tab_model_ tabAtIndex:0]); 390 EXPECT_NSEQ(tab0, [tab_model_ tabAtIndex:0]);
385 EXPECT_NSEQ(tab1, [tab_model_ tabAtIndex:1]); 391 EXPECT_NSEQ(tab1, [tab_model_ tabAtIndex:1]);
386 EXPECT_NSNE(tab0, [tab_model_ tabAtIndex:2]); 392 EXPECT_NSNE(tab0, [tab_model_ tabAtIndex:2]);
387 EXPECT_NSNE(tab0, [tab_model_ tabAtIndex:3]); 393 EXPECT_NSNE(tab0, [tab_model_ tabAtIndex:3]);
388 EXPECT_NSNE(tab0, [tab_model_ tabAtIndex:4]); 394 EXPECT_NSNE(tab0, [tab_model_ tabAtIndex:4]);
389 EXPECT_NSNE(tab1, [tab_model_ tabAtIndex:2]); 395 EXPECT_NSNE(tab1, [tab_model_ tabAtIndex:2]);
390 EXPECT_NSNE(tab1, [tab_model_ tabAtIndex:3]); 396 EXPECT_NSNE(tab1, [tab_model_ tabAtIndex:3]);
391 EXPECT_NSNE(tab1, [tab_model_ tabAtIndex:4]); 397 EXPECT_NSNE(tab1, [tab_model_ tabAtIndex:4]);
392 } 398 }
393 399
394 TEST_F(TabModelTest, RestoreSessionOnAnyTest) { 400 TEST_F(TabModelTest, RestoreSessionOnAnyTest) {
395 Tab* tab = [tab_model_ insertTabWithURL:GURL(kURL1) 401 Tab* tab = [tab_model_ insertTabWithURL:GURL(kURL1)
396 referrer:web::Referrer() 402 referrer:web::Referrer()
397 transition:ui::PAGE_TRANSITION_TYPED 403 transition:ui::PAGE_TRANSITION_TYPED
398 opener:nil 404 opener:nil
399 openedByDOM:NO 405 openedByDOM:NO
400 atIndex:0 406 atIndex:0
401 inBackground:NO]; 407 inBackground:NO];
408 web::WebStateImpl* web_state = static_cast<web::WebStateImpl*>(tab.webState);
409 web_state->GetNavigationManagerImpl().CommitPendingItem();
402 410
403 SessionWindowIOS* window(CreateSessionWindow()); 411 SessionWindowIOS* window(CreateSessionWindow());
404 [tab_model_ restoreSessionWindow:window]; 412 [tab_model_ restoreSessionWindow:window];
405 413
406 ASSERT_EQ(4U, [tab_model_ count]); 414 ASSERT_EQ(4U, [tab_model_ count]);
407 EXPECT_NSEQ([tab_model_ tabAtIndex:2], [tab_model_ currentTab]); 415 EXPECT_NSEQ([tab_model_ tabAtIndex:2], [tab_model_ currentTab]);
408 EXPECT_NSEQ(tab, [tab_model_ tabAtIndex:0]); 416 EXPECT_NSEQ(tab, [tab_model_ tabAtIndex:0]);
409 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:1]); 417 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:1]);
410 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:2]); 418 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:2]);
411 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:3]); 419 EXPECT_NSNE(tab, [tab_model_ tabAtIndex:3]);
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]); 1176 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:2]]);
1169 EXPECT_EQ([tab_model_ tabAtIndex:2], 1177 EXPECT_EQ([tab_model_ tabAtIndex:2],
1170 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]); 1178 [tab_model_ openerOfTab:[tab_model_ tabAtIndex:0]]);
1171 1179
1172 // Clean up. 1180 // Clean up.
1173 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath 1181 EXPECT_TRUE([[NSFileManager defaultManager] removeItemAtPath:stashPath
1174 error:nullptr]); 1182 error:nullptr]);
1175 } 1183 }
1176 1184
1177 } // anonymous namespace 1185 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab_model.mm ('k') | ios/web/navigation/navigation_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698