diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f62562a..99da648 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -68,7 +68,7 @@ jobs:
strategy:
fail-fast: false
- matrix: ${{ fromJSON(github.event_name == 'push' && github.ref == 'refs/heads/main' && '{"platform":["x64","Win32"],"configuration":["Debug","Release"]}' || '{"platform":["x64"],"configuration":["Debug","Release"]}') }}
+ matrix: ${{ fromJSON(github.event_name == 'push' && github.ref == 'refs/heads/main' && '{"platform":["x64","Win32"],"configuration":["Debug","Release"]}' || github.event_name == 'pull_request' && '{"include":[{"platform":"x64","configuration":"Debug"},{"platform":"x64","configuration":"Release"},{"platform":"Win32","configuration":"Debug"}]}' || '{"platform":["x64"],"configuration":["Debug","Release"]}') }}
env:
VCPKG_BINARY_SOURCES: 'clear;files,${{ github.workspace }}\vcpkg-binary-cache,readwrite'
diff --git a/.gitignore b/.gitignore
index cf623d8..6d660cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -439,6 +439,10 @@ CMakeUserPresets.json
# C++ language server compilation database
.mscppls/
+# Local tools and PowerShell editor state
+.tools/
+PowerShellEditorServices.json
+
# used by Pi.dev
/APPEND_SYSTEM.md
diff --git a/AGENTS.md b/AGENTS.md
index cf100da..ec2a0fd 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -51,13 +51,9 @@ cmake --build --preset x64-debug
ctest --preset x64-debug
```
-Until CMake registers the ActiveX tests, also build the legacy solution and run
-its ActiveX suite:
-
-```powershell
-msbuild MapWinGIS6.slnx -restore -p:Configuration=Debug -p:Platform=x64 -m
-bin\Debug\x64\MapWinGIS.ActiveX.Tests.exe
-```
+When `MWG_BUILD_ACTIVEX` is enabled, CMake also registers the ActiveX native
+tests with CTest. The registered-control activation check is labeled
+`interactive` and is excluded from the standard CTest preset.
Every task must leave the tree in this state: CMake `Debug | x64` builds with
no new Level 4 warnings and all non-interactive tests pass. The legacy
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3028e4b..a2ad0c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,11 +75,10 @@ if(MWG_BUILD_ACTIVEX)
endif()
if(MWG_BUILD_TESTS)
+ enable_testing()
+ add_subdirectory(tests/MapWinGIS.Core.Tests)
if(MWG_BUILD_ACTIVEX)
- enable_testing()
- add_subdirectory(tests/MapWinGIS.Core.Tests)
- else()
- message(STATUS "Skipping the native GoogleTest suite: it requires MWG_BUILD_ACTIVEX=ON.")
+ add_subdirectory(tests/MapWinGIS.ActiveX.Tests)
endif()
endif()
diff --git a/README.md b/README.md
index a156838..018f095 100644
--- a/README.md
+++ b/README.md
@@ -84,6 +84,9 @@ CTest runs the CMake-built test cases:
ctest --preset x64-debug
```
+CTest discovers both native suites when ActiveX is enabled. Core tests remain
+available when configuring with `-DMWG_BUILD_ACTIVEX=OFF`.
+
For the legacy MSBuild build, run its test executables from the repository root:
```powershell
@@ -115,7 +118,8 @@ See the CMake section in the build guide for target names and additional command
CI Release artifacts use the `full-drivers` feature. Their tests require
HDF5, NetCDF, KML, SpatiaLite, and PostgreSQL support.
Pull requests build and test Debug and full-driver Release for x64 using both
-CMake and MSBuild. Each CI build has a 180-minute timeout.
+CMake and MSBuild, and also run CMake Win32 Debug. Pushes to `main` include the
+full Win32 Debug and Release matrix. Each CI build has a 180-minute timeout.
After vector geometry edits, call `VectorDataset::Flush()` before closing to
persist exact Shapefile and GeoPackage bounds. The flush batches stored-extent
diff --git a/build/props/MapWinGIS.Cpp.props b/build/props/MapWinGIS.Cpp.props
index 8bae315..fd346b6 100644
--- a/build/props/MapWinGIS.Cpp.props
+++ b/build/props/MapWinGIS.Cpp.props
@@ -19,7 +19,7 @@
true
true
Level4
- true
+ true
true
ProgramDatabase
Sync
diff --git a/build/scripts/Compare-CompileCommands.ps1 b/build/scripts/Compare-CompileCommands.ps1
index a67eea6..3a6fce7 100644
--- a/build/scripts/Compare-CompileCommands.ps1
+++ b/build/scripts/Compare-CompileCommands.ps1
@@ -110,6 +110,12 @@ $explainedCompileDifferencesByTarget = @{
'^/I/.*/midl$' = 'MIDL output directory (D3)'
'^/I/[^/]+/include$' = 'MSBuild vcpkg auto-include; the OCX has no direct vcpkg dependency in CMake'
}
+ 'MapWinGIS.ActiveX.Tests' = [ordered]@{
+ '^/I$' = 'MIDL output moved from the intermediate directory to /.../midl (D3)'
+ '^/I/obj/MapWinGIS\.ActiveX/[^/]+/[^/]+$' = 'MSBuild ActiveX intermediate directory containing MIDL headers; CMake uses its MIDL target output'
+ '^/I/.*/midl$' = 'MIDL output directory (D3)'
+ '^/I/[^/]+/include$' = 'MSBuild vcpkg auto-include; CMake exposes dependency includes through imported targets'
+ }
}
# MSBuild project names that differ from the CMake target names.
diff --git a/cmake/MwgCompilerOptions.cmake b/cmake/MwgCompilerOptions.cmake
index 04d8886..55759cf 100644
--- a/cmake/MwgCompilerOptions.cmake
+++ b/cmake/MwgCompilerOptions.cmake
@@ -31,15 +31,13 @@ function(mwg_apply_common_options target)
set(c_cxx "$")
set(debug "$>")
- set(debug_x64 "$,$>")
set(release "$>")
target_compile_options(${target} PRIVATE
# WarningLevel, DisableSpecificWarnings. 4251 is safe: one toolset and
# one CRT for every binary of the product.
"$<${c_cxx}:/W4;/wd4251;/external:W4>"
- "$<$:/WX>"
- "$<$>:/WX->"
+ "$<${c_cxx}:/WX>"
# AdditionalOptions
"$<${c_cxx}:/utf-8;/Zc:__cplusplus;/Zc:preprocessor;/Zc:throwingNew;/bigobj>"
# ConformanceMode, SDLCheck, ExceptionHandling and MSBuild defaults
diff --git a/docs/BUILDING.md b/docs/BUILDING.md
index c06ce97..4953855 100644
--- a/docs/BUILDING.md
+++ b/docs/BUILDING.md
@@ -28,8 +28,10 @@ ctest --preset x64-debug
```
The first configure installs GDAL and its dependencies and can take a while;
-later builds reuse the vcpkg binary cache. See [Building with CMake](#building-with-cmake)
-for other presets, Visual Studio, and CLion.
+later builds reuse the vcpkg binary cache. CTest runs the Core suite and, when
+`MWG_BUILD_ACTIVEX` is enabled, the ActiveX suite. See
+[Building with CMake](#building-with-cmake) for other presets, Visual Studio,
+and CLion.
## Legacy MSBuild build
@@ -47,9 +49,10 @@ do not overwrite one another. If `msbuild` is not on `PATH`, see
### ActiveX activation
-The solution builds `MapWinGIS.ocx` beside `MapWinGIS.Core.dll`. To verify
-COM activation without machine-wide registration, run the activation check
-from a PowerShell process that matches the target architecture:
+The solution and CMake build `MapWinGIS.ocx` beside `MapWinGIS.Core.dll` when
+ActiveX is enabled. To verify COM activation without machine-wide registration,
+run the activation check from a PowerShell process that matches the target
+architecture:
```powershell
pwsh -File tests\MapWinGIS.ActiveX.Tests\Verify-ActiveXActivation.ps1 -Configuration Debug -Platform x64
@@ -272,9 +275,11 @@ hardcode a Visual Studio installation path in repository files.
### Building with CMake
-The CMake build covers `MapWinGIS.Core.dll`, `MapWinGIS.ocx`, and the Core
-GoogleTest suite. It does not yet build the ActiveX-specific test executable;
-run the legacy ActiveX tests until CMake registers that suite. Set
+The CMake build covers `MapWinGIS.Core.dll`, `MapWinGIS.ocx`, and both native
+GoogleTest suites. Core tests remain available when `MWG_BUILD_ACTIVEX=OFF`;
+the ActiveX suite and OCX require ActiveX to be enabled. CTest labels the
+registration-based ActiveX activation check `interactive`, so the standard
+test preset excludes it. Set
`MWG_BUILD_SAMPLES=ON` to add the `translate` sample and, when .NET and
PowerShell 7 are installed, targets to build and launch the C# ActiveX test
host. The OCX needs the **C++ ATL for latest v145 build tools** component for
@@ -316,6 +321,7 @@ Then build individual targets:
```powershell
cmake --build --preset x64-debug --target MapWinGIS.Core
cmake --build --preset x64-debug --target MapWinGIS.ActiveX
+cmake --build --preset x64-debug --target MapWinGIS.ActiveX.Tests
cmake --build --preset x64-debug --target MapWinGIS.Samples.Translate
cmake --build --preset x64-debug --target build_activex_host
cmake --build --preset x64-debug --target run_activex_host
@@ -503,4 +509,5 @@ The CMake `run_activex_host` targets pass the runtime directory automatically.
When launching the C# host script directly, pass that directory with
`-BinDirectory`, for example `-BinDirectory out\b\x64d\bin`. This directory
override does not enable native ActiveX hosting verification: that check
-requires the legacy `MapWinGIS.ActiveX.Tests.exe` and its hosting test.
+requires `MapWinGIS.ActiveX.Tests.exe` and its hosting test. CMake builds this
+executable when `MWG_BUILD_ACTIVEX` is enabled.
diff --git a/docs/CMAKE-MIGRATION.md b/docs/CMAKE-MIGRATION.md
index 6d5177a..9f6ebbc 100644
--- a/docs/CMAKE-MIGRATION.md
+++ b/docs/CMAKE-MIGRATION.md
@@ -11,11 +11,12 @@ collected with [`build/scripts/Compare-CompileCommands.ps1`](#parity-measurement
## Targets
-| MSBuild project | Output | Type | Planned CMake target |
+| MSBuild project | Output | Type | CMake target |
|---|---|---|---|
| `src/MapWinGIS.Core/MapWinGIS.Core.vcxproj` | `MapWinGIS.Core.dll` (+ `.lib`, `.pdb`) | DLL, subsystem `WINDOWS` | `MapWinGIS.Core` |
| `src/MapWinGIS.ActiveX/MapWinGIS.ActiveX.vcxproj` | `MapWinGIS.ocx` (+ `.lib`, `.pdb`, `MapWinGIS.ActiveX.tlb`) | DLL, subsystem `WINDOWS`, `UseOfAtl=Static` | `MapWinGIS.ActiveX.Interface` (MIDL) + `MapWinGIS.ActiveX` |
| `tests/MapWinGIS.Core.Tests/MapWinGIS.Core.Tests.vcxproj` | `MapWinGIS.Core.Tests.exe` | Console | `MapWinGIS.Core.Tests` |
+| `tests/MapWinGIS.ActiveX.Tests/MapWinGIS.ActiveX.Tests.vcxproj` | `MapWinGIS.ActiveX.Tests.exe` | Console | `MapWinGIS.ActiveX.Tests` |
| `samples/Cpp/Translate.vcxproj` (project name `TranslateSample`) | `translate.exe` | Console | `MapWinGIS.Samples.Translate` (`OUTPUT_NAME translate`) |
| `samples/CSharp/ActiveXTestHost/ActiveXTestHost.csproj` | `ActiveXTestHost.exe` | .NET 10 WinForms | custom targets around `dotnet build` |
@@ -57,24 +58,30 @@ and `src` (private).
`DllUnregisterServer`, `DllInstall`).
- No `.manifest` file; the linker embeds its default manifest.
-**MapWinGIS.Core.Tests** — `MWG_ENABLE_RENDERER_TEST_HOOKS`; include
-directories `src/MapWinGIS.Core/include`, `src/MapWinGIS.ActiveX` and the
-ActiveX MIDL output directory `obj/MapWinGIS.ActiveX//`.
+**MapWinGIS.Core.Tests** — include directory `src/MapWinGIS.Core/include`.
- Headers: `TestData.h`.
+- Sources: `GdalAlgorithmRunnerTests.cpp`, `GdalEnvironmentTests.cpp`,
+ `GdalModernCapabilitiesTests.cpp`, `GdalRuntimeTests.cpp`,
+ `GdalTypedOptionsTests.cpp`, `GdalUtilsTests.cpp`, `Main.cpp` (defines
+ `main`), `MapRenderSceneTests.cpp`, `MapTests.cpp`, `MapViewTests.cpp`,
+ `PolygonTriangulationTests.cpp`, `TestData.cpp`, `VectorDatasetTests.cpp`,
+ `VectorLayerTests.cpp`, `VectorRenderSceneTests.cpp`, and `ViewportTests.cpp`.
+- Project reference: Core.
+
+**MapWinGIS.ActiveX.Tests** — `MWG_ENABLE_RENDERER_TEST_HOOKS`; include
+directories `src/MapWinGIS.Core/include`, `src/MapWinGIS.ActiveX`,
+`tests/MapWinGIS.Core.Tests` and the ActiveX MIDL output directory.
+
- Sources: `ActiveXActivationTests.cpp`, `ComConversionTests.cpp`,
- `GdalAlgorithmRunnerTests.cpp`, `GdalEnvironmentTests.cpp`,
- `GdalModernCapabilitiesTests.cpp`, `GdalOperationDispatcherTests.cpp`,
- `GdalRuntimeTests.cpp`, `GdalTypedOptionsTests.cpp`, `GdalUtilsTests.cpp`,
- `Main.cpp` (defines `main`), `RenderingBaselineTests.cpp`, `TestData.cpp`,
- `VectorDatasetTests.cpp`, `VectorLayerRendererTests.cpp`,
- `VectorLayerTests.cpp`, `VectorRenderSceneTests.cpp`.
-- ActiveX sources compiled again with the test hook definition:
- `GdiVectorLayerRenderer.cpp`, `OpenGlVectorLayerRenderer.cpp`,
- `GdalOperationDispatcher.cpp`, `ComConversion.cpp`,
- `VectorLayerRenderer.cpp`, `ViewTransform.cpp`.
-- Project references: Core (linked) and ActiveX (build order only,
- `LinkLibraryDependencies=false`), so the OCX is beside the test executable.
+ `FrameBufferTests.cpp`, `GdalOperationDispatcherTests.cpp`,
+ `Main.cpp` and `TestData.cpp` from Core.Tests, `RenderingBaselineTests.cpp`,
+ `VectorLayerRendererTests.cpp`, `FrameBuffer.cpp`, and the ActiveX shared
+ implementation sources.
+- Links Core, GDAL, GoogleTest and the COM, GDI, OpenGL and process-status
+ libraries used by the tests. The OCX is a build-order dependency, not a
+ linked library, so activation tests load the built control from the runtime
+ directory.
**Translate sample** — `samples/Cpp/translate.cpp` (`wmain`); include
directory `src/MapWinGIS.Core/include`. It uses only the Core public API.
@@ -86,7 +93,7 @@ and MSBuild defaults):
| Option | Source |
|---|---|
-| `/W4 /WX (Debug x64), /WX- (other configurations) /wd4251 /external:W4` | `WarningLevel`, `TreatWarningAsError` for Debug x64, `DisableSpecificWarnings`; `/external:W4` is the MSBuild default for external headers |
+| `/W4 /WX /wd4251 /external:W4` | `WarningLevel`, `TreatWarningAsError` for every configuration and platform, `DisableSpecificWarnings`; `/external:W4` is the MSBuild default for external headers |
| `/utf-8 /Zc:__cplusplus /Zc:preprocessor /Zc:throwingNew /bigobj` | `AdditionalOptions` |
| `/permissive- /sdl /EHsc /GS /Gd /Gm- /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline` | `ConformanceMode`, `SDLCheck`, `ExceptionHandling`, MSBuild defaults |
| `/std:c++20` (`/TP`), `/std:c17` (`/TC`, `_i.c` only) | `LanguageStandard`, `LanguageStandard_C` |
@@ -104,7 +111,7 @@ Per configuration:
| Release | `/O2 /Oi /Gy /guard:cf /MD /D NDEBUG` |
Per target: `MWG_CORE_BUILD` (Core), `_ATL_APARTMENT_THREADED` (ActiveX),
-`MWG_ENABLE_RENDERER_TEST_HOOKS` (tests).
+`MWG_ENABLE_RENDERER_TEST_HOOKS` (ActiveX.Tests).
Not defined by any project: `WIN32`, `_WINDOWS`, `_USRDLL`, `_CONSOLE`. The
CMake defaults `/DWIN32 /D_WINDOWS` are therefore removed, so the two builds
@@ -135,7 +142,8 @@ hides what each target uses. From the sources and `dumpbin /dependents`:
|---|---|
| Core | `GDAL::GDAL`, `GEOS::geos_c` (`GdalEnvironment.cpp` includes `geos_c.h` and calls `GEOSversion()`). PROJ is reached only through GDAL/OGR (`OSRSetPROJSearchPaths`). Windows: `kernel32` only. |
| ActiveX | Core, `ole32`, `oleaut32`, `uuid`, `user32`, `gdi32`, `advapi32` (registration), `opengl32` (through `#pragma comment(lib, ...)` in `OpenGlVectorLayerRenderer.cpp`), static ATL. No direct GDAL use. |
-| Tests | Core, `GDAL::GDAL` (`gdal_priv.h`, `gdalalgorithm.h`, `vrtdataset.h`, `cpl_error.h`), `GTest::gtest` (not `gtest_main`: `Main.cpp` defines `main`), ATL headers (`atlbase.h`, `atlhost.h`), `ole32`, `oleaut32`, `uuid`, `user32`, `gdi32`, `opengl32`. |
+| Core.Tests | Core, `GDAL::GDAL`, `GTest::gtest` (not `gtest_main`: `Main.cpp` defines `main`). |
+| ActiveX.Tests | Core, `GDAL::GDAL`, `GTest::gtest`, ATL headers (`atlbase.h`, `atlhost.h`), `ole32`, `oleaut32`, `uuid`, `user32`, `gdi32`, `opengl32`, `psapi`. |
| Sample | Core only. |
`dumpbin` of the MSBuild tests shows `gmock.dll` instead of `gtest.dll`: the
diff --git a/docs/TESTING.md b/docs/TESTING.md
index 2e84d5b..092c196 100644
--- a/docs/TESTING.md
+++ b/docs/TESTING.md
@@ -5,10 +5,13 @@
on for CMake).
- Core test project: `tests/MapWinGIS.Core.Tests`, built with the solution or
CMake.
-- ActiveX test project: `tests/MapWinGIS.ActiveX.Tests`, built with the solution.
-- CMake currently registers the Core suite, not the ActiveX-specific tests.
-- ActiveX implementation units shared by the OCX and its tests are built as
- `MapWinGIS.ActiveX.Impl.lib`.
+- ActiveX test project: `tests/MapWinGIS.ActiveX.Tests`, built with the solution
+ or CMake when `MWG_BUILD_ACTIVEX` is enabled.
+- CMake registers the Core tests independently of ActiveX. It adds the
+ ActiveX-specific suite only when ActiveX is enabled.
+- ActiveX implementation sources used by tests are compiled into the test
+ executable with `MWG_ENABLE_RENDERER_TEST_HOOKS`; MSBuild builds those units
+ in `MapWinGIS.ActiveX.Impl.lib`.
- Shared fixtures and helpers live in `TestData.h/.cpp` (`TempDirectory`,
`MakeSampleShapefile`, `MakeProvincesDataset`, `MakeRectanglesDataset`, and
layer constants). Extend these instead of writing per-file fixture code.
@@ -31,8 +34,8 @@ up automatically).
### CMake and CTest
-The CMake target registers the Core GoogleTest sources and fixtures; the
-ActiveX-specific tests remain MSBuild-only:
+CTest discovers individual cases from both native suites. Core tests remain
+available when `MWG_BUILD_ACTIVEX` is disabled:
```powershell
cmake --preset x64-debug
@@ -40,12 +43,13 @@ cmake --build --preset x64-debug
ctest --preset x64-debug
```
-`gtest_discover_tests()` registers individual cases for CTest. Each test runs
-from the build's runtime directory, which contains the OCX, dependent DLLs,
-and GDAL/PROJ data. GoogleTest writes per-test XML files under `test-results`
-in the build directory. The `x64-debug` test preset already shows output on
-failure and excludes tests labelled `interactive`, which change per-user COM
-registration or require a desktop. CTest can also write a single JUnit report:
+`gtest_discover_tests()` registers individual cases for CTest. Tests run from
+the build's runtime directory, which contains their dependent DLLs and
+GDAL/PROJ data. When ActiveX is enabled, this directory also contains the OCX.
+GoogleTest writes per-test XML files under `test-results` in the build
+directory. The `x64-debug` test preset shows output on failure and excludes
+tests labelled `interactive`, including the registration-based activation
+check. CTest can also write a single JUnit report:
```powershell
ctest --test-dir out\b\x64d --output-on-failure -LE interactive `
@@ -93,11 +97,10 @@ pwsh -File tests\MapWinGIS.ActiveX.Tests\Verify-ActiveXActivation.ps1 -Configura
```
The native script requires `MapWinGIS.ActiveX.Tests.exe` and its
-`ActiveXHosting.ResizesRepaintsAndRecreatesControl` test, which CMake does not
-currently build. Use the MSBuild output for this verification until CMake
-registers the ActiveX test suite. CMake's `Verify-ActiveXActivation` CTest
-entry currently uses `MapWinGIS.Core.Tests.exe`, which does not contain that
-hosting test and is not a substitute for this check.
+`ActiveXHosting.ResizesRepaintsAndRecreatesControl` test. Both CMake and
+MSBuild build this executable when ActiveX is enabled. CMake's
+`Verify-ActiveXActivation` CTest entry runs the script against the
+ActiveX-specific executable and is labeled `interactive`.
## Build configuration tests
diff --git a/src/MapWinGIS.ActiveX/CMakeLists.txt b/src/MapWinGIS.ActiveX/CMakeLists.txt
index 1bcb792..2ef8e10 100644
--- a/src/MapWinGIS.ActiveX/CMakeLists.txt
+++ b/src/MapWinGIS.ActiveX/CMakeLists.txt
@@ -78,9 +78,7 @@ set_source_files_properties(MapWinGIS.ActiveX.rc PROPERTIES
target_link_libraries(MapWinGIS.ActiveX PRIVATE
MapWinGIS::Core
MapWinGIS.ActiveX.Interface.Generated
- # Explicit Windows libraries (audit). ATL is static: atlbase.h links
- # atls.lib through #pragma comment, and OpenGlVectorLayerRenderer.cpp links
- # opengl32.lib the same way.
+ # Explicit Windows dependencies of the COM, registration, and rendering code.
ole32 oleaut32 uuid user32 gdi32 advapi32 kernel32
)
diff --git a/tests/MapWinGIS.ActiveX.Tests/CMakeLists.txt b/tests/MapWinGIS.ActiveX.Tests/CMakeLists.txt
new file mode 100644
index 0000000..165ea95
--- /dev/null
+++ b/tests/MapWinGIS.ActiveX.Tests/CMakeLists.txt
@@ -0,0 +1,125 @@
+# SPDX-License-Identifier: MPL-2.0
+#
+# Native GoogleTest suite for the ActiveX implementation and COM control.
+
+find_package(GDAL CONFIG REQUIRED)
+find_package(GTest CONFIG REQUIRED)
+include(GoogleTest)
+
+set(MWG_ACTIVEX_TEST_HEADERS
+ OpenGlVectorLayerRendererTestAccess.h
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests/TestData.h"
+)
+
+if(NOT MWG_ACTIVEX_SHARED_SOURCES)
+ message(FATAL_ERROR
+ "MWG_ACTIVEX_SHARED_SOURCES is empty; the ActiveX subdirectory must be added before the tests.")
+endif()
+
+set(MWG_ACTIVEX_TEST_SOURCES
+ ActiveXActivationTests.cpp
+ ComConversionTests.cpp
+ FrameBufferTests.cpp
+ GdalOperationDispatcherTests.cpp
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests/Main.cpp"
+ RenderingBaselineTests.cpp
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests/TestData.cpp"
+ VectorLayerRendererTests.cpp
+ "${PROJECT_SOURCE_DIR}/src/MapWinGIS.ActiveX/FrameBuffer.cpp"
+ ${MWG_ACTIVEX_SHARED_SOURCES}
+)
+
+add_executable(MapWinGIS.ActiveX.Tests)
+target_sources(MapWinGIS.ActiveX.Tests PRIVATE
+ ${MWG_ACTIVEX_TEST_HEADERS}
+ ${MWG_ACTIVEX_TEST_SOURCES}
+)
+source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES
+ OpenGlVectorLayerRendererTestAccess.h
+ ActiveXActivationTests.cpp
+ ComConversionTests.cpp
+ FrameBufferTests.cpp
+ GdalOperationDispatcherTests.cpp
+ RenderingBaselineTests.cpp
+ VectorLayerRendererTests.cpp
+)
+source_group("Shared Core Test Sources" FILES
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests/Main.cpp"
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests/TestData.cpp"
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests/TestData.h"
+)
+source_group("ActiveX Implementation Sources" FILES
+ "${PROJECT_SOURCE_DIR}/src/MapWinGIS.ActiveX/FrameBuffer.cpp"
+ ${MWG_ACTIVEX_SHARED_SOURCES}
+)
+
+target_include_directories(MapWinGIS.ActiveX.Tests PRIVATE
+ "${PROJECT_SOURCE_DIR}/src/MapWinGIS.ActiveX"
+ "${PROJECT_SOURCE_DIR}/tests/MapWinGIS.Core.Tests"
+)
+
+target_compile_definitions(MapWinGIS.ActiveX.Tests PRIVATE
+ MWG_ENABLE_RENDERER_TEST_HOOKS
+)
+
+target_link_libraries(MapWinGIS.ActiveX.Tests PRIVATE
+ MapWinGIS::Core
+ MapWinGIS.ActiveX.Interface.Generated
+ GDAL::GDAL
+ GTest::gtest
+ ole32
+ oleaut32
+ uuid
+ gdi32
+ user32
+ opengl32
+ psapi
+)
+
+mwg_apply_common_options(MapWinGIS.ActiveX.Tests)
+target_link_options(MapWinGIS.ActiveX.Tests PRIVATE /SUBSYSTEM:CONSOLE)
+set_target_properties(MapWinGIS.ActiveX.Tests PROPERTIES FOLDER "tests")
+
+add_dependencies(MapWinGIS.ActiveX.Tests
+ MapWinGIS.ActiveX
+ MapWinGIS.RuntimeData
+)
+mwg_deploy_runtime_dlls(MapWinGIS.ActiveX.Tests)
+
+file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/test-results")
+gtest_discover_tests(MapWinGIS.ActiveX.Tests
+ DISCOVERY_MODE PRE_TEST
+ DISCOVERY_TIMEOUT 120
+ TEST_FILTER "*-ActiveXHosting.ResizesRepaintsAndRecreatesControl"
+ WORKING_DIRECTORY "${MWG_RUNTIME_DIR}"
+ XML_OUTPUT_DIR "${PROJECT_BINARY_DIR}/test-results"
+)
+
+if(MWG_PLATFORM STREQUAL "Win32")
+ set(_mwg_activation_shell
+ "$ENV{WINDIR}/SysWOW64/WindowsPowerShell/v1.0/powershell.exe")
+ if(NOT EXISTS "${_mwg_activation_shell}")
+ unset(_mwg_activation_shell)
+ endif()
+else()
+ find_program(_mwg_activation_shell NAMES pwsh powershell)
+endif()
+
+if(_mwg_activation_shell)
+ add_test(NAME Verify-ActiveXActivation
+ COMMAND "${_mwg_activation_shell}" -NoProfile -File
+ "${CMAKE_CURRENT_SOURCE_DIR}/Verify-ActiveXActivation.ps1"
+ -Configuration "$"
+ -Platform "${MWG_PLATFORM}"
+ -BinDirectory "${MWG_RUNTIME_DIR}"
+ -TestExecutable "MapWinGIS.ActiveX.Tests.exe"
+ )
+ set_tests_properties(Verify-ActiveXActivation PROPERTIES
+ LABELS "interactive"
+ WORKING_DIRECTORY "${MWG_RUNTIME_DIR}"
+ )
+else()
+ message(STATUS
+ "Skipping the interactive ActiveX activation CTest entry: no PowerShell process "
+ "matching ${MWG_PLATFORM} was found.")
+endif()
diff --git a/tests/MapWinGIS.ActiveX.Tests/Verify-ActiveXActivation.ps1 b/tests/MapWinGIS.ActiveX.Tests/Verify-ActiveXActivation.ps1
index ff16b2f..8597666 100644
--- a/tests/MapWinGIS.ActiveX.Tests/Verify-ActiveXActivation.ps1
+++ b/tests/MapWinGIS.ActiveX.Tests/Verify-ActiveXActivation.ps1
@@ -40,6 +40,8 @@ $registrationPaths = @(
'Software\Classes\MapWinGIS6.Control.6'
'Software\Classes\MapWinGIS6.Control'
)
+$testReport = Join-Path ([System.IO.Path]::GetTempPath()) (
+ "MapWinGIS.ActiveX.Tests.$([guid]::NewGuid().ToString('N')).xml")
$existingRegistration = @()
foreach ($view in @(
[Microsoft.Win32.RegistryView]::Registry32,
@@ -95,10 +97,20 @@ try {
$previousHostTest = $env:MWG_TEST_ACTIVEX_HOST
$env:MWG_TEST_ACTIVEX_HOST = '1'
try {
- & $testExecutable '--gtest_filter=ActiveXHosting.ResizesRepaintsAndRecreatesControl'
+ & $testExecutable `
+ '--gtest_filter=ActiveXHosting.ResizesRepaintsAndRecreatesControl' `
+ "--gtest_output=xml:$testReport"
if ($LASTEXITCODE -ne 0) {
throw "The ActiveX hosting test failed with exit code $LASTEXITCODE."
}
+
+ if (-not (Test-Path -LiteralPath $testReport -PathType Leaf)) {
+ throw 'The ActiveX hosting test did not produce its GoogleTest report.'
+ }
+ [xml]$testResults = Get-Content -LiteralPath $testReport -Raw
+ if ([int]$testResults.DocumentElement.GetAttribute('tests') -lt 1) {
+ throw 'The ActiveX hosting test filter selected no tests.'
+ }
}
finally {
if ($null -eq $previousHostTest) {
@@ -109,6 +121,7 @@ try {
}
}
finally {
+ Remove-Item -LiteralPath $testReport -Force -ErrorAction SilentlyContinue
$unregisterResult = Start-Process -FilePath $registrationTool `
-ArgumentList @('/s', '/u', '/n', '/i:user', "`"$controlPath`"") `
-Wait -PassThru
diff --git a/tests/MapWinGIS.Core.Tests/CMakeLists.txt b/tests/MapWinGIS.Core.Tests/CMakeLists.txt
index 160cf20..1c53caa 100644
--- a/tests/MapWinGIS.Core.Tests/CMakeLists.txt
+++ b/tests/MapWinGIS.Core.Tests/CMakeLists.txt
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: MPL-2.0
#
-# Native GoogleTest suite for the Core API and ActiveX rendering components.
+# Native GoogleTest suite for the Core API.
find_package(GDAL CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
@@ -36,44 +36,27 @@ add_executable(MapWinGIS.Core.Tests)
target_sources(MapWinGIS.Core.Tests PRIVATE
${MWG_CORE_TEST_HEADERS}
${MWG_CORE_TEST_SOURCES}
- ${MWG_ACTIVEX_SHARED_SOURCES}
)
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES
${MWG_CORE_TEST_HEADERS}
${MWG_CORE_TEST_SOURCES}
)
-source_group("ActiveX Test Sources" FILES ${MWG_ACTIVEX_SHARED_SOURCES})
-
-target_include_directories(MapWinGIS.Core.Tests PRIVATE
- "${PROJECT_SOURCE_DIR}/src/MapWinGIS.ActiveX"
-)
-
-target_compile_definitions(MapWinGIS.Core.Tests PRIVATE
- MWG_ENABLE_RENDERER_TEST_HOOKS
-)
target_link_libraries(MapWinGIS.Core.Tests PRIVATE
MapWinGIS::Core
- MapWinGIS.ActiveX.Interface.Generated
GDAL::GDAL
GTest::gtest
- ole32
- oleaut32
- uuid
- gdi32
- user32
- opengl32
- psapi
)
+if("full-drivers" IN_LIST VCPKG_MANIFEST_FEATURES)
+ target_compile_definitions(MapWinGIS.Core.Tests PRIVATE MWG_TEST_FULL_DRIVERS)
+endif()
+
mwg_apply_common_options(MapWinGIS.Core.Tests)
target_link_options(MapWinGIS.Core.Tests PRIVATE /SUBSYSTEM:CONSOLE)
set_target_properties(MapWinGIS.Core.Tests PROPERTIES FOLDER "tests")
-add_dependencies(MapWinGIS.Core.Tests
- MapWinGIS.ActiveX
- MapWinGIS.RuntimeData
-)
+add_dependencies(MapWinGIS.Core.Tests MapWinGIS.RuntimeData)
mwg_deploy_runtime_dlls(MapWinGIS.Core.Tests)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/test-results")
@@ -83,31 +66,3 @@ gtest_discover_tests(MapWinGIS.Core.Tests
WORKING_DIRECTORY "${MWG_RUNTIME_DIR}"
XML_OUTPUT_DIR "${PROJECT_BINARY_DIR}/test-results"
)
-
-if(MWG_PLATFORM STREQUAL "Win32")
- set(_mwg_activation_shell
- "$ENV{WINDIR}/SysWOW64/WindowsPowerShell/v1.0/powershell.exe")
- if(NOT EXISTS "${_mwg_activation_shell}")
- unset(_mwg_activation_shell)
- endif()
-else()
- find_program(_mwg_activation_shell NAMES pwsh powershell)
-endif()
-
-if(_mwg_activation_shell)
- add_test(NAME Verify-ActiveXActivation
- COMMAND "${_mwg_activation_shell}" -NoProfile -File
- "${CMAKE_CURRENT_SOURCE_DIR}/../MapWinGIS.ActiveX.Tests/Verify-ActiveXActivation.ps1"
- -Platform "${MWG_PLATFORM}"
- -BinDirectory "${MWG_RUNTIME_DIR}"
- -TestExecutable "MapWinGIS.Core.Tests.exe"
- )
- set_tests_properties(Verify-ActiveXActivation PROPERTIES
- LABELS "interactive"
- WORKING_DIRECTORY "${MWG_RUNTIME_DIR}"
- )
-else()
- message(STATUS
- "Skipping the interactive ActiveX activation CTest entry: no PowerShell process "
- "matching ${MWG_PLATFORM} was found.")
-endif()