Skip to content

Commit 73d1401

Browse files
authored
Adding Terminal Velocity Check for experimental API (#4906)
1 parent c7069ac commit 73d1401

File tree

7 files changed

+96
-7
lines changed

7 files changed

+96
-7
lines changed

build/AzurePipelinesTemplates/WindowsAppSDK-SetupBuildEnvironment-Steps.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ steps:
179179
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
180180
workingDirectory: '$(Build.SourcesDirectory)'
181181
182+
- task: powershell@2
183+
displayName: 'Create CameraCaptureUI TerminalVelocity features'
184+
inputs:
185+
targetType: filePath
186+
filePath: tools\TerminalVelocity\Generate-TerminalVelocityFeatures.ps1
187+
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
188+
workingDirectory: '$(Build.SourcesDirectory)'
189+
182190
- task: powershell@2
183191
name: UpdateTraceloggingConfig
184192
inputs:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft Corporation and Contributors.
2+
// Licensed under the MIT License.
3+
4+
// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT IT
5+
6+
// INPUT FILE: dev\common\TerminalVelocityFeatures-CameraCaptureUI.xml
7+
// OPTIONS: -Channel Experimental -Language C++ -Namespace Microsoft.Windows.Media.Capture -Path dev\common\TerminalVelocityFeatures-CameraCaptureUI.xml -Output dev\common\TerminalVelocityFeatures-CameraCaptureUI.h
8+
9+
#if defined(__midlrt)
10+
namespace features
11+
{
12+
feature_name Feature_CameraCaptureUI = { DisabledByDefault, FALSE };
13+
}
14+
#endif // defined(__midlrt)
15+
16+
// Feature constants
17+
#define WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_MEDIA_CAPTURE_FEATURE_CAMERACAPTUREUI_ENABLED 1
18+
19+
#if defined(__cplusplus)
20+
21+
namespace Microsoft::Windows::Media::Capture
22+
{
23+
24+
__pragma(detect_mismatch("ODR_violation_WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_MEDIA_CAPTURE_FEATURE_CAMERACAPTUREUI_ENABLED_mismatch", "AlwaysEnabled"))
25+
struct Feature_CameraCaptureUI
26+
{
27+
static constexpr bool IsEnabled() { return WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_MEDIA_CAPTURE_FEATURE_CAMERACAPTUREUI_ENABLED == 1; }
28+
};
29+
30+
} // namespace Microsoft.Windows.Media.Capture
31+
32+
#endif // defined(__cplusplus)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<features xmlns="http://microsoft.com/windowsappsdk/TerminalVelocity/20210729/TerminalVelocityFeatures.xsd">
3+
4+
<!-- Copyright (c) Microsoft Corporation. All rights reserved.
5+
Licensed under the MIT License. See LICENSE in the project root for license information.
6+
-->
7+
8+
<!-- See docs/Coding-Guidelines/TerminalVelocity.md for more info. -->
9+
10+
<!-- Enabled variants -->
11+
<feature>
12+
<name>Feature_CameraCaptureUI</name>
13+
<description>CameraCaptureUI for the WindowsAppRuntime</description>
14+
<state>AlwaysEnabled</state>
15+
<alwaysDisabledChannelTokens>
16+
<channelToken>Preview</channelToken>
17+
<channelToken>Stable</channelToken>
18+
</alwaysDisabledChannelTokens>
19+
</feature>
20+
</features>

dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "CameraCaptureUIPhotoCaptureSettings.h"
66
#include "CameraCaptureUIVideoCaptureSettings.h"
77
#include "TelemetryHelper.h"
8-
8+
#include <TerminalVelocityFeatures-CameraCaptureUI.h>
99

1010
namespace winrt::Microsoft::Windows::Media::Capture::implementation
1111
{
@@ -20,6 +20,7 @@ namespace winrt::Microsoft::Windows::Media::Capture::implementation
2020
CameraCaptureUI(winrt::Microsoft::UI::WindowId const& windowId) :
2121
m_windowId(windowId)
2222
{
23+
THROW_HR_IF(E_NOTIMPL, !::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled());
2324
}
2425

2526
Microsoft::Windows::Media::Capture::CameraCaptureUIPhotoCaptureSettings PhotoSettings()

dev/Interop/CameraCaptureUI/CameraCaptureUI/CameraCaptureUI.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
#include <TerminalVelocityFeatures-CameraCaptureUI.h>
34

45
namespace Microsoft.Windows.Media.Capture
56
{
@@ -73,6 +74,7 @@ namespace Microsoft.Windows.Media.Capture
7374
}
7475

7576
[contract(CameraCaptureUIContract, 1)]
77+
[feature(Feature_CameraCaptureUI)]
7678
runtimeclass CameraCaptureUI
7779
{
7880
CameraCaptureUI(Microsoft.UI.WindowId windowId);

test/CameraCaptureUITests/APITests.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <mutex>
1010
#include <winrt/Windows.Storage.h>
1111
#include <winrt/Windows.Foundation.h>
12+
#include <TerminalVelocityFeatures-CameraCaptureUI.h>
1213

1314
using namespace std::chrono_literals;
1415
using namespace WEX::Common;
@@ -59,6 +60,11 @@ namespace CameraCaptureUITests
5960
// Focusing solely on functional tests for now.
6061
TEST_METHOD(CapturePhoto_ShouldReturnFile)
6162
{
63+
if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled())
64+
{
65+
Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled.");
66+
return;
67+
}
6268
try
6369
{
6470
auto parentWindow = ::GetForegroundWindow();
@@ -96,6 +102,11 @@ namespace CameraCaptureUITests
96102
}
97103
TEST_METHOD(VerifyRequestedPhotoFormatsAreReadCorrectly)
98104
{
105+
if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled())
106+
{
107+
Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled.");
108+
return;
109+
}
99110
// Arrange
100111
auto parentWindow = ::GetForegroundWindow();
101112
winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast<uint64_t>(parentWindow) };
@@ -117,6 +128,11 @@ namespace CameraCaptureUITests
117128

118129
TEST_METHOD(VerifyRequestedVideoFormatsAreReadCorrectly)
119130
{
131+
if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled())
132+
{
133+
Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled.");
134+
return;
135+
}
120136
// Arrange
121137
auto parentWindow = ::GetForegroundWindow();
122138
winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast<uint64_t>(parentWindow) };
@@ -132,6 +148,11 @@ namespace CameraCaptureUITests
132148
}
133149
TEST_METHOD(VerifyMaxVideoResolutionValues)
134150
{
151+
if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled())
152+
{
153+
Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled.");
154+
return;
155+
}
135156
// Arrange
136157
auto parentWindow = ::GetForegroundWindow();
137158
winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast<uint64_t>(parentWindow) };
@@ -156,6 +177,11 @@ namespace CameraCaptureUITests
156177

