PackageDeploymentManager: IsReadyOrNewerAvailable(), FrameworkUdk update, Implement not-implemented functions, Tests! (#4453)

This PR does multiple things

* Add Is*ReadyOrNewerAvailable*()
* Add EnsureReadyOptions.RegisterNewerIfAvailable=bool
* Add Is*Provisioned*()
* Fix progress updates when PackageSet.Items.Count>=2 (was (re)set to 0-1.0 for each item, not collectively for the whole operation)
* Update to recent FrameworkUdk
* Implement previously not-implemented functions (Remove, Repair, Reset)
* Expanded test coverage
* Update TAEF to 10.92.240405002
* DevCheck
  * Added -InstallWindowsSDK option to install Windows (Platform) SDK if desired
  * Fix DevUnlock check on a machine w/o DeveloperMode enabled (last registry access doing registry access the unsafe way error'ing if the value doesn't exist in the registry)

KNOWN ISSUES:
* Need updated Platform SDK to resolve known issues
* Register*Async() errors on 20H2/Vb3.
* Reset*Async() succeeds but ends w/o the package being registered
* RemovePackageByUriAsync() throws E_NOTIMPL
* RemovePackageSetAsync() throws E_NOTIMPL if PackageUri=ms-uup
* Provision*Async() not supported yet
* Deprovision*Async() not supported yet

https://task.ms/49555034
https://task.ms/48914090
https://task.ms/48964562

Additional changes

* Fixed progress reporting incorrect .progress percentage values
* Added StringToSid() and SidToString()
* Refactored common code into WaitForDeploymentOperation
* Added IsPackageRegistrationPending. Removed dead code. Added Black+Blacker test Main packages.
* Added PackageFamilyName() property to PackageIdentity
* Added IsPackageDeploymentFeatureSupported and initial support for Containment.
* Fixed RemovePackageOptions.FailIfNotFound.
* Improved logging
* Expanded tests.
* Fixed RemovePackageOptions.FailIfNotFound default (was true, supposed to be false). Mostly implemented RemovePackageSetAsync; URI handling is blocked awaiting FrameworkUdk update (imminent).
* Updated to latest FrameworkUdk
* Patched tests to deal with RemovePackage is awaiting updated Platform SDK
* Removed dead code. Updated some not-impl to impl :-)
* Repair!
* Added IsProvisioned
* Added Provisioning tests and support
* Added Deprovision tests (in progress).
* Optimized test code
* Upgraded TAEF to 10.92.240405002
* Tweak build logic to support Windows SDK 10.0.26100.0 but not fail if using 10.0.22621.0
* Tweaked SDK detection
* Fixed some URI handling
* DevCheck:
* Add docs re PackageSet properties
* Added workaround for tests not wired to work on 20H2/Vb
This commit is contained in:
Howard Kapustein 2024-06-25 13:52:25 -07:00 коммит произвёл GitHub
Родитель 6eb39eafc2
Коммит c6c2234d53
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
136 изменённых файлов: 14399 добавлений и 2605 удалений

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

@ -461,9 +461,13 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManagerTests", "test\PackageManager\API\PackageManagerTests.vcxproj", "{4A38CB80-3580-4960-9B31-3301058B7AFE}"
ProjectSection(ProjectDependencies) = postProject
{09DDAE21-397F-4263-8561-7F2FF28127CF} = {09DDAE21-397F-4263-8561-7F2FF28127CF}
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF} = {28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA} = {39277B4C-4FB5-45F6-B0AA-EE8086590CDA}
{4626E11F-A7A4-41A2-B22D-5A108BC369AC} = {4626E11F-A7A4-41A2-B22D-5A108BC369AC}
{58E95711-A12F-4C0E-A978-C6B4A0842AC8} = {58E95711-A12F-4C0E-A978-C6B4A0842AC8}
{66D0D8B1-FAF4-4C6A-8303-07F3BA356FE3} = {66D0D8B1-FAF4-4C6A-8303-07F3BA356FE3}
{AC79B8FF-4C27-4326-AD20-BBC70059FF51} = {AC79B8FF-4C27-4326-AD20-BBC70059FF51}
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D} = {AD7D0A19-44B9-41D6-A68A-9FECAC28078D}
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
{D0A1DFB8-8CEE-4CFC-B57B-B7C574B411C2} = {D0A1DFB8-8CEE-4CFC-B57B-B7C574B411C2}
{F2946790-DAF7-4DFF-A754-BA471A12E494} = {F2946790-DAF7-4DFF-A754-BA471A12E494}
@ -493,6 +497,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.Managemen
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManager.Test.M.Black.msix", "PackageManager.Test.M.Black.msix", "{1AC589D7-FA54-470E-8640-AB2477CA844C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManager.Test.M.Blacker.msix", "PackageManager.Test.M.Blacker.msix", "{4567CD12-A0A7-4E65-8075-B17C09261767}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManager.Test.M.Black.msix", "test\PackageManager\data\PackageManager.Test.M.Black.msix\PackageManager.Test.M.Black.msix.vcxproj", "{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManager.Test.M.Blacker.msix", "test\PackageManager\data\PackageManager.Test.M.Blacker.msix\PackageManager.Test.M.Blacker.msix.vcxproj", "{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManager.Test.M.White.msix", "PackageManager.Test.M.White.msix", "{6759ECC6-9381-4172-89E6-853F81A03D28}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManager.Test.M.Whiter.msix", "PackageManager.Test.M.Whiter.msix", "{7C240089-0F22-4247-9C91-51255C8DC18B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManager.Test.M.Whiter.msix", "test\PackageManager\data\PackageManager.Test.M.Whiter.msix\PackageManager.Test.M.Whiter.msix.vcxproj", "{AC79B8FF-4C27-4326-AD20-BBC70059FF51}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManager.Test.M.White.msix", "test\PackageManager\data\PackageManager.Test.M.White.msix\PackageManager.Test.M.White.msix.vcxproj", "{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1739,6 +1759,70 @@ Global
{57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x64.Build.0 = Release|x64
{57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x86.ActiveCfg = Release|x86
{57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x86.Build.0 = Release|x86
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|Any CPU.ActiveCfg = Debug|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|Any CPU.Build.0 = Debug|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|ARM64.ActiveCfg = Debug|ARM64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|ARM64.Build.0 = Debug|ARM64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|x64.ActiveCfg = Debug|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|x64.Build.0 = Debug|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|x86.ActiveCfg = Debug|Win32
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Debug|x86.Build.0 = Debug|Win32
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|Any CPU.ActiveCfg = Release|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|Any CPU.Build.0 = Release|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|ARM64.ActiveCfg = Release|ARM64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|ARM64.Build.0 = Release|ARM64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|x64.ActiveCfg = Release|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|x64.Build.0 = Release|x64
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|x86.ActiveCfg = Release|Win32
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA}.Release|x86.Build.0 = Release|Win32
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|Any CPU.ActiveCfg = Debug|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|Any CPU.Build.0 = Debug|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|ARM64.Build.0 = Debug|ARM64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|x64.ActiveCfg = Debug|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|x64.Build.0 = Debug|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|x86.ActiveCfg = Debug|Win32
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Debug|x86.Build.0 = Debug|Win32
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|Any CPU.ActiveCfg = Release|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|Any CPU.Build.0 = Release|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|ARM64.ActiveCfg = Release|ARM64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|ARM64.Build.0 = Release|ARM64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|x64.ActiveCfg = Release|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|x64.Build.0 = Release|x64
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|x86.ActiveCfg = Release|Win32
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D}.Release|x86.Build.0 = Release|Win32
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|Any CPU.ActiveCfg = Debug|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|Any CPU.Build.0 = Debug|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|ARM64.ActiveCfg = Debug|ARM64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|ARM64.Build.0 = Debug|ARM64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|x64.ActiveCfg = Debug|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|x64.Build.0 = Debug|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|x86.ActiveCfg = Debug|Win32
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Debug|x86.Build.0 = Debug|Win32
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|Any CPU.ActiveCfg = Release|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|Any CPU.Build.0 = Release|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|ARM64.ActiveCfg = Release|ARM64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|ARM64.Build.0 = Release|ARM64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|x64.ActiveCfg = Release|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|x64.Build.0 = Release|x64
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|x86.ActiveCfg = Release|Win32
{AC79B8FF-4C27-4326-AD20-BBC70059FF51}.Release|x86.Build.0 = Release|Win32
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|Any CPU.ActiveCfg = Debug|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|Any CPU.Build.0 = Debug|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|ARM64.ActiveCfg = Debug|ARM64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|ARM64.Build.0 = Debug|ARM64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|x64.ActiveCfg = Debug|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|x64.Build.0 = Debug|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|x86.ActiveCfg = Debug|Win32
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Debug|x86.Build.0 = Debug|Win32
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|Any CPU.ActiveCfg = Release|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|Any CPU.Build.0 = Release|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|ARM64.ActiveCfg = Release|ARM64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|ARM64.Build.0 = Release|ARM64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x64.ActiveCfg = Release|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x64.Build.0 = Release|x64
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x86.ActiveCfg = Release|Win32
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1885,9 +1969,17 @@ Global
{4626E11F-A7A4-41A2-B22D-5A108BC369AC} = {266AE21F-0D59-4422-A95C-4B3D2BA32A4C}
{39A17DBB-F1DB-4D0C-B90E-D5F9BEC2283A} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E}
{FBAE1876-C50A-4EFC-A686-3008B6438731} = {39A17DBB-F1DB-4D0C-B90E-D5F9BEC2283A}
{B6B68924-6A0B-457E-AD53-018696EC8889} = {B03C7C69-0A52-4553-B465-04C995161E42}
{B6B68924-6A0B-457E-AD53-018696EC8889} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E}
{D0A1DFB8-8CEE-4CFC-B57B-B7C574B411C2} = {B6B68924-6A0B-457E-AD53-018696EC8889}
{57E6CCBE-EDEB-4300-8334-98A591D11B3F} = {716C26A0-E6B0-4981-8412-D14A4D410531}
{1AC589D7-FA54-470E-8640-AB2477CA844C} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E}
{4567CD12-A0A7-4E65-8075-B17C09261767} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E}
{39277B4C-4FB5-45F6-B0AA-EE8086590CDA} = {1AC589D7-FA54-470E-8640-AB2477CA844C}
{AD7D0A19-44B9-41D6-A68A-9FECAC28078D} = {4567CD12-A0A7-4E65-8075-B17C09261767}
{6759ECC6-9381-4172-89E6-853F81A03D28} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E}
{7C240089-0F22-4247-9C91-51255C8DC18B} = {6213B1A3-E854-498F-AAFA-4CFC1E71023E}
{AC79B8FF-4C27-4326-AD20-BBC70059FF51} = {7C240089-0F22-4247-9C91-51255C8DC18B}
{28DCF9CE-D9F4-4A7D-8AD1-F2EFC0D3B4DF} = {6759ECC6-9381-4172-89E6-853F81A03D28}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}

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

@ -372,6 +372,14 @@ public:
return m_packageId->publisherId;
}
std::wstring PackageFamilyName() const
{
WCHAR packageFamilyName[PACKAGE_FAMILY_NAME_MAX_LENGTH + 1]{};
UINT32 packageFamilyNameLength{ ARRAYSIZE(packageFamilyName) };
THROW_IF_WIN32_ERROR_MSG(::PackageFamilyNameFromId(m_packageId, &packageFamilyNameLength, packageFamilyName), "%ls", m_packageFullName.c_str());
return packageFamilyName;
}
explicit operator bool() const
{
return m_packageId != nullptr;
@ -384,6 +392,15 @@ private:
PACKAGE_RESOURCEID_MAX_LENGTH + 1 +
PACKAGE_PUBLISHERID_MAX_LENGTH + 1) * sizeof(WCHAR)]{};
};
template<typename T>
T ToPackageFamilyName(PCWSTR packageFullName)
{
WCHAR packageFamilyName[PACKAGE_FAMILY_NAME_MAX_LENGTH + 1]{};
UINT32 packageFamilyNameLength{ ARRAYSIZE(packageFamilyName) };
THROW_IF_WIN32_ERROR_MSG(::PackageFamilyNameFromFullName(packageFullName, &packageFamilyNameLength, packageFamilyName), "%ls", packageFullName);
return T{ packageFamilyName };
}
}
#endif // __APPMODEL_IDENTITY_H

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

@ -55,7 +55,7 @@ inline bool IsWindows11_22H2OrGreater()
inline bool IsWindows11_23H1OrGreater()
{
// TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 23H1)
return IsExportPresent(L"api-ms-win-appmodel-runtime-l1-1-7.dll", "TryCreatePackageDependency2");
return IsExportPresent(L"kernelbase.dll", "TryCreatePackageDependency2");
}
}

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

@ -18,6 +18,32 @@ inline bool IsLocalSystem(HANDLE token = nullptr)
return !!EqualSid(userSid, localSystemSid);
}
/// @return sid. Allocated via LocalAlloc; use LocalFree to deallocate
inline PSID StringToSid(PCWSTR sidString)
{
if (!sidString || (sidString[0] == L'\0'))
{
return nullptr;
}
PSID sid{};
THROW_IF_WIN32_BOOL_FALSE(::ConvertStringSidToSidW(sidString, &sid));
return sid;
}
/// @return sid as a string. Allocated via LocalAlloc; use LocalFree to deallocate
inline PWSTR SidToString(PSID sid)
{
if (!sid)
{
return nullptr;
}
PWSTR sidString{};
THROW_IF_WIN32_BOOL_FALSE(::ConvertSidToStringSidW(sid, &sidString));
return sidString;
}
}
#endif // __SECURITY_USER_H

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

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include <pch.h>
@ -403,7 +403,7 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
HRESULT deploymentOperationHResult{};
HRESULT deploymentOperationExtendedHResult{};
if (deploymentOperation.Status() != AsyncStatus::Completed)
if (deploymentOperation.Status() != winrt::Windows::Foundation::AsyncStatus::Completed)
{
deploymentOperationHResult = static_cast<HRESULT>(deploymentOperation.ErrorCode());
deploymentOperationExtendedHResult = deploymentResult.ExtendedErrorCode();

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

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
</packages>

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

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="net45" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="net45" />
</packages>

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
</packages>

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

@ -14,4 +14,12 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
{
return m_addPackageOptions;
}
bool EnsureReadyOptions::RegisterNewerIfAvailable()
{
return m_registerNewerIfAvailable;
}
void EnsureReadyOptions::RegisterNewerIfAvailable(bool value)
{
m_registerNewerIfAvailable = value;
}
}

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

