Loading tests/Fixtures.h +21 −18 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ class FrameSensorModel : public ::testing::Test { } }; class SimpleFrameIsdTest : public ::testing::Test { class FrameIsdTest : public ::testing::Test { protected: csm::Isd isd; Loading Loading @@ -103,30 +103,33 @@ protected: }; }; class FrameIsdTest : public ::testing::Test { class FrameStateTest : public ::testing::Test { protected: csm::Isd isd; void printIsd(csm::Isd &localIsd) { std::multimap<std::string,std::string> isdmap= localIsd.parameters(); for (auto it = isdmap.begin(); it != isdmap.end();++it){ std::cout << it->first << " : " << it->second << std::endl; } } UsgsAstroFrameSensorModel* createModel(csm::Isd &modifiedIsd) { UsgsAstroPlugin frameCameraPlugin; modifiedIsd.setFilename("data/simpleFramerISD.img"); csm::Model *model = frameCameraPlugin.constructModelFromISD( modifiedIsd,"USGS_ASTRO_FRAME_SENSOR_MODEL"); UsgsAstroFrameSensorModel* createModifiedStateSensorModel(std::string key, double newValue) { UsgsAstroPlugin cameraPlugin; csm::Model *model = cameraPlugin.constructModelFromISD(isd,"USGS_ASTRO_FRAME_SENSOR_MODEL"); UsgsAstroFrameSensorModel* sensorModel = dynamic_cast<UsgsAstroFrameSensorModel *>(model); if (sensorModel) if (sensorModel) { sensorModel->getModelState(); std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); return sensorModel; else } else { return nullptr; } } virtual void SetUp() { void SetUp() override { isd.setFilename("data/simpleFramerISD.img"); } }; #endif tests/FrameCameraTests.cpp +30 −65 Original line number Diff line number Diff line Loading @@ -216,22 +216,11 @@ TEST_F(FrameSensorModel, setFocalPlane_AlternatingOnes) { } // Focal Length Tests: TEST_F(FrameSensorModel, FL500_OffBody4) { TEST_F(FrameStateTest, FL500_OffBody4) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); sensorModel->setParameterValue(0, 1000.0); // X sensorModel->setParameterValue(1, 0.0); // Y sensorModel->setParameterValue(2, 0.0); // Z modelState = sensorModel->getModelState(); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(15.0, 15.0); Loading @@ -245,14 +234,10 @@ TEST_F(FrameSensorModel, FL500_OffBody4) { } TEST_F(FrameSensorModel, FL500_OffBody3) { TEST_F(FrameStateTest, FL500_OffBody3) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(0.0, 0.0); Loading @@ -266,14 +251,10 @@ TEST_F(FrameSensorModel, FL500_OffBody3) { } TEST_F(FrameSensorModel, FL500_Center) { TEST_F(FrameStateTest, FL500_Center) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 7.5); Loading @@ -287,14 +268,10 @@ TEST_F(FrameSensorModel, FL500_Center) { } TEST_F(FrameSensorModel, FL500_SlightlyOffCenter) { TEST_F(FrameStateTest, FL500_SlightlyOffCenter) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 6.5); Loading Loading @@ -325,7 +302,6 @@ TEST_F(FrameSensorModel, X10_SlightlyOffCenter) { TEST_F(FrameSensorModel, X1e9_SlightlyOffCenter) { double newValue = 1000000000.0; sensorModel->setParameterValue(0, newValue); // X ASSERT_NE(sensorModel, nullptr); Loading @@ -343,10 +319,10 @@ TEST_F(FrameSensorModel, X1e9_SlightlyOffCenter) { // Angle rotations: TEST_F(FrameSensorModel, Rotation_omegaPi_Center) { sensorModel->setParameterValue(3, 1.0); sensorModel->setParameterValue(4, 1.0); sensorModel->setParameterValue(5, 1.0); sensorModel->setParameterValue(6, 1.0); sensorModel->setParameterValue(0, 1000.0); // X Loading @@ -366,10 +342,10 @@ TEST_F(FrameSensorModel, Rotation_omegaPi_Center) { TEST_F(FrameSensorModel, Rotation_NPole_Center) { sensorModel->setParameterValue(3, 0.0); sensorModel->setParameterValue(4, -1.0); sensorModel->setParameterValue(5, 0.0); sensorModel->setParameterValue(6, 0.0); sensorModel->setParameterValue(0, 0.0); // X Loading Loading @@ -407,14 +383,11 @@ TEST_F(FrameSensorModel, Rotation_SPole_Center) { // Ellipsoid axis tests: TEST_F(FrameSensorModel, SemiMajorAxis100x_Center) { TEST_F(FrameStateTest, SemiMajorAxis100x_Center) { std::string key = "m_majorAxis"; double newValue = 1000.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 7.5); Loading @@ -428,14 +401,10 @@ TEST_F(FrameSensorModel, SemiMajorAxis100x_Center) { } TEST_F(FrameSensorModel, SemiMajorAxis10x_SlightlyOffCenter) { TEST_F(FrameStateTest, SemiMajorAxis10x_SlightlyOffCenter) { std::string key = "m_majorAxis"; double newValue = 100.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 6.5); Loading @@ -453,14 +422,10 @@ TEST_F(FrameSensorModel, SemiMajorAxis10x_SlightlyOffCenter) { // The following test is for the scenario where the semi_minor_axis is actually larger // than the semi_major_axis: TEST_F(FrameSensorModel, SemiMinorAxis10x_SlightlyOffCenter) { TEST_F(FrameStateTest, SemiMinorAxis10x_SlightlyOffCenter) { std::string key = "m_minorAxis"; double newValue = 100.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 6.5); Loading tests/FramePluginTests.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ TEST_F(FrameIsdTest, Constructible) { "USGS_ASTRO_FRAME_SENSOR_MODEL")); } TEST_F(SimpleFrameIsdTest, NotConstructible) { TEST_F(FrameIsdTest, NotConstructible) { UsgsAstroPlugin testPlugin; isd.setFilename("Not a file"); EXPECT_FALSE(testPlugin.canModelBeConstructedFromISD( Loading @@ -78,7 +78,8 @@ TEST_F(SimpleFrameIsdTest, NotConstructible) { "USGS_ASTRO_FRAME_SENSOR_MODEL")); } TEST_F(SimpleFrameIsdTest, ConstructValidCamera) { TEST_F(FrameIsdTest, ConstructValidCamera) { UsgsAstroPlugin testPlugin; csm::Model *cameraModel = NULL; EXPECT_NO_THROW( Loading @@ -94,7 +95,8 @@ TEST_F(SimpleFrameIsdTest, ConstructValidCamera) { } } TEST_F(SimpleFrameIsdTest, ConstructInValidCamera) { TEST_F(FrameIsdTest, ConstructInValidCamera) { UsgsAstroPlugin testPlugin; // Remove the model_name keyword from the ISD to make it invalid isd.clearParams("model_name"); Loading Loading
tests/Fixtures.h +21 −18 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ class FrameSensorModel : public ::testing::Test { } }; class SimpleFrameIsdTest : public ::testing::Test { class FrameIsdTest : public ::testing::Test { protected: csm::Isd isd; Loading Loading @@ -103,30 +103,33 @@ protected: }; }; class FrameIsdTest : public ::testing::Test { class FrameStateTest : public ::testing::Test { protected: csm::Isd isd; void printIsd(csm::Isd &localIsd) { std::multimap<std::string,std::string> isdmap= localIsd.parameters(); for (auto it = isdmap.begin(); it != isdmap.end();++it){ std::cout << it->first << " : " << it->second << std::endl; } } UsgsAstroFrameSensorModel* createModel(csm::Isd &modifiedIsd) { UsgsAstroPlugin frameCameraPlugin; modifiedIsd.setFilename("data/simpleFramerISD.img"); csm::Model *model = frameCameraPlugin.constructModelFromISD( modifiedIsd,"USGS_ASTRO_FRAME_SENSOR_MODEL"); UsgsAstroFrameSensorModel* createModifiedStateSensorModel(std::string key, double newValue) { UsgsAstroPlugin cameraPlugin; csm::Model *model = cameraPlugin.constructModelFromISD(isd,"USGS_ASTRO_FRAME_SENSOR_MODEL"); UsgsAstroFrameSensorModel* sensorModel = dynamic_cast<UsgsAstroFrameSensorModel *>(model); if (sensorModel) if (sensorModel) { sensorModel->getModelState(); std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); return sensorModel; else } else { return nullptr; } } virtual void SetUp() { void SetUp() override { isd.setFilename("data/simpleFramerISD.img"); } }; #endif
tests/FrameCameraTests.cpp +30 −65 Original line number Diff line number Diff line Loading @@ -216,22 +216,11 @@ TEST_F(FrameSensorModel, setFocalPlane_AlternatingOnes) { } // Focal Length Tests: TEST_F(FrameSensorModel, FL500_OffBody4) { TEST_F(FrameStateTest, FL500_OffBody4) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); sensorModel->setParameterValue(0, 1000.0); // X sensorModel->setParameterValue(1, 0.0); // Y sensorModel->setParameterValue(2, 0.0); // Z modelState = sensorModel->getModelState(); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(15.0, 15.0); Loading @@ -245,14 +234,10 @@ TEST_F(FrameSensorModel, FL500_OffBody4) { } TEST_F(FrameSensorModel, FL500_OffBody3) { TEST_F(FrameStateTest, FL500_OffBody3) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(0.0, 0.0); Loading @@ -266,14 +251,10 @@ TEST_F(FrameSensorModel, FL500_OffBody3) { } TEST_F(FrameSensorModel, FL500_Center) { TEST_F(FrameStateTest, FL500_Center) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 7.5); Loading @@ -287,14 +268,10 @@ TEST_F(FrameSensorModel, FL500_Center) { } TEST_F(FrameSensorModel, FL500_SlightlyOffCenter) { TEST_F(FrameStateTest, FL500_SlightlyOffCenter) { std::string key = "m_focalLength"; double newValue = 500.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 6.5); Loading Loading @@ -325,7 +302,6 @@ TEST_F(FrameSensorModel, X10_SlightlyOffCenter) { TEST_F(FrameSensorModel, X1e9_SlightlyOffCenter) { double newValue = 1000000000.0; sensorModel->setParameterValue(0, newValue); // X ASSERT_NE(sensorModel, nullptr); Loading @@ -343,10 +319,10 @@ TEST_F(FrameSensorModel, X1e9_SlightlyOffCenter) { // Angle rotations: TEST_F(FrameSensorModel, Rotation_omegaPi_Center) { sensorModel->setParameterValue(3, 1.0); sensorModel->setParameterValue(4, 1.0); sensorModel->setParameterValue(5, 1.0); sensorModel->setParameterValue(6, 1.0); sensorModel->setParameterValue(0, 1000.0); // X Loading @@ -366,10 +342,10 @@ TEST_F(FrameSensorModel, Rotation_omegaPi_Center) { TEST_F(FrameSensorModel, Rotation_NPole_Center) { sensorModel->setParameterValue(3, 0.0); sensorModel->setParameterValue(4, -1.0); sensorModel->setParameterValue(5, 0.0); sensorModel->setParameterValue(6, 0.0); sensorModel->setParameterValue(0, 0.0); // X Loading Loading @@ -407,14 +383,11 @@ TEST_F(FrameSensorModel, Rotation_SPole_Center) { // Ellipsoid axis tests: TEST_F(FrameSensorModel, SemiMajorAxis100x_Center) { TEST_F(FrameStateTest, SemiMajorAxis100x_Center) { std::string key = "m_majorAxis"; double newValue = 1000.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 7.5); Loading @@ -428,14 +401,10 @@ TEST_F(FrameSensorModel, SemiMajorAxis100x_Center) { } TEST_F(FrameSensorModel, SemiMajorAxis10x_SlightlyOffCenter) { TEST_F(FrameStateTest, SemiMajorAxis10x_SlightlyOffCenter) { std::string key = "m_majorAxis"; double newValue = 100.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 6.5); Loading @@ -453,14 +422,10 @@ TEST_F(FrameSensorModel, SemiMajorAxis10x_SlightlyOffCenter) { // The following test is for the scenario where the semi_minor_axis is actually larger // than the semi_major_axis: TEST_F(FrameSensorModel, SemiMinorAxis10x_SlightlyOffCenter) { TEST_F(FrameStateTest, SemiMinorAxis10x_SlightlyOffCenter) { std::string key = "m_minorAxis"; double newValue = 100.0; std::string modelState = sensorModel->getModelState(); auto state = json::parse(modelState); state[key] = newValue; sensorModel->replaceModelState(state.dump()); UsgsAstroFrameSensorModel* sensorModel = createModifiedStateSensorModel(key, newValue); ASSERT_NE(sensorModel, nullptr); csm::ImageCoord imagePt(7.5, 6.5); Loading
tests/FramePluginTests.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ TEST_F(FrameIsdTest, Constructible) { "USGS_ASTRO_FRAME_SENSOR_MODEL")); } TEST_F(SimpleFrameIsdTest, NotConstructible) { TEST_F(FrameIsdTest, NotConstructible) { UsgsAstroPlugin testPlugin; isd.setFilename("Not a file"); EXPECT_FALSE(testPlugin.canModelBeConstructedFromISD( Loading @@ -78,7 +78,8 @@ TEST_F(SimpleFrameIsdTest, NotConstructible) { "USGS_ASTRO_FRAME_SENSOR_MODEL")); } TEST_F(SimpleFrameIsdTest, ConstructValidCamera) { TEST_F(FrameIsdTest, ConstructValidCamera) { UsgsAstroPlugin testPlugin; csm::Model *cameraModel = NULL; EXPECT_NO_THROW( Loading @@ -94,7 +95,8 @@ TEST_F(SimpleFrameIsdTest, ConstructValidCamera) { } } TEST_F(SimpleFrameIsdTest, ConstructInValidCamera) { TEST_F(FrameIsdTest, ConstructInValidCamera) { UsgsAstroPlugin testPlugin; // Remove the model_name keyword from the ISD to make it invalid isd.clearParams("model_name"); Loading