1
1
namespace MaterialDesignThemes . UITests . WPF ;
2
2
3
- public class TextFieldDefaultHeightTests : TestBase
3
+ public class TextFieldDefaultHeightTests ( ITestOutputHelper output ) : TestBase ( output )
4
4
{
5
- public TextFieldDefaultHeightTests ( ITestOutputHelper output ) : base ( output ) { }
6
-
7
5
private const int Precision = 3 ;
8
6
9
7
[ Fact ]
@@ -12,14 +10,13 @@ public async Task SameHeightWithDefaultStyle()
12
10
await using var recorder = new TestRecorder ( App ) ;
13
11
14
12
// TODO: Remove controls from here as they adopt the new SmartHint approach
15
- var stackPanel = await LoadXaml < StackPanel > ( @ "
16
- <StackPanel>
17
- <PasswordBox />
18
- <DatePicker / >
19
- </StackPanel> ") ;
13
+ var stackPanel = await LoadXaml < StackPanel > ( "" "
14
+ <StackPanel>
15
+ <DatePicker />
16
+ </StackPanel >
17
+ "" ") ;
20
18
21
- var height = await GetHeight ( stackPanel , "PasswordBox" ) ;
22
- Assert . Equal ( height , await GetHeight ( stackPanel , "DatePicker" ) , Precision ) ;
19
+ await GetHeight ( stackPanel , "DatePicker" ) ;
23
20
24
21
recorder . Success ( ) ;
25
22
}
@@ -30,14 +27,17 @@ public async Task SameHeightWithDefaultStyle_PostSmartHintRefactor()
30
27
await using var recorder = new TestRecorder ( App ) ;
31
28
32
29
// TODO: Add controls here as they adopt the new SmartHint approach. Once all controls have migrated, collapse into a single test with the old name.
33
- var stackPanel = await LoadXaml < StackPanel > ( @"
34
- <StackPanel>
35
- <TextBox />
36
- <ComboBox IsEditable=""True"" />
37
- <materialDesign:TimePicker />
38
- </StackPanel>" ) ;
39
-
40
- var height = await GetHeight ( stackPanel , "TextBox" ) ;
30
+ var stackPanel = await LoadXaml < StackPanel > ( """
31
+ <StackPanel>
32
+ <TextBox />
33
+ <PasswordBox />
34
+ <ComboBox IsEditable="True" />
35
+ <materialDesign:TimePicker />
36
+ </StackPanel>
37
+ """ ) ;
38
+
39
+ double height = await GetHeight ( stackPanel , "TextBox" ) ;
40
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" ) , Precision ) ;
41
41
Assert . Equal ( height , await GetHeight ( stackPanel , "ComboBox" ) , Precision ) ;
42
42
Assert . Equal ( height , await GetHeight ( stackPanel , "TimePicker" ) , Precision ) ;
43
43
@@ -50,16 +50,14 @@ public async Task SameHeightWithFloatingHintStyle()
50
50
await using var recorder = new TestRecorder ( App ) ;
51
51
52
52
// TODO: Remove controls from here as they adopt the new SmartHint approach
53
- var stackPanel = await LoadXaml < StackPanel > ( @"
54
- <StackPanel>
55
- <PasswordBox Style=""{StaticResource MaterialDesignFloatingHintPasswordBox}"" materialDesign:HintAssist.Hint=""Hint"" />
56
- <DatePicker Style=""{StaticResource MaterialDesignFloatingHintDatePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
57
- </StackPanel>" ) ;
58
-
59
- var height = await GetHeight ( stackPanel , "PasswordBox" ) ;
60
- Assert . True ( height > 0 ) ;
61
- Assert . Equal ( height , await GetHeight ( stackPanel , "DatePicker" ) , Precision ) ;
62
-
53
+ var stackPanel = await LoadXaml < StackPanel > ( """
54
+ <StackPanel>
55
+ <DatePicker Style="{StaticResource MaterialDesignFloatingHintDatePicker}" materialDesign:HintAssist.Hint="Hint" />
56
+ </StackPanel>
57
+ """ ) ;
58
+
59
+ await GetHeight ( stackPanel , "DatePicker" ) ;
60
+
63
61
recorder . Success ( ) ;
64
62
}
65
63
@@ -69,15 +67,19 @@ public async Task SameHeightWithFloatingHintStyle_PostSmartHintRefactor()
69
67
await using var recorder = new TestRecorder ( App ) ;
70
68
71
69
// TODO: Add controls here as they adopt the new SmartHint approach. Once all controls have migrated, collapse into a single test with the old name.
72
- var stackPanel = await LoadXaml < StackPanel > ( @"
73
- <StackPanel>
74
- <TextBox Style=""{StaticResource MaterialDesignFloatingHintTextBox}"" materialDesign:HintAssist.Hint=""Hint"" />
75
- <ComboBox IsEditable=""True"" Style=""{StaticResource MaterialDesignFloatingHintComboBox}"" materialDesign:HintAssist.Hint=""Hint"" />
76
- <materialDesign:TimePicker Style=""{StaticResource MaterialDesignFloatingHintTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
77
- </StackPanel>" ) ;
78
-
79
- var height = await GetHeight ( stackPanel , "TextBox" ) ;
80
- Assert . True ( height > 0 ) ;
70
+ var stackPanel = await LoadXaml < StackPanel > ( """
71
+ <StackPanel>
72
+ <TextBox Style="{StaticResource MaterialDesignFloatingHintTextBox}" materialDesign:HintAssist.Hint="Hint" />
73
+ <PasswordBox Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" materialDesign:HintAssist.Hint="Hint" />
74
+ <PasswordBox x:Name="RevealPasswordBox" Style="{StaticResource MaterialDesignFloatingHintRevealPasswordBox}" materialDesign:HintAssist.Hint="Hint" />
75
+ <ComboBox IsEditable="True" Style="{StaticResource MaterialDesignFloatingHintComboBox}" materialDesign:HintAssist.Hint="Hint" />
76
+ <materialDesign:TimePicker Style="{StaticResource MaterialDesignFloatingHintTimePicker}" materialDesign:HintAssist.Hint="Hint" />
77
+ </StackPanel>
78
+ """ ) ;
79
+
80
+ double height = await GetHeight ( stackPanel , "TextBox" ) ;
81
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" ) , Precision ) ;
82
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" , "RevealPasswordBox" ) , Precision ) ;
81
83
Assert . Equal ( height , await GetHeight ( stackPanel , "ComboBox" ) , Precision ) ;
82
84
Assert . Equal ( height , await GetHeight ( stackPanel , "TimePicker" ) , Precision ) ;
83
85
@@ -90,16 +92,14 @@ public async Task SameHeightWithFilledStyle()
90
92
await using var recorder = new TestRecorder ( App ) ;
91
93
92
94
// TODO: Remove controls from here as they adopt the new SmartHint approach
93
- var stackPanel = await LoadXaml < StackPanel > ( @"
94
- <StackPanel>
95
- <PasswordBox Style=""{StaticResource MaterialDesignFilledPasswordBox}"" materialDesign:HintAssist.Hint=""Hint"" />
96
- <DatePicker Style=""{StaticResource MaterialDesignFilledDatePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
97
- </StackPanel>" ) ;
98
-
99
- var height = await GetHeight ( stackPanel , "PasswordBox" ) ;
100
- Assert . True ( height > 0 ) ;
101
- Assert . Equal ( height , await GetHeight ( stackPanel , "DatePicker" ) , Precision ) ;
102
-
95
+ var stackPanel = await LoadXaml < StackPanel > ( """
96
+ <StackPanel>
97
+ <DatePicker Style="{StaticResource MaterialDesignFilledDatePicker}" materialDesign:HintAssist.Hint="Hint" />
98
+ </StackPanel>
99
+ """ ) ;
100
+
101
+ await GetHeight ( stackPanel , "DatePicker" ) ;
102
+
103
103
recorder . Success ( ) ;
104
104
}
105
105
@@ -109,15 +109,19 @@ public async Task SameHeightWithFilledStyle_PostSmartHintRefactor()
109
109
await using var recorder = new TestRecorder ( App ) ;
110
110
111
111
// TODO: Add controls here as they adopt the new SmartHint approach. Once all controls have migrated, collapse into a single test with the old name.
112
- var stackPanel = await LoadXaml < StackPanel > ( @"
113
- <StackPanel>
114
- <TextBox Style=""{StaticResource MaterialDesignFilledTextBox}"" materialDesign:HintAssist.Hint=""Hint"" />
115
- <ComboBox IsEditable=""True"" Style=""{StaticResource MaterialDesignFilledComboBox}"" materialDesign:HintAssist.Hint=""Hint"" />
116
- <materialDesign:TimePicker Style=""{StaticResource MaterialDesignFilledTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
117
- </StackPanel>" ) ;
118
-
119
- var height = await GetHeight ( stackPanel , "TextBox" ) ;
120
- Assert . True ( height > 0 ) ;
112
+ var stackPanel = await LoadXaml < StackPanel > ( """
113
+ <StackPanel>
114
+ <TextBox Style="{StaticResource MaterialDesignFilledTextBox}" materialDesign:HintAssist.Hint="Hint" />
115
+ <PasswordBox Style="{StaticResource MaterialDesignFilledPasswordBox}" materialDesign:HintAssist.Hint="Hint" />
116
+ <PasswordBox x:Name="RevealPasswordBox" Style="{StaticResource MaterialDesignFilledRevealPasswordBox}" materialDesign:HintAssist.Hint="Hint" />
117
+ <ComboBox IsEditable="True" Style="{StaticResource MaterialDesignFilledComboBox}" materialDesign:HintAssist.Hint="Hint" />
118
+ <materialDesign:TimePicker Style="{StaticResource MaterialDesignFilledTimePicker}" materialDesign:HintAssist.Hint="Hint" />
119
+ </StackPanel>
120
+ """ ) ;
121
+
122
+ double height = await GetHeight ( stackPanel , "TextBox" ) ;
123
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" ) , Precision ) ;
124
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" , "RevealPasswordBox" ) , Precision ) ;
121
125
Assert . Equal ( height , await GetHeight ( stackPanel , "ComboBox" ) , Precision ) ;
122
126
Assert . Equal ( height , await GetHeight ( stackPanel , "TimePicker" ) , Precision ) ;
123
127
@@ -130,16 +134,14 @@ public async Task SameHeightWithOutlinedStyle()
130
134
await using var recorder = new TestRecorder ( App ) ;
131
135
132
136
// TODO: Remove controls from here as they adopt the new SmartHint approach
133
- var stackPanel = await LoadXaml < StackPanel > ( @"
134
- <StackPanel>
135
- <PasswordBox Style=""{StaticResource MaterialDesignOutlinedPasswordBox}"" materialDesign:HintAssist.Hint=""Hint"" />
136
- <DatePicker Style=""{StaticResource MaterialDesignOutlinedDatePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
137
- </StackPanel>" ) ;
138
-
139
- var height = await GetHeight ( stackPanel , "PasswordBox" ) ;
140
- Assert . True ( height > 0 ) ;
141
- Assert . Equal ( height , await GetHeight ( stackPanel , "DatePicker" ) , Precision ) ;
142
-
137
+ var stackPanel = await LoadXaml < StackPanel > ( """
138
+ <StackPanel>
139
+ <DatePicker Style="{StaticResource MaterialDesignOutlinedDatePicker}" materialDesign:HintAssist.Hint="Hint" />
140
+ </StackPanel>
141
+ """ ) ;
142
+
143
+ await GetHeight ( stackPanel , "DatePicker" ) ;
144
+
143
145
recorder . Success ( ) ;
144
146
}
145
147
@@ -149,25 +151,29 @@ public async Task SameHeightWithOutlinedStyle_PostSmartHintRefactor()
149
151
await using var recorder = new TestRecorder ( App ) ;
150
152
151
153
// TODO: Add controls here as they adopt the new SmartHint approach. Once all controls have migrated, collapse into a single test with the old name.
152
- var stackPanel = await LoadXaml < StackPanel > ( @"
153
- <StackPanel>
154
- <TextBox Style=""{StaticResource MaterialDesignOutlinedTextBox}"" materialDesign:HintAssist.Hint=""Hint"" />
155
- <ComboBox IsEditable=""True"" Style=""{StaticResource MaterialDesignOutlinedComboBox}"" />
156
- <materialDesign:TimePicker Style=""{StaticResource MaterialDesignOutlinedTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
157
- </StackPanel>" ) ;
158
-
159
- var height = await GetHeight ( stackPanel , "TextBox" ) ;
160
- Assert . True ( height > 0 ) ;
154
+ var stackPanel = await LoadXaml < StackPanel > ( """
155
+ <StackPanel>
156
+ <TextBox Style="{StaticResource MaterialDesignOutlinedTextBox}" materialDesign:HintAssist.Hint="Hint" />
157
+ <PasswordBox Style="{StaticResource MaterialDesignOutlinedPasswordBox}" materialDesign:HintAssist.Hint="Hint" />
158
+ <PasswordBox x:Name="RevealPasswordBox" Style="{StaticResource MaterialDesignOutlinedRevealPasswordBox}" materialDesign:HintAssist.Hint="Hint" />
159
+ <ComboBox IsEditable="True" Style="{StaticResource MaterialDesignOutlinedComboBox}" />
160
+ <materialDesign:TimePicker Style="{StaticResource MaterialDesignOutlinedTimePicker}" materialDesign:HintAssist.Hint="Hint" />
161
+ </StackPanel>
162
+ """ ) ;
163
+
164
+ double height = await GetHeight ( stackPanel , "TextBox" ) ;
165
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" ) , Precision ) ;
166
+ Assert . Equal ( height , await GetHeight ( stackPanel , "PasswordBox" , "RevealPasswordBox" ) , Precision ) ;
161
167
Assert . Equal ( height , await GetHeight ( stackPanel , "ComboBox" ) , Precision ) ;
162
168
Assert . Equal ( height , await GetHeight ( stackPanel , "TimePicker" ) , Precision ) ;
163
169
164
170
recorder . Success ( ) ;
165
171
}
166
172
167
- private static async Task < double > GetHeight ( IVisualElement container , string type )
173
+ private static async Task < double > GetHeight ( IVisualElement container , string type , string ? optionalName = null )
168
174
{
169
- var element = await container . GetElement < FrameworkElement > ( "/" + type ) ;
170
- var height = await element . GetActualHeight ( ) ;
175
+ var element = await container . GetElement < FrameworkElement > ( optionalName ?? "/" + type ) ;
176
+ double height = await element . GetActualHeight ( ) ;
171
177
Assert . True ( height > 0 ) ;
172
178
return height ;
173
179
}
0 commit comments