# HG changeset patch # User Benjamin Golinvaux # Date 1589211710 -7200 # Node ID 4e7751a4b603d153570daa8b375d31eed4672a95 # Parent afdd5be8731cee82d202698cc393b9f73f905174 Added a test for loader injection (basic "no regression" test). DISABLED_ because it requires a running Orthanc with a well-defined structure set instance. diff -r afdd5be8731c -r 4e7751a4b603 UnitTestsSources/TestStructureSet.cpp --- a/UnitTestsSources/TestStructureSet.cpp Mon May 11 17:38:29 2020 +0200 +++ b/UnitTestsSources/TestStructureSet.cpp Mon May 11 17:41:50 2020 +0200 @@ -32,6 +32,11 @@ #include "Framework/Toolbox/DicomStructureSet2.h" #include "Framework/Toolbox/DisjointDataSet.h" +#include "Framework/Loaders/GenericLoadersContext.h" +#include "Framework/Loaders/DicomStructureSetLoader.h" + +#include "boost/date_time/posix_time/posix_time.hpp" + #include #include "gtest/gtest.h" @@ -5406,9 +5411,83 @@ const std::vector& structures = structureSet.structures_; } - #endif // BGO_ENABLE_DICOMSTRUCTURESETLOADER2 - - +namespace +{ + void Initialize(const char* orthancApiUrl, OrthancStone::ILoadersContext& loadersContext) + { + Orthanc::WebServiceParameters p; + + OrthancStone::GenericLoadersContext& typedLoadersContext = + dynamic_cast(loadersContext); + // Default is http://localhost:8042 + // Here's how you may change it + p.SetUrl(orthancApiUrl); + p.SetCredentials("orthanc", "orthanc"); + typedLoadersContext.SetOrthancParameters(p); + + typedLoadersContext.StartOracle(); + } + + void Exitialize(OrthancStone::ILoadersContext& loadersContext) + { + OrthancStone::GenericLoadersContext& typedLoadersContext = + dynamic_cast(loadersContext); + + typedLoadersContext.StopOracle(); + } + + +#if 0 + class TestObserver : public ObserverBase + { + public: + TestObserver() {}; + + virtual void Handle + + }; +#endif + +} + + +TEST(StructureSet, DISABLED_StructureSetLoader_injection_feature_2020_05_10) +{ + namespace pt = boost::posix_time; + + std::unique_ptr loadersContext(new OrthancStone::GenericLoadersContext(1,4,1)); + Initialize("http://localhost:8042/", *loadersContext); + + boost::shared_ptr loader = DicomStructureSetLoader::Create(*loadersContext); + + // replace with Orthanc ID of an uploaded RTSTRUCT instance! + loader->LoadInstanceFullVisibility("72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661"); + + bool bContinue(true); + + pt::ptime initialTime = pt::second_clock::local_time(); + + while (bContinue) + { + bContinue = !loader->AreStructuresReady(); + boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); + + { + pt::ptime nowTime = pt::second_clock::local_time(); + pt::time_duration diff = nowTime - initialTime; + double seconds = static_cast(diff.total_milliseconds()) * 0.001; + std::cout << seconds << " seconds elapsed...\n"; + if (seconds > 30) + { + std::cout << "More than 30 seconds elapsed... Aborting test :(\n"; + //GTEST_FATAL_FAILURE_("More than 30 seconds elapsed... Aborting test :("); + //bContinue = false; + } + } + } +} + +