| 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 <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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 Testing)<CRWNativeContentProvider, PassKitDialogProvider, ShareToDelegate> | 75 Testing)<CRWNativeContentProvider, PassKitDialogProvider, ShareToDelegate> |
| 76 - (void)pageLoadStarted:(NSNotification*)notification; | 76 - (void)pageLoadStarted:(NSNotification*)notification; |
| 77 - (void)pageLoadComplete:(NSNotification*)notification; | 77 - (void)pageLoadComplete:(NSNotification*)notification; |
| 78 - (void)tabSelected:(Tab*)tab; | 78 - (void)tabSelected:(Tab*)tab; |
| 79 - (void)tabDeselected:(NSNotification*)notification; | 79 - (void)tabDeselected:(NSNotification*)notification; |
| 80 - (void)tabCountChanged:(NSNotification*)notification; | 80 - (void)tabCountChanged:(NSNotification*)notification; |
| 81 - (IBAction)chromeExecuteCommand:(id)sender; | 81 - (IBAction)chromeExecuteCommand:(id)sender; |
| 82 @end | 82 @end |
| 83 | 83 |
| 84 @interface BVCTestTabMock : OCMockComplexTypeHelper { | 84 @interface BVCTestTabMock : OCMockComplexTypeHelper { |
| 85 GURL _url; | |
| 86 GURL _lastCommittedURL; | 85 GURL _lastCommittedURL; |
| 87 GURL _visibleURL; | 86 GURL _visibleURL; |
| 88 WebStateImpl* _webState; | 87 WebStateImpl* _webState; |
| 89 } | 88 } |
| 90 | 89 |
| 91 @property(nonatomic, assign) const GURL& url; | |
| 92 @property(nonatomic, assign) const GURL& lastCommittedURL; | 90 @property(nonatomic, assign) const GURL& lastCommittedURL; |
| 93 @property(nonatomic, assign) const GURL& visibleURL; | 91 @property(nonatomic, assign) const GURL& visibleURL; |
| 94 @property(nonatomic, assign) WebStateImpl* webState; | 92 @property(nonatomic, assign) WebStateImpl* webState; |
| 95 | 93 |
| 96 - (web::NavigationManager*)navigationManager; | 94 - (web::NavigationManager*)navigationManager; |
| 97 - (web::NavigationManagerImpl*)navigationManagerImpl; | 95 - (web::NavigationManagerImpl*)navigationManagerImpl; |
| 98 | 96 |
| 99 @end | 97 @end |
| 100 | 98 |
| 101 @implementation BVCTestTabMock | 99 @implementation BVCTestTabMock |
| 102 - (const GURL&)url { | |
| 103 return _url; | |
| 104 } | |
| 105 - (void)setUrl:(const GURL&)url { | |
| 106 _url = url; | |
| 107 } | |
| 108 - (const GURL&)lastCommittedURL { | 100 - (const GURL&)lastCommittedURL { |
| 109 return _lastCommittedURL; | 101 return _lastCommittedURL; |
| 110 } | 102 } |
| 111 - (void)setLastCommittedURL:(const GURL&)lastCommittedURL { | 103 - (void)setLastCommittedURL:(const GURL&)lastCommittedURL { |
| 112 _lastCommittedURL = lastCommittedURL; | 104 _lastCommittedURL = lastCommittedURL; |
| 113 } | 105 } |
| 114 - (const GURL&)visibleURL { | 106 - (const GURL&)visibleURL { |
| 115 return _visibleURL; | 107 return _visibleURL; |
| 116 } | 108 } |
| 117 - (void)setVisibleURL:(const GURL&)visibleURL { | 109 - (void)setVisibleURL:(const GURL&)visibleURL { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 [bvc_ locationBarBeganEdit:nil]; | 423 [bvc_ locationBarBeganEdit:nil]; |
| 432 | 424 |
| 433 EXPECT_OCMOCK_VERIFY(tabMock); | 425 EXPECT_OCMOCK_VERIFY(tabMock); |
| 434 } | 426 } |
| 435 | 427 |
| 436 // Verifies that BVC invokes -shareURL on ShareController with the correct | 428 // Verifies that BVC invokes -shareURL on ShareController with the correct |
| 437 // parameters in response to the IDC_SHARE_PAGE command. | 429 // parameters in response to the IDC_SHARE_PAGE command. |
| 438 TEST_F(BrowserViewControllerTest, TestSharePageCommandHandling) { | 430 TEST_F(BrowserViewControllerTest, TestSharePageCommandHandling) { |
| 439 GURL expectedUrl("http://www.testurl.net"); | 431 GURL expectedUrl("http://www.testurl.net"); |
| 440 NSString* expectedTitle = @"title"; | 432 NSString* expectedTitle = @"title"; |
| 441 static_cast<BVCTestTabMock*>(tab_.get()).url = expectedUrl; | |
| 442 static_cast<BVCTestTabMock*>(tab_.get()).lastCommittedURL = expectedUrl; | 433 static_cast<BVCTestTabMock*>(tab_.get()).lastCommittedURL = expectedUrl; |
| 443 static_cast<BVCTestTabMock*>(tab_.get()).visibleURL = expectedUrl; | 434 static_cast<BVCTestTabMock*>(tab_.get()).visibleURL = expectedUrl; |
| 444 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_.get()); | 435 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_.get()); |
| 445 ios::ChromeBrowserState* ptr = chrome_browser_state_.get(); | 436 ios::ChromeBrowserState* ptr = chrome_browser_state_.get(); |
| 446 [[[tabMock stub] andReturnValue:OCMOCK_VALUE(ptr)] browserState]; | 437 [[[tabMock stub] andReturnValue:OCMOCK_VALUE(ptr)] browserState]; |
| 447 [[[tabMock stub] andReturn:expectedTitle] title]; | 438 [[[tabMock stub] andReturn:expectedTitle] title]; |
| 448 [[[tabMock stub] andReturn:expectedTitle] originalTitle]; | 439 [[[tabMock stub] andReturn:expectedTitle] originalTitle]; |
| 449 | 440 |
| 450 UIImage* tabSnapshot = ui::test::uiimage_utils::UIImageWithSizeAndSolidColor( | 441 UIImage* tabSnapshot = ui::test::uiimage_utils::UIImageWithSizeAndSolidColor( |
| 451 CGSizeMake(300, 400), [UIColor blueColor]); | 442 CGSizeMake(300, 400), [UIColor blueColor]); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 482 EXPECT_OCMOCK_VERIFY(shareControllerMock); | 473 EXPECT_OCMOCK_VERIFY(shareControllerMock); |
| 483 } | 474 } |
| 484 | 475 |
| 485 // Verifies that BVC does not invoke -shareURL on ShareController in response | 476 // Verifies that BVC does not invoke -shareURL on ShareController in response |
| 486 // to the IDC_SHARE_PAGE command if tab is in the process of being closed. | 477 // to the IDC_SHARE_PAGE command if tab is in the process of being closed. |
| 487 TEST_F(BrowserViewControllerTest, TestSharePageWhenClosing) { | 478 TEST_F(BrowserViewControllerTest, TestSharePageWhenClosing) { |
| 488 GURL expectedUrl("http://www.testurl.net"); | 479 GURL expectedUrl("http://www.testurl.net"); |
| 489 NSString* expectedTitle = @"title"; | 480 NSString* expectedTitle = @"title"; |
| 490 // Sets WebState to nil because [tab close] clears the WebState. | 481 // Sets WebState to nil because [tab close] clears the WebState. |
| 491 static_cast<BVCTestTabMock*>(tab_.get()).webState = nil; | 482 static_cast<BVCTestTabMock*>(tab_.get()).webState = nil; |
| 492 static_cast<BVCTestTabMock*>(tab_.get()).url = expectedUrl; | |
| 493 static_cast<BVCTestTabMock*>(tab_.get()).lastCommittedURL = expectedUrl; | 483 static_cast<BVCTestTabMock*>(tab_.get()).lastCommittedURL = expectedUrl; |
| 494 static_cast<BVCTestTabMock*>(tab_.get()).visibleURL = expectedUrl; | 484 static_cast<BVCTestTabMock*>(tab_.get()).visibleURL = expectedUrl; |
| 495 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_.get()); | 485 OCMockObject* tabMock = static_cast<OCMockObject*>(tab_.get()); |
| 496 [[[tabMock stub] andReturn:expectedTitle] title]; | 486 [[[tabMock stub] andReturn:expectedTitle] title]; |
| 497 [[[tabMock stub] andReturn:expectedTitle] originalTitle]; | 487 [[[tabMock stub] andReturn:expectedTitle] originalTitle]; |
| 498 // Explicitly disallow the execution of the ShareController. | 488 // Explicitly disallow the execution of the ShareController. |
| 499 OCMockObject* shareControllerMock = | 489 OCMockObject* shareControllerMock = |
| 500 static_cast<OCMockObject*>(shareController_.get()); | 490 static_cast<OCMockObject*>(shareController_.get()); |
| 501 [[shareControllerMock reject] | 491 [[shareControllerMock reject] |
| 502 shareWithData:[OCMArg any] | 492 shareWithData:[OCMArg any] |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 static_cast<OCMockObject*>(shareController_.get()); | 575 static_cast<OCMockObject*>(shareController_.get()); |
| 586 [[shareControllerMock expect] cancelShareAnimated:NO]; | 576 [[shareControllerMock expect] cancelShareAnimated:NO]; |
| 587 EXPECT_CALL(*this, OnCompletionCalled()); | 577 EXPECT_CALL(*this, OnCompletionCalled()); |
| 588 [bvc_ clearPresentedStateWithCompletion:^{ | 578 [bvc_ clearPresentedStateWithCompletion:^{ |
| 589 this->OnCompletionCalled(); | 579 this->OnCompletionCalled(); |
| 590 }]; | 580 }]; |
| 591 EXPECT_OCMOCK_VERIFY(shareControllerMock); | 581 EXPECT_OCMOCK_VERIFY(shareControllerMock); |
| 592 } | 582 } |
| 593 | 583 |
| 594 } // namespace | 584 } // namespace |
| OLD | NEW |