Skip to content

Commit

Permalink
[Dialogs] Refactoring alert actions test
Browse files Browse the repository at this point in the history
Issue: b/137070719, cl/299739784
PiperOrigin-RevId: 299739784
  • Loading branch information
galiak11 committed Mar 12, 2020
1 parent ecb6de8 commit 21fcdf3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions components/Dialogs/tests/snapshot/MDCAlertControllerActionsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (void)changeToRTL:(MDCAlertController *)alertController {
[self changeViewToRTL:alertController.view];
}

#pragma mark - Tests
#pragma mark - Actions Layout Tests

// Horizontal Layout | Low Emphasis | Default Alignment (trailing)
- (void)testLowEmphasisActionsOrderInHorizontalLayout {
Expand Down Expand Up @@ -206,8 +206,8 @@ - (void)testAutomaticChangeToVerticalLayoutForLongMediumEmphasisActionsInRTL {
// Horizontal Layout | Low Emphasis | Center Alignment
- (void)testLowEmphasisActionsAreCenteredInHorizontalLayout {
// Given
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:NO];
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:YES];
[self addOKActionWithEmphasis:MDCActionEmphasisLow];
[self addCancelActionWithEmphasis:MDCActionEmphasisLow];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -221,8 +221,8 @@ - (void)testLowEmphasisActionsAreCenteredInHorizontalLayout {
// Horizontal Layout | Low Emphasis | Leading Alignment
- (void)testLowEmphasisActionsAreLeadingInHorizontalLayout {
// Given
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:NO];
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:YES];
[self addOKActionWithEmphasis:MDCActionEmphasisLow];
[self addCancelActionWithEmphasis:MDCActionEmphasisLow];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -236,8 +236,8 @@ - (void)testLowEmphasisActionsAreLeadingInHorizontalLayout {
// Horizontal Layout | Low Emphasis | Justified Alignment
- (void)testLowEmphasisActionsAreJustifiedInHorizontalLayout {
// Given
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:NO];
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:YES];
[self addOKActionWithEmphasis:MDCActionEmphasisLow];
[self addCancelActionWithEmphasis:MDCActionEmphasisLow];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -251,8 +251,8 @@ - (void)testLowEmphasisActionsAreJustifiedInHorizontalLayout {
// Horizontal Layout | Medium Emphasis | Center Alignment
- (void)testMediumEmphasisActionsAreCenteredInHorizontalLayout {
// Given
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:NO];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addOKActionWithEmphasis:MDCActionEmphasisMedium];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -266,8 +266,8 @@ - (void)testMediumEmphasisActionsAreCenteredInHorizontalLayout {
// Horizontal Layout | Medium Emphasis | Leading Alignment
- (void)testMediumEmphasisActionsAreLeadingInHorizontalLayout {
// Given
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:NO];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addOKActionWithEmphasis:MDCActionEmphasisMedium];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -281,8 +281,8 @@ - (void)testMediumEmphasisActionsAreLeadingInHorizontalLayout {
// Horizontal Layout | Medium Emphasis | Justified Alignment
- (void)testMediumEmphasisActionsAreJustifiedInHorizontalLayout {
// Given
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:NO];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addOKActionWithEmphasis:MDCActionEmphasisMedium];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -297,7 +297,7 @@ - (void)testMediumEmphasisActionsAreJustifiedInHorizontalLayout {
- (void)testLowEmphasisActionsAreTrailingInVerticalLayout {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisLow];
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisLow];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -312,7 +312,7 @@ - (void)testLowEmphasisActionsAreTrailingInVerticalLayout {
- (void)testLowEmphasisActionsAreLeadingInVerticalLayout {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisLow];
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisLow];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -327,7 +327,7 @@ - (void)testLowEmphasisActionsAreLeadingInVerticalLayout {
- (void)testLowEmphasisActionsAreJustifiedInVerticalLayout {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisLow];
[self addShortActionWithEmphasis:MDCActionEmphasisLow cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisLow];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -342,7 +342,7 @@ - (void)testLowEmphasisActionsAreJustifiedInVerticalLayout {
- (void)testMediumEmphasisActionsAreTrailingInVerticalLayout {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisMedium];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -357,7 +357,7 @@ - (void)testMediumEmphasisActionsAreTrailingInVerticalLayout {
- (void)testMediumEmphasisActionsAreLeadingInVerticalLayout {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisMedium];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -372,7 +372,7 @@ - (void)testMediumEmphasisActionsAreLeadingInVerticalLayout {
- (void)testMediumEmphasisActionsAreJustifiedInVerticalLayout {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisMedium];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -385,10 +385,10 @@ - (void)testMediumEmphasisActionsAreJustifiedInVerticalLayout {

#pragma mark - Vertical Order Tests

- (void)testOrderVerticalActionsByEmphasis {
- (void)testVerticalActionsAreOrderedByEmphasis {
// Given
[self addFirstLongActionWithEmphasis:MDCActionEmphasisHigh];
[self addShortActionWithEmphasis:MDCActionEmphasisMedium cancelAction:YES];
[self addCancelActionWithEmphasis:MDCActionEmphasisMedium];
[self.alertController applyThemeWithScheme:self.containerScheme2019];

// When
Expand All @@ -407,9 +407,14 @@ - (void)addFirstLongActionWithEmphasis:(MDCActionEmphasis)emphasis {
handler:nil]];
}

- (void)addShortActionWithEmphasis:(MDCActionEmphasis)emphasis cancelAction:(BOOL)cancelAction {
NSString *title = cancelAction ? @"Cancel" : @"OK";
[self.alertController addAction:[MDCAlertAction actionWithTitle:title
- (void)addOKActionWithEmphasis:(MDCActionEmphasis)emphasis {
[self.alertController addAction:[MDCAlertAction actionWithTitle:@"OK"
emphasis:emphasis
handler:nil]];
}

- (void)addCancelActionWithEmphasis:(MDCActionEmphasis)emphasis {
[self.alertController addAction:[MDCAlertAction actionWithTitle:@"Cancel"
emphasis:emphasis
handler:nil]];
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 21fcdf3

Please sign in to comment.