Skip to content

Commit

Permalink
Merge pull request #18387 from unoplatform/dev/jela/test-update
Browse files Browse the repository at this point in the history
Misc test updates
  • Loading branch information
jeromelaban authored Oct 5, 2024
2 parents 7474c70 + 521bcd1 commit 8832212
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 93 deletions.
2 changes: 2 additions & 0 deletions build/ci/.azure-devops-android-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ jobs:
## First tests run (https://github.com/unoplatform/uno/issues/6714)
- bash: |
# always set execute bit, as git has a tendency to remove it
chmod +x $(build.sourcesdirectory)/build/test-scripts/android-uitest-run.sh
$(build.sourcesdirectory)/build/test-scripts/android-uitest-run.sh
displayName: Run Android Tests
Expand Down
10 changes: 7 additions & 3 deletions build/test-scripts/android-uitest-run.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,19 @@ else

cd $UNO_TESTS_LOCAL_TESTS_FILE

# Response file for testing to avoid the command line length limitation
# new parameters must include the ":" to separate parameter options
# the response file contains only the filters, in order to get proper stderr
echo "--filter:\"$UNO_TESTS_FILTER\"" > tests.rsp

## Run NUnit tests
dotnet test \
-c Release \
-l:"console;verbosity=normal" \
--logger "nunit;LogFileName=$UNO_ORIGINAL_TEST_RESULTS" \
--filter "$UNO_TESTS_FILTER" \
--blame-hang-timeout 120m \
-v m || true

-v m \
@tests.rsp || true
fi

## Dump the emulator's system log
Expand Down
2 changes: 1 addition & 1 deletion build/test-scripts/ios-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ if [ ! -f "$UNO_ORIGINAL_TEST_RESULTS" ]; then
fi