@ -12,8 +12,11 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
EnsureReadyOptions() = default;
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions AddPackageOptions();
bool RegisterNewerIfAvailable();
void RegisterNewerIfAvailable(bool value);
private:
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions m_addPackageOptions{};
bool m_registerNewerIfAvailable{};
};
}
namespace winrt::Microsoft::Windows::Management::Deployment::factory_implementation

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -10,9 +10,16 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
struct PackageDeploymentManager : PackageDeploymentManagerT<PackageDeploymentManager>
{
static winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager GetDefault();
static bool IsPackageDeploymentFeatureSupported(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature feature);
private:
static bool IsPackageDeploymentFeatureSupported(PCWSTR feature);
public:
bool IsPackageReady(hstring const& package);
bool IsPackageReadyByUri(winrt::Windows::Foundation::Uri const& packageUri);
bool IsPackageSetReady(winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet);
winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus IsPackageReadyOrNewerAvailable(hstring const& package);
winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus IsPackageReadyOrNewerAvailableByUri(winrt::Windows::Foundation::Uri const& packageUri);
winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus IsPackageSetReadyOrNewerAvailable(winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> EnsurePackageReadyAsync(hstring package, winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> EnsurePackageReadyByUriAsync(winrt::Windows::Foundation::Uri packageUri, winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> EnsurePackageSetReadyAsync(winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet, winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options);
@ -36,14 +43,20 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> RepairPackageAsync(hstring package);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> RepairPackageByUriAsync(winrt::Windows::Foundation::Uri packageUri);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> RepairPackageSetAsync(winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet);
bool IsPackageProvisioned(hstring const& package);
bool IsPackageProvisionedByUri(winrt::Windows::Foundation::Uri const& packageUri);
bool IsPackageSetProvisioned(winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> ProvisionPackageAsync(hstring package, winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> ProvisionPackageByUriAsync(winrt::Windows::Foundation::Uri packageUri, winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> ProvisionPackageSetAsync(winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet, winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> DeprovisionPackageAsync(hstring package);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> DeprovisionPackageByUriAsync(winrt::Windows::Foundation::Uri packageUri);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> DeprovisionPackageSetAsync(winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet);
bool IsPackageRegistrationPending(hstring const& packageFamilyName);
bool IsPackageRegistrationPendingForUser(hstring const& userSecurityId, hstring const& packageFamilyName);
bool IsPackageRegistrationPending(hstring const& packageFullName);
bool IsPackageRegistrationPendingForUser(hstring const& userSecurityId, hstring const& packageFullName);
private:
bool IsPackageRegistrationPendingForUser(PSID userSid, PCWSTR packageFullName);
private:
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> AddPackageByAppInstallerFileAsync(winrt::Windows::Foundation::Uri packageUri, winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options);
@ -51,23 +64,44 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> RegisterPackageByPackageFullNameAsync(winrt::hstring const& packageFullName, winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options);
private:
winrt::hstring GetUupProductIdIfMsUup(winrt::Windows::Foundation::Uri const& uri) const;
wil::unique_cotaskmem_array_ptr<wil::unique_cotaskmem_string> GetPackageFullNamesFromUupProductUriIfMsUup(winrt::Windows::Foundation::Uri const& uri) const;
bool IsReadyByPackageFullName(hstring const& packageFullName);
bool IsReady(winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSet);
void Validate(winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet) const;
void Validate(winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem) const;
bool IsReady(winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus IsReadyOrNewerAvailableByPackageFullName(hstring const& packageFullName);
winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus IsReadyOrNewerAvailable(winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem);
void Validate_PackageUriIsRequired(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet) const;
void Validate_PackageUriIsOptional(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet) const;
void _Validate(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet,
const bool packageUriIsRequired) const;
void _Validate(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet,
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem,
const bool packageUriIsRequired) const;
void Validate_PackageUriOrFamilyName(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet) const;
void Validate_PackageUriOrFamilyName(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet,
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem) const;
HRESULT EnsureReadyAsync(
winrt::Windows::Foundation::Uri const& packageUri,
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem,
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageSetItem,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT AddPackage(
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem,
winrt::Windows::Foundation::Uri const& packageUri,
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageSetItem,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
@ -76,14 +110,16 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Windows::Management::Deployment::AddPackageOptions const& addOptions,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT StagePackage(
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem,
winrt::Windows::Foundation::Uri const& packageUri,
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageSetItem,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
@ -92,14 +128,16 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Windows::Management::Deployment::StagePackageOptions const& stageOptions,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT RegisterPackage(
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem,
winrt::Windows::Foundation::Uri const& packageUri,
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageSetItem,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
@ -108,6 +146,7 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Windows::Management::Deployment::RegisterPackageOptions const& registerOptions,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
@ -127,6 +166,121 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT RemovePackage(
winrt::Windows::Foundation::Uri const& packageUri,
winrt::Microsoft::Windows::Management::Deployment::RemovePackageOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageSetItem,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT RemovePackage(
winrt::Windows::Foundation::Uri const& packageUri,
winrt::Windows::Management::Deployment::RemovalOptions const& removeOptions,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT RemovePackageByFullName(
winrt::hstring const& packageFullName,
winrt::Microsoft::Windows::Management::Deployment::RemovePackageOptions const& options,
winrt::Windows::Management::Deployment::RemovalOptions const& removeOptions,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT RemovePackageByFamilyName(
winrt::hstring const& packageFamilyName,
winrt::Microsoft::Windows::Management::Deployment::RemovePackageOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageFamily,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
HRESULT RemovePackageByFamilyName(
winrt::hstring const& packageFamilyName,
winrt::Microsoft::Windows::Management::Deployment::RemovePackageOptions const& options,
winrt::Windows::Management::Deployment::RemovalOptions const& removeOptions,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageFamily,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> ResetPackageByFamilyNameAsync(
hstring packageFamilyName);
HRESULT ResetPackageByFamilyName(
winrt::hstring const& packageFamilyName,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageFamily,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> ResetPackageByFullNameAsync(
hstring packageFullName);
HRESULT ResetPackageByFullName(
winrt::hstring const& packageFullName,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> RepairPackageByFamilyNameAsync(
hstring packageFamilyName);
HRESULT RepairPackageByFamilyName(
winrt::hstring const& packageFamilyName,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackageFamily,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> RepairPackageByFullNameAsync(
hstring packageFullName);
HRESULT RepairPackageByFullName(
winrt::hstring const& packageFullName,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
const double progressMaxPerPackage,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
bool IsProvisionedByPackageFamilyName(
hstring const& packageFamilyName);
bool IsProvisionedByPackageFamilyName(
winrt::Windows::Foundation::Collections::IVector<winrt::Windows::ApplicationModel::Package> const& provisionedPackages,
hstring const& packageFamilyName);
bool IsProvisioned(
winrt::Windows::Foundation::Collections::IVector<winrt::Windows::ApplicationModel::Package> const& provisionedPackages,
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> ProvisionPackageByFamilyNameAsync(
hstring packageFamilyName,
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions const& options);
HRESULT ProvisionPackageByFamilyName(
winrt::hstring const& packageFamilyName,
winrt::Windows::Management::Deployment::PackageAllUserProvisioningOptions const& options,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress> DeprovisionPackageByFamilyNameAsync(
hstring packageFamilyName);
HRESULT DeprovisionPackageByFamilyName(
winrt::hstring const& packageFamilyName,
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress& packageDeploymentProgress,
wistd::function<void(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress)> progress,
HRESULT& extendedError,
winrt::hstring& errorText,
winrt::guid& activityId);
winrt::Windows::Management::Deployment::PackageVolume ToPackageVolume(winrt::Microsoft::Windows::Management::Deployment::PackageVolume const& packageVolume) const;
winrt::Windows::Management::Deployment::AddPackageOptions ToOptions(winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions const& options) const;
winrt::Windows::Management::Deployment::StagePackageOptions ToOptions(winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions const& options) const;
@ -134,8 +288,64 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
winrt::Windows::Management::Deployment::RemovalOptions ToOptions(winrt::Microsoft::Windows::Management::Deployment::RemovePackageOptions const& options) const;
winrt::Windows::Management::Deployment::AddPackageOptions ToOptions(winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions const& options) const;
winrt::Windows::Management::Deployment::DeploymentOptions ToDeploymentOptions(winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions const& options) const;
static double PercentageToProgress(uint32_t percentage);
winrt::Windows::Management::Deployment::PackageAllUserProvisioningOptions ToOptions(winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions const& options) const;
static double PercentageToProgress(uint32_t percentage, const double progressMaxPerItem);
static bool IsUriEndsWith(winrt::Windows::Foundation::Uri const& packageUri, PCWSTR target);
static winrt::Windows::Foundation::Uri GetEffectivePackageUri(
winrt::Microsoft::Windows::Management::Deployment::PackageSet const& packageSet,
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem const& packageSetItem);
static bool IsUriScheme_MsUup(winrt::Windows::Foundation::Uri const& packageUri);
private:
static size_t Count(winrt::Windows::Foundation::Collections::IIterable<winrt::Windows::ApplicationModel::Package> packages)
{
size_t count{};
if (packages)
{
const auto iterator{ packages.First() };
if (iterator.HasCurrent())
{
++count;
while (iterator.MoveNext())
{
++count;
}
}
}
return count;
}
private:
static bool Any(winrt::Windows::Foundation::Collections::IIterable<winrt::Windows::ApplicationModel::Package> packages)
{
return packages ? packages.First().HasCurrent() : false;
}
private:
static int StringCompareNoCase(PCWSTR left, PCWSTR right)
{
return CompareStringOrdinal(left, -1, right, -1, TRUE) - CSTR_EQUAL;
}
static bool StringEqualsNoCase(PCWSTR left, PCWSTR right)
{
return StringCompareNoCase(left, right) == 0;
}
static int StringCompareNoCase(PCWSTR left, const size_t leftLength, PCWSTR right, const size_t rightLength)
{
return CompareStringOrdinal(left, static_cast<int>(leftLength), right, static_cast<int>(rightLength), TRUE) - CSTR_EQUAL;
}
static int StringEqualsNoCase(PCWSTR left, const size_t leftLength, PCWSTR right, const size_t rightLength)
{
return StringCompareNoCase(left, leftLength, right, rightLength) == 0;
}
private:
static int StringCompareNoCase(const winrt::hstring& left, const winrt::hstring& right)
{
return StringCompareNoCase(left.c_str(), right.c_str());
}
static bool StringEqualsNoCase(const winrt::hstring& left, const winrt::hstring& right)
{
return StringEqualsNoCase(left.c_str(), right.c_str());
}
private:
winrt::Windows::Management::Deployment::PackageManager m_packageManager;

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

@ -21,7 +21,7 @@ namespace winrt::Microsoft::Windows::Management::Deployment::implementation
void RemoveForAllUsers(bool value);
private:
bool m_failIfNotFound{ true };
bool m_failIfNotFound{};
bool m_preserveApplicationData{};
bool m_preserveRoamableApplicationData{};
bool m_removeForAllUsers{};

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

@ -330,3 +330,12 @@ winrt::hstring Microsoft::Windows::ApplicationModel::PackageDeploymentResolver::
}
return bestFitPackageFullName;
}
bool Microsoft::Windows::ApplicationModel::PackageDeploymentResolver::IsRegistered(
const winrt::Windows::Management::Deployment::PackageManager& packageManager,
const winrt::hstring& packageFullName)
{
// Find the match
auto package{ packageManager.FindPackageForUser(winrt::hstring(), packageFullName) };
return !!package;
}

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

@ -24,6 +24,10 @@ namespace Microsoft::Windows::ApplicationModel::PackageDeploymentResolver
bool FindAny(
const winrt::Windows::Management::Deployment::PackageManager& packageManager,
const winrt::hstring& packageFullName);
bool IsRegistered(
const winrt::Windows::Management::Deployment::PackageManager& packageManager,
const winrt::hstring& packageFullName);
}
#endif // PACKAGERESOLVER_H

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

@ -7,9 +7,22 @@ import "M.AM.DynamicDependency.idl";
namespace Microsoft.Windows.Management.Deployment
{
[contractversion(1)]
[contractversion(2)]
apicontract PackageDeploymentContract{};
/// Features can be queried if currently available/enabled.
/// @see PackageDeploymentManager.IsPackageDeploymentFeatureSupported()
[contract(PackageDeploymentContract, 2)]
enum PackageDeploymentFeature
{
PackageUriScheme_ms_uup = 1,
IsPackageReadyOrNewerAvailable = 2,
RemovePackageByUri = 3,
ResetPackage = 4,
RepairPackage = 5,
ProvisionPackage_Framework = 6,
};
/// Represents a package storage volume.
/// @note A volume 'name' is the volume's media ID (you can treat 'Volume Name' == 'Volume Media ID').
/// @see https://learn.microsoft.com/uwp/api/windows.management.deployment.packagevolume
@ -71,6 +84,15 @@ namespace Microsoft.Windows.Management.Deployment
UsePreference,
};
/// Defines the stub behavior for an app package that is being added or staged.
[contract(PackageDeploymentContract, 2)]
enum PackageReadyOrNewerAvailableStatus
{
NotReady = 0,
Ready = 1,
NewerAvailable = 2,
};
/// The progress status of the deployment request.
/// @see https://learn.microsoft.com/uwp/api/windows.management.deployment.deploymentprogress.state
[contract(PackageDeploymentContract, 1)]
@ -258,6 +280,9 @@ namespace Microsoft.Windows.Management.Deployment
EnsureReadyOptions();
AddPackageOptions AddPackageOptions { get; };
[contract(PackageDeploymentContract, 2)]
Boolean RegisterNewerIfAvailable;
}
[contract(PackageDeploymentContract, 1)]
@ -266,6 +291,11 @@ namespace Microsoft.Windows.Management.Deployment
// Get an instance of the manager
static PackageDeploymentManager GetDefault();
//-------------------------------------------------------------
// IsPackageDeploymentFeatureSupported
static Boolean IsPackageDeploymentFeatureSupported(PackageDeploymentFeature feature);
//-------------------------------------------------------------
// IsReady
@ -275,8 +305,24 @@ namespace Microsoft.Windows.Management.Deployment
Boolean IsPackageReadyByUri(Windows.Foundation.Uri packageUri);
/// @note packageSet[Item].PackageUri is optional
Boolean IsPackageSetReady(PackageSet packageSet);
//-------------------------------------------------------------
// IsReadyOrNewerAvailable
// Return true if the package(s) are present and available for use
[contract(PackageDeploymentContract, 2)]
PackageReadyOrNewerAvailableStatus IsPackageReadyOrNewerAvailable(String package);
[contract(PackageDeploymentContract, 2)]
PackageReadyOrNewerAvailableStatus IsPackageReadyOrNewerAvailableByUri(Windows.Foundation.Uri packageUri);
/// @note packageSet[Item].PackageUri is optional
[contract(PackageDeploymentContract, 2)]
PackageReadyOrNewerAvailableStatus IsPackageSetReadyOrNewerAvailable(PackageSet packageSet);
//-------------------------------------------------------------
// EnsureReady
@ -292,6 +338,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
EnsurePackageReadyByUriAsync(Windows.Foundation.Uri packageUri, EnsureReadyOptions options);
/// @note packageSet[Item].PackageUri is required
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
EnsurePackageSetReadyAsync(PackageSet packageSet, EnsureReadyOptions options);
@ -304,6 +351,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
AddPackageByUriAsync(Windows.Foundation.Uri packageUri, AddPackageOptions options);
/// @note packageSet[Item].PackageUri is required
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
AddPackageSetAsync(PackageSet packageSet, AddPackageOptions options);
@ -316,6 +364,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
StagePackageByUriAsync(Windows.Foundation.Uri packageUri, StagePackageOptions options);
/// @note packageSet[Item].PackageUri is required
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
StagePackageSetAsync(PackageSet packageSet, StagePackageOptions options);
@ -328,6 +377,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
RegisterPackageByUriAsync(Windows.Foundation.Uri packageUri, RegisterPackageOptions options);
/// @note packageSet[Item].PackageUri is optional
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
RegisterPackageSetAsync(PackageSet packageSet, RegisterPackageOptions options);
@ -346,6 +396,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
RemovePackageByUriAsync(Windows.Foundation.Uri packageUri, RemovePackageOptions options);
/// @note packageSet[Item].PackageUri is optional
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
RemovePackageSetAsync(PackageSet packageSet, RemovePackageOptions options);
@ -358,6 +409,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
ResetPackageByUriAsync(Windows.Foundation.Uri packageUri);
/// @note packageSet[Item].PackageUri is optional
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
ResetPackageSetAsync(PackageSet packageSet);
@ -370,9 +422,25 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
RepairPackageByUriAsync(Windows.Foundation.Uri packageUri);
/// @note packageSet[Item].PackageUri is optional
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
RepairPackageSetAsync(PackageSet packageSet);
//-------------------------------------------------------------
// IsProvisioned
// Return true if the package(s) are provisioned
[contract(PackageDeploymentContract, 2)]
Boolean IsPackageProvisioned(String package);
[contract(PackageDeploymentContract, 2)]
Boolean IsPackageProvisionedByUri(Windows.Foundation.Uri packageUri);
/// @note packageSet[Item].PackageUri is optional
[contract(PackageDeploymentContract, 2)]
Boolean IsPackageSetProvisioned(PackageSet packageSet);
//-------------------------------------------------------------
// Provision packages
@ -382,6 +450,7 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
ProvisionPackageByUriAsync(Windows.Foundation.Uri packageUri, ProvisionPackageOptions options);
/// @note packageSet[Item].PackageUri is optional
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
ProvisionPackageSetAsync(PackageSet packageSet, ProvisionPackageOptions options);
@ -394,15 +463,16 @@ namespace Microsoft.Windows.Management.Deployment
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
DeprovisionPackageByUriAsync(Windows.Foundation.Uri packageUri);
/// @note packageSet[Item].PackageUri is optional
Windows.Foundation.IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>
DeprovisionPackageSetAsync(PackageSet packageSet);
//-------------------------------------------------------------
// IsRegistrationPending
Boolean IsPackageRegistrationPending(String packageFamilyName);
Boolean IsPackageRegistrationPending(String packageFullName);
Boolean IsPackageRegistrationPendingForUser(String userSecurityId, String packageFamilyName);
Boolean IsPackageRegistrationPendingForUser(String userSecurityId, String packageFullName);
}
[contract(PackageDeploymentContract, 1)]

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

@ -126,11 +126,11 @@ public:
CATCH_LOG()
END_ACTIVITY_CLASS();
BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(EnsurePackageAsync, PDT_ProductAndServicePerformance);
BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(EnsurePackageReadyAsync, PDT_ProductAndServicePerformance);
DEFINE_ACTIVITY_START(winrt::hstring const& package) noexcept try
{
TraceLoggingClassWriteStart(
EnsurePackageAsync,
EnsurePackageReadyAsync,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingWideString(package.c_str(), "Package"));
}
@ -138,17 +138,17 @@ public:
DEFINE_ACTIVITY_STOP(winrt::hstring const& package) noexcept try
{
TraceLoggingClassWriteStop(
EnsurePackageAsync,
EnsurePackageReadyAsync,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingWideString(package.c_str(), "Package"));
}
CATCH_LOG()
END_ACTIVITY_CLASS();
BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(EnsurePackageByUriAsync, PDT_ProductAndServicePerformance);
BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(EnsurePackageReadyByUriAsync, PDT_ProductAndServicePerformance);
DEFINE_ACTIVITY_START(winrt::hstring const& packageUri) noexcept try
{
TraceLoggingClassWriteStart(
EnsurePackageByUriAsync,
EnsurePackageReadyByUriAsync,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingWideString(packageUri.c_str(), "PackageUri"));
}
@ -156,7 +156,7 @@ public:
DEFINE_ACTIVITY_STOP(winrt::hstring const& packageUri) noexcept try
{
TraceLoggingClassWriteStop(
EnsurePackageByUriAsync,
EnsurePackageReadyByUriAsync,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingWideString(packageUri.c_str(), "PackageUri"));
}

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

@ -7,6 +7,7 @@
#include <unknwn.h>
#include <appmodel.h>
#include <sddl.h>
#include <filesystem>
#include <thread>
@ -15,6 +16,7 @@
#include <wil/cppwinrt.h>
#include <wil/resource.h>
#include <wil/result_macros.h>
#include <wil/winrt.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
@ -28,5 +30,9 @@
#include <appmodel.identity.h>
#include <appmodel.package.h>
#include <security.user.h>
#include "MsixPackageManager.h"
#include <FrameworkUdk/PackageManagement.h>
#include <FrameworkUdk/UupStateRepository.h>

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

@ -5,4 +5,5 @@
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.FrameworkUdk" version="1.7.0-CI-26107.1701.240510-1748.0" targetFramework="native" />
</packages>

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

@ -12,6 +12,7 @@
#include <shellapi.h>
#include <appmodel.h>
#include <xmllite.h>
#include <sddl.h>
#include <string>
#include <string_view>
@ -30,6 +31,7 @@
#include <wil/filesystem.h>
#include <wil/com.h>
#include <wil/win32_helpers.h>
#include <wil/winrt.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
@ -53,6 +55,7 @@
#include <microsoft.configuration.h>
#include <microsoft.utf8.h>
#include <security.integritylevel.h>
#include <security.user.h>
#include <windowsappruntime.selfcontained.h>
#include <windowsappruntime.versioninfo.h>

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

@ -18,7 +18,14 @@ or via the browser:
**NOTE:** Visual Studio 2022 doesn't include this SDK but will use it if installed on the machine.
2. Visual Studio 2022 with...
2. Windows 11 SDK 10.0.26100.0 (24H2)
a. Browse to https://go.microsoft.com/fwlink/?linkid=2272610
b. Save the offered download `winsdksetup.exe`
c. Run winsdksetup.exe
**NOTE:** Visual Studio 2022 doesn't include this SDK but will use it if installed on the machine.
3. Visual Studio 2022 with...
* Workloads
* .NET desktop development
* Desktop development with C++
@ -51,7 +58,7 @@ or via the browser:
**NOTE:** You can tell the Visual Studio Installer to do the heavy lifting for you
via `More` / `Import configuration` and select `docs\Coding-Guidelines\VisualStudio2022.vsconfig`.
3. Run NuGet Restore
4. Run NuGet Restore
* Download nuget.exe version >= 6.2.1 from https://www.nuget.org/downloads
e.g. https://dist.nuget.org/win-x86-commandline/v6.2.1/nuget.exe
* Open a command prompt
@ -88,7 +95,7 @@ Some tips:
## MSBuild Tips
Build everything from the command line via msbuild e.g.
### Build everything from the command line via msbuild e.g.
| Goal | Command Line |
|---|---|
@ -103,6 +110,17 @@ See MSBuild documentation for more details.
Troubleshoot build problems by enabling binary logging (e.g. `msbuild...-bl`) and use
[MSBuild Binary and Structured Log Viewer](https://msbuildlog.com/) to review the log.
### Common Build Errors
PROBLEM 001: Expired Test Certificate
SYMPTOMS:
VS ErrorList:
MSB3073 The command "signtool.exe sign ..." exited with code 1...\MakeMsix.targets...
Build Output:
Build Output: EXEC : SignTool error : No certificates were found that met all the given criteria.
...\MakeMsix.targets...error MSB3073: The command "signtool.exe sign ..." exited with code 1.
SOLUTION: Run DevCheck.cmd (from an admin prompt). This detects the expired certificate and prompts to create a new one.
## Testing Tips
* Use Test Explorer to view and run tests via the View menu's `Test Explorer`

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

@ -29,7 +29,7 @@
<Dependency Name="Microsoft.Build.Tasks.Git" Version="1.1.1"/>
<Dependency Name="Microsoft.SourceLink.Common" Version="1.1.1"/>
<Dependency Name="Microsoft.SourceLink.GitHub" Version="1.1.1"/>
<Dependency Name="Microsoft.Taef" Version="10.82.230714001"/>
<Dependency Name="Microsoft.Taef" Version="10.92.240405002"/>
<Dependency Name="Microsoft.Telemetry.Inbox.Native" Version="10.0.19041.1-191206-1406.vb-release.x86fre" />
<Dependency Name="Microsoft.Windows.CppWinRT" Version="2.0.230706.1"/>
<Dependency Name="Microsoft.Windows.ImplementationLibrary" Version="1.0.220914.1"/>

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

@ -43,6 +43,9 @@
.PARAMETER NoInteractive
Run in non-interactive mode (fail if any need for user input)
.PARAMETER InstallWindowsSDK
Download and install Windows Platform SDKs (if necessary).
.PARAMETER Offline
Do not access the network
@ -100,6 +103,8 @@ Param(
[Switch]$Clean=$false,
[Switch]$InstallWindowsSDK=$false,
[Switch]$NoInteractive=$false,
[Switch]$Offline=$false,
@ -307,7 +312,6 @@ function Get-VSWhereOnline
Write-Host "Downloading $global:vswhere from $global:vswhere_url..."
Write-Verbose "Executing: curl.exe --output $path -L -# $global:vswhere_url"
$null = Start-Process curl.exe -ArgumentList "--output $path -L -# $global:vswhere_url" -Wait -NoNewWindow -PassThru
}
if (-not(Test-Path -Path $path -PathType Leaf))
{
@ -456,17 +460,61 @@ function Test-VisualStudio2022Install
return $ok
}
function Install-WindowsSDK
{
param(
[String]$version,
[uri]$url
)
$path = Join-Path $env:TEMP "winsdksetup-$($version).exe"
if ($Clean -eq $true -And (Test-Path -Path $path -PathType Leaf))
{
Write-Verbose "Found $path. Deleting per -Clean..."
Remove-Item -Path $path -Force
}
$log = Join-Path $env:TEMP "winsdksetup-$($version).log"
if ($Clean -eq $true -And (Test-Path -Path $log -PathType Leaf))
{
Write-Verbose "Found $log. Deleting per -Clean..."
Remove-Item -Path $log -Force
}
if (-not(Test-Path -Path $path -PathType Leaf))
{
Write-Host "Downloading Windows SDK $version from $url..."
Write-Verbose "Executing: curl.exe --output $path -L -# $url"
$null = Start-Process curl.exe -ArgumentList "--output $path -L -# $url" -Wait -NoNewWindow -PassThru
}
$p = Start-Process $path -ArgumentList "/features + /q /log $log" -Wait -NoNewWindow -PassThru
if ($p.ExitCode -ne 0)
{
Write-Host "...ERROR: Windows SDK $($version) install failed. See $log" -ForegroundColor Red -BackgroundColor Black
$global:issues++
return $false
}
Write-Host "Install Windows SDK $($version)...OK"
return $true
}
function Test-WindowsSDKInstall
{
param(
[String]$version
[String]$version,
[uri]$url
)
$regkey = "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\$version"
$found = Test-Path $regkey -PathType Container
if ($found)
{
Write-Verbose "Windows SDK $($version) = OK"
Write-Host "Windows SDK $($version) = OK"
}
elseif ($InstallWindowsSDK -eq $true)
{
Write-Warning "WARNING: Windows SDK $($version) not found. Installing..."
$null = Install-WindowsSDK $version $url
}
else
{
@ -1279,8 +1327,8 @@ function Get-DeveloperMode
$regkey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock'
if (Test-Path -Path $regkey -PathType Container)
{
$value = Get-ItemProperty -Path $regkey -Name AllowDevelopmentWithoutDevLicense
return $value.AllowDevelopmentWithoutDevLicense -eq 1
$value = $(Get-Item -Path $regkey).GetValue('AllowDevelopmentWithoutDevLicense')
return $value -eq 1
}
return $false
@ -1297,7 +1345,6 @@ function Test-DeveloperMode
{
Write-Host "ERROR: Developer mode is not enabled. Enable it via Settings" -ForegroundColor Red -BackgroundColor Black
$global:issues++
$fatal_errors++
}
}
@ -1354,7 +1401,8 @@ if (($CheckAll -ne $false) -Or ($CheckVisualStudio -ne $false))
{
$null = Test-VisualStudioComponents
}
$null = Test-WindowsSDKInstall '10.0.17763.0'
$null = Test-WindowsSDKInstall '10.0.17763.0' [uri]'https://go.microsoft.com/fwlink/p/?LinkID=2033908'
#TODO Uncomment to require new SDK: $null = Test-WindowsSDKInstall '10.0.26100.0' [uri]'https://go.microsoft.com/fwlink/?linkid=2272610'
}
if (($CheckAll -ne $false) -Or ($CheckTestPfx -ne $false))

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -17,10 +17,12 @@ but with additional functionality, improved developer experience and performance
- [3.6. Reset](#36-reset)
- [3.7. IsPackageRegistrationPending](#37-ispackageregistrationpending)
- [3.8. PackageSet](#38-packageset)
- [3.8.1. PackageSet Properties](#381-packageset-properties)
- [3.8.2. PackageSetItem Properties](#382-packagesetitem-properties)
- [3.9. PackageRuntimeManager](#39-packageruntimemanager)
- [3.10. PackageVolume Repair](#310-packagevolume-repair)
- [3.11. Usability](#311-usability)
- [3.12 Is\*Provisioned()](#312-isprovisioned)
- [3.12. Is\*Provisioned()](#312-312-isprovisioned)
- [4. Examples](#4-examples)
- [4.1. AddPackageAsync()](#41-addpackageasync)
- [4.2. AddPackageByUriAsync()](#42-addpackagebyuriasync)
@ -133,10 +135,10 @@ The following table shows the supported permutations of verbs and targets:
Legend:
* OS = Supported by Windows (OS) APIs in the Windows.Management.Deployment.PackageManager namespace.
* WAS = Supported by Windows App SDK APIs in the
* **OS** = Supported by Windows (OS) APIs in the Windows.Management.Deployment.PackageManager namespace.
* **WAS** = Supported by Windows App SDK APIs in the
Microsoft.Windows.Management.Deployment.PackageDeploymentManager namespace.
* X = Not supported
* **X** = Not supported
## 3.2. Is\*Ready()
@ -286,6 +288,50 @@ foreach (PackageSetItem psi in ps.Items)
return new PackageDeploymentResult(PackageDeploymentStatus.CompletedSuccess);
```
### 3.8.1. PackageSet Properties
`Id` is optional. This is used primarily for logging and troubleshooting.
`Items` is required to contain 1+ item.
`PackageUri` is optional. This is used if a `PackageUri` is needed for a `PackageSetItem` but the
`PackageSetItem.PackageUri` is not specified.
### 3.8.2. PackageSetItem Properties
`Id` is required and used primarily for logging and troubleshooting.
`MinVersion` is optional. If not set the default value is 0.0.0.0. Some verbs use this property (see below).
`PackageFamilyName` is optional. Some verbs require this property (see below).
`PackageUri` is optional. If a `PackageUri` is needed and this is not set the `PackageSet`'s `PackageUri` property is used. Some verbs require this property (see below).
`ProcessorArchitectureFilter` is optional. If not set the default value is `Microsoft.Windows.ApplicationModel.DynamicDependency.PackageDependencyProcessorArchitectures.None`. Only some verbs use this property (see below).
|Verb | MinVersion | PackageFamilyName | PackageUri | ProcessorArchitectureFilter |
|------------------------|:----------:|:-------------------------:|:----------:|:---------------------------:|
|IsReady | Used | Required | N/A | Optional |
|IsReadyOrNewerAvailable | Used | Required | N/A | Optional |
|EnsureReady | Used | Required | Used | Optional |
|Add | N/A | N/A | Used | N/A |
|Stage | N/A | N/A | USed | N/A |
|Register | N/A | N/A | Used | N/A |
|Remove | N/A | Used-if-no-PackageUri | Optional | N/A |
|Repair | N/A | Used-if-no-PackageUri | Optional | N/A |
|Reset | N/A | Used-if-no-PackageUri | Optional | N/A |
|IsProvisioned | N/A | Used | Optional | N/A |
|Provision | N/A | Used-if-no-PackageUri | Optional | N/A |
|Deprovision | N/A | Used-if-no-PackageUri | Optional | N/A |
**Legend:**
* **N/A** = Not applicable. This property is not used.
* **Optional** = This property is used, if specified.
* **Required** = This property is required.
* **Used** = This property is used; if not specified, the default value is used.
## 3.9. PackageRuntimeManager
The `PackageRuntimeManager` API provides Dynamic Dependency support for PackageSet operations,
@ -347,7 +393,7 @@ package management APIs in Windows (e.g. Windows.Management.Deployment.PackageMa
not PackageFamilyName. `PackageDeploymentManager` provides a richer API accepting additional
identifiers.
## 3.12 Is*Provisioned()
## 3.12. Is*Provisioned()
Is\*Provisioned\*() methods determine if the target is provisioned.
@ -1173,9 +1219,9 @@ namespace Microsoft.Windows.Management.Deployment
//-------------------------------------------------------------
// IsRegistrationPending
Boolean IsPackageRegistrationPending(String packageFamilyName);
Boolean IsPackageRegistrationPending(String packageFullName);
Boolean IsPackageRegistrationPendingForUser(String userSecurityId, String packageFamilyName);
Boolean IsPackageRegistrationPendingForUser(String userSecurityId, String packageFullName);
}
[contract(PackageDeploymentContract, 1)]

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
</packages>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -11,6 +11,7 @@
#define PCH_H
#include <unknwn.h>
#include <sddl.h>
#include <wil/cppwinrt.h>
#include <wil/token_helpers.h>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
</packages>

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

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
</packages>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,167 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
inline bool SkipIfFeatureNotSupported(
const winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature feature,
PCWSTR message)
{
const bool isSupported{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::IsPackageDeploymentFeatureSupported(feature) };
if (!isSupported)
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, message);
}
return !isSupported;
}
inline bool SkipIfFeatureNotSupported_PackageUriScheme_ms_uup()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::PackageUriScheme_ms_uup };
PCWSTR message{ L"ms-uup: not supported on this system. Skipping test" };
return TPMT::SkipIfFeatureNotSupported(feature, message);
}
inline bool SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::IsPackageReadyOrNewerAvailable };
PCWSTR message{ L"IsPackageReadyOrNewerAvailable not supported on this system. Skipping test" };
return TPMT::SkipIfFeatureNotSupported(feature, message);
}
inline bool SkipIfFeatureNotSupported_RemovePackageByUri()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::RemovePackageByUri };
PCWSTR message{ L"RemovePackageByUri not supported on this system. Skipping test" };
return TPMT::SkipIfFeatureNotSupported(feature, message);
}
inline bool SkipIfFeatureNotSupported_ResetPackage()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::ResetPackage };
PCWSTR message{ L"ResetPackage not supported on this system. Skipping test" };
return TPMT::SkipIfFeatureNotSupported(feature, message);
}
inline bool SkipIfFeatureNotSupported_RepairPackage()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::RepairPackage };
PCWSTR message{ L"RepairPackage not supported on this system. Skipping test" };
return TPMT::SkipIfFeatureNotSupported(feature, message);
}
inline bool SkipIfFeatureNotSupported_ProvisionPackage_Framework()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::ProvisionPackage_Framework };
PCWSTR message{ L"ProvisionPackage.Framework not supported on this system. Skipping test" };
return TPMT::SkipIfFeatureNotSupported(feature, message);
}
inline bool PreBootstrap_SkipIfFeatureNotSupported(
const winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature feature,
PCWSTR message)
{
// NOTE: Some tests can't use winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature
// due to chicken/egg dependencies (can't use it before Bootstrapper's initialized but need access
// before Bootstrapper's initialized...). So we'll handle them by directly calling the FrameworkUdk
//
// NOTE: Only support necessary features here.
switch (feature)
{
case winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::ProvisionPackage_Framework:
{
//TODO Awaiting ProvisionPackageForAllUsersAsync() support for Framework packages
//return IsPackageDeploymentFeatureSupported(L"ProvisionPackage.Framework");
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, message);
return true;
}
default:
{
// Unsupported pre-Bootstrap feature check
WEX::Logging::Log::Result(WEX::Logging::TestResults::Blocked, message);
VERIFY_FAIL(WEX::Common::String().Format(L"Feature:%d", static_cast<int>(feature)));
return true;
}
}
}
inline bool PreBootstrap_SkipIfFeatureNotSupported_ProvisionPackage_Framework()
{
const auto feature{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentFeature::ProvisionPackage_Framework };
PCWSTR message{ L"ProvisionPackage.Framework not supported on this system. Skipping test" };
return TPMT::PreBootstrap_SkipIfFeatureNotSupported(feature, message);
}
void VerifyDeploymentSucceeded(
const winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult& deploymentResult,
PCSTR filename,
int line,
PCSTR function);
class PackageDeploymentManagerTests_Base
{
protected:
inline bool DoNotExecuteTestMethod() const
{
return m_doNotExecuteTestMethod;
}
inline void DoNotExecuteTestMethod(const bool doNotExecuteTestMethod)
{
m_doNotExecuteTestMethod = doNotExecuteTestMethod;
}
private:
bool m_doNotExecuteTestMethod{};
protected:
winrt::Windows::ApplicationModel::PackageStatus GetPackageStatus(PCWSTR packageFullName)
{
return TPMT::GetPackageStatus(m_packageManager, packageFullName);
}
void SetPackageStatus(PCWSTR packageFullName, winrt::Windows::Management::Deployment::PackageStatus status)
{
TPMT::SetPackageStatus(m_packageManager, packageFullName, status);
}
void SetPackageStatusByPackageFamilyName(PCWSTR packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus status)
{
TPMT::SetPackageStatusByPackageFamilyName(m_packageManager, packageFamilyName, status);
}
void ClearPackageStatus(PCWSTR packageFullName, winrt::Windows::Management::Deployment::PackageStatus status)
{
TPMT::ClearPackageStatus(m_packageManager, packageFullName, status);
}
void ClearPackageStatusByPackageFamilyName(PCWSTR packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus status)
{
TPMT::ClearPackageStatusByPackageFamilyName(m_packageManager, packageFamilyName, status);
}
winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult WaitForDeploymentOperation(
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentResult, winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentProgress>& deploymentOperation)
{
using namespace winrt::Windows::Foundation;
using namespace winrt::Microsoft::Windows::Management::Deployment;
AsyncOperationProgressHandler<PackageDeploymentResult, PackageDeploymentProgress> progressCallback(
[&](const IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress>&, PackageDeploymentProgress progress)
{
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"...State:%d Percentage:%lf", static_cast<int>(progress.Status), progress.Progress));
}
);
deploymentOperation.Progress(progressCallback);
auto deploymentResult{ deploymentOperation.get() };
return deploymentResult;
}
protected:
winrt::Windows::Management::Deployment::PackageManager m_packageManager;
};
}

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

@ -0,0 +1,700 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Add : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Add)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(AddPackageAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR package{ L"c:\\does\\not\\exist.msix" };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentResult{ packageDeploymentManager.AddPackageAsync(package, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(AddPackageAsync_NotInstalled_Success)
{
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(AddPackageAsync_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(AddPackageAsync_Registered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(AddPackageAsync_OlderRegistered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
RemovePackage_Redder();
}
TEST_METHOD(AddPackageAsync_NewerRegistered_Success)
{
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Redder());
RemovePackage_Redder();
}
TEST_METHOD(AddPackageByUriAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentResult{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(AddPackageByUriAsync_NotInstalled_Success)
{
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(AddPackageByUriAsync_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(AddPackageByUriAsync_Registered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(AddPackageByUriAsync_OlderRegistered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
RemovePackage_Redder();
}
TEST_METHOD(AddPackageByUriAsync_NewerRegistered_Success)
{
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Redder());
RemovePackage_Redder();
}
TEST_METHOD(AddPackageSetAsync_1_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentResult{ packageDeploymentManager.AddPackageSetAsync(packageSet, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_1_NotInstalled_Success)
{
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_1_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_1_Registered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_1_OlderRegistered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(AddPackageSetAsync_1_NewerRegistered_Success)
{
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(AddPackageSetAsync_N_NotInstalled_Success)
{
RemovePackage_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_N_Registered_Success)
{
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_N_NewerRegistered_Success)
{
AddPackage_Redder();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(AddPackageSetAsync_N_OlderRegistered_Success)
{
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(AddPackageSetAsync_N_RegisteredAndNotInstalled_Success)
{
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(AddPackageSetAsync_N_RegisteredAndNotInstalledAndStaged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
AddPackage_Red();
RemovePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
class PackageDeploymentManagerTests_Add_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Add_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
AddPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(AddPackageAsync_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(AddPackageByUriAsync_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(AddPackageSetAsync_1_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(AddPackageSetAsync_N_RegisteredPackageStatusOkAndBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
AddPackage_Green();
SetPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::AddPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.AddPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
}
};
}

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

@ -0,0 +1,637 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Deprovision_Framework : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Deprovision_Framework)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"RunFixtureAs", L"ElevatedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
if (TPMT::PreBootstrap_SkipIfFeatureNotSupported_ProvisionPackage_Framework())
{
return true;
}
RemovePackage_Red();
AddPackage_Red();
ProvisionPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
DeprovisionPackage_Red();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(DeprovisionPackageAsync_Registered_AccessDenied)
{
AddPackage_Red();
VERIFY_IS_TRUE(IsPackageRegistered_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(E_ACCESSDENIED, deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(S_OK, deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
};
class PackageDeploymentManagerTests_Deprovision_Framework_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Deprovision_Framework_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
TEST_CLASS_PROPERTY(L"RunFixtureAs", L"ElevatedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
if (TPMT::PreBootstrap_SkipIfFeatureNotSupported_ProvisionPackage_Framework())
{
return true;
}
TD::DumpExecutionContext();
DeprovisionPackage_Blue();
DeprovisionPackage_Green();
DeprovisionPackage_Red();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
DeprovisionPackage_Blue();
DeprovisionPackage_Green();
DeprovisionPackage_Red();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(DeprovisionPackageAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
auto deploymentResult{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(DeprovisionPackageAsync_Staged_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(DeprovisionPackageAsync_Registered_Success)
{
DeprovisionPackage_Red();
AddPackage_Red();
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
}
TEST_METHOD(DeprovisionPackageAsync_StagedProvisioned_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
ProvisionPackage_Red();
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
}
TEST_METHOD(DeprovisionPackageAsync_RegisteredProvisioned_Success)
{
AddPackage_Red();
ProvisionPackage_Red();
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
}
TEST_METHOD(DeprovisionPackageAsync_RegisteredPackageStatusBad_Success)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
DeprovisionPackage_Red();
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(DeprovisionPackageByUriAsync_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_Staged_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_StagedProvisioned_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_RegisteredProvisioned_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageSetAsync_1_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
auto deploymentResult{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_Staged_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_Registered_Success)
{
DeprovisionPackage_Red();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_StagedProvisioned_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
ProvisionPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_RegisteredProvisioned_Success)
{
DeprovisionPackage_Red();
AddPackage_Red();
ProvisionPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_Staged_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
StagePackage_Red();
StagePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_Registered_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_StagedProvisioned_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
StagePackage_Red();
StagePackage_Green();
StagePackage_Blue();
ProvisionPackage_Red();
ProvisionPackage_Green();
ProvisionPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_RegisteredProvisioned_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
ProvisionPackage_Red();
ProvisionPackage_Green();
ProvisionPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_RegisteredAndNoSuchPackage_Fail)
{
DeprovisionPackage_Green();
DeprovisionPackage_Red();
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_RegisteredAndNoSuchPackageAndStaged_Fail)
{
DeprovisionPackage_Blue();
DeprovisionPackage_Green();
DeprovisionPackage_Red();
AddPackage_Red();
RemovePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(IsPackageRegistered_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(IsPackageRegistered_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
};
}

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

@ -0,0 +1,702 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Deprovision_Main : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Deprovision_Main)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"RunFixtureAs", L"ElevatedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
DoNotExecuteTestMethod(true);
return true;
}
if (TPMT::PreBootstrap_SkipIfFeatureNotSupported_ProvisionPackage_Framework())
{
DoNotExecuteTestMethod(true);
return true;
}
RemovePackage_Black();
AddPackage_Black();
ProvisionPackage_Black();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
DeprovisionPackage_Black();
RemovePackage_Black();
::TB::Cleanup();
return true;
}
TEST_METHOD(DeprovisionPackageAsync_Registered_AccessDenied)
{
if (DoNotExecuteTestMethod())
{
return;
}
AddPackage_Black();
VERIFY_IS_TRUE(IsPackageRegistered_Black());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPM::Black::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(E_ACCESSDENIED, deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(S_OK, deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
};
class PackageDeploymentManagerTests_Deprovision_Main_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Deprovision_Main_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
TEST_CLASS_PROPERTY(L"RunFixtureAs", L"ElevatedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
DoNotExecuteTestMethod(true);
return true;
}
if (TPMT::PreBootstrap_SkipIfFeatureNotSupported_ProvisionPackage_Framework())
{
DoNotExecuteTestMethod(true);
return true;
}
TD::DumpExecutionContext();
DeprovisionPackage_White();
DeprovisionPackage_Black();
RemovePackage_White();
RemovePackage_Blacker();
RemovePackage_Black();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
DeprovisionPackage_White();
DeprovisionPackage_Black();
RemovePackage_White();
RemovePackage_Blacker();
RemovePackage_Black();
::TB::Cleanup();
return true;
}
TEST_METHOD(DeprovisionPackageAsync_NoSuchPackage_Fail)
{
if (DoNotExecuteTestMethod())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
auto deploymentResult{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(DeprovisionPackageAsync_Staged_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
StagePackage_Black();
VERIFY_IS_TRUE(IsPackageStaged_Black());
VERIFY_IS_FALSE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageProvisioned_Black());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPM::Black::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Black());
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageProvisioned_Black());
}
TEST_METHOD(DeprovisionPackageAsync_Registered_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
AddPackage_Black();
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageProvisioned_Black());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPM::Black::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageProvisioned_Black());
}
TEST_METHOD(DeprovisionPackageAsync_StagedProvisioned_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
StagePackage_Black();
ProvisionPackage_Black();
VERIFY_IS_TRUE(IsPackageStaged_Black());
VERIFY_IS_FALSE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageProvisioned_Black());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPM::Black::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Black());
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageProvisioned_Black());
}
TEST_METHOD(DeprovisionPackageAsync_RegisteredProvisioned_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
AddPackage_Black();
ProvisionPackage_Black();
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageProvisioned_Black());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPM::Black::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageProvisioned_Black());
}
TEST_METHOD(DeprovisionPackageAsync_RegisteredPackageStatusBad_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
DeprovisionPackage_Black();
AddPackage_Black();
SetPackageStatusByPackageFamilyName(::TPM::Black::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPM::Black::GetPackageFullName()));
VERIFY_IS_FALSE(IsPackageProvisioned_Black());
const auto packageFamilyName{ ::TPM::Black::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPM::Black::GetPackageFullName()));
VERIFY_IS_TRUE(IsPackageProvisioned_Black());
}
TEST_METHOD(DeprovisionPackageByUriAsync_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_Staged_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_StagedProvisioned_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_RegisteredProvisioned_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageByUriAsync_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(DeprovisionPackageSetAsync_1_NoSuchPackage_Fail)
{
if (DoNotExecuteTestMethod())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
auto deploymentResult{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_Staged_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
StagePackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
black.PackageUri(packageUri);
packageSet.Items().Append(black);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_Registered_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
AddPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
black.PackageUri(packageUri);
packageSet.Items().Append(black);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_StagedProvisioned_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
StagePackage_Black();
ProvisionPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
black.PackageUri(packageUri);
packageSet.Items().Append(black);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_1_RegisteredProvisioned_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
AddPackage_Black();
ProvisionPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
black.PackageUri(packageUri);
packageSet.Items().Append(black);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_Staged_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
DeprovisionPackage_White();
StagePackage_Black();
StagePackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_Registered_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
DeprovisionPackage_White();
AddPackage_Black();
AddPackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_StagedProvisioned_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
DeprovisionPackage_White();
StagePackage_Black();
StagePackage_White();
ProvisionPackage_Black();
ProvisionPackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_RegisteredProvisioned_Success)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_Black();
DeprovisionPackage_White();
AddPackage_Black();
AddPackage_White();
ProvisionPackage_Black();
ProvisionPackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_RegisteredAndNoSuchPackage_Fail)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_White();
DeprovisionPackage_Black();
AddPackage_Black();
RemovePackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageRegistered_White());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageRegistered_White());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(DeprovisionPackageSetAsync_N_RegisteredAndNoSuchPackageAndStaged_Fail)
{
if (DoNotExecuteTestMethod())
{
return;
}
DeprovisionPackage_White();
DeprovisionPackage_Black();
AddPackage_Black();
RemovePackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageRegistered_White());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
auto deploymentOperation{ packageDeploymentManager.DeprovisionPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
VERIFY_IS_FALSE(IsPackageRegistered_White());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
};
}

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

@ -0,0 +1,551 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_EnsureReady : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_EnsureReady)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(EnsurePackageSetReadyAsync_InvalidParameter)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentResult{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options).get() };
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentResult{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options).get() };
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentResult{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options).get() };
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Not a valid Package Family Name" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentResult{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options).get() };
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentResult{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options).get() };
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageUriAsString{ L"file://c:/assemble.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentResult{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options).get() };
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_NotInstalled_Success)
{
RemovePackageFamily_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_Registered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_OlderRegistered_Success)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_NewerRegistered_Success)
{
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_NotInstalled_Success)
{
RemovePackageFamily_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_Registered_Success)
{
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_NewerRegistered_Success)
{
AddPackage_Redder();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_OlderRegistered_Success)
{
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_RegisteredAndNotInstalled_Success)
{
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_RegisteredAndNotInstalledAndStaged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
AddPackage_Red();
RemovePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
class PackageDeploymentManagerTests_EnsureReady_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_EnsureReady_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
AddPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(EnsurePackageSetReadyAsync_1_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(EnsurePackageSetReadyAsync_N_RegisteredPackageStatusOkAndBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
AddPackage_Green();
SetPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::EnsureReadyOptions options;
auto deploymentOperation{ packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
}

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

@ -0,0 +1,163 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_IsPackageRegistrationPending : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_IsPackageRegistrationPending)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blacker();
RemovePackage_Black();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blacker();
RemovePackage_Black();
::TB::Cleanup();
return true;
}
TEST_METHOD(IsPackageRegistrationPending_NoSuchPackage)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ L"Does.Not.Exist_0.0.0.0_neutral__1234567890abc" };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageRegistrationPending(packageFullName));
}
TEST_METHOD(IsPackageRegistrationPending_NotInstalled)
{
RemovePackage_Blacker();
RemovePackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageRegistrationPending(packageFullName));
}
TEST_METHOD(IsPackageRegistrationPending_Registered)
{
RemovePackage_Blacker();
AddPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageRegistrationPending(packageFullName));
}
TEST_METHOD(IsPackageRegistrationPending_Pending)
{
RemovePackage_Blacker();
AddPackage_Black();
PCWSTR eventName{ L"PackageManagerTests.IsPackageRegistrationPending_Pending.EndOfTheLine" };
wil::unique_event_nothrow endOfTheLine{ ::CreateEventW(nullptr, TRUE, FALSE, eventName) };
if (!endOfTheLine)
{
const auto rc{ GetLastError() };
VERIFY_FAIL(WEX::Common::String().Format(L"CreateEventW() LastError:%u (0x%08X)", rc, rc));
}
wil::com_ptr<IApplicationActivationManager> AAM{ wil::CoCreateInstance<IApplicationActivationManager>(CLSID_ApplicationActivationManager, CLSCTX_LOCAL_SERVER) };
PCWSTR appUserModelId{ ::TPM::Black::c_appUserModelId };
DWORD processId{};
VERIFY_SUCCEEDED(AAM->ActivateApplication(appUserModelId, eventName, AO_NONE, &processId));
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"AppUserModleId:%s Arguments:%s ProcessId:%u", appUserModelId, eventName, processId));
AddPackageDefer_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageRegistrationPending(packageFullName));
VERIFY_SUCCEEDED(LOG_IF_WIN32_BOOL_FALSE(::SetEvent(endOfTheLine.get())));
}
TEST_METHOD(IsPackageRegistrationPendingForUser_NoSuchPackage)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ L"Does.Not.Exist_0.0.0.0_neutral__1234567890abc" };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageRegistrationPendingForUser(winrt::hstring{}, packageFullName));
}
TEST_METHOD(IsPackageRegistrationPendingForUser_NotInstalled)
{
RemovePackage_Blacker();
RemovePackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageRegistrationPendingForUser(winrt::hstring{}, packageFullName));
}
TEST_METHOD(IsPackageRegistrationPendingForUser_Registered)
{
RemovePackage_Blacker();
AddPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageRegistrationPendingForUser(winrt::hstring{}, packageFullName));
}
TEST_METHOD(IsPackageRegistrationPendingForUser_Pending)
{
RemovePackage_Blacker();
AddPackage_Black();
PCWSTR eventName{ L"PackageManagerTests.IsPackageRegistrationPendingForUser_Pending.EndOfTheLine" };
wil::unique_event_nothrow endOfTheLine{ ::CreateEventW(nullptr, TRUE, FALSE, eventName) };
if (!endOfTheLine)
{
const auto rc{ GetLastError() };
VERIFY_FAIL(WEX::Common::String().Format(L"CreateEventW() LastError:%u (0x%08X)", rc, rc));
}
wil::com_ptr<IApplicationActivationManager> AAM{ wil::CoCreateInstance<IApplicationActivationManager>(CLSID_ApplicationActivationManager, CLSCTX_LOCAL_SERVER) };
PCWSTR appUserModelId{ ::TPM::Black::c_appUserModelId };
DWORD processId{};
VERIFY_SUCCEEDED(AAM->ActivateApplication(appUserModelId, eventName, AO_NONE, &processId));
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"AppUserModleId:%s Arguments:%s ProcessId:%u", appUserModelId, eventName, processId));
AddPackageDefer_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageRegistrationPendingForUser(winrt::hstring{}, packageFullName));
VERIFY_SUCCEEDED(LOG_IF_WIN32_BOOL_FALSE(::SetEvent(endOfTheLine.get())));
}
};
}

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

@ -0,0 +1,416 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_IsReady : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_IsReady)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(IsPackageReady_InvalidParameter)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
try
{
PCWSTR packageFullName{ L"Not a valid Package Full Name" };
packageDeploymentManager.IsPackageReady(packageFullName);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
}
TEST_METHOD(IsPackageReady_NoSuchPackage_No)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageFullName{ L"Does.Not.Exist_1.2.3.4_neutral__1234567890abc" };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(c_packageFullName));
}
TEST_METHOD(IsPackageReady_NotInstalled_No)
{
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Red::GetPackageFullName() };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(packageFullName));
}
TEST_METHOD(IsPackageReady_Registered_Yes)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Red::GetPackageFullName() };
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(packageFullName));
}
TEST_METHOD(IsPackageReady_OlderRegistered_No)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Redder::GetPackageFullName() };
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(packageFullName));
}
TEST_METHOD(IsPackageReady_NewerRegistered_Yes)
{
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Red::GetPackageFullName() };
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(packageFullName));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageSetReady_InvalidParameter)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
packageDeploymentManager.IsPackageSetReady(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
packageDeploymentManager.IsPackageSetReady(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReady(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Not a valid Package Family Name" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReady(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageUriAsString{ L"https://doesnotexist.com/assemble.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReady(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
}
TEST_METHOD(IsPackageSetReady_1_NoSuchPackage_No)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_1_NotInstalled_No)
{
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_1_Registered_Yes)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_1_OlderRegistered_No)
{
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_1_NewerRegistered_Yes)
{
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageSetReady_N_NotInstalled_No)
{
RemovePackage_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_N_Registered_Yes)
{
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_N_OlderRegistered_No)
{
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_N_NewerRegistered_Yes)
{
AddPackage_Redder();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageSetReady_N_RegisteredAndNotInstalled_No)
{
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(IsPackageSetReady_N_No_NotAllPackageStatusOK)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
AddPackage_Green();
SetPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
ClearPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
}
};
}

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

@ -0,0 +1,834 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_IsReadyOrNewerAvailable : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_IsReadyOrNewerAvailable)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_InvalidParameter)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
try
{
PCWSTR packageFullName{ L"Not a valid Package Full Name" };
packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFullName);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_NoSuchPackage_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageFullName{ L"Does.Not.Exist_1.2.3.4_neutral__1234567890abc" };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(c_packageFullName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_NotInstalled_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Red::GetPackageFullName() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFullName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_Registered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Red::GetPackageFullName() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFullName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_OlderRegistered_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Redder::GetPackageFullName() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFullName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_NewerRegistered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPF::Red::GetPackageFullName() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFullName));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFullName_NewerAvailable)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Blacker();
AddPackage_Black();
StagePackage_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ ::TPM::Black::GetPackageFullName() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NewerAvailable, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFullName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_InvalidParameter)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
try
{
PCWSTR packageFamilyName{ L"Not a valid Package Family Name" };
packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFamilyName);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_NoSuchPackage_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(c_packageFamilyName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_NotInstalled_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ ::TPF::Red::c_packageFamilyName };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFamilyName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_Registered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ ::TPF::Red::c_packageFamilyName };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFamilyName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_OlderRegistered_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ ::TPF::Redder::c_packageFamilyName };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFamilyName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_NewerRegistered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ ::TPF::Red::c_packageFamilyName };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFamilyName));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageReadyOrNewerAvailable_PackageFamilyName_NewerAvailable)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Blacker();
AddPackage_Black();
StagePackage_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ ::TPM::Black::c_packageFamilyName };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NewerAvailable, packageDeploymentManager.IsPackageReadyOrNewerAvailable(packageFamilyName));
}
TEST_METHOD(IsPackageReadyOrNewerAvailableByUri_InvalidParameter)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(IsPackageReadyOrNewerAvailableByUri_NoSuchPackage_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(IsPackageReadyOrNewerAvailableByUri_NotInstalled_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(IsPackageReadyOrNewerAvailableByUri_Registered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(IsPackageReadyOrNewerAvailableByUri_OlderRegistered_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(IsPackageReadyOrNewerAvailableByUri_NewerRegistered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_InvalidParameter)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Not a valid Package Family Name" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
try
{
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageUriAsString{ L"https://doesnotexist.com/assemble.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet);
VERIFY_FAIL(L"Success is not expected");
}
catch (winrt::hresult_error& e)
{
VERIFY_ARE_EQUAL(E_INVALIDARG, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str()));
}
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_1_NoSuchPackage_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_1_NotInstalled_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_1_Registered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_1_OlderRegistered_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_1_NewerRegistered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_1_NewerAvailable)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Blacker();
AddPackage_Black();
StagePackage_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"B" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NewerAvailable, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_NotInstalled_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
RemovePackage_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_Registered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_OlderRegistered_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_NewerRegistered_Ready)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Redder();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::Ready, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
RemovePackage_Redder();
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_RegisteredAndNotInstalled_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_RegisteredAndNewerAvailable_NotReady)
{
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
AddPackage_Black();
RemovePackage_Whiter();
AddPackage_White();
StagePackage_Whiter();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"BW" };
packageSet.Id(c_packageSetId);
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem(::TPM::Black::GetPackageFullName(), ::TPM::Black::c_packageDirName) };
packageSet.Items().Append(black);
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem(::TPM::White::GetPackageFullName(), ::TPM::White::c_packageDirName) };
packageSet.Items().Append(white);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NewerAvailable, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
}
TEST_METHOD(IsPackageSetReadyOrNewerAvailable_N_No_NotAllPackageStatusOK)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_IsPackageReadyOrNewerAvailable())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
AddPackage_Green();
SetPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(::TPF::Green::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageSetReadyOrNewerAvailable(packageSet));
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageReadyOrNewerAvailableStatus::NotReady, packageDeploymentManager.IsPackageReadyOrNewerAvailable(::TPF::Green::GetPackageFullName()));
ClearPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
}
};
class PackageDeploymentManagerTests_IsReadyOrNewerAvailable_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_IsReadyOrNewerAvailable_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
AddPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(IsPackageSetReady_1_RegisteredPackageStatusBad_No)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
ClearPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
}
};
}

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

@ -0,0 +1,722 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Provision : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Provision)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
#if !defined(TODO_Not_Latest_Platform_SDK)
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Provision* requires latest platform SDK. Skipping tests");
return true;
#else
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Red();
::TB::Setup();
return true;
#endif
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
#if !defined(TODO_Not_Latest_Platform_SDK)
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Provision* requires latest platform SDK. Skipping tests");
return true;
#else
RemovePackage_Red();
::TB::Cleanup();
return true;
#endif
}
TEST_METHOD(ProvisionPackageAsync_Registered_AccessDenied)
{
AddPackage_Red();
VERIFY_IS_TRUE(IsPackageRegistered_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(E_ACCESSDENIED, deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(S_OK, deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
};
class PackageDeploymentManagerTests_Provision_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Provision_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
TEST_CLASS_PROPERTY(L"RunFixtureAs", L"ElevatedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
#if !defined(TODO_Not_Latest_Platform_SDK)
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Provision* requires latest platform SDK. Skipping tests");
return true;
#else
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
DeprovisionPackage_Blue();
DeprovisionPackage_Green();
DeprovisionPackage_Red();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
#endif
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
#if !defined(TODO_Not_Latest_Platform_SDK)
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Provision* requires latest platform SDK. Skipping tests");
return true;
#else
TD::DumpExecutionContext();
DeprovisionPackage_Blue();
DeprovisionPackage_Green();
DeprovisionPackage_Red();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
#endif
}
TEST_METHOD(ProvisionPackageAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentResult{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(ProvisionPackageAsync_Staged_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(ProvisionPackageAsync_Registered_Success)
{
DeprovisionPackage_Red();
AddPackage_Red();
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(ProvisionPackageAsync_StagedProvisioned_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
ProvisionPackage_Red();
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(ProvisionPackageAsync_RegisteredProvisioned_Success)
{
AddPackage_Red();
ProvisionPackage_Red();
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(ProvisionPackageAsync_RegisteredPackageStatusBad_Success)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
DeprovisionPackage_Red();
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
VERIFY_IS_FALSE(IsPackageProvisioned_Red());
const auto packageFamilyName{ ::TPF::Red::c_packageFamilyName };
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageAsync(packageFamilyName, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
VERIFY_IS_TRUE(IsPackageProvisioned_Red());
}
TEST_METHOD(ProvisionPackageByUriAsync_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ProvisionPackageByUriAsync_Staged_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ProvisionPackageByUriAsync_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ProvisionPackageByUriAsync_StagedProvisioned_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ProvisionPackageByUriAsync_RegisteredProvisioned_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ProvisionPackageByUriAsync_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ProvisionPackageSetAsync_1_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentResult{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(ProvisionPackageSetAsync_1_Staged_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_1_Registered_Success)
{
DeprovisionPackage_Red();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_1_StagedProvisioned_Success)
{
DeprovisionPackage_Red();
StagePackage_Red();
ProvisionPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_1_RegisteredProvisioned_Success)
{
DeprovisionPackage_Red();
AddPackage_Red();
ProvisionPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
winrt::Windows::Foundation::Uri packageUri{ nullptr };
red.PackageUri(packageUri);
packageSet.Items().Append(red);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_1_RegisteredPackageStatusBad_Success)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
DeprovisionPackage_Red();
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_Staged_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
StagePackage_Red();
StagePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_Registered_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_StagedProvisioned_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
StagePackage_Red();
StagePackage_Green();
StagePackage_Blue();
ProvisionPackage_Red();
ProvisionPackage_Green();
ProvisionPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_RegisteredProvisioned_Success)
{
DeprovisionPackage_Red();
DeprovisionPackage_Green();
DeprovisionPackage_Blue();
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
ProvisionPackage_Red();
ProvisionPackage_Green();
ProvisionPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_RegisteredAndNoSuchPackage_Fail)
{
DeprovisionPackage_Green();
DeprovisionPackage_Red();
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_RegisteredAndNoSuchPackageAndStaged_Fail)
{
DeprovisionPackage_Blue();
DeprovisionPackage_Green();
DeprovisionPackage_Red();
AddPackage_Red();
RemovePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(IsPackageRegistered_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_FALSE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(IsPackageRegistered_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
}
TEST_METHOD(ProvisionPackageSetAsync_N_RegisteredPackageStatusOkAndBad_Success)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
DeprovisionPackage_Green();
DeprovisionPackage_Red();
AddPackage_Red();
AddPackage_Green();
SetPackageStatusByPackageFamilyName(::TPF::Green::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetProvisioned(packageSet));
winrt::Microsoft::Windows::Management::Deployment::ProvisionPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.ProvisionPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Green());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
}
};
}

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

@ -0,0 +1,712 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
#if !defined(TODO_Register_error_0x80073D2B_ERROR_UNSIGNED_PACKAGE_INVALID_CONTENT_on_20h_vb)
#define RETURN_TRUE_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST() \
if (!::WindowsVersion::IsWindows11_21H2OrGreater()) \
{ \
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager.Register*() tests require >= 21H2 (SV1). Skipping tests"); \
return true; \
}
#define RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST() \
if (!::WindowsVersion::IsWindows11_21H2OrGreater()) \
{ \
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager.Register*() tests require >= 21H2 (SV1). Skipping tests"); \
return; \
}
#endif
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Register : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Register)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RETURN_TRUE_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
RemovePackage_White();
RemovePackage_Blacker();
RemovePackage_Black();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
RemovePackage_White();
RemovePackage_Blacker();
RemovePackage_Black();
::TB::Cleanup();
return true;
}
TEST_METHOD(RegisterPackageAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR package{ L"c:\\does\\not\\exist\\appxmanifest.xml" };
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(RegisterPackageAsync_Framework_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPF::Red::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(RegisterPackageAsync_Main_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
StagePackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPM::Black::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
}
TEST_METHOD(RegisterPackageAsync_Framework_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPF::Red::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(RegisterPackageAsync_Main_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPM::Black::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
}
TEST_METHOD(RegisterPackageAsync_Framework_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
StagePackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPF::Redder::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Redder());
RemovePackage_Redder();
}
TEST_METHOD(RegisterPackageAsync_Main_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
StagePackage_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPM::Blacker::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageRegistered_Blacker());
RemovePackage_Blacker();
}
TEST_METHOD(RegisterPackageByUriAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist/appxmanifest.xml" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_OPEN_PACKAGE_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(RegisterPackageByUriAsync_Framework_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPF::Red::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Windows::Foundation::Uri packageUri{ package };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"packageUri: %ls", packageUri.ToString().c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(RegisterPackageByUriAsync_Main_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
StagePackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPM::Black::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Windows::Foundation::Uri packageUri{ package };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"packageUri: %ls", packageUri.ToString().c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
}
TEST_METHOD(RegisterPackageByUriAsync_Framework_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPF::Red::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Windows::Foundation::Uri packageUri{ package };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"packageUri: %ls", packageUri.ToString().c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(RegisterPackageByUriAsync_Main_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPM::Black::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Windows::Foundation::Uri packageUri{ package };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"packageUri: %ls", packageUri.ToString().c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Black());
}
TEST_METHOD(RegisterPackageByUriAsync_Framework_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
StagePackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPF::Redder::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Windows::Foundation::Uri packageUri{ package };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"packageUri: %ls", packageUri.ToString().c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Redder());
RemovePackage_Redder();
}
TEST_METHOD(RegisterPackageByUriAsync_Main_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
StagePackage_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto appxManifestPath{ TP::GetAppxManifestPackagePath(::TPM::Blacker::GetPackageFullName()) };
const winrt::hstring package{ appxManifestPath.c_str() };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"package: %ls", package.c_str()));
winrt::Windows::Foundation::Uri packageUri{ package };
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"packageUri: %ls", packageUri.ToString().c_str()));
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageRegistered_Blacker());
RemovePackage_Blacker();
}
TEST_METHOD(RegisterPackageSetAsync_Framework_1_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem_ForRegister(::TPF::Red::GetPackageFullName()) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Main_1_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
StagePackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem_ForRegister(::TPM::Black::GetPackageFullName()) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Framework_1_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem_ForRegister(::TPF::Red::GetPackageFullName()) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Main_1_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"BW" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem_ForRegister(::TPM::Black::GetPackageFullName()) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Framework_1_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
StagePackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem_ForRegister(::TPF::Redder::GetPackageFullName()) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Redder());
RemovePackage_Redder();
}
TEST_METHOD(RegisterPackageSetAsync_Main_1_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
StagePackage_Blacker();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem_ForRegister(::TPM::Blacker::GetPackageFullName()) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageRegistered_Blacker());
RemovePackage_Blacker();
}
TEST_METHOD(RegisterPackageSetAsync_Framework_N_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem_ForRegister(::TPF::Red::GetPackageFullName()) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem_ForRegister(::TPF::Green::GetPackageFullName()) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem_ForRegister(::TPF::Blue::GetPackageFullName()) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Main_N_Registered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
AddPackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"BW" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem_ForRegister(::TPM::Black::GetPackageFullName()) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem_ForRegister(::TPM::White::GetPackageFullName()) };
packageSet.Items().Append(white);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Framework_N_OlderRegistered_Success)
{
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
StagePackage_Redder();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem_ForRegister(::TPF::Redder::GetPackageFullName()) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem_ForRegister(::TPF::Green::GetPackageFullName()) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem_ForRegister(::TPF::Blue::GetPackageFullName()) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(IsPackageRegistered_Redder());
RemovePackage_Redder();
}
TEST_METHOD(RegisterPackageSetAsync_Main_N_OlderRegistered_Success)
{
AddPackage_Black();
StagePackage_Blacker();
AddPackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blacker{ Make_PackageSetItem_ForRegister(::TPM::Blacker::GetPackageFullName()) };
packageSet.Items().Append(blacker);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem_ForRegister(::TPM::White::GetPackageFullName()) };
packageSet.Items().Append(white);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
VERIFY_IS_FALSE(IsPackageRegistered_Black());
VERIFY_IS_TRUE(IsPackageRegistered_Blacker());
RemovePackage_Blacker();
}
TEST_METHOD(RegisterPackageSetAsync_Framework_N_RegisteredAndStaged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Red();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem_ForRegister(::TPF::Red::GetPackageFullName()) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem_ForRegister(::TPF::Blue::GetPackageFullName()) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RegisterPackageSetAsync_Main_N_RegisteredAndStaged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RETURN_IF_SKIP_ON_WIN10_DUE_TO_0x80073D2B_IN_TEST();
AddPackage_Black();
StagePackage_White();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"BW" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem black{ Make_PackageSetItem_ForRegister(::TPM::Black::GetPackageFullName()) };
packageSet.Items().Append(black);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem white{ Make_PackageSetItem_ForRegister(::TPM::White::GetPackageFullName()) };
packageSet.Items().Append(white);
winrt::Microsoft::Windows::Management::Deployment::RegisterPackageOptions options;
auto deploymentOperation{ packageDeploymentManager.RegisterPackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,625 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Repair : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Repair)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(RepairPackageAsync_PackageFullName_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ L"Does.Not.Exist_0.0.0.0_neutral__1234567890abc" };
auto deploymentResult{ packageDeploymentManager.RepairPackageAsync(packageFullName).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(RepairPackageAsync_PackageFullName_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageAsync_PackageFullName_Staged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageAsync_PackageFullName_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageAsync_PackageFamilyName_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageAsync_PackageFamilyName_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageAsync_PackageFamilyName_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageByUriAsync_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageUriAsString{ L"ms-uup://Product/does.not.exist" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
auto deploymentResult{ packageDeploymentManager.RepairPackageByUriAsync(packageUri).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(RepairPackageByUriAsync_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(RepairPackageByUriAsync_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(RepairPackageByUriAsync_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(RepairPackageSetAsync_1_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"ms-uup://Product/does.not.exist" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
auto deploymentResult{ packageDeploymentManager.RepairPackageSetAsync(packageSet).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(RepairPackageSetAsync_1_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageSetAsync_1_Staged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RepairPackageSetAsync_1_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RepairPackageSetAsync_N_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
RemovePackage_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(RepairPackageSetAsync_N_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RepairPackageSetAsync_N_RegisteredAndNotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(RepairPackageSetAsync_N_RegisteredAndNotInstalledAndStaged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
AddPackage_Red();
RemovePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
auto deploymentOperation{ packageDeploymentManager.RepairPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
class PackageDeploymentManagerTests_Repair_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Repair_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
AddPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(RepairPackageAsync_PackageFullName_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(RepairPackageAsync_PackageFamilyName_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_RepairPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.RepairPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(RepairPackageByUriAsync_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(RepairPackageSetAsync_1_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(RepairPackageSetAsync_N_RegisteredPackageStatusOkAndBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_RepairPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
};
}

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

@ -0,0 +1,641 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Reset : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Reset)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(ResetPackageAsync_PackageFullName_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR packageFullName{ L"Does.Not.Exist_0.0.0.0_neutral__1234567890abc" };
auto deploymentResult{ packageDeploymentManager.ResetPackageAsync(packageFullName).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(ResetPackageAsync_PackageFullName_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(ResetPackageAsync_PackageFullName_Staged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(ResetPackageAsync_PackageFullName_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
#if defined(TODO_Reset_succeed_but_IsRegistered_is_false_on_rs_prerelease_x64fre)
VERIFY_IS_TRUE(IsPackageRegistered_Red());
#else
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"TODO: Reset succeeds but package not registered on rs_prerelease_x64fre; see error 0x80070002 in Microsoft-Windows-AppxDeploymentServer/Operational");
#endif
}
TEST_METHOD(ResetPackageAsync_PackageFamilyName_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(ResetPackageAsync_PackageFamilyName_Staged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(ResetPackageAsync_PackageFamilyName_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
#if defined(TODO_Reset_succeed_but_IsRegistered_is_false_on_rs_prerelease_x64fre)
VERIFY_IS_TRUE(IsPackageRegistered_Red());
#else
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"TODO: Reset succeeds but package not registered on rs_prerelease_x64fre; see error 0x80070002 in Microsoft-Windows-AppxDeploymentServer/Operational");
#endif
}
TEST_METHOD(ResetPackageByUriAsync_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageUriAsString{ L"ms-uup://Product/does.not.exist" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
auto deploymentResult{ packageDeploymentManager.ResetPackageByUriAsync(packageUri).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(ResetPackageByUriAsync_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ResetPackageByUriAsync_Staged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ResetPackageByUriAsync_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ResetPackageSetAsync_1_NoSuchPackage_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
auto deploymentResult{ packageDeploymentManager.ResetPackageSetAsync(packageSet).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
TEST_METHOD(ResetPackageSetAsync_1_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
RemovePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(ResetPackageSetAsync_1_Staged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(ResetPackageSetAsync_1_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(ResetPackageSetAsync_N_NotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
RemovePackage_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(IsPackageRegistered_Red());
}
TEST_METHOD(ResetPackageSetAsync_N_Registered_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(ResetPackageSetAsync_N_RegisteredAndNotInstalled_Fail)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
AddPackage_Red();
RemovePackage_Green();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(ResetPackageSetAsync_N_RegisteredAndNotInstalledAndStaged_Fail)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
AddPackage_Red();
RemovePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
auto deploymentOperation{ packageDeploymentManager.ResetPackageSetAsync(packageSet) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_PACKAGE_NOT_FOUND), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), deploymentResult.ExtendedError(), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
class PackageDeploymentManagerTests_Reset_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Reset_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
AddPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(ResetPackageAsync_PackageFullName_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
const winrt::hstring packageFullName{ ::TPF::Red::GetPackageFullName() };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFullName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
#if defined(TODO_Reset_succeed_but_IsRegistered_is_false_on_rs_prerelease_x64fre)
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
#else
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"TODO: Reset succeeds but package not registered on rs_prerelease_x64fre; see error 0x80070002 in Microsoft-Windows-AppxDeploymentServer/Operational");
#endif
}
TEST_METHOD(ResetPackageAsync_PackageFamilyName_RegisteredPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
if (TPMT::SkipIfFeatureNotSupported_ResetPackage())
{
return;
}
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
AddPackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::c_packageFamilyName, winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
const winrt::hstring packageFamilyName{ ::TPF::Red::c_packageFamilyName };
auto deploymentOperation{ packageDeploymentManager.ResetPackageAsync(packageFamilyName) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
#if defined(TODO_Reset_succeed_but_IsRegistered_is_false_on_rs_prerelease_x64fre)
VERIFY_IS_TRUE(IsPackageRegistered_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
#else
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"TODO: Reset succeeds but package not registered on rs_prerelease_x64fre; see error 0x80070002 in Microsoft-Windows-AppxDeploymentServer/Operational");
#endif
}
TEST_METHOD(ResetPackageByUriAsync_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ResetPackageSetAsync_1_RegisteredPackageStatusBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
TEST_METHOD(ResetPackageSetAsync_N_RegisteredPackageStatusOkAndBad_Success)
{
if (TPMT::SkipIfFeatureNotSupported_ResetPackage() || TPMT::SkipIfFeatureNotSupported_PackageUriScheme_ms_uup())
{
return;
}
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Cannot test ms-uup: URIs here. Skipping test");
}
};
}

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

@ -0,0 +1,839 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
#include "PackageDeploymentManagerTests.h"
#include <IsWindowsVersion.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests
{
class PackageDeploymentManagerTests_Stage : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Stage)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(StagePackageAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR package{ L"c:\\does\\not\\exist.msix" };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentResult{ packageDeploymentManager.StagePackageAsync(package, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
//
// NOTE: ExtendedError() should be HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) but on some platforms may be S_OK (and also ErrorText() may be empty)
VERIFY_IS_TRUE((deploymentResult.ExtendedError() == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) || (deploymentResult.ExtendedError() == S_OK), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
if (FAILED(deploymentResult.ExtendedError()))
{
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
}
TEST_METHOD(StagePackageAsync_NotInstalled_Success)
{
RemovePackageFamily_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
VERIFY_IS_TRUE(IsPackageStaged_Red());
}
TEST_METHOD(StagePackageAsync_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RemovePackageFamily_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
}
TEST_METHOD(StagePackageAsync_Registered_Success)
{
RemovePackageFamily_Red();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
}
TEST_METHOD(StagePackageAsync_OlderStaged_Success)
{
RemovePackageFamily_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(IsPackageStaged_Redder());
RemovePackage_Redder();
}
TEST_METHOD(StagePackageAsync_NewerStaged_Success)
{
RemovePackageFamily_Redder();
StagePackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Redder());
RemovePackageFamily_Redder();
}
TEST_METHOD(StagePackageByUriAsync_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentResult{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
//
// NOTE: ExtendedError() should be HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) but on some platforms may be S_OK (and also ErrorText() may be empty)
VERIFY_IS_TRUE((deploymentResult.ExtendedError() == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) || (deploymentResult.ExtendedError() == S_OK), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
if (FAILED(deploymentResult.ExtendedError()))
{
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
}
TEST_METHOD(StagePackageByUriAsync_NotInstalled_Success)
{
RemovePackageFamily_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
}
TEST_METHOD(StagePackageByUriAsync_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RemovePackageFamily_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
}
TEST_METHOD(StagePackageByUriAsync_Registered_Success)
{
RemovePackageFamily_Red();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
}
TEST_METHOD(StagePackageByUriAsync_OlderStaged_Success)
{
RemovePackageFamily_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(IsPackageStaged_Redder());
RemovePackageFamily_Redder();
}
TEST_METHOD(StagePackageByUriAsync_NewerStaged_Success)
{
RemovePackageFamily_Redder();
StagePackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Redder());
RemovePackageFamily_Redder();
}
TEST_METHOD(StagePackageSetAsync_1_NoSuchPackage_Fail)
{
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentResult{ packageDeploymentManager.StagePackageSetAsync(packageSet, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
//
// NOTE: ExtendedError() should be HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) but on some platforms may be S_OK (and also ErrorText() may be empty)
VERIFY_IS_TRUE((deploymentResult.ExtendedError() == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) || (deploymentResult.ExtendedError() == S_OK), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
if (FAILED(deploymentResult.ExtendedError()))
{
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_1_NotInstalled_Success)
{
RemovePackageFamily_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_1_Staged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RemovePackageFamily_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_1_Registered_Success)
{
RemovePackageFamily_Red();
AddPackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_1_OlderStaged_Success)
{
RemovePackageFamily_Red();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Redder());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
RemovePackageFamily_Red();
}
TEST_METHOD(StagePackageSetAsync_1_NewerStaged_Success)
{
RemovePackageFamily_Red();
StagePackage_Redder();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_FALSE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Redder());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_NoSuchPackage_Fail)
{
RemovePackageFamily_Red();
RemovePackage_Blue();
StagePackage_Red();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"Does.Not.Exist" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem packageSetItem;
PCWSTR c_packageFamilyName{ L"Does.Not.Exist_1234567890abc" };
packageSetItem.PackageFamilyName(c_packageFamilyName);
PCWSTR c_packageUriAsString{ L"file://c:/does/not/exist.msix" };
winrt::Windows::Foundation::Uri packageUri{ c_packageUriAsString };
packageSetItem.PackageUri(packageUri);
packageSet.Items().Append(packageSetItem);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentResult{ packageDeploymentManager.StagePackageSetAsync(packageSet, options).get() };
VERIFY_ARE_EQUAL(winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentStatus::CompletedFailure, deploymentResult.Status());
VERIFY_ARE_EQUAL(HRESULT_FROM_WIN32(ERROR_INSTALL_FAILED), deploymentResult.Error(), WEX::Common::String().Format(L"0x%X", deploymentResult.Error()));
//
// NOTE: ExtendedError() should be HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) but on some platforms may be S_OK (and also ErrorText() may be empty)
VERIFY_IS_TRUE((deploymentResult.ExtendedError() == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) || (deploymentResult.ExtendedError() == S_OK), WEX::Common::String().Format(L"0x%X", deploymentResult.ExtendedError()));
if (FAILED(deploymentResult.ExtendedError()))
{
VERIFY_IS_FALSE(deploymentResult.ErrorText().empty(), WEX::Common::String().Format(L"%s", deploymentResult.ErrorText().c_str()));
}
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_NotInstalled_Success)
{
RemovePackageFamily_Red();
RemovePackage_Green();
RemovePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_Staged_Success)
{
RemovePackageFamily_Red();
RemovePackage_Green();
RemovePackage_Blue();
StagePackage_Red();
StagePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_Registered_Success)
{
RemovePackageFamily_Red();
RemovePackage_Green();
RemovePackage_Blue();
AddPackage_Red();
AddPackage_Green();
AddPackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_TRUE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_OlderStaged_Success)
{
RemovePackageFamily_Red();
RemovePackage_Green();
RemovePackage_Blue();
StagePackage_Red();
StagePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem redder{ Make_PackageSetItem(::TPF::Redder::GetPackageFullName(), ::TPF::Redder::c_packageDirName) };
packageSet.Items().Append(redder);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Redder());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_NewerStaged_Success)
{
RemovePackageFamily_Redder();
RemovePackage_Green();
RemovePackage_Blue();
StagePackage_Redder();
StagePackage_Green();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Redder());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_StagedAndNotInstalled_Success)
{
RemovePackageFamily_Red();
RemovePackage_Green();
StagePackage_Red();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_StagedAndNotInstalledAndStaged_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
RemovePackageFamily_Red();
RemovePackage_Green();
RemovePackage_Blue();
StagePackage_Red();
StagePackage_Blue();
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem blue{ Make_PackageSetItem(::TPF::Blue::GetPackageFullName(), ::TPF::Blue::c_packageDirName) };
packageSet.Items().Append(blue);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_TRUE(IsPackageStaged_Blue());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
};
class PackageDeploymentManagerTests_Stage_Elevated : PackageDeploymentManagerTests_Base
{
public:
BEGIN_TEST_CLASS(PackageDeploymentManagerTests_Stage_Elevated)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"IsolationLevel", L"Method")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassSetup)
{
if (!::WindowsVersion::IsWindows10_20H1OrGreater())
{
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"PackageDeploymentManager requires >= 20H1 (Vibranium). Skipping tests");
return true;
}
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
AddPackage_Red();
::TB::Setup();
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
TD::DumpExecutionContext();
RemovePackage_Blue();
RemovePackage_Green();
RemovePackage_Redder();
RemovePackage_Red();
::TB::Cleanup();
return true;
}
TEST_METHOD(StagePackageAsync_StagedPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
RemovePackageFamily_Red();
StagePackage_Red();
SetPackageStatus(::TPF::Red::GetPackageFullName(), winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(IsPackageRegistered_Red());
const auto packagePath{ TP::GetMsixPackagePath(::TPF::Red::c_packageDirName) };
const winrt::hstring package{ packagePath.c_str() };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageAsync(package, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(StagePackageByUriAsync_StagedPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
RemovePackageFamily_Red();
StagePackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::GetPackageFullName(), winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
winrt::Windows::Foundation::Uri packageUri{ TP::GetMsixPackageUri(::TPF::Red::c_packageDirName) };
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageByUriAsync(packageUri, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
}
TEST_METHOD(StagePackageSetAsync_1_StagedPackageStatusBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
RemovePackageFamily_Red();
StagePackage_Red();
SetPackageStatusByPackageFamilyName(::TPF::Red::GetPackageFullName(), winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Red::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageSetReady(packageSet));
}
TEST_METHOD(StagePackageSetAsync_N_StagedPackageStatusOkAndBad_Success)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_CLASS_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD_PROPERTIES()
auto packageDeploymentManager{ winrt::Microsoft::Windows::Management::Deployment::PackageDeploymentManager::GetDefault() };
RemovePackageFamily_Red();
RemovePackage_Green();
StagePackage_Red();
StagePackage_Green();
SetPackageStatusByPackageFamilyName(::TPF::Green::GetPackageFullName(), winrt::Windows::Management::Deployment::PackageStatus::Modified);
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
winrt::Microsoft::Windows::Management::Deployment::PackageSet packageSet;
PCWSTR c_packageSetId{ L"RGB" };
packageSet.Id(c_packageSetId);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem red{ Make_PackageSetItem(::TPF::Red::GetPackageFullName(), ::TPF::Red::c_packageDirName) };
packageSet.Items().Append(red);
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem green{ Make_PackageSetItem(::TPF::Green::GetPackageFullName(), ::TPF::Green::c_packageDirName) };
packageSet.Items().Append(green);
winrt::Microsoft::Windows::Management::Deployment::StagePackageOptions options;
auto deploymentOperation{ packageDeploymentManager.StagePackageSetAsync(packageSet, options) };
auto deploymentResult{ WaitForDeploymentOperation(deploymentOperation) };
TPMT::VerifyDeploymentSucceeded(deploymentResult, __FILE__, __LINE__, __FUNCTION__);
VERIFY_IS_TRUE(IsPackageStaged_Red());
VERIFY_IS_TRUE(IsPackageStaged_Green());
VERIFY_IS_FALSE(packageDeploymentManager.IsPackageReady(::TPF::Green::GetPackageFullName()));
}
};
}

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

@ -4,7 +4,21 @@
#ifndef __PACKAGEMANAGERTESTS_PACKAGES_H
#define __PACKAGEMANAGERTESTS_PACKAGES_H
namespace Test::Packages::Framework
namespace Test::Packages::Framework{}
namespace Test::Packages::Main{}
namespace Test::PackageManager::Tests{}
//
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::Packages
{
namespace Framework
{
namespace Red
{
@ -87,6 +101,94 @@ namespace Blue
}
}
}
namespace Main
{
namespace Black
{
constexpr PCWSTR c_packageDirName = L"PackageManager.Test.M.Black.msix";
constexpr PCWSTR c_packageFamilyName = L"Test.PackageManager.M.Black_8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x86 = L"Test.PackageManager.M.Black_1.2.3.4_x86__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x64 = L"Test.PackageManager.M.Black_1.2.3.4_x64__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_arm64 = L"Test.PackageManager.M.Black_1.2.3.4_arm64__8wekyb3d8bbwe";
constexpr inline PCWSTR GetPackageFullName()
{
#if defined(_M_ARM64)
return c_packageFullName_arm64;
#elif defined(_M_IX86)
return c_packageFullName_x86;
#elif defined(_M_X64)
return c_packageFullName_x64;
#else
# error "Unknown processor architecture"
#endif
}
constexpr PCWSTR c_appUserModelId = L"Test.PackageManager.M.Black_8wekyb3d8bbwe!App";
}
namespace Blacker
{
constexpr PCWSTR c_packageDirName = L"PackageManager.Test.M.Blacker.msix";
constexpr PCWSTR c_packageFamilyName = L"Test.PackageManager.M.Black_8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x86 = L"Test.PackageManager.M.Black_2.4.6.8_x86__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x64 = L"Test.PackageManager.M.Black_2.4.6.8_x64__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_arm64 = L"Test.PackageManager.M.Black_2.4.6.8_arm64__8wekyb3d8bbwe";
constexpr inline PCWSTR GetPackageFullName()
{
#if defined(_M_ARM64)
return c_packageFullName_arm64;
#elif defined(_M_IX86)
return c_packageFullName_x86;
#elif defined(_M_X64)
return c_packageFullName_x64;
#else
# error "Unknown processor architecture"
#endif
}
constexpr PCWSTR c_appUserModelId = L"Test.PackageManager.M.Black_8wekyb3d8bbwe!App";
}
namespace White
{
constexpr PCWSTR c_packageDirName = L"PackageManager.Test.M.White.msix";
constexpr PCWSTR c_packageFamilyName = L"Test.PackageManager.M.White_8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x86 = L"Test.PackageManager.M.White_1.2.3.4_x86__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x64 = L"Test.PackageManager.M.White_1.2.3.4_x64__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_arm64 = L"Test.PackageManager.M.White_1.2.3.4_arm64__8wekyb3d8bbwe";
constexpr inline PCWSTR GetPackageFullName()
{
#if defined(_M_ARM64)
return c_packageFullName_arm64;
#elif defined(_M_IX86)
return c_packageFullName_x86;
#elif defined(_M_X64)
return c_packageFullName_x64;
#else
# error "Unknown processor architecture"
#endif
}
constexpr PCWSTR c_appUserModelId = L"Test.PackageManager.M.White_8wekyb3d8bbwe!App";
}
namespace Whiter
{
constexpr PCWSTR c_packageDirName = L"PackageManager.Test.M.Whiter.msix";
constexpr PCWSTR c_packageFamilyName = L"Test.PackageManager.M.White_8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x86 = L"Test.PackageManager.M.White_2.4.6.8_x86__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_x64 = L"Test.PackageManager.M.White_2.4.6.8_x64__8wekyb3d8bbwe";
constexpr PCWSTR c_packageFullName_arm64 = L"Test.PackageManager.M.White_2.4.6.8_arm64__8wekyb3d8bbwe";
constexpr inline PCWSTR GetPackageFullName()
{
#if defined(_M_ARM64)
return c_packageFullName_arm64;
#elif defined(_M_IX86)
return c_packageFullName_x86;
#elif defined(_M_X64)
return c_packageFullName_x64;
#else
# error "Unknown processor architecture"
#endif
}
constexpr PCWSTR c_appUserModelId = L"Test.PackageManager.M.White_8wekyb3d8bbwe!App";
}
}
}
namespace Test::PackageManager::Tests
{
@ -96,21 +198,36 @@ namespace Test::PackageManager::Tests
// Forward declarations
void RemovePackageFamily_Redder();
inline winrt::Microsoft::Windows::Management::Deployment::PackageSetItem Make_PackageSetItem(
inline winrt::Microsoft::Windows::Management::Deployment::PackageSetItem _Make_PackageSetItem(
PCWSTR packageFullName,
PCWSTR packageDirName)
winrt::Windows::Foundation::Uri const& packageUri)
{
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"PackageSetItem: PackageFullName:%s Path:%s", packageFullName, packageDirName));
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"PackageSetItem: PackageFullName:%s Path:%s", packageFullName, packageUri.ToString().c_str()));
const auto [packageName, packageVersion, packageArchitecture, packageResourceId, packagePublisherId, packageFamilyName]{ ::AppModel::Package::ParsePackageFullName(packageFullName) };
winrt::Microsoft::Windows::Management::Deployment::PackageSetItem psi;
psi.PackageFamilyName(packageFamilyName);
psi.PackageUri(TP::GetMsixPackageUri(packageDirName));
psi.PackageUri(packageUri);
const ::AppModel::Identity::PackageVersion version{ packageVersion };
psi.MinVersion(version.ToWinrtPackageVersion());
return psi;
}
inline winrt::Microsoft::Windows::Management::Deployment::PackageSetItem Make_PackageSetItem(
PCWSTR packageFullName,
PCWSTR packageDirName)
{
const auto packageUri{ TP::GetMsixPackageUri(packageDirName) };
return _Make_PackageSetItem(packageFullName, packageUri);
}
inline winrt::Microsoft::Windows::Management::Deployment::PackageSetItem Make_PackageSetItem_ForRegister(
PCWSTR packageFullName)
{
const auto appxManifestUri{ TP::GetAppxManifestPackageUri(packageFullName) };
return _Make_PackageSetItem(packageFullName, appxManifestUri);
}
inline bool IsPackageRegistered_Red()
{
return TP::IsPackageRegistered(TPF::Red::GetPackageFullName());
@ -121,11 +238,15 @@ namespace Test::PackageManager::Tests
}
inline void AddPackage_Red()
{
TP::AddPackageIfNecessary(Test::Packages::Framework::Red::c_packageDirName, TPF::Red::GetPackageFullName());
TP::AddPackageIfNecessary(TPF::Red::c_packageDirName, TPF::Red::GetPackageFullName());
}
inline void StagePackage_Red()
{
TP::StagePackageIfNecessary(Test::Packages::Framework::Red::c_packageDirName, TPF::Red::GetPackageFullName());
TP::StagePackageIfNecessary(TPF::Red::c_packageDirName, TPF::Red::GetPackageFullName());
}
inline void RegisterPackage_Red()
{
TP::RegisterPackageIfNecessary(TPF::Red::GetPackageFullName());
}
inline void RemovePackage_Red()
{
@ -145,16 +266,18 @@ namespace Test::PackageManager::Tests
{
// Same as RemovePackageFamily_Redder
RemovePackageFamily_Redder();
#if 0
// The package could be staged and not registered so checking
// checking for registered packages in the family is insufficient,
// and checking for staged packages not registered for the current user
// requires admin privilege (which we may not have). So we'll rely on
// remove for each package in the family handling it whether the packages
// are staged or registered.
TP::RemovePackageIfNecessary(TPF::Red::GetPackageFullName());
TP::RemovePackageIfNecessary(TPF::Redder::GetPackageFullName());
#endif
}
inline bool IsPackageProvisioned_Red()
{
return TP::IsPackageProvisioned(TPF::Red::c_packageFamilyName);
}
inline void ProvisionPackage_Red()
{
TP::ProvisionPackage(TPF::Red::c_packageFamilyName);
}
inline void DeprovisionPackage_Red()
{
TP::DeprovisionPackageIfNecessary(TPF::Red::c_packageFamilyName);
}
inline bool IsPackageRegistered_Redder()
@ -167,11 +290,15 @@ namespace Test::PackageManager::Tests
}
inline void AddPackage_Redder()
{
TP::AddPackageIfNecessary(Test::Packages::Framework::Redder::c_packageDirName, TPF::Redder::GetPackageFullName());
TP::AddPackageIfNecessary(TPF::Redder::c_packageDirName, TPF::Redder::GetPackageFullName());
}
inline void StagePackage_Redder()
{
TP::StagePackageIfNecessary(Test::Packages::Framework::Redder::c_packageDirName, TPF::Redder::GetPackageFullName());
TP::StagePackageIfNecessary(TPF::Redder::c_packageDirName, TPF::Redder::GetPackageFullName());
}
inline void RegisterPackage_Redder()
{
TP::RegisterPackageIfNecessary(TPF::Redder::GetPackageFullName());
}
inline void RemovePackage_Redder()
{
@ -191,16 +318,18 @@ namespace Test::PackageManager::Tests
{
RemovePackage_Redder();
RemovePackage_Red();
#if 0
// The package could be staged and not registered so checking
// checking for registered packages in the family is insufficient,
// and checking for staged packages not registered for the current user
// requires admin privilege (which we may not have). So we'll rely on
// remove for each package in the family handling it whether the packages
// are staged or registered.
TP::RemovePackageIfNecessary(TPF::Red::GetPackageFullName());
TP::RemovePackageIfNecessary(TPF::Redder::GetPackageFullName());
#endif
}
inline bool IsPackageProvisioned_Redder()
{
return TP::IsPackageProvisioned(TPF::Redder::c_packageFamilyName);
}
inline void ProvisionPackage_Redder()
{
TP::ProvisionPackage(TPF::Redder::c_packageFamilyName);
}
inline void DeprovisionPackage_Redder()
{
TP::DeprovisionPackageIfNecessary(TPF::Redder::c_packageFamilyName);
}
inline bool IsPackageRegistered_Green()
@ -213,11 +342,15 @@ namespace Test::PackageManager::Tests
}
inline void AddPackage_Green()
{
TP::AddPackageIfNecessary(Test::Packages::Framework::Green::c_packageDirName, TPF::Green::GetPackageFullName());
TP::AddPackageIfNecessary(TPF::Green::c_packageDirName, TPF::Green::GetPackageFullName());
}
inline void StagePackage_Green()
{
TP::StagePackageIfNecessary(Test::Packages::Framework::Green::c_packageDirName, TPF::Green::GetPackageFullName());
TP::StagePackageIfNecessary(TPF::Green::c_packageDirName, TPF::Green::GetPackageFullName());
}
inline void RegisterPackage_Green()
{
TP::RegisterPackageIfNecessary(TPF::Green::GetPackageFullName());
}
inline void RemovePackage_Green()
{
@ -236,15 +369,18 @@ namespace Test::PackageManager::Tests
inline void RemovePackageFamily_Green()
{
RemovePackage_Green();
#if 0
// The package could be staged and not registered so checking
// checking for registered packages in the family is insufficient,
// and checking for staged packages not registered for the current user
// requires admin privilege (which we may not have). So we'll rely on
// remove for each package in the family handling it whether the packages
// are staged or registered.
TP::RemovePackageIfNecessary(TPF::Green::GetPackageFullName());
#endif
}
inline bool IsPackageProvisioned_Green()
{
return TP::IsPackageProvisioned(TPF::Green::c_packageFamilyName);
}
inline void ProvisionPackage_Green()
{
TP::ProvisionPackage(TPF::Green::c_packageFamilyName);
}
inline void DeprovisionPackage_Green()
{
TP::DeprovisionPackageIfNecessary(TPF::Green::c_packageFamilyName);
}
inline bool IsPackageRegistered_Blue()
@ -257,11 +393,15 @@ namespace Test::PackageManager::Tests
}
inline void AddPackage_Blue()
{
TP::AddPackageIfNecessary(Test::Packages::Framework::Blue::c_packageDirName, TPF::Blue::GetPackageFullName());
TP::AddPackageIfNecessary(TPF::Blue::c_packageDirName, TPF::Blue::GetPackageFullName());
}
inline void StagePackage_Blue()
{
TP::StagePackageIfNecessary(Test::Packages::Framework::Blue::c_packageDirName, TPF::Blue::GetPackageFullName());
TP::StagePackageIfNecessary(TPF::Blue::c_packageDirName, TPF::Blue::GetPackageFullName());
}
inline void RegisterPackage_Blue()
{
TP::RegisterPackageIfNecessary(TPF::Blue::GetPackageFullName());
}
inline void RemovePackage_Blue()
{
@ -280,15 +420,238 @@ namespace Test::PackageManager::Tests
inline void RemovePackageFamily_Blue()
{
RemovePackage_Blue();
#if 0
// The package could be staged and not registered so checking
// checking for registered packages in the family is insufficient,
// and checking for staged packages not registered for the current user
// requires admin privilege (which we may not have). So we'll rely on
// remove for each package in the family handling it whether the packages
// are staged or registered.
TP::RemovePackageIfNecessary(TPF::Green::GetPackageFullName());
#endif
}
inline bool IsPackageProvisioned_Blue()
{
return TP::IsPackageProvisioned(TPF::Blue::c_packageFamilyName);
}
inline void ProvisionPackage_Blue()
{
TP::ProvisionPackage(TPF::Blue::c_packageFamilyName);
}
inline void DeprovisionPackage_Blue()
{
TP::DeprovisionPackageIfNecessary(TPF::Blue::c_packageFamilyName);
}
inline bool IsPackageRegistered_Black()
{
return TP::IsPackageRegistered(TPM::Black::GetPackageFullName());
}
inline bool IsPackageStaged_Black()
{
return TP::IsPackageStaged(TPM::Black::GetPackageFullName());
}
inline void AddPackage_Black()
{
TP::AddPackageIfNecessary(TPM::Black::c_packageDirName, TPM::Black::GetPackageFullName());
}
inline void AddPackageDefer_Black()
{
TP::AddPackageDeferIfNecessary(TPM::Black::c_packageDirName, TPM::Black::GetPackageFullName());
}
inline void StagePackage_Black()
{
TP::StagePackageIfNecessary(TPM::Black::c_packageDirName, TPM::Black::GetPackageFullName());
}
inline void RegisterPackage_Black()
{
TP::RegisterPackageIfNecessary(TPM::Black::GetPackageFullName());
}
inline void RemovePackage_Black()
{
if (IsPackageRegistered_Black())
{
TP::RemovePackage(TPM::Black::GetPackageFullName());
}
else if (IsPackageStaged_Black())
{
// We can't directly remove a Stage package not registered for current user
// w/o admin privilege but we can add it to make it registered and then remove it.
AddPackage_Black();
TP::RemovePackage(TPM::Black::GetPackageFullName());
}
}
inline void RemovePackageFamily_Black()
{
RemovePackage_Black();
}
inline bool IsPackageProvisioned_Black()
{
return TP::IsPackageProvisioned(TPM::Black::c_packageFamilyName);
}
inline void ProvisionPackage_Black()
{
TP::ProvisionPackage(TPM::Black::c_packageFamilyName);
}
inline void DeprovisionPackage_Black()
{
TP::DeprovisionPackageIfNecessary(TPM::Black::c_packageFamilyName);
}
inline bool IsPackageRegistered_Blacker()
{
return TP::IsPackageRegistered(TPM::Blacker::GetPackageFullName());
}
inline bool IsPackageStaged_Blacker()
{
return TP::IsPackageStaged(TPM::Blacker::GetPackageFullName());
}
inline void AddPackage_Blacker()
{
TP::AddPackageIfNecessary(TPM::Blacker::c_packageDirName, TPM::Blacker::GetPackageFullName());
}
inline void AddPackageDefer_Blacker()
{
TP::AddPackageDeferIfNecessary(TPM::Blacker::c_packageDirName, TPM::Blacker::GetPackageFullName());
}
inline void StagePackage_Blacker()
{
TP::StagePackageIfNecessary(TPM::Blacker::c_packageDirName, TPM::Blacker::GetPackageFullName());
}
inline void RegisterPackage_Blacker()
{
TP::RegisterPackageIfNecessary(TPM::Blacker::GetPackageFullName());
}
inline void RemovePackage_Blacker()
{
if (IsPackageRegistered_Blacker())
{
TP::RemovePackage(TPM::Blacker::GetPackageFullName());
}
else if (IsPackageStaged_Blacker())
{
// We can't directly remove a Stage package not registered for current user
// w/o admin privilege but we can add it to make it registered and then remove it.
AddPackage_Blacker();
TP::RemovePackage(TPM::Blacker::GetPackageFullName());
}
}
inline void RemovePackageFamily_Blacker()
{
RemovePackage_Blacker();
}
inline bool IsPackageProvisioned_Blacker()
{
return TP::IsPackageProvisioned(TPM::Blacker::c_packageFamilyName);
}
inline void ProvisionPackage_Blacker()
{
TP::ProvisionPackage(TPM::Blacker::c_packageFamilyName);
}
inline void DeprovisionPackage_Blacker()
{
TP::DeprovisionPackageIfNecessary(TPM::Blacker::c_packageFamilyName);
}
inline bool IsPackageRegistered_White()
{
return TP::IsPackageRegistered(TPM::White::GetPackageFullName());
}
inline bool IsPackageStaged_White()
{
return TP::IsPackageStaged(TPM::White::GetPackageFullName());
}
inline void AddPackage_White()
{
TP::AddPackageIfNecessary(TPM::White::c_packageDirName, TPM::White::GetPackageFullName());
}
inline void AddPackageDefer_White()
{
TP::AddPackageDeferIfNecessary(TPM::White::c_packageDirName, TPM::White::GetPackageFullName());
}
inline void StagePackage_White()
{
TP::StagePackageIfNecessary(TPM::White::c_packageDirName, TPM::White::GetPackageFullName());
}
inline void RegisterPackage_White()
{
TP::RegisterPackageIfNecessary(TPM::White::GetPackageFullName());
}
inline void RemovePackage_White()
{
if (IsPackageRegistered_White())
{
TP::RemovePackage(TPM::White::GetPackageFullName());
}
else if (IsPackageStaged_White())
{
// We can't directly remove a Stage package not registered for current user
// w/o admin privilege but we can add it to make it registered and then remove it.
AddPackage_White();
TP::RemovePackage(TPM::White::GetPackageFullName());
}
}
inline void RemovePackageFamily_White()
{
RemovePackage_White();
}
inline bool IsPackageProvisioned_White()
{
return TP::IsPackageProvisioned(TPM::White::c_packageFamilyName);
}
inline void ProvisionPackage_White()
{
TP::ProvisionPackage(TPM::White::c_packageFamilyName);
}
inline void DeprovisionPackage_White()
{
TP::DeprovisionPackageIfNecessary(TPM::White::c_packageFamilyName);
}
inline bool IsPackageRegistered_Whiter()
{
return TP::IsPackageRegistered(TPM::Whiter::GetPackageFullName());
}
inline bool IsPackageStaged_Whiter()
{
return TP::IsPackageStaged(TPM::Whiter::GetPackageFullName());
}
inline void AddPackage_Whiter()
{
TP::AddPackageIfNecessary(TPM::Whiter::c_packageDirName, TPM::Whiter::GetPackageFullName());
}
inline void AddPackageDefer_Whiter()
{
TP::AddPackageDeferIfNecessary(TPM::Whiter::c_packageDirName, TPM::Whiter::GetPackageFullName());
}
inline void StagePackage_Whiter()
{
TP::StagePackageIfNecessary(TPM::Whiter::c_packageDirName, TPM::Whiter::GetPackageFullName());
}
inline void RegisterPackage_Whiter()
{
TP::RegisterPackageIfNecessary(TPM::Whiter::GetPackageFullName());
}
inline void RemovePackage_Whiter()
{
if (IsPackageRegistered_Whiter())
{
TP::RemovePackage(TPM::Whiter::GetPackageFullName());
}
else if (IsPackageStaged_Whiter())
{
// We can't directly remove a Stage package not registered for current user
// w/o admin privilege but we can add it to make it registered and then remove it.
AddPackage_Whiter();
TP::RemovePackage(TPM::Whiter::GetPackageFullName());
}
}
inline void RemovePackageFamily_Whiter()
{
RemovePackage_Whiter();
}
inline bool IsPackageProvisioned_Whiter()
{
return TP::IsPackageProvisioned(TPM::Whiter::c_packageFamilyName);
}
inline void ProvisionPackage_Whiter()
{
TP::ProvisionPackage(TPM::Whiter::c_packageFamilyName);
}
inline void DeprovisionPackage_Whiter()
{
TP::DeprovisionPackageIfNecessary(TPM::Whiter::c_packageFamilyName);
}
inline winrt::Windows::ApplicationModel::PackageStatus GetPackageStatus(winrt::Windows::Management::Deployment::PackageManager packageManager, PCWSTR packageFullName)

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

@ -88,6 +88,7 @@
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>Microsoft.Internal.FrameworkUdk.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
@ -110,10 +111,24 @@
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Add.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Deprovision_Framework.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Deprovision_Main.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_EnsureReady.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_IsPackageRegistrationPending.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_IsReady.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_IsReadyOrNewerAvailable.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Provision.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Register.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Remove.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Repair.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Reset.cpp" />
<ClCompile Include="PackageDeploymentManagerTests_Stage.cpp" />
<ClCompile Include="PackageRuntimeManagerTests.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="PackageDeploymentManagerTests.h" />
<ClInclude Include="PackageManagerTests.Packages.h" />
</ItemGroup>
<ItemGroup>
@ -153,6 +168,7 @@
<Import Project="$(NugetPackageDirectory)\Microsoft.Taef.$(MicrosoftTaefVersion)\build\Microsoft.Taef.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Taef.$(MicrosoftTaefVersion)\build\Microsoft.Taef.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.$(MicrosoftWindowsCppWinRTVersion)\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.$(MicrosoftWindowsCppWinRTVersion)\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.FrameworkUdk\$(MicrosoftFrameworkUdkPackageVersion)\build\native\Microsoft.FrameworkUdk.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.FrameworkUdk\$(MicrosoftFrameworkUdkPackageVersion)\build\native\Microsoft.FrameworkUdk.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@ -168,5 +184,6 @@
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.$(MicrosoftWindowsCppWinRTVersion)\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.$(MicrosoftWindowsCppWinRTVersion)\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.$(MicrosoftWindowsCppWinRTVersion)\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.$(MicrosoftWindowsCppWinRTVersion)\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.FrameworkUdk\$(MicrosoftFrameworkUdkPackageVersion)\build\native\Microsoft.FrameworkUdk.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.FrameworkUdk\$(MicrosoftFrameworkUdkPackageVersion)\build\native\Microsoft.FrameworkUdk.targets'))" />
</Target>
</Project>

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

@ -21,6 +21,45 @@
<ClCompile Include="PackageDeploymentManagerTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Add.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Deprovision_Framework.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Deprovision_Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_EnsureReady.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_IsPackageRegistrationPending.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_IsReady.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_IsReadyOrNewerAvailable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Provision.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Register.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Remove.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Repair.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Reset.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageDeploymentManagerTests_Stage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PackageRuntimeManagerTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -29,6 +68,9 @@
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PackageDeploymentManagerTests.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PackageManagerTests.Packages.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -36,4 +78,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
</ItemGroup>
</Project>

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

@ -5,9 +5,11 @@
#include <MddWin11.h>
namespace TD = ::Test::Diagnostics;
namespace TB = ::Test::Bootstrap;
namespace TP = ::Test::Packages;
namespace TPF = ::Test::Packages::Framework;
namespace TPM = ::Test::Packages::Main;
namespace TPMT = ::Test::PackageManager::Tests;
namespace Test::PackageManager::Tests

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

@ -3,7 +3,8 @@
<package id="Microsoft.Build.Tasks.Git" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Taef" version="10.82.230714001" targetFramework="native" />
<package id="Microsoft.Taef" version="10.92.240405002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.FrameworkUdk" version="1.7.0-CI-26107.1701.240510-1748.0" targetFramework="native" />
</packages>

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

@ -6,6 +6,9 @@
#include <unknwn.h>
#include <ShObjIdl.h>
#include <wil/com.h>
#include <wil/cppwinrt.h>
#include <winrt/Windows.Foundation.h>
@ -28,4 +31,24 @@
#include "PackageManagerTests.Packages.h"
#include <windows.foundation.h>
#include <windows.foundation.collections.h>
#include <windows.management.deployment.h>
#if defined(NTDDI_WIN11_GE)
# define TODO_UpdatedWindowsSDK_with_Windows_Management_Deployment_IRemovePackageOptions
#endif
#if !defined(TODO_UpdatedWindowsSDK_with_Windows_Management_Deployment_IRemovePackageOptions)
// Until we have access to the updated Windows SDK we can't use RemovePackageOptions
// but we need *something* to satisfy PackageManagement_RemovePackageByUriAsync() in the FrameworkUDK
// so we'll make a placeholder definition to satisfy the compiler enough to let us call
// PackageManagement_RemovePackageByUriAsync2(uri, nullptr). Remove this once the updated
// Windows SDK makes this unnecessary.
namespace ABI::Windows::Management::Deployment
{
typedef void * IRemovePackageOptions;
}
#endif
//
#include <FrameworkUdk/PackageManagement.h>
#endif //PCH_H

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

@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

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

@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
#include <unknwn.h>
#include <filesystem>
#include <thread>
#include <mutex>
#include <wil/win32_helpers.h>
#include <wil/resource.h>
#include <wil/result_macros.h>
#endif //PCH_H

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

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, PSTR /*lpCmdLine*/, int /*nCmdShow*/)
{
// Usage: This.Exe <eventname>
// where
// eventname = event name signaling we should quit.
// Parse the command line
const auto eventName{ GetCommandLineW() };
if (eventName)
{
wil::unique_event_nothrow endOfTheLine{ ::OpenEventW(SYNCHRONIZE, FALSE, eventName) };
RETURN_LAST_ERROR_IF_NULL(endOfTheLine);
auto rc{ WaitForSingleObject(endOfTheLine.get(), INFINITE) };
if (rc != WAIT_OBJECT_0)
{
if (rc == WAIT_FAILED)
{
LOG_LAST_ERROR();
}
else
{
LOG_HR_MSG(E_UNEXPECTED, "%u", rc);
}
return rc;
}
}
return 0;
}

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

После

Ширина:  |  Высота:  |  Размер: 76 KiB

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

После

Ширина:  |  Высота:  |  Размер: 11 KiB

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

После

Ширина:  |  Высота:  |  Размер: 2.7 KiB

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

После

Ширина:  |  Высота:  |  Размер: 11 KiB

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

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

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

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{39277b4c-4fb5-45f6-b0aa-ee8086590cda}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PackageManager.Test.M.Black.Msix</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup>
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<TargetName>PackageManager.Test.M.Black</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<TargetName>PackageManager.Test.M.Black</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Black</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Black</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Black</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Black</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="winmain.cpp" />
</ItemGroup>
<ItemGroup>
<Xml Include="appxmanifest-arm64.xml" />
<Xml Include="appxmanifest-x64.xml" />
<Xml Include="appxmanifest-x86.xml" />
</ItemGroup>
<PropertyGroup>
<MakeMsixOutputFilename>PackageManager.Test.M.Black.msix</MakeMsixOutputFilename>
<TargetBasename>PackageManager.Test.M.Black</TargetBasename>
<TargetExe>$(TargetBasename)</TargetExe>
<TargetExeDir>$(OutDir)$(ProjectName)</TargetExeDir>
<TargetExeFile>$(TargetExeDir)\$(TargetExe).exe</TargetExeFile>
</PropertyGroup>
<ItemGroup>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-x86.xml" Condition="'$(PlatformTarget)' == 'x86'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-x64.xml" Condition="'$(PlatformTarget)' == 'x64'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-arm64.xml" Condition="'$(PlatformTarget)' == 'arm64'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputAssets Include="$(MSBuildThisFileDirectory)\Assets\*" />
<MakeMsixInputs Include="$(TargetExeFile)" />
</ItemGroup>
<PropertyGroup>
<PackageCertificateKeyFile>$(RepoTestCertificatePFX)</PackageCertificateKeyFile>
<PackageCertificatePassword>$(RepoTestCertificatePassword)</PackageCertificatePassword>
</PropertyGroup>
<Import Project="$(RepoRoot)\MakeMsix.targets" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>

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

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="winmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="appxmanifest-arm64.xml" />
<None Include="appxmanifest-x64.xml" />
<None Include="appxmanifest-x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

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

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="appxmanifest-arm64.xml" />
<None Include="appxmanifest-x64.xml" />
<None Include="appxmanifest-x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
<Identity
Name="Test.PackageManager.M.Black"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="1.2.3.4"
ProcessorArchitecture="arm64" />
<Properties>
<DisplayName>Test.PackageManager.M.Black</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
<Applications>
<Application Id="App"
Executable="PackageManager.Test.M.Black.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Test.PackageManager.M.Black"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="Windows App SDK Test Test.PackageManager.M.Black"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
<Identity
Name="Test.PackageManager.M.Black"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="1.2.3.4"
ProcessorArchitecture="x64" />
<Properties>
<DisplayName>Test.PackageManager.M.Black</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
<Applications>
<Application Id="App"
Executable="PackageManager.Test.M.Black.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Test.PackageManager.M.Black"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="Windows App SDK Test Test.PackageManager.M.Black"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
<Identity
Name="Test.PackageManager.M.Black"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="1.2.3.4"
ProcessorArchitecture="x86" />
<Properties>
<DisplayName>Test.PackageManager.M.Black</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
<Applications>
<Application Id="App"
Executable="PackageManager.Test.M.Black.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Test.PackageManager.M.Black"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="Windows App SDK Test Test.PackageManager.M.Black"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

Двоичные данные
test/PackageManager/data/PackageManager.Test.M.Black.msix/logo.png Normal file

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

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

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Build.Tasks.Git" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

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

@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
#include <unknwn.h>
#include <filesystem>
#include <thread>
#include <mutex>
#include <wil/win32_helpers.h>
#include <wil/resource.h>
#include <wil/result_macros.h>
#endif //PCH_H

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

@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, PSTR /*lpCmdLine*/, int /*nCmdShow*/)
{
// Usage: This.Exe <eventname>
// where
// eventname = event name signaling we should quit.
// Parse the command line
const auto commandLine{ GetCommandLineW() };
int argc{};
PWSTR* argv{ CommandLineToArgvW(commandLine, &argc) };
RETURN_HR_IF_NULL(E_INVALIDARG, argv);
if (argc >= 2)
{
PCWSTR eventName{ argv[1] };
wil::unique_event_nothrow endOfTheLine{ ::OpenEventW(SYNCHRONIZE, FALSE, eventName) };
RETURN_LAST_ERROR_IF_NULL(endOfTheLine);
auto rc{ WaitForSingleObject(endOfTheLine.get(), INFINITE) };
if (rc != WAIT_OBJECT_0)
{
if (rc == WAIT_FAILED)
{
LOG_LAST_ERROR();
}
else
{
LOG_HR_MSG(E_UNEXPECTED, "%u", rc);
}
return rc;
}
}
return 0;
}

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

После

Ширина:  |  Высота:  |  Размер: 76 KiB

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

После

Ширина:  |  Высота:  |  Размер: 11 KiB

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

После

Ширина:  |  Высота:  |  Размер: 2.7 KiB

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

После

Ширина:  |  Высота:  |  Размер: 11 KiB

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

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

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

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{ad7d0a19-44b9-41d6-a68a-9fecac28078d}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PackageManager.Test.M.Blacker.Msix</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup>
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<TargetName>PackageManager.Test.M.Blacker</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<TargetName>PackageManager.Test.M.Blacker</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Blacker</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Blacker</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Blacker</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetName>PackageManager.Test.M.Blacker</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="winmain.cpp" />
</ItemGroup>
<ItemGroup>
<Xml Include="appxmanifest-arm64.xml" />
<Xml Include="appxmanifest-x64.xml" />
<Xml Include="appxmanifest-x86.xml" />
</ItemGroup>
<PropertyGroup>
<MakeMsixOutputFilename>PackageManager.Test.M.Blacker.msix</MakeMsixOutputFilename>
<TargetBasename>PackageManager.Test.M.Blacker</TargetBasename>
<TargetExe>$(TargetBasename)</TargetExe>
<TargetExeDir>$(OutDir)$(ProjectName)</TargetExeDir>
<TargetExeFile>$(TargetExeDir)\$(TargetExe).exe</TargetExeFile>
</PropertyGroup>
<ItemGroup>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-x86.xml" Condition="'$(PlatformTarget)' == 'x86'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-x64.xml" Condition="'$(PlatformTarget)' == 'x64'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-arm64.xml" Condition="'$(PlatformTarget)' == 'arm64'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputAssets Include="$(MSBuildThisFileDirectory)\Assets\*" />
<MakeMsixInputs Include="$(TargetExeFile)" />
</ItemGroup>
<PropertyGroup>
<PackageCertificateKeyFile>$(RepoTestCertificatePFX)</PackageCertificateKeyFile>
<PackageCertificatePassword>$(RepoTestCertificatePassword)</PackageCertificatePassword>
</PropertyGroup>
<Import Project="$(RepoRoot)\MakeMsix.targets" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>

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

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="winmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="appxmanifest-arm64.xml" />
<None Include="appxmanifest-x64.xml" />
<None Include="appxmanifest-x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

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

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="appxmanifest-arm64.xml" />
<None Include="appxmanifest-x64.xml" />
<None Include="appxmanifest-x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
<Identity
Name="Test.PackageManager.M.Black"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="2.4.6.8"
ProcessorArchitecture="arm64" />
<Properties>
<DisplayName>Test.PackageManager.M.Blacker</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
<Applications>
<Application Id="App"
Executable="PackageManager.Test.M.Blacker.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Test.PackageManager.M.Blacker"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="Windows App SDK Test Test.PackageManager.M.Blacker"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
<Identity
Name="Test.PackageManager.M.Black"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="2.4.6.8"
ProcessorArchitecture="x64" />
<Properties>
<DisplayName>Test.PackageManager.M.Blacker</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
<Applications>
<Application Id="App"
Executable="PackageManager.Test.M.Blacker.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Test.PackageManager.M.Blacker"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="Windows App SDK Test Test.PackageManager.M.Blacker"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap5 rescap">
<Identity
Name="Test.PackageManager.M.Black"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="2.4.6.8"
ProcessorArchitecture="x86" />
<Properties>
<DisplayName>Test.PackageManager.M.Blacker</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22621.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
<Applications>
<Application Id="App"
Executable="PackageManager.Test.M.Blacker.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Test.PackageManager.M.Blacker"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="Windows App SDK Test Test.PackageManager.M.Blacker"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

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

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

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Build.Tasks.Git" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>

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

@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

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

@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
#include <unknwn.h>
#include <filesystem>
#include <thread>
#include <mutex>
#include <wil/win32_helpers.h>
#include <wil/resource.h>
#include <wil/result_macros.h>
#endif //PCH_H

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

@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, PSTR /*lpCmdLine*/, int /*nCmdShow*/)
{
// Usage: This.Exe <eventname>
// where
// eventname = event name signaling we should quit.
// Parse the command line
const auto commandLine{ GetCommandLineW() };
int argc{};
PWSTR* argv{ CommandLineToArgvW(commandLine, &argc) };
RETURN_HR_IF_NULL(E_INVALIDARG, argv);
if (argc >= 2)
{
PCWSTR eventName{ argv[1] };
wil::unique_event_nothrow endOfTheLine{ ::OpenEventW(SYNCHRONIZE, FALSE, eventName) };
RETURN_LAST_ERROR_IF_NULL(endOfTheLine);
auto rc{ WaitForSingleObject(endOfTheLine.get(), INFINITE) };
if (rc != WAIT_OBJECT_0)
{
if (rc == WAIT_FAILED)
{
LOG_LAST_ERROR();
}
else
{
LOG_HR_MSG(E_UNEXPECTED, "%u", rc);
}
return rc;
}
}
return 0;
}

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

После

Ширина:  |  Высота:  |  Размер: 76 KiB

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

После

Ширина:  |  Высота:  |  Размер: 11 KiB

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

После

Ширина:  |  Высота:  |  Размер: 2.7 KiB

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

После

Ширина:  |  Высота:  |  Размер: 11 KiB

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

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

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

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{28dcf9ce-d9f4-4a7d-8ad1-f2efc0d3b4df}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PackageManager.Test.M.White.Msix</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup>
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<TargetName>PackageManager.Test.M.White</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<TargetName>PackageManager.Test.M.White</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<TargetName>PackageManager.Test.M.White</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<TargetName>PackageManager.Test.M.White</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetName>PackageManager.Test.M.White</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetName>PackageManager.Test.M.White</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="winmain.cpp" />
</ItemGroup>
<ItemGroup>
<Xml Include="appxmanifest-arm64.xml" />
<Xml Include="appxmanifest-x64.xml" />
<Xml Include="appxmanifest-x86.xml" />
</ItemGroup>
<PropertyGroup>
<MakeMsixOutputFilename>PackageManager.Test.M.White.msix</MakeMsixOutputFilename>
<TargetBasename>PackageManager.Test.M.White</TargetBasename>
<TargetExe>$(TargetBasename)</TargetExe>
<TargetExeDir>$(OutDir)$(ProjectName)</TargetExeDir>
<TargetExeFile>$(TargetExeDir)\$(TargetExe).exe</TargetExeFile>
</PropertyGroup>
<ItemGroup>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-x86.xml" Condition="'$(PlatformTarget)' == 'x86'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-x64.xml" Condition="'$(PlatformTarget)' == 'x64'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputsWithLocations Include="$(MSBuildThisFileDirectory)appxmanifest-arm64.xml" Condition="'$(PlatformTarget)' == 'arm64'">
<TargetFile>appxmanifest.xml</TargetFile>
</MakeMsixInputsWithLocations>
<MakeMsixInputAssets Include="$(MSBuildThisFileDirectory)\Assets\*" />
<MakeMsixInputs Include="$(TargetExeFile)" />
</ItemGroup>
<PropertyGroup>
<PackageCertificateKeyFile>$(RepoTestCertificatePFX)</PackageCertificateKeyFile>
<PackageCertificatePassword>$(RepoTestCertificatePassword)</PackageCertificatePassword>
</PropertyGroup>
<Import Project="$(RepoRoot)\MakeMsix.targets" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets')" />
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.Common.$(MicrosoftSourceLinkCommonVersion)\build\Microsoft.SourceLink.Common.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Build.Tasks.Git.$(MicrosoftBuildTasksGitVersion)\build\Microsoft.Build.Tasks.Git.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.props'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.SourceLink.GitHub.$(MicrosoftSourceLinkGitHubVersion)\build\Microsoft.SourceLink.GitHub.targets'))" />
<Error Condition="!Exists('$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(NugetPackageDirectory)\Microsoft.Windows.ImplementationLibrary.$(MicrosoftWindowsImplementationLibraryVersion)\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>

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

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="winmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="appxmanifest-arm64.xml" />
<None Include="appxmanifest-x64.xml" />
<None Include="appxmanifest-x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

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

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="appxmanifest-arm64.xml" />
<None Include="appxmanifest-x64.xml" />
<None Include="appxmanifest-x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше