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

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller_unittest.mm

Issue 2968973002: [ios] Removes IDC_BOOKMARK_PAGE and IDC_SHARE_PAGE
Patch Set: Rebased Created 3 years, 5 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
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 <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 #import <PassKit/PassKit.h> 6 #import <PassKit/PassKit.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
26 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" 26 #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
27 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" 27 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
28 #import "ios/chrome/browser/tabs/tab.h" 28 #import "ios/chrome/browser/tabs/tab.h"
29 #import "ios/chrome/browser/tabs/tab_model.h" 29 #import "ios/chrome/browser/tabs/tab_model.h"
30 #import "ios/chrome/browser/ui/activity_services/share_protocol.h" 30 #import "ios/chrome/browser/ui/activity_services/share_protocol.h"
31 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" 31 #import "ios/chrome/browser/ui/activity_services/share_to_data.h"
32 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" 32 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
33 #import "ios/chrome/browser/ui/browser_view_controller.h" 33 #import "ios/chrome/browser/ui/browser_view_controller.h"
34 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" 34 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h"
35 #import "ios/chrome/browser/ui/browser_view_controller_testing.h" 35 #import "ios/chrome/browser/ui/browser_view_controller_testing.h"
36 #import "ios/chrome/browser/ui/commands/browser_commands.h"
36 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 37 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
37 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 38 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
38 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" 39 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
39 #import "ios/chrome/browser/ui/page_not_available_controller.h" 40 #import "ios/chrome/browser/ui/page_not_available_controller.h"
40 #include "ios/chrome/browser/ui/toolbar/test_toolbar_model_ios.h" 41 #include "ios/chrome/browser/ui/toolbar/test_toolbar_model_ios.h"
41 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" 42 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
42 #include "ios/chrome/browser/ui/ui_util.h" 43 #include "ios/chrome/browser/ui/ui_util.h"
43 #import "ios/chrome/browser/web/error_page_content.h" 44 #import "ios/chrome/browser/web/error_page_content.h"
44 #import "ios/chrome/browser/web/passkit_dialog_provider.h" 45 #import "ios/chrome/browser/web/passkit_dialog_provider.h"
45 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" 46 #include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // Have the TestToolbarModel indicate that the page load is complete. 423 // Have the TestToolbarModel indicate that the page load is complete.
423 static_cast<TestToolbarModelIOS*>(toolbarModelIOS_)->set_is_loading(false); 424 static_cast<TestToolbarModelIOS*>(toolbarModelIOS_)->set_is_loading(false);
424 425
425 // Don't set any expectation for stopLoading to be called on the mock tab. 426 // Don't set any expectation for stopLoading to be called on the mock tab.
426 [bvc_ locationBarBeganEdit:nil]; 427 [bvc_ locationBarBeganEdit:nil];
427 428
428 EXPECT_OCMOCK_VERIFY(tabMock); 429 EXPECT_OCMOCK_VERIFY(tabMock);
429 } 430 }
430 431
431 // Verifies that BVC invokes -shareURL on ShareController with the correct 432 // Verifies that BVC invokes -shareURL on ShareController with the correct
432 // parameters in response to the IDC_SHARE_PAGE command. 433 // parameters in response to the -sharePage command.
433 TEST_F(BrowserViewControllerTest, TestSharePageCommandHandling) { 434 TEST_F(BrowserViewControllerTest, TestSharePageCommandHandling) {
434 GURL expectedUrl("http://www.testurl.net"); 435 GURL expectedUrl("http://www.testurl.net");
435 NSString* expectedTitle = @"title"; 436 NSString* expectedTitle = @"title";
436 static_cast<BVCTestTabMock*>(tab_).lastCommittedURL = expectedUrl; 437 static_cast<BVCTestTabMock*>(tab_).lastCommittedURL = expectedUrl;
437 static_cast<BVCTestTabMock*>(tab_).visibleURL = expectedUrl; 438 static_cast<BVCTestTabMock*>(tab_).visibleURL = expectedUrl;
438 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_); 439 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_);
439 ios::ChromeBrowserState* ptr = chrome_browser_state_.get(); 440 ios::ChromeBrowserState* ptr = chrome_browser_state_.get();
440 [[[tabMock stub] andReturnValue:OCMOCK_VALUE(ptr)] browserState]; 441 [[[tabMock stub] andReturnValue:OCMOCK_VALUE(ptr)] browserState];
441 [[[tabMock stub] andReturn:expectedTitle] title]; 442 [[[tabMock stub] andReturn:expectedTitle] title];
442 [[[tabMock stub] andReturn:expectedTitle] originalTitle]; 443 [[[tabMock stub] andReturn:expectedTitle] originalTitle];
(...skipping 22 matching lines...) Expand all
465 shareToData.isPagePrintable == NO && thumbnailDataIsEqual; 466 shareToData.isPagePrintable == NO && thumbnailDataIsEqual;
466 }; 467 };
467 468
468 [[shareControllerMock expect] 469 [[shareControllerMock expect]
469 shareWithData:[OCMArg checkWithBlock:shareDataChecker] 470 shareWithData:[OCMArg checkWithBlock:shareDataChecker]
470 controller:bvc_ 471 controller:bvc_
471 browserState:chrome_browser_state_.get() 472 browserState:chrome_browser_state_.get()
472 shareToDelegate:bvc_ 473 shareToDelegate:bvc_
473 fromRect:[bvc_ testing_shareButtonAnchorRect] 474 fromRect:[bvc_ testing_shareButtonAnchorRect]
474 inView:[OCMArg any]]; 475 inView:[OCMArg any]];
475 [bvc_ chromeExecuteCommand:GetCommandWithTag(IDC_SHARE_PAGE)]; 476 [bvc_.browserCommandDispatcher sharePage];
476 EXPECT_OCMOCK_VERIFY(shareControllerMock); 477 EXPECT_OCMOCK_VERIFY(shareControllerMock);
477 } 478 }
478 479
479 // Verifies that BVC does not invoke -shareURL on ShareController in response 480 // Verifies that BVC does not invoke -shareURL on ShareController in response
480 // to the IDC_SHARE_PAGE command if tab is in the process of being closed. 481 // to the |-sharePage| command if tab is in the process of being closed.
481 TEST_F(BrowserViewControllerTest, TestSharePageWhenClosing) { 482 TEST_F(BrowserViewControllerTest, TestSharePageWhenClosing) {
482 GURL expectedUrl("http://www.testurl.net"); 483 GURL expectedUrl("http://www.testurl.net");
483 NSString* expectedTitle = @"title"; 484 NSString* expectedTitle = @"title";
484 // Sets WebState to nil because [tab close] clears the WebState. 485 // Sets WebState to nil because [tab close] clears the WebState.
485 static_cast<BVCTestTabMock*>(tab_).webState = nil; 486 static_cast<BVCTestTabMock*>(tab_).webState = nil;
486 static_cast<BVCTestTabMock*>(tab_).lastCommittedURL = expectedUrl; 487 static_cast<BVCTestTabMock*>(tab_).lastCommittedURL = expectedUrl;
487 static_cast<BVCTestTabMock*>(tab_).visibleURL = expectedUrl; 488 static_cast<BVCTestTabMock*>(tab_).visibleURL = expectedUrl;
488 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_); 489 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_);
489 [[[tabMock stub] andReturn:expectedTitle] title]; 490 [[[tabMock stub] andReturn:expectedTitle] title];
490 [[[tabMock stub] andReturn:expectedTitle] originalTitle]; 491 [[[tabMock stub] andReturn:expectedTitle] originalTitle];
491 // Explicitly disallow the execution of the ShareController. 492 // Explicitly disallow the execution of the ShareController.
492 OCMockObject* shareControllerMock = 493 OCMockObject* shareControllerMock =
493 static_cast<OCMockObject*>(shareController_); 494 static_cast<OCMockObject*>(shareController_);
494 [[shareControllerMock reject] 495 [[shareControllerMock reject]
495 shareWithData:[OCMArg any] 496 shareWithData:[OCMArg any]
496 controller:bvc_ 497 controller:bvc_
497 browserState:chrome_browser_state_.get() 498 browserState:chrome_browser_state_.get()
498 shareToDelegate:bvc_ 499 shareToDelegate:bvc_
499 fromRect:[bvc_ testing_shareButtonAnchorRect] 500 fromRect:[bvc_ testing_shareButtonAnchorRect]
500 inView:[OCMArg any]]; 501 inView:[OCMArg any]];
501 [bvc_ chromeExecuteCommand:GetCommandWithTag(IDC_SHARE_PAGE)]; 502 [bvc_.browserCommandDispatcher sharePage];
502 EXPECT_OCMOCK_VERIFY(shareControllerMock); 503 EXPECT_OCMOCK_VERIFY(shareControllerMock);
503 } 504 }
504 505
505 // Verifies that BVC instantiates a bubble to show the given success message on 506 // Verifies that BVC instantiates a bubble to show the given success message on
506 // receiving a -shareDidComplete callback for a successful share. 507 // receiving a -shareDidComplete callback for a successful share.
507 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithSuccess) { 508 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithSuccess) {
508 NSString* completionMessage = @"Completion!"; 509 NSString* completionMessage = @"Completion!";
509 [[dependencyFactory_ expect] showSnackbarWithMessage:completionMessage]; 510 [[dependencyFactory_ expect] showSnackbarWithMessage:completionMessage];
510 511
511 [bvc_ shareDidComplete:ShareTo::SHARE_SUCCESS 512 [bvc_ shareDidComplete:ShareTo::SHARE_SUCCESS
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 static_cast<OCMockObject*>(shareController_); 579 static_cast<OCMockObject*>(shareController_);
579 [[shareControllerMock expect] cancelShareAnimated:NO]; 580 [[shareControllerMock expect] cancelShareAnimated:NO];
580 EXPECT_CALL(*this, OnCompletionCalled()); 581 EXPECT_CALL(*this, OnCompletionCalled());
581 [bvc_ clearPresentedStateWithCompletion:^{ 582 [bvc_ clearPresentedStateWithCompletion:^{
582 this->OnCompletionCalled(); 583 this->OnCompletionCalled();
583 }]; 584 }];
584 EXPECT_OCMOCK_VERIFY(shareControllerMock); 585 EXPECT_OCMOCK_VERIFY(shareControllerMock);
585 } 586 }
586 587
587 } // namespace 588 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | ios/chrome/browser/ui/commands/browser_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698