-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
190 additions
and
309 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
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 |
---|---|---|
@@ -1,17 +1,13 @@ | ||
|
||
enable_language("RC") | ||
|
||
add_subdirectory(components) | ||
|
||
add_executable(${PROJECT_NAME} WIN32 | ||
DisplayLock.c | ||
main.c | ||
ui.c | ||
menu.c | ||
notify.c | ||
settings.c | ||
update.c | ||
win.c | ||
applications.c | ||
) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE version Shlwapi winhttp iphlpapi) | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC -DUNICODE) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC display_lock_components) | ||
target_include_directories(display_lock_components PUBLIC resources) | ||
|
||
add_subdirectory(resources) |
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,13 @@ | ||
project(display_lock_components) | ||
|
||
add_library(${PROJECT_NAME} STATIC | ||
menu.c | ||
notify.c | ||
settings.c | ||
update.c | ||
win.c | ||
applications.c | ||
) | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC -DUNICODE) | ||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC version Shlwapi winhttp iphlpapi) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,2 +1,44 @@ | ||
project(display-lock-unittests) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}/tests) | ||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/tests) | ||
|
||
message(STATUS "BINARY PATH ${CMAKE_BINARY_DIR}") | ||
|
||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") | ||
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") | ||
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake" | ||
"${CMAKE_BINARY_DIR}/conan.cmake" | ||
TLS_VERIFY ON) | ||
endif() | ||
|
||
include(${CMAKE_BINARY_DIR}/conan.cmake) | ||
|
||
conan_cmake_configure( | ||
REQUIRES gtest/1.13.0 | ||
GENERATORS cmake_find_package | ||
) | ||
|
||
conan_cmake_autodetect(settings) | ||
|
||
conan_cmake_install( | ||
PATH_OR_REFERENCE . | ||
BUILD missing | ||
REMOTE conancenter | ||
SETTINGS ${settings} | ||
) | ||
|
||
enable_testing() | ||
|
||
find_package(GTest REQUIRED) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
add_executable(${PROJECT_NAME} test_settings.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest_main display_lock_components) | ||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/resources) | ||
|
||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_resources $<TARGET_FILE_DIR:${PROJECT_NAME}>) |
File renamed without changes.
File renamed without changes.
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,97 @@ | ||
#include "gtest/gtest.h" | ||
|
||
extern "C" { | ||
#include "settings.h" | ||
} | ||
|
||
// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers | ||
// #include <Windows.h> | ||
#include <iostream> | ||
#include <filesystem> | ||
#include <source_location> | ||
|
||
|
||
namespace { | ||
|
||
// settings.h | ||
TEST(SettingsTest, DefaultSettings) | ||
{ | ||
SETTINGS settings; | ||
defaultSettings(&settings, L"5"); | ||
|
||
// It's impossible to test the default version, as it's determined at run time | ||
ASSERT_STREQ(settings.header, "DLOCK"); | ||
ASSERT_EQ(settings.version, 5); | ||
ASSERT_EQ(settings.borderless, false); | ||
ASSERT_EQ(settings.foreground, false); | ||
ASSERT_EQ(settings.fullScreen, false); | ||
ASSERT_EQ(settings.minimize, true); | ||
} | ||
|
||
TEST(SettingsTest, CheckVersion) | ||
{ | ||
SETTINGS settings; | ||
|
||
defaultSettings(&settings, L"5"); | ||
ASSERT_EQ(checkVersion(&settings, L"5"), true); | ||
ASSERT_EQ(checkVersion(&settings, L"0005"), true); | ||
ASSERT_EQ(checkVersion(&settings, L"15"), false); | ||
ASSERT_EQ(checkVersion(&settings, L"A"), false); | ||
ASSERT_EQ(checkVersion(&settings, L"FOO"), false); | ||
ASSERT_EQ(checkVersion(&settings, L"F5"), false); | ||
|
||
strcpy_s(settings.header, 6, "5A!"); | ||
ASSERT_EQ(checkVersion(&settings, L"5"), false); | ||
strcpy_s(settings.header, 6, "FOO"); | ||
ASSERT_EQ(checkVersion(&settings, L"5"), false); | ||
strcpy_s(settings.header, 6, ""); | ||
ASSERT_EQ(checkVersion(&settings, L"5"), false); | ||
} | ||
|
||
TEST(SettingsTest, FindPath) | ||
{ | ||
wchar_t path[MAX_PATH]; | ||
BOOL res = findPath(path); | ||
|
||
ASSERT_EQ(res, true); | ||
} | ||
|
||
TEST(SettingsTest, ReadSettings) | ||
{ | ||
SETTINGS settings = { 0 }; | ||
BOOL result; | ||
|
||
result = readSettings(&settings, L"5", L"test1.DLOCK"); | ||
ASSERT_EQ(result, true); | ||
ASSERT_EQ(strcmp(settings.header, "DLOCK"), 0); | ||
ASSERT_EQ(settings.version, 5); | ||
ASSERT_EQ(settings.minimize, false); | ||
ASSERT_EQ(settings.foreground, false); | ||
ASSERT_EQ(settings.borderless, false); | ||
ASSERT_EQ(settings.fullScreen, false); | ||
} | ||
|
||
TEST(SettingsTest, WriteSettings) | ||
{ | ||
BOOL result; | ||
|
||
SETTINGS settings = {"DLOCK", 5, true, true, false, false}; | ||
|
||
result = writeSettings(settings, L"output.DLOCK"); | ||
ASSERT_EQ(result, true); | ||
|
||
settings.version = 0; | ||
|
||
result = writeSettings(settings, L"output.DLOCK"); | ||
ASSERT_EQ(result, false); | ||
|
||
settings.version = 5; | ||
|
||
strcpy_s(settings.header, 6, "FOOBA"); | ||
|
||
result = writeSettings(settings, L".\\output.DLOCK"); | ||
ASSERT_EQ(result, false); | ||
|
||
DeleteFileW(L"output.DLOCK"); | ||
} | ||
} |
Oops, something went wrong.