Skip to content

Commit 41ff3fe

Browse files
committed
feat: Update CommandBar UITests
1 parent 1f0ea0c commit 41ff3fe

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

src/SamplesApp/SamplesApp.Shared/App.xaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:xamarin="http://nventive.com/xamarin"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
56
xmlns:ios="http://nventive.com/ios"
67
xmlns:toolkit="using:Uno.UI.Toolkit"
8+
mc:Ignorable="ios"
79
RequestedTheme="Light">
810
<Application.Resources>
911
<ResourceDictionary>
@@ -113,15 +115,14 @@
113115
</Style>
114116

115117
<Style x:Key="DefaultCommandBarStyle"
116-
TargetType="CommandBar"
117-
xamarin:BasedOn="{StaticResource NativeDefaultCommandBar}">
118+
TargetType="CommandBar">
118119

119-
<!-- Remove the back button title (and only leave the back arrow) -->
120+
<!--Remove the back button title (and only leave the back arrow)-->
120121
<ios:Setter Property="(toolkit:CommandBarExtensions.BackButtonTitle)"
121122
Value="" />
122123
</Style>
123124

124-
<!-- Default Style -->
125+
<!--Default Style-->
125126
<Style TargetType="CommandBar"
126127
BasedOn="{StaticResource DefaultCommandBarStyle}" />
127128

src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/CommandBarTests/UnoSamples_Tests.NativeCommandBar.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,15 @@ public void When_Navigated_CommandBarShouldHideBackButtonTitle_NativeFrame()
217217
_app.WaitForElement("NavigateToPage2Button");
218218
_app.FastTap("NavigateToPage2Button");
219219

220-
_app.WaitForElement("Page2CommandBar");
220+
_app.WaitForElement("BackButtonTitleButton");
221+
222+
_app.FastTap("BackButtonTitleButton");
223+
224+
_app.Wait(TimeSpan.FromMilliseconds(800));
221225

222-
var backButtonText = _app.Marked("Back").FirstResult();
226+
var textblock = _app.Marked("InfoTextBlock");
223227

224-
Assert.IsNull(backButtonText);
228+
Assert.AreEqual("PASSED", textblock.GetDependencyPropertyValue("Text"));
225229
}
226230
}
227231
}

src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonTitle/CommandBar_Page2.xaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,19 @@
1515
<RowDefinition Height="*" />
1616
</Grid.RowDefinitions>
1717

18-
<CommandBar Content="Page 2"
19-
x:Name="Page2CommandBar" />
18+
<CommandBar Content="Page 2"
19+
x:Name="Page2CommandBar" />
20+
21+
<StackPanel Grid.Row="1"
22+
VerticalAlignment="Center">
23+
<Button x:Name="BackButtonTitleButton"
24+
Content="Get Back Text"
25+
Click="OnButtonClicked"
26+
HorizontalAlignment="Center"/>
27+
28+
<TextBlock x:Name="InfoTextBlock"
29+
HorizontalAlignment="Center"/>
30+
</StackPanel>
2031

2132
</Grid>
2233
</Page>

src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/CommandBar/BackButtonTitle/CommandBar_Page2.xaml.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
using Windows.UI.Xaml.Media;
1515
using Windows.UI.Xaml.Navigation;
1616

17+
#if __IOS__
18+
using UIKit;
19+
using Uno.UI.Controls;
20+
#endif
21+
1722
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
1823

1924
namespace UITests.Windows_UI_Xaml_Controls.CommandBar.BackButtonTitle
@@ -24,5 +29,25 @@ public CommandBar_Page2()
2429
{
2530
this.InitializeComponent();
2631
}
32+
33+
public void OnButtonClicked(object sender, object args)
34+
{
35+
36+
#if __IOS__
37+
UIView parent = this;
38+
while (parent.HasParent())
39+
{
40+
parent = parent.Superview;
41+
}
42+
43+
var navigationBar = parent.FindFirstChild<UnoNavigationBar>();
44+
45+
var uiLabels = navigationBar?.FindSubviewsOfType<UILabel>();
46+
47+
var result = uiLabels?.Any(x => x.Text == "Back") ?? true;
48+
49+
InfoTextBlock.Text = result ? "FAILED" : "PASSED";
50+
#endif
51+
}
2752
}
2853
}

0 commit comments

Comments
 (0)