mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
Some refactoring of FancyZones::IsInterestingWindow and added Unit Tests (#1521)
* Some refactoring of FancyZones::IsInterestingWindow and added UnitTests
This commit is contained in:
committed by
GitHub
parent
04027b9c32
commit
02857d1b7f
@@ -91,10 +91,11 @@
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>RuntimeObject.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>RuntimeObject.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="UnitTestsCommon.cpp" />
|
||||
<ClCompile Include="UnitTestsVersionHelper.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
<ClCompile Include="UnitTestsVersionHelper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UnitTestsCommon.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
|
||||
57
src/common/UnitTests-CommonLib/UnitTestsCommon.cpp
Normal file
57
src/common/UnitTests-CommonLib/UnitTestsCommon.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "pch.h"
|
||||
#include "common.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace UnitTestsCommon
|
||||
{
|
||||
TEST_CLASS (CommonUtils)
|
||||
{
|
||||
std::vector<std::wstring> what_global{
|
||||
L"TELEGRAM",
|
||||
L"SUBLIME TEXT",
|
||||
L"PROGRAM",
|
||||
L"TEXT",
|
||||
};
|
||||
|
||||
TEST_METHOD (FindAppNameInPathTest1)
|
||||
{
|
||||
std::wstring where(L"C:\\USERS\\GUEST\\APPDATA\\ROAMING\\TELEGRAM DESKTOP\\TELEGRAM.EXE");
|
||||
bool ans = find_app_name_in_path(where, what_global);
|
||||
Assert::IsTrue(ans);
|
||||
}
|
||||
TEST_METHOD (FindAppNameInPathTest2)
|
||||
{
|
||||
std::vector<std::wstring> what{
|
||||
L"NOTEPAD",
|
||||
};
|
||||
std::wstring where(L"C:\\PROGRAM FILES\\NOTEPAD++\\NOTEPAD++.EXE");
|
||||
bool ans = find_app_name_in_path(where, what);
|
||||
Assert::IsTrue(ans);
|
||||
}
|
||||
TEST_METHOD (FindAppNameInPathTest3)
|
||||
{
|
||||
std::vector<std::wstring> what{
|
||||
L"NOTEPAD++.EXE",
|
||||
};
|
||||
std::wstring where(L"C:\\PROGRAM FILES\\NOTEPAD++\\NOTEPAD++.EXE");
|
||||
bool ans = find_app_name_in_path(where, what);
|
||||
Assert::IsTrue(ans);
|
||||
}
|
||||
TEST_METHOD (FindAppNameInPathTest4)
|
||||
{
|
||||
std::wstring where(L"C:\\PROGRAM FILES\\SUBLIME TEXT 3\\SUBLIME_TEXT.EXE");
|
||||
bool ans = find_app_name_in_path(where, what_global);
|
||||
Assert::IsFalse(ans);
|
||||
}
|
||||
TEST_METHOD (FindAppNameInPathTest5)
|
||||
{
|
||||
std::vector<std::wstring> what{
|
||||
L"NOTEPAD.EXE",
|
||||
};
|
||||
std::wstring where(L"C:\\PROGRAM FILES\\NOTEPAD++\\NOTEPAD++.EXE");
|
||||
bool ans = find_app_name_in_path(where, what);
|
||||
Assert::IsFalse(ans);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user