# HG changeset patch # User Sebastien Jodogne # Date 1606232394 -3600 # Node ID 03afa09cfcf1db023f1c67c8d14b4eaeae187c41 # Parent 5b8b88e5bfd6451d668519914562bb5e304a1d44 running the tests of the Orthanc Framework in WebAssembly diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 Applications/Resources/RunCppCheck.sh --- a/Applications/Resources/RunCppCheck.sh Tue Nov 24 12:59:10 2020 +0100 +++ b/Applications/Resources/RunCppCheck.sh Tue Nov 24 16:39:54 2020 +0100 @@ -29,7 +29,7 @@ cat < /tmp/cppcheck-suppressions.txt stlFindInsert:../../Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h -stlFindInsert:../../Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp:703 +stlFindInsert:../../Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp:827 unpreciseMathCall:../../OrthancStone/Sources/Scene2D/Internals/CairoFloatTextureRenderer.cpp unpreciseMathCall:../../OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:143 diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 Applications/Samples/Common/RtViewerView.cpp --- a/Applications/Samples/Common/RtViewerView.cpp Tue Nov 24 12:59:10 2020 +0100 +++ b/Applications/Samples/Common/RtViewerView.cpp Tue Nov 24 16:39:54 2020 +0100 @@ -319,7 +319,7 @@ { std::unique_ptr lock(viewport_->Lock()); ViewportController& controller = lock->GetController(); - Scene2D& scene = controller.GetScene(); + const Scene2D& scene = controller.GetScene(); int depth = scene.GetMaxDepth() + 1; ctVolumeLayerSource_.reset(new VolumeSceneLayerSource(viewport_, depth, volume)); @@ -337,7 +337,7 @@ { std::unique_ptr lock(viewport_->Lock()); ViewportController& controller = lock->GetController(); - Scene2D& scene = controller.GetScene(); + const Scene2D& scene = controller.GetScene(); int depth = scene.GetMaxDepth() + 1; doseVolumeLayerSource_.reset(new VolumeSceneLayerSource(viewport_, depth, volume)); @@ -352,7 +352,7 @@ { std::unique_ptr lock(viewport_->Lock()); ViewportController& controller = lock->GetController(); - Scene2D& scene = controller.GetScene(); + const Scene2D& scene = controller.GetScene(); int depth = scene.GetMaxDepth() + 1; structLayerSource_.reset(new VolumeSceneLayerSource(viewport_, depth, volume)); diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Nov 24 12:59:10 2020 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Nov 24 16:39:54 2020 +0100 @@ -1466,16 +1466,16 @@ void SetupPrefetchAfterRendering(const Orthanc::ImageAccessor& frame, DisplayedFrameQuality quality) { - const size_t frameSize = frame.GetPitch() * frame.GetHeight(); const size_t cursorIndex = cursor_->GetCurrentIndex(); // Prepare prefetching prefetchQueue_.clear(); - size_t prefetchedSize = 0; - if (1) // DISABLE PREFETCHING { + const size_t frameSize = frame.GetPitch() * frame.GetHeight(); + size_t prefetchedSize = 0; + for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16 && prefetchedSize <= framesCache_->GetMaximumSize() / 2; i++) { @@ -1492,8 +1492,7 @@ if (observer_.get() != NULL) { - observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(), - frames_->GetFramesCount(), quality); + observer_->SignalFrameUpdated(*this, cursorIndex, frames_->GetFramesCount(), quality); } } @@ -1974,8 +1973,6 @@ void Redraw() { - DisplayedFrameQuality quality = DisplayedFrameQuality_None; - if (cursor_.get() != NULL && frames_.get() != NULL) { diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 UnitTestsSources/GenericToolboxTests.cpp --- a/UnitTestsSources/GenericToolboxTests.cpp Tue Nov 24 12:59:10 2020 +0100 +++ b/UnitTestsSources/GenericToolboxTests.cpp Tue Nov 24 16:39:54 2020 +0100 @@ -26,9 +26,14 @@ #include #include -#include // For PRId64 #include +#if __cplusplus >= 201103L // Is C++11? +# include // For PRId64 +#else +# define PRId64 "%lld" +#endif + TEST(GenericToolbox, TestLegitDoubleString) { using OrthancStone::GenericToolbox::LegitDoubleString; diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 UnitTestsSources/UnitTestsMain.cpp --- a/UnitTestsSources/UnitTestsMain.cpp Tue Nov 24 12:59:10 2020 +0100 +++ b/UnitTestsSources/UnitTestsMain.cpp Tue Nov 24 16:39:54 2020 +0100 @@ -64,7 +64,7 @@ int result; { - Orthanc::Logging::Initialize(); + OrthancStone::StoneInitialize(); Orthanc::Logging::EnableInfoLevel(true); ::testing::InitGoogleTest(&argc, argv); @@ -75,16 +75,17 @@ result = RUN_ALL_TESTS(); - Orthanc::Logging::Finalize(); - #if defined(__EMSCRIPTEN__) output = testing::internal::GetCapturedStdout(); #endif + + OrthancStone::StoneFinalize(); } #if defined(__EMSCRIPTEN__) EM_ASM({ document.getElementById("output").innerHTML = UTF8ToString($0); + window.scrollTo(0, document.body.scrollHeight); // Scroll to the end of the page }, output.c_str()); #endif diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 UnitTestsSources/WebAssembly/CMakeLists.txt --- a/UnitTestsSources/WebAssembly/CMakeLists.txt Tue Nov 24 12:59:10 2020 +0100 +++ b/UnitTestsSources/WebAssembly/CMakeLists.txt Tue Nov 24 16:39:54 2020 +0100 @@ -49,14 +49,13 @@ include(${CMAKE_SOURCE_DIR}/../../Applications/Platforms/WebAssembly/OrthancStoneWebAssemblyParameters.cmake) -SET(ENABLE_DCMTK OFF) # Not necessary +SET(ENABLE_DCMTK ON) # Necessary for the tests of the Orthanc framework +SET(ENABLE_PUGIXML ON) # Necessary for the tests of the Orthanc framework SET(ENABLE_GOOGLE_TEST OFF) SET(ENABLE_LOCALE ON) # Necessary for text rendering +SET(ENABLE_LUA ON) # Necessary for the tests of the Orthanc framework SET(ORTHANC_SANDBOXED ON) -# Needed to redirect std::cout to a
-set(ORTHANC_ENABLE_LOGGING_STDIO OFF CACHE INTERNAL "") - # this will set up the build system for Stone of Orthanc and will # populate the ORTHANC_STONE_SOURCES CMake variable include(${CMAKE_SOURCE_DIR}/../../Applications/Platforms/WebAssembly/OrthancStoneWebAssemblyConfiguration.cmake) @@ -75,7 +74,32 @@ include(${CMAKE_SOURCE_DIR}/../UnitTestsSources.cmake) -add_executable(UnitTests ${UNIT_TESTS_SOURCES}) +add_executable(UnitTests + # Testing Stone + ${UNIT_TESTS_SOURCES} + + # Testing the Orthanc Framework + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/DicomMapTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FrameworkTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FromDcmtkTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ImageProcessingTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ImageTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/JpegLosslessTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/LoggingTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/LuaTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/RestApiTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/StreamTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ToolboxTests.cpp + + # Tests that are not compatible with WebAssembly + + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FileStorageTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/JobsTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/MemoryCacheTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/SQLiteChromiumTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/SQLiteTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ZipTests.cpp + ) # Declare installation files for the module diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 UnitTestsSources/WebAssembly/NOTES.txt --- a/UnitTestsSources/WebAssembly/NOTES.txt Tue Nov 24 12:59:10 2020 +0100 +++ b/UnitTestsSources/WebAssembly/NOTES.txt Tue Nov 24 16:39:54 2020 +0100 @@ -8,7 +8,7 @@ # source ~/Downloads/emsdk/emsdk_env.sh # mkdir Build && cd Build -# cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DALLOW_DOWNLOADS=ON -G Ninja +# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DALLOW_DOWNLOADS=ON -G Ninja # ninja install => The binaries will be put in "../../../wasm-binaries/UnitTests/" diff -r 5b8b88e5bfd6 -r 03afa09cfcf1 UnitTestsSources/WebAssembly/index.html --- a/UnitTestsSources/WebAssembly/index.html Tue Nov 24 12:59:10 2020 +0100 +++ b/UnitTestsSources/WebAssembly/index.html Tue Nov 24 16:39:54 2020 +0100 @@ -7,7 +7,7 @@

Stone of Orthanc - Unit tests

-      Executing the tests...
+      Running the tests...