From 0629062ff8d5e950a9449c4f0a8c6a0de2eb4fe4 Mon Sep 17 00:00:00 2001 From: Matt Cooley Date: Wed, 6 Jul 2022 10:28:31 -0700 Subject: [PATCH] Turn off animation effects --- build/pipelines/templates/run-ui-tests.yaml | 8 +++++++- build/scripts/TurnOffAnimationEffects.ps1 | 22 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 build/scripts/TurnOffAnimationEffects.ps1 diff --git a/build/pipelines/templates/run-ui-tests.yaml b/build/pipelines/templates/run-ui-tests.yaml index d74ee9c4..23e070b3 100644 --- a/build/pipelines/templates/run-ui-tests.yaml +++ b/build/pipelines/templates/run-ui-tests.yaml @@ -18,7 +18,8 @@ jobs: variables: skipComponentGovernanceDetection: true steps: - - checkout: none + - checkout: self + fetchDepth: 1 - task: ScreenResolutionUtility@1 displayName: Set resolution to 1920x1080 @@ -27,6 +28,11 @@ jobs: width: 1920 height: 1080 + - task: PowerShell@2 + displayName: Turn off animation effects + inputs: + filePath: $(Build.SourcesDirectory)\build\scripts\TurnOffAnimationEffects.ps1 + - task: DownloadBuildArtifacts@0 displayName: Download MsixBundle and CalculatorUITests inputs: diff --git a/build/scripts/TurnOffAnimationEffects.ps1 b/build/scripts/TurnOffAnimationEffects.ps1 new file mode 100644 index 00000000..94a0a18e --- /dev/null +++ b/build/scripts/TurnOffAnimationEffects.ps1 @@ -0,0 +1,22 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +<# +.SYNOPSIS + Disables animations on the system. Equivalent to turning off the "Animation effects" setting in the Windows Settings app. +#> + +Add-Type -AssemblyName System.Runtime.WindowsRuntime +$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] + +Function WaitForAsyncAction($WinRtTask, $ResultType) { + $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) + $task = $asTask.Invoke($null, @($WinRtTask)) + $task.GetAwaiter().GetResult() +} + +[Windows.UI.ViewManagement.Core.UISettingsController,Windows.UI.ViewManagement.Core,ContentType=WindowsRuntime] | Out-Null + +$controller = WaitForAsyncAction ([Windows.UI.ViewManagement.Core.UISettingsController]::RequestDefaultAsync()) ([Windows.UI.ViewManagement.Core.UISettingsController]) + +$controller.SetAnimationsEnabled($false) \ No newline at end of file