Commit 3590f6ae authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by jlaura
Browse files

Updated ISD and tests (#87)

* updated tests + RIP TestyMcTestFace

* keys updated

* Probably should not hard code .cpps in the CMakeLists.txt for GTest

* updated specs to mimic synthetic json

* appveyor assumed broken from standup, disabling until fixed

* eulers are now quats

* merge from jay's changes

* merge markers

* renamed quats as per Jessie's reccomendation

* only appends sensor_orientation to missing params

* stupid markers

* updated test ISD

* changes as per some comments

* updated as per comments

* defaults are all 0

* #pragma once to C style header guard

* stragler change

* missed some params

* missed another

* moving things around
parent 0ed5dca2
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -14,10 +14,11 @@ environment:
  CSM_INCLUDE_PATH: C:\\Miniconda36-x64\include

install:
  - git submodule update --init --recursive
  # - git submodule update --init --recursive
  # This pulls csm from conda
  - cmd: call C:\\Miniconda36-x64\Scripts\activate.bat
  - cmd: conda install -y -c usgs-astrogeology libcsm
  - cmake .
  # - cmd: call C:\\Miniconda36-x64\Scripts\activate.bat
  # - cmd: conda install -y -c usgs-astrogeology libcsm
  # - cmake .
build_script:
  - cmake --build . -- %MSBUILD_ARGS%
  # - cmake --build . -- %MSBUILD_ARGS%
  - echo pass
+225 −184

File changed.

Preview size limit exceeded, changes collapsed.

+46 −62

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.10)

# Link runCSMCameraModelTests with what we want to test and the GTest and pthread library
add_executable(runCSMCameraModelTests TestyMcTestFace.cpp FrameCameraTests.cpp)
add_executable(runCSMCameraModelTests FramePluginTests.cpp FrameCameraTests.cpp)
target_link_libraries(runCSMCameraModelTests usgscsm ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)

gtest_discover_tests(runCSMCameraModelTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)

tests/Fixtures.h

0 → 100644
+72 −0
Original line number Diff line number Diff line
#ifndef Fixtures_h
#define Fixtures_h

#include "UsgsAstroFramePlugin.h"
#include "UsgsAstroFrameSensorModel.h"

#include <json.hpp>

#include <sstream>
#include <fstream>

#include <gtest/gtest.h>

using json = nlohmann::json;

// Should this be positioned somewhere in the public API?
inline void jsonToIsd(json &object, csm::Isd &isd, std::string prefix="") {
  for (json::iterator it = object.begin(); it != object.end(); ++it) {
     json jsonValue = it.value();
     if (jsonValue.is_array()) {
        for (int i = 0; i < jsonValue.size(); i++) {
           isd.addParam(prefix+it.key(), jsonValue[i].dump());
        }
     }
     else {
        isd.addParam(prefix+it.key(), jsonValue.dump());
     }
  }
}

class FrameSensorModel : public ::testing::Test {
   protected:

      UsgsAstroFrameSensorModel *sensorModel;

      void SetUp() override {
         sensorModel = NULL;
         csm::Isd isd;
         std::ifstream isdFile("data/simpleFramerISD.json");
         json jsonIsd = json::parse(isdFile);
         jsonToIsd(jsonIsd, isd);
         isdFile.close();
         UsgsAstroFramePlugin frameCameraPlugin;
         csm::Model *model = frameCameraPlugin.constructModelFromISD(
               isd,
               "USGS_ASTRO_FRAME_SENSOR_MODEL");
         sensorModel = dynamic_cast<UsgsAstroFrameSensorModel *>(model);

         ASSERT_NE(sensorModel, nullptr);
      }

      void TearDown() override {
         if (sensorModel) {
            delete sensorModel;
            sensorModel = NULL;
         }
      }
};

class FrameIsdTest : public ::testing::Test {
   protected:

      csm::Isd isd;

   virtual void SetUp() {
      std::ifstream isdFile("data/simpleFramerISD.json");
      json jsonIsd = json::parse(isdFile);
      jsonToIsd(jsonIsd, isd);
      isdFile.close();
   }
};
#endif
Loading