echo "Copying crash reports"
cp -R ~/Library/Logs/DiagnosticReports/* $LOG_FILE_DIRECTORY
cp -R ~/Library/Logs/DiagnosticReports/* $LOG_FILE_DIRECTORY || true

pushd $BUILD_SOURCESDIRECTORY/src/Uno.NUnitTransformTool
mkdir -p $(dirname ${UNO_TESTS_FAILED_LIST})
Expand Down
145 changes: 144 additions & 1 deletion src/SamplesApp/SamplesApp.Shared/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
xmlns:ios="http://nventive.com/ios"
xmlns:local="using:SamplesApp"
xmlns:toolkit="using:Uno.UI.Toolkit"
mc:Ignorable="ios"
xmlns:uc="using:Uno.UI.Controls"
mc:Ignorable="ios not_win"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
Expand Down Expand Up @@ -170,6 +171,148 @@
<!-- used by ResourceMarkupTest_Setup -->
<x:String x:Key="GlobalStaticResource_TestText">global App.Resources</x:String>

<!--
Duplicate the fluent button style to remove the default animation
that breaks screenshot tests.
-->
<not_win:Style TargetType="Button">
<Setter Property="Background"
Value="{ThemeResource ButtonBackground}" />
<Setter Property="BackgroundSizing"
Value="InnerBorderEdge" />
<Setter Property="Foreground"
Value="{ThemeResource ButtonForeground}" />
<Setter Property="BorderBrush"
Value="{ThemeResource ButtonBorderBrush}" />
<Setter Property="BorderThickness"
Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="Padding"
Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="FontFamily"
Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight"
Value="Normal" />
<Setter Property="FontSize"
Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="UseSystemFocusVisuals"
Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="FocusVisualMargin"
Value="-3" />
<Setter Property="CornerRadius"
Value="{ThemeResource ControlCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<!-- Uno specific (LinearGradientBrush borders): Additional Grid as template root needed #6457 -->
<Grid>
<ContentPresenter x:Name="ContentPresenter"
Background="{TemplateBinding Background}"
Foreground="{TemplateBinding Foreground}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
local:AnimatedIcon.State="Normal"
xmlns:local="using:Microsoft.UI.Xaml.Controls">
</ContentPresenter>
<!-- Uno specific (LinearGradientBrush borders): #6457 -->
<uc:FauxGradientBorderPresenter
RequestedBorderBrush="{Binding ElementName=ContentPresenter, Path=BorderBrush}"
RequestedBorderThickness="{Binding ElementName=ContentPresenter, Path=BorderThickness}"
RequestedCornerRadius="{Binding ElementName=ContentPresenter, Path=CornerRadius}" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<VisualState.Setters>
<Setter Target="ContentPresenter.(controls:AnimatedIcon.State)"
Value="PointerOver" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonBackgroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonBorderBrushPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonForegroundPressed}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<VisualState.Setters>
<Setter Target="ContentPresenter.(controls:AnimatedIcon.State)"
Value="Pressed" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource ButtonForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<VisualState.Setters>
<!-- DisabledVisual Should be handled by the control, not the animated icon. -->
<Setter Target="ContentPresenter.(controls:AnimatedIcon.State)"
Value="Normal" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</not_win:Style>


</ResourceDictionary>

</Application.Resources>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Uno.UI.Samples.Controls;

using Uno.UI.Samples.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

Expand All @@ -16,6 +18,16 @@ public sealed partial class Flyout_ShowAt_Window_Content : Page
public Flyout_ShowAt_Window_Content()
{
this.InitializeComponent();

#if HAS_UNO
XamlRoot _xamlRoot = null;
Loaded += (s, e) => _xamlRoot = XamlRoot;
Unloaded += (s, e) =>
{
// close all popups at the end of the test.
VisualTreeHelper.CloseAllPopups(_xamlRoot);
};
#endif
}

private void ButtonButton_Click(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,46 +276,50 @@ public async Task CanOpenCloseFlyoutBySettingIsCalendarOpen()
{
TestCleanupWrapper cleanup;

Grid rootPanel = null;
CalendarDatePickerHelper helper = new CalendarDatePickerHelper();
await helper.PrepareLoadedEvent();
Microsoft.UI.Xaml.Controls.CalendarDatePicker cp = await helper.GetCalendarDatePicker();
// This test may be unstable on iOS
await TestHelper.RetryAssert(async () =>
{
Grid rootPanel = null;
CalendarDatePickerHelper helper = new CalendarDatePickerHelper();
await helper.PrepareLoadedEvent();
Microsoft.UI.Xaml.Controls.CalendarDatePicker cp = await helper.GetCalendarDatePicker();
rootPanel = await CreateTestResources();
rootPanel = await CreateTestResources();
// load into visual tree
await RunOnUIThread(() =>
{
rootPanel.Children.Append(cp);
});
// load into visual tree
await RunOnUIThread(() =>
{
rootPanel.Children.Append(cp);
});
await helper.WaitForLoaded();
await helper.WaitForLoaded();
await TestServices.WindowHelper.WaitForIdle();
await TestServices.WindowHelper.WaitForIdle();
await helper.PrepareOpenedEvent();
await helper.PrepareOpenedEvent();
await RunOnUIThread(() =>
{
cp.IsCalendarOpen = true;
});
await helper.WaitForOpened();
await RunOnUIThread(() =>
{
cp.IsCalendarOpen = true;
});
await helper.WaitForOpened();
await helper.PrepareClosedEvent();
await helper.PrepareClosedEvent();
await RunOnUIThread(() =>
{
cp.IsCalendarOpen = false;
});
await RunOnUIThread(() =>
{
cp.IsCalendarOpen = false;
});
await helper.WaitForClosed();
await helper.WaitForClosed();
await RunOnUIThread(() =>
{
// disable CP to make sure input pane is not open during clean up.
cp.IsEnabled = false;
await RunOnUIThread(() =>
{
// disable CP to make sure input pane is not open during clean up.
cp.IsEnabled = false;
});
await TestServices.WindowHelper.WaitForIdle();
});
await TestServices.WindowHelper.WaitForIdle();
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,13 +1361,18 @@ await RunOnUIThread(() =>
KeyboardHelper.Down(secondaryItemsPresenter);
await WindowHelper.WaitForIdle();

await RunOnUIThread(() =>
await TestHelper.RetryAssert(async () =>
{
var item = (AppBarButton)cmdBar.SecondaryCommands[0];
var transform = item.TransformToVisual(null);
var firstItemNewPosition = transform.TransformPoint(new Point(0, 0));
// This keyboard and animation driven, it may need a few retries to get the right position.
VERIFY_ARE_EQUAL(firstItemNewPosition, firstItemOriginalPosition);
await RunOnUIThread(() =>
{
var item = (AppBarButton)cmdBar.SecondaryCommands[0];
var transform = item.TransformToVisual(null);
var firstItemNewPosition = transform.TransformPoint(new Point(0, 0));
VERIFY_ARE_EQUAL(firstItemNewPosition, firstItemOriginalPosition);
});
});
}

Expand Down Expand Up @@ -3251,27 +3256,32 @@ await RunOnUIThread(() =>
VERIFY_ARE_EQUAL(primaryItemsControl.Visibility, Visibility.Collapsed);
});

LOG_OUTPUT("Now open and close the CommandBar.");
await OpenCommandBar(cmdBar, OpenMethod.Programmatic);
await CloseCommandBar(cmdBar);

await RunOnUIThread(() =>
// in some unknown conditions, the OpenCommandBar may not happen on android
// Retry a few times until it does.
await TestHelper.RetryAssert(async () =>
{
LOG_OUTPUT("The primary items control should still be collapsed.");
VERIFY_ARE_EQUAL(primaryItemsControl.Visibility, Visibility.Collapsed);
LOG_OUTPUT("Now open and close the CommandBar.");
await OpenCommandBar(cmdBar, OpenMethod.Programmatic);
await CloseCommandBar(cmdBar);
LOG_OUTPUT("Change the width of the CommandBar back to 600. The AppBarButton should be moved back from the overflow.");
expectItemsAdded = false;
cmdBar.Width = 600;
});
await RunOnUIThread(() =>
{
LOG_OUTPUT("The primary items control should still be collapsed.");
VERIFY_ARE_EQUAL(primaryItemsControl.Visibility, Visibility.Collapsed);
await dynamicOverflowItemsChangingEvent.WaitForDefault();
await WindowHelper.WaitForIdle();
LOG_OUTPUT("Change the width of the CommandBar back to 600. The AppBarButton should be moved back from the overflow.");
expectItemsAdded = false;
cmdBar.Width = 600;
});
await RunOnUIThread(() =>
{
LOG_OUTPUT("The primary items control should now be visible since the AppBarButton is back in it.");
VERIFY_ARE_EQUAL(primaryItemsControl.Visibility, Visibility.Visible);
await dynamicOverflowItemsChangingEvent.WaitForDefault();
await WindowHelper.WaitForIdle();
await RunOnUIThread(() =>
{
LOG_OUTPUT("The primary items control should now be visible since the AppBarButton is back in it.");
VERIFY_ARE_EQUAL(primaryItemsControl.Visibility, Visibility.Visible);
});
});
}

Expand Down Expand Up @@ -5226,7 +5236,11 @@ private async Task CloseCommandBar(CommandBar cmdBar)
var closedRegistration = CreateSafeEventRegistration<CommandBar, EventHandler<object>>("Closed");
closedRegistration.Attach(cmdBar, (s, e) => closedEvent.Set());

await RunOnUIThread(() => cmdBar.IsOpen = false);
await RunOnUIThread(() =>
{
Assert.IsTrue(cmdBar.IsOpen, "Command bar is not opened");
cmdBar.IsOpen = false;
});
await closedEvent.WaitForDefault();
await WindowHelper.WaitForIdle();
}
Expand Down
Loading

0 comments on commit 8832212

Please sign in to comment.