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

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

Issue 2752643004: Stop showing snackbar with success message when sharing with Chrome iOS. (Closed)
Patch Set: Addressed comments. Created 3 years, 9 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/ui/browser_view_controller.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 <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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 shareToDelegate:bvc_ 462 shareToDelegate:bvc_
463 fromRect:[bvc_ testing_shareButtonAnchorRect] 463 fromRect:[bvc_ testing_shareButtonAnchorRect]
464 inView:[OCMArg any]]; 464 inView:[OCMArg any]];
465 [bvc_ chromeExecuteCommand:GetCommandWithTag(IDC_SHARE_PAGE)]; 465 [bvc_ chromeExecuteCommand:GetCommandWithTag(IDC_SHARE_PAGE)];
466 EXPECT_OCMOCK_VERIFY(shareControllerMock); 466 EXPECT_OCMOCK_VERIFY(shareControllerMock);
467 } 467 }
468 468
469 // Verifies that BVC instantiates a bubble to show the given success message on 469 // Verifies that BVC instantiates a bubble to show the given success message on
470 // receiving a -shareDidComplete callback for a successful share. 470 // receiving a -shareDidComplete callback for a successful share.
471 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithSuccess) { 471 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithSuccess) {
472 NSString* successMessage = @"Success"; 472 NSString* completionMessage = @"Completion!";
473 [[dependencyFactory_ expect] showSnackbarWithMessage:successMessage]; 473 [[dependencyFactory_ expect] showSnackbarWithMessage:completionMessage];
474 474
475 [bvc_ shareDidComplete:ShareTo::SHARE_SUCCESS successMessage:successMessage]; 475 [bvc_ shareDidComplete:ShareTo::SHARE_SUCCESS
476 completionMessage:completionMessage];
476 EXPECT_OCMOCK_VERIFY(dependencyFactory_); 477 EXPECT_OCMOCK_VERIFY(dependencyFactory_);
477 } 478 }
478 479
479 // Verifies that BVC shows an alert with the proper error message on 480 // Verifies that BVC shows an alert with the proper error message on
480 // receiving a -shareDidComplete callback for a failed share. 481 // receiving a -shareDidComplete callback for a failed share.
481 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithError) { 482 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithError) {
482 [[dependencyFactory_ reject] showSnackbarWithMessage:OCMOCK_ANY]; 483 [[dependencyFactory_ reject] showSnackbarWithMessage:OCMOCK_ANY];
483 base::scoped_nsobject<OCMockObject> mockCoordinator( 484 base::scoped_nsobject<OCMockObject> mockCoordinator(
484 [[OCMockObject niceMockForClass:[AlertCoordinator class]] retain]); 485 [[OCMockObject niceMockForClass:[AlertCoordinator class]] retain]);
485 AlertCoordinator* alertCoordinator = 486 AlertCoordinator* alertCoordinator =
486 static_cast<AlertCoordinator*>(mockCoordinator.get()); 487 static_cast<AlertCoordinator*>(mockCoordinator.get());
487 NSString* errorTitle = 488 NSString* errorTitle =
488 l10n_util::GetNSString(IDS_IOS_SHARE_TO_ERROR_ALERT_TITLE); 489 l10n_util::GetNSString(IDS_IOS_SHARE_TO_ERROR_ALERT_TITLE);
489 NSString* errorMessage = l10n_util::GetNSString(IDS_IOS_SHARE_TO_ERROR_ALERT); 490 NSString* errorMessage = l10n_util::GetNSString(IDS_IOS_SHARE_TO_ERROR_ALERT);
490 [[[dependencyFactory_ expect] andReturn:alertCoordinator] 491 [[[dependencyFactory_ expect] andReturn:alertCoordinator]
491 alertCoordinatorWithTitle:errorTitle 492 alertCoordinatorWithTitle:errorTitle
492 message:errorMessage 493 message:errorMessage
493 viewController:OCMOCK_ANY]; 494 viewController:OCMOCK_ANY];
494 [static_cast<AlertCoordinator*>([mockCoordinator expect]) start]; 495 [static_cast<AlertCoordinator*>([mockCoordinator expect]) start];
495 496
496 [bvc_ shareDidComplete:ShareTo::SHARE_ERROR successMessage:@"dummy"]; 497 [bvc_ shareDidComplete:ShareTo::SHARE_ERROR completionMessage:@"dummy"];
497 EXPECT_OCMOCK_VERIFY(dependencyFactory_); 498 EXPECT_OCMOCK_VERIFY(dependencyFactory_);
498 EXPECT_OCMOCK_VERIFY(mockCoordinator); 499 EXPECT_OCMOCK_VERIFY(mockCoordinator);
499 } 500 }
500 501
501 // Verifies that BVC does not show a success bubble or error alert on receiving 502 // Verifies that BVC does not show a success bubble or error alert on receiving
502 // a -shareDidComplete callback for a cancelled share. 503 // a -shareDidComplete callback for a cancelled share.
503 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithCancellation) { 504 TEST_F(BrowserViewControllerTest, TestShareDidCompleteWithCancellation) {
504 [[dependencyFactory_ reject] showSnackbarWithMessage:OCMOCK_ANY]; 505 [[dependencyFactory_ reject] showSnackbarWithMessage:OCMOCK_ANY];
505 [[dependencyFactory_ reject] alertCoordinatorWithTitle:OCMOCK_ANY 506 [[dependencyFactory_ reject] alertCoordinatorWithTitle:OCMOCK_ANY
506 message:OCMOCK_ANY 507 message:OCMOCK_ANY
507 viewController:OCMOCK_ANY]; 508 viewController:OCMOCK_ANY];
508 509
509 [bvc_ shareDidComplete:ShareTo::SHARE_CANCEL successMessage:@"dummy"]; 510 [bvc_ shareDidComplete:ShareTo::SHARE_CANCEL completionMessage:@"dummy"];
510 EXPECT_OCMOCK_VERIFY(dependencyFactory_); 511 EXPECT_OCMOCK_VERIFY(dependencyFactory_);
511 } 512 }
512 513
513 TEST_F(BrowserViewControllerTest, TestPassKitDialogDisplayed) { 514 TEST_F(BrowserViewControllerTest, TestPassKitDialogDisplayed) {
514 // Create a good Pass and make sure the controller is displayed. 515 // Create a good Pass and make sure the controller is displayed.
515 base::FilePath pass_path; 516 base::FilePath pass_path;
516 ASSERT_TRUE(PathService::Get(ios::DIR_TEST_DATA, &pass_path)); 517 ASSERT_TRUE(PathService::Get(ios::DIR_TEST_DATA, &pass_path));
517 pass_path = pass_path.Append(FILE_PATH_LITERAL("testpass.pkpass")); 518 pass_path = pass_path.Append(FILE_PATH_LITERAL("testpass.pkpass"));
518 NSData* passKitObject = [NSData 519 NSData* passKitObject = [NSData
519 dataWithContentsOfFile:base::SysUTF8ToNSString(pass_path.value())]; 520 dataWithContentsOfFile:base::SysUTF8ToNSString(pass_path.value())];
(...skipping 21 matching lines...) Expand all
541 static_cast<OCMockObject*>(shareController_.get()); 542 static_cast<OCMockObject*>(shareController_.get());
542 [[shareControllerMock expect] cancelShareAnimated:NO]; 543 [[shareControllerMock expect] cancelShareAnimated:NO];
543 EXPECT_CALL(*this, OnCompletionCalled()); 544 EXPECT_CALL(*this, OnCompletionCalled());
544 [bvc_ clearPresentedStateWithCompletion:^{ 545 [bvc_ clearPresentedStateWithCompletion:^{
545 this->OnCompletionCalled(); 546 this->OnCompletionCalled();
546 }]; 547 }];
547 EXPECT_OCMOCK_VERIFY(shareControllerMock); 548 EXPECT_OCMOCK_VERIFY(shareControllerMock);
548 } 549 }
549 550
550 } // namespace 551 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698