Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Terminal Velocity Check for CameraCaptureUI Experimental API #4906

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,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
Saharsh979 marked this conversation as resolved.
Show resolved Hide resolved
workingDirectory: '$(Build.SourcesDirectory)'

- task: powershell@2
name: UpdateTraceloggingConfig
inputs:
Expand Down
32 changes: 32 additions & 0 deletions dev/Common/TerminalVelocityFeatures-CameraCaptureUI.h
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 20 additions & 0 deletions dev/Common/TerminalVelocityFeatures-CameraCaptureUI.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<features xmlns="http://microsoft.com/windowsappsdk/TerminalVelocity/20210729/TerminalVelocityFeatures.xsd">

<!-- Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE in the project root for license information.
-->

<!-- See docs/Coding-Guidelines/TerminalVelocity.md for more info. -->

<!-- Enabled variants -->
<feature>
<name>Feature_CameraCaptureUI</name>
<description>CameraCaptureUI for the WindowsAppRuntime</description>
<state>AlwaysEnabled</state>
<alwaysDisabledChannelTokens>
<channelToken>Preview</channelToken>
<channelToken>Stable</channelToken>
</alwaysDisabledChannelTokens>
</feature>
</features>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "CameraCaptureUIPhotoCaptureSettings.h"
#include "CameraCaptureUIVideoCaptureSettings.h"
#include "TelemetryHelper.h"

#include <TerminalVelocityFeatures-CameraCaptureUI.h>

namespace winrt::Microsoft::Windows::Media::Capture::implementation
{
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <TerminalVelocityFeatures-CameraCaptureUI.h>

namespace Microsoft.Windows.Media.Capture
{
Expand Down Expand Up @@ -73,6 +74,7 @@ namespace Microsoft.Windows.Media.Capture
}

[contract(CameraCaptureUIContract, 1)]
[feature(Feature_CameraCaptureUI)]
Saharsh979 marked this conversation as resolved.
Show resolved Hide resolved
runtimeclass CameraCaptureUI
{
CameraCaptureUI(Microsoft.UI.WindowId windowId);
Expand Down
26 changes: 26 additions & 0 deletions test/CameraCaptureUITests/APITests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <mutex>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Foundation.h>
#include <TerminalVelocityFeatures-CameraCaptureUI.h>

using namespace std::chrono_literals;
using namespace WEX::Common;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<uint64_t>(parentWindow) };
Expand All @@ -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<uint64_t>(parentWindow) };
Expand All @@ -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<uint64_t>(parentWindow) };
Expand All @@ -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<uint64_t>(parentWindow) };
Expand Down
12 changes: 6 additions & 6 deletions test/CameraCaptureUITests/CameraCaptureUITests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -125,7 +125,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -143,7 +143,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -161,7 +161,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -179,7 +179,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -197,7 +197,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
Loading