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

Unified Diff: ios/chrome/browser/ui/alert_coordinator/alert_coordinator_unittest.mm

Issue 2167683002: Creates coordinator for ActionSheet and TextInput (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alertCoordinator
Patch Set: Keep message property Created 4 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/alert_coordinator/alert_coordinator_unittest.mm
diff --git a/ios/chrome/browser/ui/alert_coordinator/alert_coordinator_unittest.mm b/ios/chrome/browser/ui/alert_coordinator/alert_coordinator_unittest.mm
index b93666153d0e4e034d2891de3e52bf636f32f300..b4c28cb3c9c3892d1878df609de56d1943966193 100644
--- a/ios/chrome/browser/ui/alert_coordinator/alert_coordinator_unittest.mm
+++ b/ios/chrome/browser/ui/alert_coordinator/alert_coordinator_unittest.mm
@@ -30,25 +30,18 @@ class AlertCoordinatorTest : public PlatformTest {
UIViewController* getViewController() { return view_controller_; }
AlertCoordinator* getAlertCoordinator(UIViewController* viewController) {
- return getAlertCoordinator(viewController, @"Test title");
+ return getAlertCoordinator(viewController, @"Test title", nil);
}
AlertCoordinator* getAlertCoordinator(UIViewController* viewController,
- NSString* title) {
+ NSString* title,
+ NSString* message) {
alert_coordinator_.reset([[AlertCoordinator alloc]
initWithBaseViewController:viewController
- title:title]);
+ title:title
+ message:message]);
return alert_coordinator_;
}
- AlertCoordinator* getAlertCoordinator(UIViewController* viewController,
- NSString* title,
- CGRect rect,
- UIView* view) {
- AlertCoordinator* alertCoordinator =
- getAlertCoordinator(viewController, title);
- [alertCoordinator configureForActionSheetWithRect:rect popoverView:view];
- return alertCoordinator;
- }
void deleteAlertCoordinator() { alert_coordinator_.reset(); }
@@ -77,7 +70,10 @@ TEST_F(AlertCoordinatorTest, ValidateIsVisible) {
EXPECT_TRUE(alertCoordinator.isVisible);
EXPECT_TRUE([viewController.presentedViewController
isKindOfClass:[UIAlertController class]]);
- EXPECT_EQ(1LU, [alertCoordinator actionsCount]);
+ UIAlertController* alertController =
+ base::mac::ObjCCastStrict<UIAlertController>(
+ viewController.presentedViewController);
+ EXPECT_EQ(1LU, alertController.actions.count);
}
// Tests the alert coordinator reports as not visible after presenting on a non
@@ -108,8 +104,7 @@ TEST_F(AlertCoordinatorTest, TitleAndMessage) {
NSString* message = @"Foo bar message.";
AlertCoordinator* alertCoordinator =
- getAlertCoordinator(viewController, title);
- alertCoordinator.message = message;
+ getAlertCoordinator(viewController, title, message);
// Action.
[alertCoordinator start];
@@ -258,36 +253,3 @@ TEST_F(AlertCoordinatorTest, OnlyOneCancelAction) {
EXPECT_EQ(firstButtonTitle, action.title);
EXPECT_EQ(UIAlertActionStyleCancel, action.style);
}
-
-// Tests that if there is a popover, it uses the CGRect passed in init.
-TEST_F(AlertCoordinatorTest, CGRectUsage) {
- // Setup.
- UIViewController* viewController = getViewController();
- UIView* view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]
- autorelease];
- [viewController.view addSubview:view];
- CGRect rect = CGRectMake(124, 432, 126, 63);
- AlertCoordinator* alertCoordinator =
- getAlertCoordinator(viewController, @"Title", rect, view);
-
- // Action.
- [alertCoordinator start];
-
- // Test.
- // Get the alert.
- EXPECT_TRUE([viewController.presentedViewController
- isKindOfClass:[UIAlertController class]]);
- UIAlertController* alertController =
- base::mac::ObjCCastStrict<UIAlertController>(
- viewController.presentedViewController);
-
- // Test the results.
- EXPECT_EQ(UIAlertControllerStyleActionSheet, alertController.preferredStyle);
-
- if (alertController.popoverPresentationController) {
- UIPopoverPresentationController* popover =
- alertController.popoverPresentationController;
- EXPECT_TRUE(CGRectEqualToRect(rect, popover.sourceRect));
- EXPECT_EQ(view, popover.sourceView);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698