157178
TEST_METHOD(VerifyMaxPhotoResolutionValues)
158179
{
180+
if (!::Microsoft::Windows::Media::Capture::Feature_CameraCaptureUI::IsEnabled())
181+
{
182+
Log::Result(TestResults::Skipped, L"CameraCaptureUI API Features are not enabled.");
183+
return;
184+
}
159185
// Arrange
160186
auto parentWindow = ::GetForegroundWindow();
161187
winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast<uint64_t>(parentWindow) };

test/CameraCaptureUITests/CameraCaptureUITests.vcxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<ConformanceMode>true</ConformanceMode>
108108
<PrecompiledHeader>Use</PrecompiledHeader>
109109
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
110-
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
110+
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
111111
</ClCompile>
112112
<Link>
113113
<SubSystem>Windows</SubSystem>
@@ -125,7 +125,7 @@
125125
<ConformanceMode>true</ConformanceMode>
126126
<PrecompiledHeader>Use</PrecompiledHeader>
127127
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
128-
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
128+
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
129129
</ClCompile>
130130
<Link>
131131
<SubSystem>Windows</SubSystem>
@@ -143,7 +143,7 @@
143143
<ConformanceMode>true</ConformanceMode>
144144
<PrecompiledHeader>Use</PrecompiledHeader>
145145
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
146-
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
146+
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
147147
</ClCompile>
148148
<Link>
149149
<SubSystem>Windows</SubSystem>
@@ -161,7 +161,7 @@
161161
<ConformanceMode>true</ConformanceMode>
162162
<PrecompiledHeader>Use</PrecompiledHeader>
163163
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
164-
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
164+
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
165165
</ClCompile>
166166
<Link>
167167
<SubSystem>Windows</SubSystem>
@@ -179,7 +179,7 @@
179179
<ConformanceMode>true</ConformanceMode>
180180
<PrecompiledHeader>Use</PrecompiledHeader>
181181
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
182-
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
182+
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
183183
</ClCompile>
184184
<Link>
185185
<SubSystem>Windows</SubSystem>
@@ -197,7 +197,7 @@
197197
<ConformanceMode>true</ConformanceMode>
198198
<PrecompiledHeader>Use</PrecompiledHeader>
199199
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
200-
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\</AdditionalIncludeDirectories>
200+
<AdditionalIncludeDirectories>$(ProjectDir)..\inc;$(ProjectDir)..\..\dev\WindowsAppRuntime_BootstrapDLL\;$(MSBuildProjectDirectory)\..\..\dev\common</AdditionalIncludeDirectories>
201201
</ClCompile>
202202
<Link>
203203
<SubSystem>Windows</SubSystem>

0 commit comments

Comments
 (0)