Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dialogs] Refactoring alert actions test #9886

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.