mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Packaged apps test (#4921)
* Added wrapper for PackageManager and Package class * Added tests for package in development and framework mode * Renamed UWP test file * Improved readability of UWP tests
This commit is contained in:
committed by
GitHub
parent
ec803d63c8
commit
653ae777d5
@@ -0,0 +1,50 @@
|
||||
<?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 build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
|
||||
<Identity Name="3b548ab3-3034-4edf-a625-4691c73b43a9" Publisher="CN=divyan" Version="1.0.0.0" ProcessorArchitecture="x86" />
|
||||
<mp:PhoneIdentity PhoneProductId="3b548ab3-3034-4edf-a625-4691c73b43a9" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>DevelopmentApp</DisplayName>
|
||||
<PublisherDisplayName>divyan</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.18362.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27810.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.NET.CoreRuntime.2.2" MinVersion="2.2.27902.3" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.NET.CoreFramework.Debug.2.2" MinVersion="2.2.27909.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="EN-US" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="DevelopmentApp.exe" EntryPoint="DevelopmentApp.App">
|
||||
<uap:VisualElements DisplayName="DevelopmentApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="DevelopmentApp" BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
<Extensions>
|
||||
<Extension Category="windows.activatableClass.inProcessServer">
|
||||
<InProcessServer>
|
||||
<Path>DevelopmentApp.exe</Path>
|
||||
<ActivatableClass ActivatableClassId="Microsoft.UI.Xaml.Markup.ReflectionXamlMetadataProvider" ThreadingModel="both" />
|
||||
</InProcessServer>
|
||||
</Extension>
|
||||
</Extensions>
|
||||
<build:Metadata>
|
||||
<build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0" />
|
||||
<build:Item Name="VisualStudio" Version="16.0" />
|
||||
<build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Enterprise 2019" />
|
||||
<build:Item Name="OperatingSystem" Version="10.0.18362.1 (WinBuild.160101.0800)" />
|
||||
<build:Item Name="Microsoft.Build.AppxPackage.dll" Version="16.0.30009.100" />
|
||||
<build:Item Name="ProjectGUID" Value="{A995B1F6-B462-4CC0-8E7F-3C9A9354A700}" />
|
||||
<build:Item Name="OptimizingToolset" Value="None" />
|
||||
<build:Item Name="TargetRuntime" Value="Managed" />
|
||||
<build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="10.0.18362.1" />
|
||||
<build:Item Name="MakePri.exe" Version="10.0.18362.1 (WinBuild.160101.0800)" />
|
||||
</build:Metadata>
|
||||
</Package>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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 build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
|
||||
<Identity Name="3b548ab3-3034-4edf-a625-4691c73b43a9" Publisher="CN=divyan" Version="1.0.0.0" ProcessorArchitecture="x86" />
|
||||
<mp:PhoneIdentity PhoneProductId="3b548ab3-3034-4edf-a625-4691c73b43a9" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>FrameworkApp</DisplayName>
|
||||
<PublisherDisplayName>divyan</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.18362.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27810.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.NET.CoreRuntime.2.2" MinVersion="2.2.27902.3" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.NET.CoreFramework.Debug.2.2" MinVersion="2.2.27909.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="EN-US" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="FrameworkApp.exe" EntryPoint="FrameworkApp.App">
|
||||
<uap:VisualElements DisplayName="FrameworkApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="FrameworkApp" BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
<Extensions>
|
||||
<Extension Category="windows.activatableClass.inProcessServer">
|
||||
<InProcessServer>
|
||||
<Path>FrameworkApp.exe</Path>
|
||||
<ActivatableClass ActivatableClassId="Microsoft.UI.Xaml.Markup.ReflectionXamlMetadataProvider" ThreadingModel="both" />
|
||||
</InProcessServer>
|
||||
</Extension>
|
||||
</Extensions>
|
||||
<build:Metadata>
|
||||
<build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0" />
|
||||
<build:Item Name="VisualStudio" Version="16.0" />
|
||||
<build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Enterprise 2019" />
|
||||
<build:Item Name="OperatingSystem" Version="10.0.18362.1 (WinBuild.160101.0800)" />
|
||||
<build:Item Name="Microsoft.Build.AppxPackage.dll" Version="16.0.30009.100" />
|
||||
<build:Item Name="ProjectGUID" Value="{A995B1F6-B462-4CC0-8E7F-3C9A9354A700}" />
|
||||
<build:Item Name="OptimizingToolset" Value="None" />
|
||||
<build:Item Name="TargetRuntime" Value="Managed" />
|
||||
<build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="10.0.18362.1" />
|
||||
<build:Item Name="MakePri.exe" Version="10.0.18362.1 (WinBuild.160101.0800)" />
|
||||
</build:Metadata>
|
||||
</Package>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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 build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
|
||||
<Identity Name="3b548ab3-3034-4edf-a625-4691c73b43a9" Publisher="CN=divyan" Version="1.0.0.0" ProcessorArchitecture="x86" />
|
||||
<mp:PhoneIdentity PhoneProductId="3b548ab3-3034-4edf-a625-4691c73b43a9" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>PackagedApp</DisplayName>
|
||||
<PublisherDisplayName>divyan</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.18362.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27810.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.NET.CoreRuntime.2.2" MinVersion="2.2.27902.3" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.NET.CoreFramework.Debug.2.2" MinVersion="2.2.27909.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="EN-US" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="PackagedApp.exe" EntryPoint="PackagedApp.App">
|
||||
<uap:VisualElements DisplayName="PackagedApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="PackagedApp" BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
<Extensions>
|
||||
<Extension Category="windows.activatableClass.inProcessServer">
|
||||
<InProcessServer>
|
||||
<Path>PackagedApp.exe</Path>
|
||||
<ActivatableClass ActivatableClassId="Microsoft.UI.Xaml.Markup.ReflectionXamlMetadataProvider" ThreadingModel="both" />
|
||||
</InProcessServer>
|
||||
</Extension>
|
||||
</Extensions>
|
||||
<build:Metadata>
|
||||
<build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0" />
|
||||
<build:Item Name="VisualStudio" Version="16.0" />
|
||||
<build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Enterprise 2019" />
|
||||
<build:Item Name="OperatingSystem" Version="10.0.18362.1 (WinBuild.160101.0800)" />
|
||||
<build:Item Name="Microsoft.Build.AppxPackage.dll" Version="16.0.30009.100" />
|
||||
<build:Item Name="ProjectGUID" Value="{A995B1F6-B462-4CC0-8E7F-3C9A9354A700}" />
|
||||
<build:Item Name="OptimizingToolset" Value="None" />
|
||||
<build:Item Name="TargetRuntime" Value="Managed" />
|
||||
<build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="10.0.18362.1" />
|
||||
<build:Item Name="MakePri.exe" Version="10.0.18362.1 (WinBuild.160101.0800)" />
|
||||
</build:Metadata>
|
||||
</Package>
|
||||
@@ -6,6 +6,8 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<Platforms>x64</Platforms>
|
||||
|
||||
<ApplicationManifest>AppxManifests\developmentApp\AppxManifest.xml</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -23,4 +25,16 @@
|
||||
<ProjectReference Include="..\Microsoft.Plugin.Program\Microsoft.Plugin.Program.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="AppxManifests\DevelopmentApp\AppxManifest.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="AppxManifests\FrameworkApp\AppxManifest.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="AppxManifests\PackagedApp\AppxManifest.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using Castle.Core.Internal;
|
||||
using Microsoft.Plugin.Program.Programs;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
{
|
||||
[TestFixture]
|
||||
class UWPTests
|
||||
{
|
||||
static readonly PackageWrapper developmentModeApp = new PackageWrapper(
|
||||
"DevelopmentApp",
|
||||
"DevelopmentApp",
|
||||
"DevelopmentApp",
|
||||
false,
|
||||
true,
|
||||
"AppxManifests/DevelopmentApp"
|
||||
);
|
||||
|
||||
static readonly PackageWrapper frameworkApp = new PackageWrapper(
|
||||
"FrameworkApp",
|
||||
"FrameworkApp",
|
||||
"FrameworkApp",
|
||||
true,
|
||||
false,
|
||||
"AppxManifests/FrameworkApp"
|
||||
);
|
||||
|
||||
static readonly PackageWrapper packagedApp = new PackageWrapper(
|
||||
"PackagedApp",
|
||||
"PackagedApp",
|
||||
"PackagedApp",
|
||||
false,
|
||||
false,
|
||||
"AppxManifests/PackagedApp"
|
||||
);
|
||||
|
||||
[Test]
|
||||
public void All_ShouldReturnPackagesWithDevelopmentMode_WhenCalled()
|
||||
{
|
||||
// Arrange
|
||||
Main._settings = new Settings();
|
||||
List<IPackage> packages = new List<IPackage>() { developmentModeApp, packagedApp };
|
||||
var mock = new Mock<IPackageManager>();
|
||||
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
||||
UWP.PackageManagerWrapper = mock.Object;
|
||||
|
||||
// Act
|
||||
var applications = UWP.All();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(applications.Length, 2);
|
||||
Assert.IsTrue(applications.FindAll(x => x.Name == "DevelopmentApp").Length > 0);
|
||||
Assert.IsTrue(applications.FindAll(x => x.Name == "PackagedApp").Length > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void All_ShouldNotReturnPackageFrameworks_WhenCalled()
|
||||
{
|
||||
// Arrange
|
||||
Main._settings = new Settings();
|
||||
List<IPackage> packages = new List<IPackage>() { frameworkApp, packagedApp };
|
||||
var mock = new Mock<IPackageManager>();
|
||||
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
||||
UWP.PackageManagerWrapper = mock.Object;
|
||||
|
||||
// Act
|
||||
var applications = UWP.All();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(applications.Length, 1);
|
||||
Assert.IsTrue(applications.FindAll(x => x.Name == "PackagedApp").Length > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user