Skip to content
Permalink
Browse files

[TextFields] Add `isEditing` snapshots for Outlined style (#5990)

Outlined (unthemed) text fields need snapshot tests when `isEditing` is true
so that we can capture the "active" state of the text field.

Part of #5762
  • Loading branch information
romoore committed Dec 12, 2018
1 parent 2ace39a commit 4fee7d0096b259c4414957bdfd8dae96b56c526c
Showing with 205 additions and 0 deletions.
  1. +166 −0 components/TextFields/tests/snapshot/MDCTextFieldOutlinedControllerSnapshotTests.m
  2. +3 −0 ...ns_64/MDCTextFieldOutlinedControllerSnapshotTests/testOutlinedTextFieldEmptyIsEditing_11_2@2x.png
  3. +3 −0 ...tFieldOutlinedControllerSnapshotTests/testOutlinedTextFieldWithLongErrorTextIsEditing_11_2@2x.png
  4. +3 −0 ...FieldOutlinedControllerSnapshotTests/testOutlinedTextFieldWithLongHelperTextIsEditing_11_2@2x.png
  5. +3 −0 ...trollerSnapshotTests/testOutlinedTextFieldWithLongInputPlaceholderErrorTextsIsEditing_11_2@2x.png
  6. +3 −0 ...rollerSnapshotTests/testOutlinedTextFieldWithLongInputPlaceholderHelperTextsIsEditing_11_2@2x.png
  7. +3 −0 ...tFieldOutlinedControllerSnapshotTests/testOutlinedTextFieldWithLongInputTextIsEditing_11_2@2x.png
  8. +3 −0 ...OutlinedControllerSnapshotTests/testOutlinedTextFieldWithLongPlaceholderTextIsEditing_11_2@2x.png
  9. +3 −0 ...FieldOutlinedControllerSnapshotTests/testOutlinedTextFieldWithShortErrorTextIsEditing_11_2@2x.png
  10. +3 −0 ...ieldOutlinedControllerSnapshotTests/testOutlinedTextFieldWithShortHelperTextIsEditing_11_2@2x.png
  11. +3 −0 ...rollerSnapshotTests/testOutlinedTextFieldWithShortInputPlaceholderErrorTextsIsEditing_11_2@2x.png
  12. +3 −0 ...ollerSnapshotTests/testOutlinedTextFieldWithShortInputPlaceholderHelperTextsIsEditing_11_2@2x.png
  13. +3 −0 ...FieldOutlinedControllerSnapshotTests/testOutlinedTextFieldWithShortInputTextIsEditing_11_2@2x.png
  14. +3 −0 ...utlinedControllerSnapshotTests/testOutlinedTextFieldWithShortPlaceholderTextIsEditing_11_2@2x.png
@@ -47,6 +47,16 @@ - (void)testOutlinedTextFieldEmpty {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldEmptyIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

#pragma mark - Single field tests

- (void)testOutlinedTextFieldWithShortPlaceholderText {
@@ -60,6 +70,18 @@ - (void)testOutlinedTextFieldWithShortPlaceholderText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortPlaceholderTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textFieldController.placeholderText = MDCTextFieldSnapshotTestsPlaceholderShortTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongPlaceholderText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -71,6 +93,18 @@ - (void)testOutlinedTextFieldWithLongPlaceholderText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongPlaceholderTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textFieldController.placeholderText = MDCTextFieldSnapshotTestsPlaceholderLongTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortHelperText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -82,6 +116,18 @@ - (void)testOutlinedTextFieldWithShortHelperText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortHelperTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textFieldController.helperText = MDCTextFieldSnapshotTestsHelperShortTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongHelperText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -93,6 +139,18 @@ - (void)testOutlinedTextFieldWithLongHelperText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongHelperTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textFieldController.helperText = MDCTextFieldSnapshotTestsHelperLongTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortErrorText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -105,6 +163,19 @@ - (void)testOutlinedTextFieldWithShortErrorText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortErrorTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
[self.textFieldController setErrorText:MDCTextFieldSnapshotTestsErrorShortTextLatin
errorAccessibilityValue:MDCTextFieldSnapshotTestsErrorShortTextLatin];
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongErrorText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -117,6 +188,19 @@ - (void)testOutlinedTextFieldWithLongErrorText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongErrorTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
[self.textFieldController setErrorText:MDCTextFieldSnapshotTestsErrorLongTextLatin
errorAccessibilityValue:MDCTextFieldSnapshotTestsErrorLongTextLatin];
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortInputText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -128,6 +212,18 @@ - (void)testOutlinedTextFieldWithShortInputText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortInputTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textField.text = MDCTextFieldSnapshotTestsInputShortTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongInputText {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -139,6 +235,18 @@ - (void)testOutlinedTextFieldWithLongInputText {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongInputTextIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textField.text = MDCTextFieldSnapshotTestsInputLongTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

#pragma mark - Multiple field tests

- (void)testOutlinedTextFieldWithShortInputPlaceholderHelperTexts {
@@ -154,6 +262,20 @@ - (void)testOutlinedTextFieldWithShortInputPlaceholderHelperTexts {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortInputPlaceholderHelperTextsIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textField.text = MDCTextFieldSnapshotTestsInputShortTextLatin;
self.textFieldController.placeholderText = MDCTextFieldSnapshotTestsPlaceholderShortTextLatin;
self.textFieldController.helperText = MDCTextFieldSnapshotTestsHelperShortTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongInputPlaceholderHelperTexts {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -167,6 +289,20 @@ - (void)testOutlinedTextFieldWithLongInputPlaceholderHelperTexts {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongInputPlaceholderHelperTextsIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textField.text = MDCTextFieldSnapshotTestsInputLongTextLatin;
self.textFieldController.placeholderText = MDCTextFieldSnapshotTestsPlaceholderLongTextLatin;
self.textFieldController.helperText = MDCTextFieldSnapshotTestsHelperLongTextLatin;
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortInputPlaceholderErrorTexts {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -181,6 +317,21 @@ - (void)testOutlinedTextFieldWithShortInputPlaceholderErrorTexts {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithShortInputPlaceholderErrorTextsIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textField.text = MDCTextFieldSnapshotTestsInputShortTextLatin;
self.textFieldController.placeholderText = MDCTextFieldSnapshotTestsPlaceholderShortTextLatin;
[self.textFieldController setErrorText:MDCTextFieldSnapshotTestsErrorShortTextLatin
errorAccessibilityValue:MDCTextFieldSnapshotTestsErrorShortTextLatin];
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongInputPlaceholderErrorTexts {
// Uncomment below to recreate the golden
// self.recordMode = YES;
@@ -195,4 +346,19 @@ - (void)testOutlinedTextFieldWithLongInputPlaceholderErrorTexts {
[self generateSnapshotAndVerify];
}

- (void)testOutlinedTextFieldWithLongInputPlaceholderErrorTextsIsEditing {
// Uncomment below to recreate the golden
// self.recordMode = YES;

// When
self.textField.text = MDCTextFieldSnapshotTestsInputLongTextLatin;
self.textFieldController.placeholderText = MDCTextFieldSnapshotTestsPlaceholderLongTextLatin;
[self.textFieldController setErrorText:MDCTextFieldSnapshotTestsErrorLongTextLatin
errorAccessibilityValue:MDCTextFieldSnapshotTestsErrorLongTextLatin];
[self.textField MDCtest_setIsEditing:YES];

// Then
[self generateSnapshotAndVerify];
}

@end

0 comments on commit 4fee7d0

Please sign in to comment.
You can’t perform that action at this time.