-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick of #3808 , then fixing up the changes (mostly namespace changes, but also bring one extra function over) for the fact that the SQLite base code moved around.
- Loading branch information
Showing
44 changed files
with
1,041 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,7 @@ ENDSESSION | |
EPester | ||
epth | ||
EQU | ||
errcode | ||
errmsg | ||
ERRORONEXIT | ||
ESource | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "TestCommon.h" | ||
#include "TestHooks.h" | ||
#include "Microsoft/ARPHelper.h" | ||
#include "AppInstallerStrings.h" | ||
|
||
using namespace AppInstaller::Manifest; | ||
using namespace AppInstaller::Repository::Microsoft; | ||
using namespace AppInstaller::Utility; | ||
using namespace AppInstaller::Registry; | ||
|
||
|
||
TEST_CASE("ARPHelper_Watcher", "[ARPHelper]") | ||
{ | ||
ARPHelper helper; | ||
|
||
wil::unique_event callbackEvent; | ||
callbackEvent.create(); | ||
|
||
ScopeEnum scopeCallback = ScopeEnum::Unknown; | ||
Architecture architectureCallback = Architecture::Unknown; | ||
|
||
ScopeEnum scopeTarget = ScopeEnum::Machine; | ||
Architecture architectureTarget = Architecture::X86; | ||
|
||
auto fakeRoot = TestCommon::RegCreateVolatileTestRoot(); | ||
TestHook::SetGetARPKey_Override arpOverride([&](ScopeEnum scope, Architecture arch) | ||
{ | ||
if (scope == scopeTarget && arch == architectureTarget) | ||
{ | ||
return Key(fakeRoot.get(), L""); | ||
} | ||
else | ||
{ | ||
return Key{}; | ||
} | ||
}); | ||
|
||
auto watchers = helper.CreateRegistryWatchers(scopeTarget, [&](ScopeEnum scope, Architecture arch, wil::RegistryChangeKind) | ||
{ | ||
scopeCallback = scope; | ||
architectureCallback = arch; | ||
callbackEvent.SetEvent(); | ||
}); | ||
|
||
auto arpKey = helper.GetARPKey(scopeTarget, architectureTarget); | ||
REQUIRE(!!arpKey); | ||
|
||
GUID guid; | ||
std::ignore = CoCreateGuid(&guid); | ||
std::ostringstream stream; | ||
stream << guid; | ||
|
||
auto testKey = TestCommon::RegCreateVolatileSubKey(arpKey, ConvertToUTF16(stream.str())); | ||
|
||
REQUIRE(callbackEvent.wait(1000)); | ||
REQUIRE(scopeTarget == scopeCallback); | ||
REQUIRE(architectureTarget == architectureCallback); | ||
|
||
// Reset for changing a value | ||
scopeCallback = ScopeEnum::Unknown; | ||
architectureCallback = Architecture::Unknown; | ||
|
||
TestCommon::SetRegistryValue(testKey.get(), L"testValue", L"valueValue"); | ||
|
||
REQUIRE(callbackEvent.wait(1000)); | ||
REQUIRE(scopeTarget == scopeCallback); | ||
REQUIRE(architectureTarget == architectureCallback); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.