From d6e1cfd46c04039358a5563f4b045c3bcf441840 Mon Sep 17 00:00:00 2001 From: Saharsh Ananta Jaiswal Date: Fri, 22 Nov 2024 13:37:11 +0530 Subject: [PATCH] Adding Terminal Velocity Check for experimental API (#4906) --- ...dowsAppSDK-SetupBuildEnvironment-Steps.yml | 8 +++++ ...TerminalVelocityFeatures-CameraCaptureUI.h | 32 +++++++++++++++++++ ...rminalVelocityFeatures-CameraCaptureUI.xml | 20 ++++++++++++ .../CameraCaptureUI/CameraCaptureUI.h | 3 +- .../CameraCaptureUI/CameraCaptureUI.idl | 2 ++ test/CameraCaptureUITests/APITests.cpp | 26 +++++++++++++++ .../CameraCaptureUITests.vcxproj | 12 +++---- 7 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 dev/Common/TerminalVelocityFeatures-CameraCaptureUI.h create mode 100644 dev/Common/TerminalVelocityFeatures-CameraCaptureUI.xml diff --git a/build/AzurePipelinesTemplates/WindowsAppSDK-SetupBuildEnvironment-Steps.yml b/build/AzurePipelinesTemplates/WindowsAppSDK-SetupBuildEnvironment-Steps.yml index 48138e9365..3f47e1caae 100644 --- a/build/AzurePipelinesTemplates/WindowsAppSDK-SetupBuildEnvironment-Steps.yml +++ b/build/AzurePipelinesTemplates/WindowsAppSDK-SetupBuildEnvironment-Steps.yml @@ -179,6 +179,14 @@ steps: arguments: -Path $(Build.SourcesDirectory)\dev\common\TerminalVelocityFeatures-PackageManager.xml -Channel $(channel) -Language C++ -Namespace Microsoft.Windows.Management.Deployment -Output $(Build.SourcesDirectory)\dev\common\TerminalVelocityFeatures-PackageManager.h workingDirectory: '$(Build.SourcesDirectory)' +- task: powershell@2 + displayName: 'Create CameraCaptureUI TerminalVelocity features' + inputs: + targetType: filePath + filePath: tools\TerminalVelocity\Generate-TerminalVelocityFeatures.ps1 + arguments: -Path $(Build.SourcesDirectory)\dev\common\TerminalVelocityFeatures-CameraCaptureUI.xml -Channel $(channel) -Language C++ -Namespace Microsoft.Windows.Media.Capture -Output $(Build.SourcesDirectory)\dev\common\TerminalVelocityFeatures-CameraCaptureUI.h + workingDirectory: '$(Build.SourcesDirectory)' + - task: powershell@2 name: UpdateTraceloggingConfig inputs: diff --git a/dev/Common/TerminalVelocityFeatures-CameraCaptureUI.h b/dev/Common/TerminalVelocityFeatures-CameraCaptureUI.h new file mode 100644 index 0000000000..d18c868fe2 --- /dev/null +++ b/dev/Common/TerminalVelocityFeatures-CameraCaptureUI.h @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT IT + +// INPUT FILE: dev\common\TerminalVelocityFeatures-CameraCaptureUI.xml +// OPTIONS: -Channel Experimental -Language C++ -Namespace Microsoft.Windows.Media.Capture -Path dev\common\TerminalVelocityFeatures-CameraCaptureUI.xml -Output dev\common\TerminalVelocityFeatures-CameraCaptureUI.h + +#if defined(__midlrt) +namespace features +{ + feature_name Feature_CameraCaptureUI = { DisabledByDefault, FALSE }; +} +#endif // defined(__midlrt) + +// Feature constants +#define WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_MEDIA_CAPTURE_FEATURE_CAMERACAPTUREUI_ENABLED 1 + +#if defined(__cplusplus) + +namespace Microsoft::Windows::Media::Capture +{ + +__pragma(detect_mismatch("ODR_violation_WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_MEDIA_CAPTURE_FEATURE_CAMERACAPTUREUI_ENABLED_mismatch", "AlwaysEnabled")) +struct Feature_CameraCaptureUI +{ + static constexpr bool IsEnabled() { return WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_MEDIA_CAPTURE_FEATURE_CAMERACAPTUREUI_ENABLED == 1; } +}; + +} // namespace Microsoft.Windows.Media.Capture + +#endif // defined(__cplusplus) diff --git a/dev/Common/TerminalVelocityFeatures-CameraCaptureUI.xml b/dev/Common/TerminalVelocityFeatures-CameraCaptureUI.xml new file mode 100644 index 0000000000..c0b3acbfe3 --- /dev/null +++ b/dev/Common/TerminalVelocityFeatures-CameraCaptureUI.xml @@ -0,0 +1,20 @@ + + + + + + + + + + Feature_CameraCaptureUI + CameraCaptureUI for the WindowsAppRuntime + AlwaysEnabled + + Preview + Stable + + + diff --git a/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.h b/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.h index 2e8519d2ae..6f1e4a7323 100644 --- a/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.h +++ b/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.h @@ -5,7 +5,7 @@ #include "CameraCaptureUIPhotoCaptureSettings.h" #include "CameraCaptureUIVideoCaptureSettings.h" #include "TelemetryHelper.h" - +#include namespace winrt::Microsoft::Windows::Media::Capture::implementation { @@ -20,6 +20,7 @@ namespace winrt::Microsoft::Windows::Media::Capture::implementation CameraCaptureUI(winrt::Microsoft::UI::WindowId const& windowId) : m_windowId(windowId) { + THROW_HR_IF(E_NOTIMPL, !::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled()); } Microsoft::Windows::Media::Capture::CameraCaptureUIPhotoCaptureSettings PhotoSettings() diff --git a/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.idl b/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.idl index e531857730..550b708351 100644 --- a/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.idl +++ b/dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.idl @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. +#include namespace Microsoft.Windows.Media.Capture { @@ -73,6 +74,7 @@ namespace Microsoft.Windows.Media.Capture } [contract(CameraCaptureUIContract, 1)] + [feature(Feature_CameraCaptureUI)] runtimeclass CameraCaptureUI { CameraCaptureUI(Microsoft.UI.WindowId windowId); diff --git a/test/CameraCaptureUITests/APITests.cpp b/test/CameraCaptureUITests/APITests.cpp index 37e135203b..195f25ad83 100644 --- a/test/CameraCaptureUITests/APITests.cpp +++ b/test/CameraCaptureUITests/APITests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include using namespace std::chrono_literals; using namespace WEX::Common; @@ -59,6 +60,11 @@ namespace CameraCaptureUITests // Focusing solely on functional tests for now. TEST_METHOD(CapturePhoto_ShouldReturnFile) { + if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled()) + { + Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled."); + return; + } try { auto parentWindow = ::GetForegroundWindow(); @@ -96,6 +102,11 @@ namespace CameraCaptureUITests } TEST_METHOD(VerifyRequestedPhotoFormatsAreReadCorrectly) { + if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled()) + { + Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled."); + return; + } // Arrange auto parentWindow = ::GetForegroundWindow(); winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast(parentWindow) }; @@ -117,6 +128,11 @@ namespace CameraCaptureUITests TEST_METHOD(VerifyRequestedVideoFormatsAreReadCorrectly) { + if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled()) + { + Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled."); + return; + } // Arrange auto parentWindow = ::GetForegroundWindow(); winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast(parentWindow) }; @@ -132,6 +148,11 @@ namespace CameraCaptureUITests } TEST_METHOD(VerifyMaxVideoResolutionValues) { + if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled()) + { + Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled."); + return; + } // Arrange auto parentWindow = ::GetForegroundWindow(); winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast(parentWindow) }; @@ -156,6 +177,11 @@ namespace CameraCaptureUITests TEST_METHOD(VerifyMaxPhotoResolutionValues) { + if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled()) + { + Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled."); + return; + } // Arrange auto parentWindow = ::GetForegroundWindow(); winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast(parentWindow) }; diff --git a/test/CameraCaptureUITests/CameraCaptureUITests.vcxproj b/test/CameraCaptureUITests/CameraCaptureUITests.vcxproj index 447d8ef33f..1c4a3d46dc 100644 --- a/test/CameraCaptureUITests/CameraCaptureUITests.vcxproj +++ b/test/CameraCaptureUITests/CameraCaptureUITests.vcxproj @@ -107,7 +107,7 @@ true Use pch.h - $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL;$(MSBuildProjectDirectory)\..\..\dev\common Windows @@ -125,7 +125,7 @@ true Use pch.h - $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common Windows @@ -143,7 +143,7 @@ true Use pch.h - $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common Windows @@ -161,7 +161,7 @@ true Use pch.h - $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common Windows @@ -179,7 +179,7 @@ true Use pch.h - $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common Windows @@ -197,7 +197,7 @@ true Use pch.h - $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\ + $(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common Windows