Various bug fixes and build features to public samples (#203)

This commit is contained in:
Ori Levari 2019-03-26 13:48:39 -07:00 коммит произвёл GitHub
Родитель 835513da82
Коммит 796e4f91d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
26 изменённых файлов: 220 добавлений и 113 удалений

Просмотреть файл

@ -63,10 +63,12 @@ int main(int argc, char* argv[])
// user selects adapter
printf("Please enter the index of the adapter you want to use...\n");
int selectedIndex;
while (!(cin >> selectedIndex) || selectedIndex < 0 || selectedIndex >= static_cast<int>(validAdapters.size())) {
cin >> selectedIndex;
while (selectedIndex < 0 || selectedIndex >= static_cast<int>(validAdapters.size())) {
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
printf("Invalid index, please try again.\n");
cin >> selectedIndex;
}
printf("Selected adapter at index %d\n", selectedIndex);

Просмотреть файл

@ -163,8 +163,12 @@ void SaveOutputToDisk(
std::wstring outputPath = modulePath;
std::wstring filename{ TensorizationHelper::GetFileName() };
int32_t i = modulePath.find(filename);
if (i != std::wstring::npos) {
outputPath = outputPath.substr(0, i + wcslen(filename.c_str())) + L"\\" + filename + L"\\";
StorageFolder parentFolder = StorageFolder::GetFolderFromPathAsync(outputPath.substr(0, i + wcslen(filename.c_str()))).get();
if (parentFolder.TryGetItemAsync(filename).get() != nullptr) {
outputPath = outputPath.substr(0, i + wcslen(filename.c_str())) + L"\\" + filename + L"\\";
}
}
StorageFolder currentfolder = StorageFolder::GetFolderFromPathAsync(outputPath).get();

Просмотреть файл

@ -17,11 +17,11 @@
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>Emoji_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<PackageCertificateKeyFile>Emoji8_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Never</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<PackageCertificateThumbprint>319D19788E0D363D117116248BEB1C90C9C6B4F1</PackageCertificateThumbprint>
<PackageCertificateThumbprint>AEF8CDB5C6F65B590EC236F9692BB1BB89BEDA51</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
@ -129,8 +129,7 @@
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="cert.pfx" />
<None Include="Emoji_TemporaryKey.pfx" />
<None Include="Emoji8_TemporaryKey.pfx" />
<Content Include="Assets\emoji8.png" />
<Content Include="Assets\emoji8Small.png" />
<Content Include="Assets\LargeTile.scale-100.png" />

Двоичные данные
Samples/Emoji8/UWP/cs/Emoji8/Emoji8_TemporaryKey.pfx Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="Microsoft.Emoji8" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="1.0.29.0" />
<mp:PhoneIdentity PhoneProductId="b453530a-3933-419b-98d9-1b52e2b63bee" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Emoji8</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Emoji.App">
<uap:VisualElements DisplayName="Emoji8" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Emoji" BackgroundColor="white">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="white" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="webcam" />
</Capabilities>
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="Microsoft.Emoji8" Publisher="CN=winml" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="b453530a-3933-419b-98d9-1b52e2b63bee" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Emoji8</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Emoji.App">
<uap:VisualElements DisplayName="Emoji8" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Emoji" BackgroundColor="white">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="white" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="webcam" />
</Capabilities>
</Package>

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="257918C9-ABE3-483E-A202-C5C69AEBD825" Publisher="CN=winml" Version="1.1.36.0" />
<Identity Name="257918C9-ABE3-483E-A202-C5C69AEBD825" Publisher="CN=winml" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="3bd922b5-d779-4208-8c35-aec4dea61330" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Shortcut</DisplayName>

Просмотреть файл

@ -18,10 +18,13 @@
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>SnapCandy_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Never</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<PackageCertificateThumbprint>6D23597D1B6024B45E38A0762F178A76CE73B1B2</PackageCertificateThumbprint>
<PackageCertificateThumbprint>71864B33C72C34F3EC08C77989B2DE1D92E780A5</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>

Двоичные данные
Samples/FNSCandyStyleTransfer/UWP/cs/SnapCandy_TemporaryKey.pfx Normal file

Двоичный файл не отображается.

Двоичные данные
Samples/MNIST/Tutorial/cs/MNIST_Demo_TemporaryKey.pfx Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -18,9 +18,9 @@ Global
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|ARM.ActiveCfg = Debug|ARM
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|ARM.Build.0 = Debug|ARM
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|ARM.Deploy.0 = Debug|ARM
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x64.ActiveCfg = Debug|Win32
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x64.Build.0 = Debug|Win32
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x64.Deploy.0 = Debug|Win32
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x64.ActiveCfg = Debug|x64
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x64.Build.0 = Debug|x64
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x64.Deploy.0 = Debug|x64
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x86.ActiveCfg = Debug|Win32
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x86.Build.0 = Debug|Win32
{8B9EC025-3997-48E1-8670-07937D7856DB}.Debug|x86.Deploy.0 = Debug|Win32

Просмотреть файл

@ -98,6 +98,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<PackageCertificateKeyFile>mnist_cppcx_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>B23CBDBC47A77064D6E6EF69178D43BD014FC24D</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Never</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>

Двоичные данные
Samples/MNIST/UWP/cppcx/mnist_cppcx_TemporaryKey.pfx Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -18,6 +18,13 @@
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>MNIST_Demo_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>0C7693B440908EA43036A02969766F6388787EA2</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Never</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@ -138,6 +145,9 @@
<ItemGroup>
<Content Include="Assets\mnist.onnx" />
</ItemGroup>
<ItemGroup>
<None Include="MNIST_Demo_TemporaryKey.pfx" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>

Двоичные данные
Samples/MNIST/UWP/cs/MNIST_Demo_TemporaryKey.pfx Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="9B904DD1-22BF-4715-A2D3-B0F44457074A" Publisher="CN=winml" Version="1.0.2.0" />
<Identity Name="9B904DD1-22BF-4715-A2D3-B0F44457074A" Publisher="CN=winml" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="f8b38171-639a-4bbc-8ada-d45651bba59e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>SqueezeNetObjectDetection</DisplayName>

Просмотреть файл

@ -17,11 +17,11 @@
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>SqueezeNetObjectDetection_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<PackageCertificateKeyFile>SqueezeNetObjectDetectionCS_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Never</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<PackageCertificateThumbprint>14D57F74BF96CAD225E7582AB8131D29C691D591</PackageCertificateThumbprint>
<PackageCertificateThumbprint>8518A7FC71FAFB37AE8C7D3E7A8D84207B9A31F4</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
@ -148,6 +148,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="SqueezeNetObjectDetectionCS_TemporaryKey.pfx" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>

Двоичный файл не отображается.

Просмотреть файл

@ -52,7 +52,14 @@
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>$(VersionNumberMajor).$(VersionNumberMinor)</MinimumVisualStudioVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>SqueezeNetObjectDetection_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateKeyFile>SqueezeNetObjectDetectionJS_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>C3CF24DA639657EFA9A19E2696BD94C12C1E03C3</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Never</AppxBundle>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.appxmanifest">

Двоичный файл не отображается.

Просмотреть файл

@ -13,7 +13,7 @@ using OpenQA.Selenium.Remote;
// up to OpenQA.Selenium.Interactions and this alias can simply be removed.
using PointerInputDevice = OpenQA.Selenium.Appium.Interactions.PointerInputDevice;
namespace MnistTest
namespace SamplesTest
{
public class MnistSession
{
@ -27,15 +27,11 @@ namespace MnistTest
protected static WindowsElement clearButton;
protected static WindowsElement numberLabel;
public void Setup(string appid)
public void Setup(string appid, string name)
{
if (session == null)
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", appid);
appCapabilities.SetCapability("deviceName", "WindowsPC");
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Assert.IsNotNull(session);
session = TestHelper.GetSession(appid, name);
// Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
inkCanvas = session.FindElementByClassName("InkCanvas");
@ -243,12 +239,14 @@ namespace MnistTest
[TestClass]
public class MnistTestCSharp : MnistSession
{
private const string MNISTAppId_CS = "f330385a-7468-4688-859d-7d11a61d1b29_atz7ne7vp47fr!App";
private const string MNISTAppId_CS = "f330385a-7468-4688-859d-7d11a61d1b29_7td7jx2gva3r8!App";
private const string MNISTName_CS = "WinML_Demo";
[TestInitialize]
public void TestInitialize()
{
Setup(MNISTAppId_CS);
Setup(MNISTAppId_CS, MNISTName_CS);
}
[TestCleanup()]
@ -268,12 +266,13 @@ namespace MnistTest
[TestClass]
public class MnistTestCPPCX : MnistSession
{
private const string MNISTAppId_CPPCX = "7c575962-f37f-4240-a2ba-33fbf54c19f6_ms3keja78xfsy!App";
private const string MNISTAppId_CPPCX = "7c575962-f37f-4240-a2ba-33fbf54c19f6_7td7jx2gva3r8!App";
private const string MNISTName_CPPCX = "mnist_cppcx";
[TestInitialize]
public void TestInitialize()
{
Setup(MNISTAppId_CPPCX);
Setup(MNISTAppId_CPPCX, MNISTName_CPPCX);
}
[TestCleanup()]

Просмотреть файл

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("SamplesTest")]

Просмотреть файл

@ -82,6 +82,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StyleTransferTest.cs" />
<Compile Include="SqueezenetTest.cs" />
<Compile Include="TestHelper.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Appium.WebDriver">

Просмотреть файл

@ -17,23 +17,17 @@ namespace SamplesTest
{
public class SqueezenetSession
{
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
// This string key is present in RegisteredUserModeAppID under AppX/vs.appxrecipe
// TODO: this string value has to be retrieved from local test machine
// More information on https://github.com/Microsoft/WinAppDriver
private const string SqueezenetAppId = "9B904DD1-22BF-4715-A2D3-B0F44457074A_qzvbm97bn12kp!App";
private const string SqueezenetAppId = "9B904DD1-22BF-4715-A2D3-B0F44457074A_7td7jx2gva3r8!App";
protected static WindowsDriver<WindowsElement> session;
public static void Setup(TestContext context)
{
if (session == null)
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", SqueezenetAppId);
appCapabilities.SetCapability("deviceName", "WindowsPC");
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Assert.IsNotNull(session);
session = TestHelper.GetSession(SqueezenetAppId, "SqueezeNetObjectDetectionCS");
// Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
}

Просмотреть файл

@ -28,11 +28,10 @@ namespace SamplesTest
public class StyleTransferSession
{
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
// This string key is present in RegisteredUserModeAppID under AppX/vs.appxrecipe
// TODO: this string value has to be retrieved from local test machine
// More information on https://github.com/Microsoft/WinAppDriver
private const string StyleTransferAppId = "257918C9-ABE3-483E-A202-C5C69AEBD825_adth261zac3sy!App";
private const string StyleTransferAppId = "257918C9-ABE3-483E-A202-C5C69AEBD825_7td7jx2gva3r8!App";
protected static WindowsDriver<WindowsElement> session;
protected static WindowsElement resultImage;
@ -46,11 +45,7 @@ namespace SamplesTest
{
if (session == null)
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", StyleTransferAppId);
appCapabilities.SetCapability("deviceName", "WindowsPC");
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Assert.IsNotNull(session);
session = TestHelper.GetSession(StyleTransferAppId, "SnapCandy");
}
// wait for first style transfer to be done
Thread.Sleep(styleTransferTimeout);
@ -115,14 +110,17 @@ namespace SamplesTest
public void TestStyle(Style style)
{
styleElements[style].Click();
var cts = new CancellationTokenSource();
var cts = new CancellationTokenSource();
var stopwatch = new Stopwatch();
stopwatch.Start();
while (statusBlock.Text != "Done!" && stopwatch.ElapsedMilliseconds < styleTransferTimeout)
do
{
// ensures that the test waits a bit for the processing status block to show up
Thread.Sleep(500);
}
} while (statusBlock.Text != "Done!" && stopwatch.ElapsedMilliseconds < styleTransferTimeout);
stopwatch.Stop();
Assert.IsTrue(statusBlock.Text == "Done!", String.Format("{0} style timed out", style.ToString()));
@ -138,21 +136,37 @@ namespace SamplesTest
public void CompareImages(string resultPath, string baselinePath)
{
byte[] result = ImageToByteArray(resultPath);
byte[] expected = ImageToByteArray(baselinePath);
var maxPixelErrorsAllowed = 0.01; // maximum percentage of pixels allowed to be different
int pixelTolerance = 20; // minimum pixel value difference to mark two pixel as "different"
int numPixelErrors = 0;
for (int i = 0; i < result.Length; i++)
{
if (Math.Abs(result[i] - expected[i]) > pixelTolerance)
{
numPixelErrors++;
if ((numPixelErrors / (float)result.Length) > maxPixelErrorsAllowed)
{
Assert.Fail("the result is different from what's expected");
}
int numPixelErrors = 0;
Image resultImage = Image.FromFile(resultPath);
Image expectedImage = Image.FromFile(baselinePath);
Assert.AreEqual(resultImage.PixelFormat, expectedImage.PixelFormat);
Bitmap result = new Bitmap(resultPath, false); ;
Bitmap expected = new Bitmap(baselinePath, false);
Assert.AreEqual(result.Width, expected.Width);
Assert.AreEqual(result.Height, expected.Height);
for (int x = 0; x < result.Width; x++)
{
for (int y = 0; y < result.Height; y++)
{
Color resultPixel = result.GetPixel(x, y);
Color expectedPixel = expected.GetPixel(x, y);
int redDifference = Math.Abs(resultPixel.R - expectedPixel.R);
int greenDifference = Math.Abs(resultPixel.G - expectedPixel.G);
int blueDifference = Math.Abs(resultPixel.B - expectedPixel.B);
if (redDifference + greenDifference + blueDifference > pixelTolerance)
{
numPixelErrors++;
if (((float)numPixelErrors / ((float)result.Width * result.Height)) > maxPixelErrorsAllowed)
{
Assert.Fail("the result is different from what's expected");
}
}
}
}
}
@ -164,5 +178,7 @@ namespace SamplesTest
img.Save(ms, img.RawFormat);
return ms.ToArray();
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Remote;
namespace SamplesTest
{
class TestHelper
{
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
public static WindowsDriver<WindowsElement> GetSession(String appid, String name)
{
WindowsDriver<WindowsElement> session;
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", appid);
appCapabilities.SetCapability("deviceName", "WindowsPC");
try
{
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
}
catch (System.InvalidOperationException)
{
// get desktop session
DesiredCapabilities desktopAppCapabilities = new DesiredCapabilities();
desktopAppCapabilities.SetCapability("app", "Root");
WindowsDriver<WindowsElement> desktopSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), desktopAppCapabilities);
// use desktop session to locate existing app session
WindowsElement appWindow = desktopSession.FindElementByName(name);
String topLevelWindowHandle = appWindow.GetAttribute("NativeWindowHandle");
topLevelWindowHandle = (int.Parse(topLevelWindowHandle)).ToString("x");
appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("appTopLevelWindow", topLevelWindowHandle);
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
}
Assert.IsNotNull(session);
return session;
}
}
}

Просмотреть файл

@ -4,9 +4,7 @@
clean: true
variables:
SamplesBin: SamplesBin
system.debug: false
WINDOWS_WINMD: C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\Windows.winmd
strategy:
@ -25,6 +23,10 @@ strategy:
BuildPlatform: x86
BuildConfiguration: Debug
pool:
name: Package ES CodeHub Lab E
# demands: agent.osversion -equals 10.0.17763
# CI trigger
trigger:
branches:
@ -67,11 +69,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build UI test solution winml/samples/public/WinMLGithub/Testing/**/SamplesTest.sln'
displayName: 'Build UI test solution Testing/**/SamplesTest.sln'
inputs:
solution: 'Testing/**/SamplesTest.sln'
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\SamplesTest\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\SamplesTest\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -80,11 +82,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build AdapterSelection Sample '
displayName: 'Build AdapterSelection Sample'
inputs:
solution: Samples/AdapterSelection/AdapterSelection.sln
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\AdapterSelection\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\AdapterSelection\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -93,11 +95,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build CustomOperatorCPU Sample '
displayName: 'Build CustomOperatorCPU Sample'
inputs:
solution: Samples/CustomOperatorCPU/desktop/cpp/custom-operator-cpu-sample.sln
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\CustomOperatorCPU\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\CustomOperatorCPU\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -107,11 +109,11 @@ steps:
- task: VSBuild@1
displayName: 'Build MNIST-Tutorial-cs'
displayName: 'Build MNIST-Tutorial-cs Sample'
inputs:
solution: 'Samples/MNIST/Tutorial/cs/mnist_demo.sln'
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\MNIST-Tutorial\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\MNIST-Tutorial\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -120,11 +122,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build MNIST-UWP-cs'
displayName: 'Build MNIST-UWP-cs Sample'
inputs:
solution: 'Samples/MNIST/UWP/cs/mnist_demo.sln'
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\MNIST-cs\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\MNIST-cs\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -133,11 +135,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build SqueezenetObjectDetection'
displayName: 'Build SqueezenetObjectDetection Sample'
inputs:
solution: Samples/SqueezeNetObjectDetection/squeezenetobjectdetection.sln
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\SqueezeNetObjectDetection\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\SqueezeNetObjectDetection\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -146,11 +148,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build FNSCandyStyleTransfer-UWP-CS'
displayName: 'Build FNSCandyStyleTransfer-UWP-CS Sample'
inputs:
solution: Samples/FNSCandyStyleTransfer/UWP/CS/snapcandy.sln
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\FNSCandyStyleTransfer\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\FNSCandyStyleTransfer\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -159,11 +161,11 @@ steps:
condition: succeededOrFailed()
- task: VSBuild@1
displayName: 'Build MNIST-UWP-cppcx '
displayName: 'Build MNIST-UWP-cppcx Sample'
inputs:
solution: 'Samples/MNIST/UWP/cppcx/mnist_cppcx.sln'
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\MNIST-cppcx\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\MNIST-cppcx\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -176,7 +178,7 @@ steps:
inputs:
solution: Samples/CustomTensorization/CustomTensorization.sln
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\CustomTensorization\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\CustomTensorization\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -189,7 +191,7 @@ steps:
inputs:
solution: Samples/Emoji8/UWP/cs/Emoji8.sln
vsVersion: 15.0
msbuildArgs: '/p:AppxPackageSigningEnabled=false -v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\Emoji8\'
msbuildArgs: '-v:diag /p:OutDir=$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\Emoji8\'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
@ -201,8 +203,28 @@ steps:
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)\$(BuildPlatform)\$(BuildConfiguration)\'
sourceFolder: '$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\'
Contents: |
**\SamplesTest\**
**\AppPackages\**
condition: succeededOrFailed()
- task: CopyFiles@2
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)\$(BuildPlatform)\$(BuildConfiguration)\'
sourceFolder: '$(System.DefaultWorkingDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)\'
Contents: |
?(AdapterSelection|CustomOperatorCPU|CustomTensorization)**\*
SqueezeNetObjectDetection\*
condition: succeededOrFailed()
- task: CopyFiles@2
inputs:
targetFolder: '$(Build.ArtifactStagingDirectory)\$(BuildPlatform)\$(BuildConfiguration)\SharedContent'
sourceFolder: 'SharedContent'
contents: '**\*'
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: Samples'
inputs: