Skip to content

Commit

Permalink
Setup scaffolding for legacy test runner (#21423)
Browse files Browse the repository at this point in the history
* Just added a couple of tests

* Focus on Android and iOS (for now)

* Added legacy tests to the pipeline

* More changes

* More changes

* Fixed build

* Created ui-tests-legacy-steps.yml

* More changes

* More changes

* Updated Appium to RC7

* Update ui-tests.yml

* Fixed test on Android

* Fixed test

* More changes

* More changes

* Updated snapshot

* More fixes

* Clean code

* Run test only on iOS

* Added pending constant

* Fix build error

* More changes

* Update ControlGallery.iOS.Appium.UITests.csproj

* Update ControlGallery.Shared.Appium.UITests.csproj

* Trying to run only on iOS

* This is the fix, I feel it

* Fix merge error

---------

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
  • Loading branch information
jsuarezruiz and jfversluis authored Apr 22, 2024
1 parent be17057 commit 632080a
Show file tree
Hide file tree
Showing 27 changed files with 1,396 additions and 6 deletions.
27 changes: 24 additions & 3 deletions Microsoft.Maui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controls.Xaml.UnitTests.Int
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controls.Sample.UITests", "src\Controls\samples\Controls.Sample.UITests\Controls.Sample.UITests.csproj", "{F39F75DC-671B-4649-8005-1929797B3217}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITest.Core", "src\TestUtils\src\UITest.Core\UITest.Core.csproj", "{352C2381-1DEC-4487-819D-340D1EA98FBE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITest.Core", "src\TestUtils\src\UITest.Core\UITest.Core.csproj", "{352C2381-1DEC-4487-819D-340D1EA98FBE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITest.Appium", "src\TestUtils\src\UITest.Appium\UITest.Appium.csproj", "{8C8CD467-11F9-4A14-8AF3-047B2CFD19A7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITest.Appium", "src\TestUtils\src\UITest.Appium\UITest.Appium.csproj", "{8C8CD467-11F9-4A14-8AF3-047B2CFD19A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITest.NUnit", "src\TestUtils\src\UITest.NUnit\UITest.NUnit.csproj", "{8050448A-E08F-4972-9B47-16042A5DFE82}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITest.NUnit", "src\TestUtils\src\UITest.NUnit\UITest.NUnit.csproj", "{8050448A-E08F-4972-9B47-16042A5DFE82}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlGallery.Android.Appium.UITests", "src\Compatibility\ControlGallery\test\Android.Appium.UITests\ControlGallery.Android.Appium.UITests.csproj", "{F748974F-A8E4-4659-801C-804B739D6326}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlGallery.iOS.Appium.UITests", "src\Compatibility\ControlGallery\test\iOS.Appium.UITests\ControlGallery.iOS.Appium.UITests.csproj", "{5923B35B-EA24-4B86-A384-9DAF9F2AFD56}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlGallery.Shared.Appium.UITests", "src\Compatibility\ControlGallery\test\Shared.Appium.UITests\ControlGallery.Shared.Appium.UITests.csproj", "{07D8D4B5-C89D-4BE3-A14A-17668358587C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -644,6 +650,18 @@ Global
{8050448A-E08F-4972-9B47-16042A5DFE82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8050448A-E08F-4972-9B47-16042A5DFE82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8050448A-E08F-4972-9B47-16042A5DFE82}.Release|Any CPU.Build.0 = Release|Any CPU
{F748974F-A8E4-4659-801C-804B739D6326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F748974F-A8E4-4659-801C-804B739D6326}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F748974F-A8E4-4659-801C-804B739D6326}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F748974F-A8E4-4659-801C-804B739D6326}.Release|Any CPU.Build.0 = Release|Any CPU
{5923B35B-EA24-4B86-A384-9DAF9F2AFD56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5923B35B-EA24-4B86-A384-9DAF9F2AFD56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5923B35B-EA24-4B86-A384-9DAF9F2AFD56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5923B35B-EA24-4B86-A384-9DAF9F2AFD56}.Release|Any CPU.Build.0 = Release|Any CPU
{07D8D4B5-C89D-4BE3-A14A-17668358587C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07D8D4B5-C89D-4BE3-A14A-17668358587C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07D8D4B5-C89D-4BE3-A14A-17668358587C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07D8D4B5-C89D-4BE3-A14A-17668358587C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -762,6 +780,9 @@ Global
{352C2381-1DEC-4487-819D-340D1EA98FBE} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{8C8CD467-11F9-4A14-8AF3-047B2CFD19A7} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{8050448A-E08F-4972-9B47-16042A5DFE82} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{F748974F-A8E4-4659-801C-804B739D6326} = {DDBA9144-36FC-429E-99E1-2A64825434C1}
{5923B35B-EA24-4B86-A384-9DAF9F2AFD56} = {DDBA9144-36FC-429E-99E1-2A64825434C1}
{07D8D4B5-C89D-4BE3-A14A-17668358587C} = {DDBA9144-36FC-429E-99E1-2A64825434C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
146 changes: 146 additions & 0 deletions eng/pipelines/common/ui-tests-legacy-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
parameters:
platform: '' # [ android, ios, windows, catalyst ]
path: '' # path to csproj
device: '' # the xharness device to use
cakeArgs: '' # additional cake args
app: '' #path to app to test
version: '' #the iOS version'
provisionatorChannel: 'latest'
agentPoolAccessToken: ''
targetSample: "dotnet-legacy-controlgallery"
configuration : "Release"

steps:
- ${{ if eq(parameters.platform, 'ios')}}:
- bash: |
chmod +x $(System.DefaultWorkingDirectory)/eng/scripts/clean-bot.sh
$(System.DefaultWorkingDirectory)/eng/scripts/clean-bot.sh
displayName: 'Clean bot'
continueOnError: true
timeoutInMinutes: 60
- template: provision.yml
parameters:
skipProvisioning: ${{ eq(parameters.platform, 'windows') }}
skipAndroidSdks: ${{ ne(parameters.platform, 'android') }}
skipXcode: ${{ or(eq(parameters.platform, 'android'), eq(parameters.platform, 'windows')) }}
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- task: PowerShell@2
condition: ne('${{ parameters.platform }}' , 'windows')
inputs:
targetType: 'inline'
script: |
defaults write -g NSAutomaticCapitalizationEnabled -bool false
defaults write -g NSAutomaticTextCompletionEnabled -bool false
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
displayName: "Modify defaults"
continueOnError: true

# AzDO hosted agents default to 1024x768; set something bigger for Windows UI tests
- task: ScreenResolutionUtility@1
condition: eq('${{ parameters.platform }}' , 'windows')
inputs:
displaySettings: 'specific'
width: '1920'
height: '1080'
displayName: "Set screen resolution"

- task: UseNode@1
inputs:
version: "20.3.1"
displayName: "Install node"

- bash: |
echo "##[group]Running ls -al $(npm root -g)"
ls -al $(npm root -g)
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/appium"
ls -al $(npm root -g)/appium
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/.appium-????????"
ls -al $(npm root -g)/.appium-????????
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/appium-doctor"
ls -al $(npm root -g)/appium-doctor
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/.appium-doctor-????????"
ls -al $(npm root -g)/.appium-doctor-????????
echo "##[endgroup]"
echo "##[group]Running ps aux"
ps aux
echo "##[endgroup]"
displayName: "Debugging output"
continueOnError: true
condition: startsWith(variables['Agent.Name'], 'XAMBOT')
# Clean up any leftover cached folders of appium and appium-doctor node modules
- bash: |
rm -rf $(npm root -g)/.appium-????????
rm -rf $(npm root -g)/.appium-doctor-????????
displayName: "Delete temp .appium-???????? and .appium-doctor-???????? folders"
continueOnError: true
- pwsh: ./eng/scripts/appium-install.ps1
displayName: "Install Appium (Drivers)"
continueOnError: false
retryCountOnTaskFailure: 1

- pwsh: ./build.ps1 --target=dotnet --configuration="${{ parameters.configuration }}" --verbosity=diagnostic
displayName: 'Install .NET'
retryCountOnTaskFailure: 2
env:
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
PRIVATE_BUILD: $(PrivateBuild)

- pwsh: echo "##vso[task.prependpath]$(DotNet.Dir)"
displayName: 'Add .NET to PATH'

- pwsh: ./build.ps1 --target=dotnet-buildtasks --configuration="${{ parameters.configuration }}"
displayName: 'Build the MSBuild Tasks'

- pwsh: ./build.ps1 --target=${{ parameters.targetSample }} --configuration="${{ parameters.configuration }}" --${{ parameters.platform }} --verbosity=diagnostic --usenuget=false
displayName: 'Build the Legacy ControlGallery'

- bash: |
if [ -f "$HOME/Library/Logs/CoreSimulator/*" ]; then rm -r $HOME/Library/Logs/CoreSimulator/*; fi
if [ -f "$HOME/Library/Logs/DiagnosticReports/*" ]; then rm -r $HOME/Library/Logs/DiagnosticReports/*; fi
displayName: Delete Old Simulator Logs
condition: ${{ eq(parameters.platform, 'ios') }}
continueOnError: true
- pwsh: ./build.ps1 -Script eng/devices/${{ parameters.platform }}.cake --target=uitest --project="${{ parameters.path }}" --appproject="${{ parameters.app }}" --device="${{ parameters.device }}" --apiversion="${{ parameters.version }}" --configuration="${{ parameters.configuration }}" --results="$(TestResultsDirectory)" --binlog="$(LogDirectory)" ${{ parameters.cakeArgs }} --verbosity=diagnostic
displayName: $(Agent.JobName)
${{ if ne(parameters.platform, 'android')}}:
retryCountOnTaskFailure: 1

- bash: |
suffix=$(date +%Y%m%d%H%M%S)
zip -9r "$(LogDirectory)/CoreSimulatorLog_${suffix}.zip" "$HOME/Library/Logs/CoreSimulator/"
zip -9r "$(LogDirectory)/DiagnosticReports_${suffix}.zip" "$HOME/Library/Logs/DiagnosticReports/"
displayName: Zip Simulator Logs
condition: ${{ eq(parameters.platform, 'ios') }}
continueOnError: true
- task: PublishTestResults@2
displayName: Publish the $(System.PhaseName) test results
condition: always()
inputs:
testResultsFormat: VSTest
testResultsFiles: '$(TestResultsDirectory)/*.trx'
testRunTitle: '$(System.PhaseName)'
failTaskOnFailedTests: true

- task: PublishBuildArtifacts@1
condition: always()
displayName: publish artifacts

# This must always be placed as the last step in the job
- template: agent-rebooter/mac.v1.yml@yaml-templates
parameters:
AgentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}
73 changes: 72 additions & 1 deletion eng/pipelines/common/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ parameters:
macosPool: { }
androidCompatibilityPool: { }
iosCompatibilityPool: { }
androidLegacyPool: { }
iosLegacyPool: { }
androidApiLevels: [ 30 ]
iosVersions: [ 'latest' ]
provisionatorChannel: 'latest'
agentPoolAccessToken: ''
runCompatibilityTests: false
runLegacyTests: true
projects:
- name: name
desc: Human Description
Expand All @@ -22,6 +25,10 @@ parameters:
compatibilityAndroidTestProject: /optional/path/to/android.csproj
compatibilityiOSTestProject: /optional/path/to/ios.csproj
compatibilityiOSApp: /optional/path/to/app.csproj
legacyAndroidApp: /optional/path/to/app.csproj
legacyAndroidTestProject: /optional/path/to/android.csproj
legacyiOSTestProject: /optional/path/to/ios.csproj
legacyiOSApp: /optional/path/to/app.csproj

stages:

Expand Down Expand Up @@ -170,7 +177,6 @@ stages:
provisionatorChannel: ${{ parameters.provisionatorChannel }}
agentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}


- stage: ios_compatibility_ui_tests
displayName: iOS Compatibility UITests
dependsOn: []
Expand Down Expand Up @@ -206,3 +212,68 @@ stages:
device: ios-simulator-64_${{ version }}
provisionatorChannel: ${{ parameters.provisionatorChannel }}
agentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}
- ${{ if eq(parameters.runLegacyTests, true) }}:
- stage: android_legacy_ui_tests
displayName: Android Legacy UITests
dependsOn: []
jobs:
- ${{ each project in parameters.projects }}:
- ${{ if ne(project.android, '') }}:
- ${{ each api in parameters.androidApiLevels }}:
- ${{ if not(containsValue(project.androidApiLevelsExclude, api)) }}:
- job: android_legacy_ui_tests_${{ project.name }}_${{ api }}
timeoutInMinutes: 240
workspace:
clean: all
displayName: ${{ coalesce(project.desc, project.name) }} (API ${{ api }})
pool: ${{ parameters.androidLegacyPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
steps:
- template: ui-tests-legacy-steps.yml
parameters:
platform: android
version: ${{ api }}
path: ${{ project.legacyAndroidTestProject }}
app: ${{ project.legacyAndroidApp }}
targetSample: "dotnet-legacy-controlgallery-android"
${{ if eq(api, 27) }}:
device: android-emulator-32_${{ api }}
${{ if not(eq(api, 27)) }}:
device: android-emulator-64_${{ api }}
provisionatorChannel: ${{ parameters.provisionatorChannel }}
agentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}

- stage: ios_legacy_ui_tests
displayName: iOS Legacy UITests
dependsOn: []
jobs:
- ${{ each project in parameters.projects }}:
- ${{ if ne(project.ios, '') }}:
- ${{ each version in parameters.iosVersions }}:
- ${{ if not(containsValue(project.iosVersionsExclude, version)) }}:
- job: ios_legacy_ui_tests_${{ project.name }}_${{ replace(version, '.', '_') }}
timeoutInMinutes: 240
workspace:
clean: all
displayName: ${{ coalesce(project.desc, project.name) }} (v${{ version }})
pool: ${{ parameters.iosLegacyPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
steps:
- template: ui-tests-legacy-steps.yml
parameters:
platform: ios
${{ if eq(version, 'latest') }}:
version: 16.4
${{ if ne(version, 'latest') }}:
version: ${{ version }}
path: ${{ project.legacyiOSTestProject }}
app: ${{ project.legacyiOSApp }}
targetSample: "dotnet-legacy-controlgallery-ios"
${{ if eq(version, 'latest') }}:
device: ios-simulator-64
${{ if ne(version, 'latest') }}:
device: ios-simulator-64_${{ version }}
provisionatorChannel: ${{ parameters.provisionatorChannel }}
agentPoolAccessToken: ${{ parameters.agentPoolAccessToken }}
23 changes: 23 additions & 0 deletions eng/pipelines/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ parameters:
- macOS.Name -equals Ventura
- macOS.Architecture -equals x64

- name: androidLegacyPool
type: object
default:
name: $(androidTestsVmPool)
vmImage: $(androidTestsVmImage)
demands:
- macOS.Name -equals Ventura
- macOS.Architecture -equals x64

- name: iosLegacyPool
type: object
default:
name: $(iosTestsVmPool)
vmImage: $(iosTestsVmImage)
demands:
- macOS.Name -equals Ventura
- macOS.Architecture -equals x64

resources:
repositories:
Expand All @@ -128,6 +145,8 @@ stages:
macosPool: ${{ parameters.macosPool }}
androidCompatibilityPool: ${{ parameters.androidCompatibilityPool }}
iosCompatibilityPool: ${{ parameters.iosCompatibilityPool }}
iosLegacyPool: ${{ parameters.iosLegacyPool }}
androidLegacyPool: ${{ parameters.androidLegacyPool }}
agentPoolAccessToken: $(AgentPoolAccessToken)
${{ if or(parameters.BuildEverything, and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'devdiv'))) }}:
androidApiLevels: [ 30 ]
Expand All @@ -153,4 +172,8 @@ stages:
compatibilityAndroidTestProject: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/test/Android.UITests/Compatibility.ControlGallery.Android.UITests.csproj
compatibilityiOSApp: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/src/iOS/Compatibility.ControlGallery.iOS.csproj
compatibilityiOSTestProject: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/test/iOS.UITests/Compatibility.ControlGallery.iOS.UITests.csproj
legacyAndroidApp: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/src/Android/Compatibility.ControlGallery.Android.csproj
legacyAndroidTestProject: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/test/Android.Appium.UITests/ControlGallery.Android.Appium.UITests.csproj
legacyiOSApp: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/src/iOS/Compatibility.ControlGallery.iOS.csproj
legacyiOSTestProject: $(System.DefaultWorkingDirectory)/src/Compatibility/ControlGallery/test/iOS.Appium.UITests/ControlGallery.iOS.Appium.UITests.csproj

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Runtime;
using Java.Interop;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using Microsoft.Maui.Controls.ControlGallery;
Expand All @@ -28,6 +29,7 @@ namespace Microsoft.Maui.Controls.ControlGallery.Android
DataScheme = "http", DataHost = App.AppName, DataPathPrefix = "/gallery/"
)
]
[Register("com.microsoft.mauicompatibilitygallery.MainActivity")]
public partial class Activity1 : MauiAppCompatActivity
{
App App => Microsoft.Maui.Controls.Application.Current as App;
Expand Down
Loading

0 comments on commit 632080a

Please sign in to comment.