From fad03e76d23874a16319609f1df7530d3d353b79 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Mon, 11 Nov 2024 09:47:31 -0600 Subject: [PATCH] Setup lane to run CV2 and CV1 tests (#25719) * Setup lane to run CV2 and CV1 tests * - fix cake * - fix args * - fix * - yaml * - maybe * - force CV2 for failing CV1 scenarios * Update CarouselViewLoopNoFreeze.cs * Update Issue12574.cs * - force CV2 --- eng/devices/ios.cake | 4 ++ eng/pipelines/common/ui-tests-steps.yml | 5 ++ eng/pipelines/common/ui-tests.yml | 37 ++++++++++ .../src/Issues.Shared/Issue12574.cs | 3 +- .../CollectionViewHostBuilderExtentions.cs | 68 +++++++++++++++++++ .../HeaderFooterGrid.xaml | 19 +++--- .../HeaderFooterGridHorizontal.xaml | 19 +++--- .../Issues/CarouselViewLoopNoFreeze.cs | 6 +- .../Issues/CarouselViewRemoveAt.cs | 4 +- .../TestCases.HostApp/Issues/Issue11896.xaml | 24 +++---- .../TestCases.HostApp/Issues/Issue22035.xaml | 2 +- .../Issues/Issue22035.xaml.cs | 6 +- .../Issues/Issue22035Page2.xaml | 11 +-- .../tests/TestCases.HostApp/MauiProgram.cs | 7 +- .../tests/TestCases.Shared.Tests/UITest.cs | 12 ++++ .../Actions/AppiumLifecycleActions.cs | 12 +++- .../src/UITest.Appium/AppiumIOSApp.cs | 6 ++ .../src/UITest.Appium/HelperExtensions.cs | 8 +++ 18 files changed, 202 insertions(+), 51 deletions(-) create mode 100644 src/Controls/tests/TestCases.HostApp/CollectionViewHostBuilderExtentions.cs diff --git a/eng/devices/ios.cake b/eng/devices/ios.cake index 1e1517b9a8cb..df2a60758c3b 100644 --- a/eng/devices/ios.cake +++ b/eng/devices/ios.cake @@ -247,6 +247,10 @@ void ExecuteUITests(string project, string app, string device, string resultsDir .Append("/bl:" + binlog) }); + var TEST_CONFIGURATION_ARGS = Argument("TEST_CONFIGURATION_ARGS", EnvironmentVariable("TEST_CONFIGURATION_ARGS") ?? ""); + + Information("TEST_CONFIGURATION_ARGS {0}", TEST_CONFIGURATION_ARGS); + SetEnvironmentVariable("TEST_CONFIGURATION_ARGS", TEST_CONFIGURATION_ARGS); SetEnvironmentVariable("APPIUM_LOG_FILE", appiumLog); Information("Run UITests project {0}", project); diff --git a/eng/pipelines/common/ui-tests-steps.yml b/eng/pipelines/common/ui-tests-steps.yml index e102aa71f55c..2ffc7c08fde3 100644 --- a/eng/pipelines/common/ui-tests-steps.yml +++ b/eng/pipelines/common/ui-tests-steps.yml @@ -10,6 +10,7 @@ parameters: configuration : "Release" runtimeVariant : "Mono" testFilter: '' + testConfigurationArgs: '' steps: - task: DownloadPipelineArtifact@2 @@ -95,6 +96,7 @@ steps: $command += " --results=""$(TestResultsDirectory)"" --binlog=""$(LogDirectory)"" ${{ parameters.cakeArgs }} --verbosity=diagnostic" $testFilter = "" + $testConfigrationArgs = "${{ parameters.testConfigurationArgs }}" "${{ parameters.testFilter }}".Split(",") | ForEach { $testFilter += "TestCategory=" + $_ + "|" @@ -103,6 +105,9 @@ steps: $testFilter = $testFilter.TrimEnd("|") # Cake does not allow empty parameters, so check if our filter is empty before adding it + if ($testConfigrationArgs) { + $command += " --TEST_CONFIGURATION_ARGS=""$testConfigrationArgs""" + } if ($testFilter) { $command += " --test-filter ""$testFilter""" } diff --git a/eng/pipelines/common/ui-tests.yml b/eng/pipelines/common/ui-tests.yml index d3bb528cf96c..5a4f89f8f708 100644 --- a/eng/pipelines/common/ui-tests.yml +++ b/eng/pipelines/common/ui-tests.yml @@ -166,6 +166,43 @@ stages: runtimeVariant : "Mono" testFilter: $(CATEGORYGROUP) + - stage: ios_ui_tests_mono_cv2 + displayName: iOS UITests Mono CollectionView2 + dependsOn: build_ui_tests + jobs: + - ${{ each project in parameters.projects }}: + - ${{ if ne(project.ios, '') }}: + - ${{ each version in parameters.iosVersions }}: + - ${{ if not(containsValue(project.iosVersionsExclude, version)) }}: + - job: ios_ui_tests_mono_${{ project.name }}_${{ replace(version, '.', '_') }} + timeoutInMinutes: 240 # how long to run the job before automatically cancelling + workspace: + clean: all + displayName: ${{ coalesce(project.desc, project.name) }} (v${{ version }}) + pool: ${{ parameters.iosPool }} + variables: + REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE) + APPIUM_HOME: $(System.DefaultWorkingDirectory)/.appium/ + steps: + - template: ui-tests-steps.yml + parameters: + platform: ios + ${{ if eq(version, 'latest') }}: + version: 16.4 + ${{ if ne(version, 'latest') }}: + version: ${{ version }} + path: ${{ project.ios }} + app: ${{ project.app }} + ${{ if eq(version, 'latest') }}: + device: ios-simulator-64 + ${{ if ne(version, 'latest') }}: + device: ios-simulator-64_${{ version }} + provisionatorChannel: ${{ parameters.provisionatorChannel }} + agentPoolAccessToken: ${{ parameters.agentPoolAccessToken }} + runtimeVariant : "Mono" + testFilter: "CollectionView" + testConfigurationArgs: "CollectionView2" + - ${{ if or(parameters.BuildEverything, and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'devdiv'))) }}: - stage: ios_ui_tests_nativeaot displayName: iOS UITests NativeAOT diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue12574.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue12574.cs index dc0d346be150..48a3a45fc6c9 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue12574.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue12574.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; @@ -47,6 +47,7 @@ protected override void Init() }; _btn2.SetBinding(Button.CommandProperty, "RemoveAllItemsCommand"); + // https://github.com/dotnet/maui/pull/25692 _carouselView = new CarouselView { AutomationId = carouselAutomationId, diff --git a/src/Controls/tests/TestCases.HostApp/CollectionViewHostBuilderExtentions.cs b/src/Controls/tests/TestCases.HostApp/CollectionViewHostBuilderExtentions.cs new file mode 100644 index 000000000000..83d047bc5910 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/CollectionViewHostBuilderExtentions.cs @@ -0,0 +1,68 @@ + +#if IOS || MACCATALYST +using Foundation; +#endif + +namespace Maui.Controls.Sample +{ + + class CollectionView1 : CollectionView{} + class CollectionView2 : CollectionView{} + + + class CarouselView1 : CarouselView{} + class CarouselView2 : CarouselView{} + + public static partial class CollectionViewHostBuilderExtentions + { + /// + /// Configure the .NET MAUI app to listen for fold-related events + /// in the Android lifecycle. Ensures + /// can detect and layout around a hinge or screen fold. + /// + /// + /// Relies on Jetpack Window Manager to detect and respond to + /// foldable device features and capabilities. + /// + public static MauiAppBuilder ConfigureCollectionViewHandlers(this MauiAppBuilder builder) + { + + #if IOS || MACCATALYST + builder.ConfigureMauiHandlers(handlers => + { + bool cv2Handlers = false; + foreach(var en in NSProcessInfo.ProcessInfo.Environment) + { + if ($"{en.Key}" == "TEST_CONFIGURATION_ARGS") + { + cv2Handlers = $"{en.Value}".Contains("CollectionView2", StringComparison.OrdinalIgnoreCase); + break; + } + } + + if (cv2Handlers) + { + Console.WriteLine($"Using CollectionView2 handlers"); + handlers.AddHandler(); + handlers.AddHandler(); + } + else + { + Console.WriteLine($"Using CollectionView handlers"); + handlers.AddHandler(); + handlers.AddHandler(); + } + + handlers.AddHandler(); + handlers.AddHandler(); + + + handlers.AddHandler(); + handlers.AddHandler(); + }); + #endif + + return builder; + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGrid.xaml b/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGrid.xaml index bfd55fca7425..d201367a3d12 100644 --- a/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGrid.xaml +++ b/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGrid.xaml @@ -4,7 +4,8 @@ xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - x:Class="Maui.Controls.Sample.CollectionViewGalleries.HeaderFooterGalleries.HeaderFooterGrid"> + x:Class="Maui.Controls.Sample.CollectionViewGalleries.HeaderFooterGalleries.HeaderFooterGrid" + xmlns:local="clr-namespace:Maui.Controls.Sample"> @@ -15,27 +16,27 @@ - - + + - - + + - - + + - - + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml b/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml index f2f627596f15..602d8cc7e8d8 100644 --- a/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml +++ b/src/Controls/tests/TestCases.HostApp/Elements/CollectionView/HeaderFooterGalleries/HeaderFooterGridHorizontal.xaml @@ -4,7 +4,8 @@ xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - x:Class="Maui.Controls.Sample.CollectionViewGalleries.HeaderFooterGalleries.HeaderFooterGridHorizontal"> + x:Class="Maui.Controls.Sample.CollectionViewGalleries.HeaderFooterGalleries.HeaderFooterGridHorizontal" + xmlns:local="clr-namespace:Maui.Controls.Sample"> @@ -17,15 +18,15 @@ - - + + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewLoopNoFreeze.cs b/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewLoopNoFreeze.cs index 71454a52d1a2..e135c6a92a6f 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewLoopNoFreeze.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewLoopNoFreeze.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; @@ -13,7 +13,7 @@ public class CarouselViewLoopNoFreeze : ContentPage readonly string _btnRemoveAllAutomationId = "btnRemoveAll"; readonly ViewModelIssue12574 _viewModel; - readonly CarouselView _carouselView; + readonly CarouselView2 _carouselView; readonly Button _btn; readonly Button _btn2; @@ -33,7 +33,7 @@ public CarouselViewLoopNoFreeze() }; _btn2.SetBinding(Button.CommandProperty, "RemoveAllItemsCommand"); - _carouselView = new CarouselView + _carouselView = new CarouselView2 { AutomationId = _carouselAutomationId, Margin = new Thickness(30), diff --git a/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewRemoveAt.cs b/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewRemoveAt.cs index a5f191d0bef7..e888ef217d89 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewRemoveAt.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/CarouselViewRemoveAt.cs @@ -6,7 +6,7 @@ namespace Maui.Controls.Sample.Issues [Issue(IssueTracker.None, 10300, "ObservableCollection.RemoveAt(index) with a valid index raises ArgumentOutOfRangeException", PlatformAffected.iOS)] public class CarouselViewRemoveAt : ContentPage { - readonly CarouselView _carousel; + readonly CarouselView2 _carousel; public class ModalPage : ContentPage { @@ -47,7 +47,7 @@ public CarouselViewRemoveAt() new ModelCarouselViewRemoveAt("8", Colors.IndianRed), new ModelCarouselViewRemoveAt("9", Colors.Khaki), }); - _carousel = new CarouselView + _carousel = new CarouselView2 { ItemTemplate = new DataTemplate(() => { diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue11896.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue11896.xaml index 7de4c4225914..684cdcbbf3a2 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue11896.xaml +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue11896.xaml @@ -2,9 +2,9 @@ + Title="Main Page" + xmlns:local="clr-namespace:Maui.Controls.Sample"> @@ -17,9 +17,9 @@