Skip to content

Commit c128e76

Browse files
committed
Added UI Unit Test to guard against regression.
1 parent 8e42644 commit c128e76

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

UITests/UITests.Tests.Shared/Controls/TextBoxMaskTest.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,31 @@ public void TestTextBoxMaskBinding_Property()
5252

5353
Verify.AreEqual(newValue, textBox.GetText());
5454
}
55+
56+
[TestMethod]
57+
[TestPage("TextBoxMaskTestPage")]
58+
public void TestTextBoxMaskBinding_TextChanging_RegressionCheck()
59+
{
60+
var initialValue = FindElement.ById<TextBlock>("InitialValueTextBlock").GetText();
61+
var textBox = FindElement.ById<Edit>("TextBox");
62+
63+
Verify.AreEqual(initialValue, textBox.GetText());
64+
65+
var setEmptyButton = FindElement.ById<Button>("SetEmptyButton");
66+
67+
setEmptyButton.Click();
68+
Wait.ForIdle();
69+
70+
// Previously, if the bound value of TextBox with a mask was set to an empty
71+
// string. It would display the old values after text was entered by the user.
72+
// PR #4048 should fix this issue.
73+
textBox.SendKeys("0");
74+
75+
// The user entering "0" key at the start position of the TextBox would result
76+
// in the following value prior to PR #4048.
77+
const string incorrectValue = "02:50:59";
78+
79+
Verify.AreNotEqual(incorrectValue, textBox.GetText());
80+
}
5581
}
5682
}

UITests/UITests.Tests.Shared/Controls/TextBoxMaskTestPage.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<RowDefinition Height="Auto" />
1313
<RowDefinition Height="10" />
1414
<RowDefinition Height="Auto" />
15+
<RowDefinition Height="10" />
16+
<RowDefinition Height="Auto" />
1517
</Grid.RowDefinitions>
1618
<Grid.ColumnDefinitions>
1719
<ColumnDefinition Width="Auto" />
@@ -43,5 +45,10 @@
4345
Grid.Column="2"
4446
HorizontalAlignment="Center"
4547
Text="{x:Bind NewValue}" />
48+
<Button x:Name="SetEmptyButton"
49+
Grid.Row="4"
50+
Grid.Column="0"
51+
Click="SetEmptyButton_Click"
52+
Content="Set Target Value Empty" />
4653
</Grid>
4754
</Page>

UITests/UITests.Tests.Shared/Controls/TextBoxMaskTestPage.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,11 @@ private void ChangeButton_Click(object sender, RoutedEventArgs e)
3838
Value = NEW_VALUE;
3939
Log.Comment("Value Changed to {0}", Value);
4040
}
41+
42+
private void SetEmptyButton_Click(object sender, RoutedEventArgs e)
43+
{
44+
Value = string.Empty;
45+
Log.Comment("Value Changed to {0}", Value);
46+
}
4147
}
4248
}

0 commit comments

Comments
 (0)