Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Line Scan construction and condensed plugin tests #145

Merged
merged 12 commits into from
Oct 22, 2018
Prev Previous commit
Next Next commit
Initial LS plugin test suite
  • Loading branch information
jessemapel committed Oct 12, 2018
commit 2ad58ae9c6bce29c932ececf07a4674928681874
18 changes: 15 additions & 3 deletions tests/Fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,23 @@ class SimpleFrameIsdTest : public ::testing::Test {
}
};

class ConstVelLineScanIsdTest : public ::testing::Test {
protected:
csm::Isd isd;

virtual void SetUp() {
std::ifstream isdFile("data/constVelocityLineScan.json");
json jsonIsd = json::parse(isdFile);
isd.clearAllParams();
jsonToIsd(jsonIsd, isd);
}
};

class FramerParameterizedTest : public ::testing::TestWithParam<csm::ImageCoord> {

protected:
csm::Isd isd;

std::string printIsd(csm::Isd &localIsd) {
std::string str;
std::multimap<std::string,std::string> isdmap= localIsd.parameters();
Expand All @@ -79,11 +91,11 @@ class FramerParameterizedTest : public ::testing::TestWithParam<csm::ImageCoord>
return str;
}
UsgsAstroFrameSensorModel* createModel(csm::Isd &modifiedIsd) {

UsgsAstroFramePlugin frameCameraPlugin;
csm::Model *model = frameCameraPlugin.constructModelFromISD(
modifiedIsd,"USGS_ASTRO_FRAME_SENSOR_MODEL");

UsgsAstroFrameSensorModel* sensorModel = dynamic_cast<UsgsAstroFrameSensorModel *>(model);

if (sensorModel)
Expand Down
47 changes: 47 additions & 0 deletions tests/LineScanPluginTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,50 @@ TEST(LineScanPluginTests, NumModels) {
UsgsAstroLsPlugin testPlugin;
EXPECT_EQ(1, testPlugin.getNumModels());;
}

TEST_F(ConstVelLineScanIsdTest, Constructible) {
UsgsAstroLsPlugin testPlugin;
EXPECT_TRUE(testPlugin.canModelBeConstructedFromISD(
isd,
"USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL"));
}

TEST_F(ConstVelLineScanIsdTest, ConstructValidCamera) {
UsgsAstroLsPlugin testPlugin;
csm::Model *cameraModel = NULL;
EXPECT_NO_THROW(
cameraModel = testPlugin.constructModelFromISD(
isd,
"USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL",
NULL)
);
UsgsAstroLsSensorModel *frameModel = dynamic_cast<UsgsAstroLsSensorModel *>(cameraModel);
EXPECT_NE(frameModel, nullptr);
if (cameraModel) {
delete cameraModel;
}
}

TEST_F(ConstVelLineScanIsdTest, ConstructInValidCamera) {
UsgsAstroLsPlugin testPlugin;
// Remove the model_name keyword from the ISD to make it invalid
isd.clearAllParams();
csm::Model *cameraModel = NULL;
try {
testPlugin.constructModelFromISD(
isd,
"USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL",
NULL);
FAIL() << "Expected csm ISD_NOT_SUPPORTED error";

}
catch(csm::Error &e) {
EXPECT_EQ(e.getError(), csm::Error::ISD_NOT_SUPPORTED);
}
catch(...) {
FAIL() << "Expected csm ISD_NOT_SUPPORTED error";
}
if (cameraModel) {
delete cameraModel;
}
}