* Fix existing tests

* Add test with shared binaries
This commit is contained in:
jyvenugo 2019-09-25 15:56:48 -07:00 коммит произвёл GitHub
Родитель 1389e84cbb
Коммит bfa7bf7400
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 41 добавлений и 2 удалений

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

@ -10,6 +10,10 @@
const std::wstring scribbleFileName = L"scribble.appx";
const std::wstring scribblePackageFullName = L"ScribbleOleDocumentSample_1.1.0.0_x86__8wekyb3d8bbwe";
const std::wstring windows10PackageRoot = L"C:\\Program Files\\Windowsapps";
const std::wstring notepadplusFileName = L"notepadplus.msix";
const std::wstring notepadplusFullName = L"notepadplus_0.0.0.0_x64__8wekyb3d8bbwe";
const std::wstring notepadplusCopyFileName = L"notepadplusCopy.msix";
const std::wstring notepadplusCopyFullName = L"notepadplusCopy_0.0.0.0_x64__8wekyb3d8bbwe";
MsixCoreTest::~MsixCoreTest()
{
@ -47,7 +51,7 @@ bool MsixCoreTest::CleanupMethod()
void MsixCoreTest::VerifyPackageInstalled(std::wstring & packageFullName)
{
std::unique_ptr<std::vector<std::shared_ptr<MsixCoreLib::IInstalledPackage>>> packages;
VERIFY_SUCCEEDED(m_packageManager->FindPackages(packages));
VERIFY_SUCCEEDED(m_packageManager->FindPackages(L"*", packages));
bool found = false;
for (auto& package : *packages)
@ -122,7 +126,7 @@ void MsixCoreTest::InstallIStreamPackageTest()
VERIFY_SUCCEEDED(m_packageManager->AddPackage(packageStream, DeploymentOptions::None));
std::unique_ptr<std::vector<std::shared_ptr<MsixCoreLib::IInstalledPackage>>> packages;
VERIFY_SUCCEEDED(m_packageManager->FindPackages(packages));
VERIFY_SUCCEEDED(m_packageManager->FindPackages(L"*", packages));
bool found = false;
for (auto& package : *packages)
@ -213,4 +217,32 @@ void MsixCoreTest::InstallFromEmbeddedStreamTest()
VerifyPackageInstalled(expectedPackageFullName);
VERIFY_SUCCEEDED(m_packageManager->RemovePackage(expectedPackageFullName));
}
void MsixCoreTest::TestSharedBinaries()
{
//Install first package
std::wstring packagePath = std::wstring(m_testDeploymentDir) + L"\\" + notepadplusFileName;
std::wstring expectedPackageFullName = notepadplusFullName;
VERIFY_SUCCEEDED(m_packageManager->AddPackage(packagePath, DeploymentOptions::None));
VerifyPackageInstalled(expectedPackageFullName);
//Install second package with same binary
std::wstring packagePathSecond = std::wstring(m_testDeploymentDir) + L"\\" + notepadplusCopyFileName;
std::wstring expectedPackageFullNameSecond = notepadplusCopyFullName;
VERIFY_SUCCEEDED(m_packageManager->AddPackage(packagePathSecond, DeploymentOptions::None));
VerifyPackageInstalled(expectedPackageFullNameSecond);
//Remove first package
VERIFY_SUCCEEDED(m_packageManager->RemovePackage(expectedPackageFullName));
//the exe file in the actual location should still exist
std::wstring notepadExeName = L"C:\\Program Files (x86)\\Notepad++\\notepad++.exe";
VERIFY_IS_TRUE(std::experimental::filesystem::exists(notepadExeName));
//Remove second package
VERIFY_SUCCEEDED(m_packageManager->RemovePackage(expectedPackageFullNameSecond));
//After removing second package with shared binary, the exe should now not exist
VERIFY_IS_TRUE(!std::experimental::filesystem::exists(notepadExeName));
}

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

@ -34,6 +34,10 @@ public:
BEGIN_TEST_METHOD(InstallFromEmbeddedStreamTest)
TEST_METHOD_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD()
BEGIN_TEST_METHOD(TestSharedBinaries)
TEST_METHOD_PROPERTY(L"RunAs", L"ElevatedUser")
END_TEST_METHOD()
private:
MsixCoreLib::IPackageManager * m_packageManager;
WEX::Common::String m_testDeploymentDir;

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

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:141ed9f54048786a664274a6884f846bd436e7e24592f1ef98c00c94c58ff475
size 3112186