MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / worldFileTemplateTest

Method worldFileTemplateTest

test/template_t.cpp:224–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222 }
223
224 void worldFileTemplateTest()
225 {
226 Map map;
227 MapView view{ &map };
228 QVERIFY(map.loadFrom(QStringLiteral("testdata:templates/world-file.xmap"), &view));
229
230 const auto& georef = map.getGeoreferencing();
231 QCOMPARE(georef.getState(), Georeferencing::Geospatial);
232
233 QCOMPARE(map.getNumTemplates(), 1);
234 auto temp = map.getTemplate(0);
235 QCOMPARE(temp->getTemplateType(), "TemplateImage");
236 QCOMPARE(temp->getTemplateFilename(), QString::fromLatin1("world-file.png"));
237 QVERIFY(temp->isTemplateGeoreferenced());
238
239 QVERIFY(temp->getTemplateState() != Template::Invalid);
240 QCOMPARE(temp->getTemplateRelativePath(), QStringLiteral("world-file.png"));
241 QCOMPARE(temp->getTemplateRelativePath(nullptr), QStringLiteral("world-file.png"));
242 auto base_dir = QDir(QStringLiteral("testdata:templates"));
243 QCOMPARE(temp->getTemplateRelativePath(&base_dir), QStringLiteral("world-file.png"));
244 base_dir.cdUp();
245 QCOMPARE(temp->getTemplateRelativePath(&base_dir), QStringLiteral("templates/world-file.png"));
246
247 map.loadTemplateFiles(view);
248 QCOMPARE(temp->getTemplateState(), Template::Loaded);
249 auto rotation_template = 0.01 * qRound(100 * qRadiansToDegrees(temp->getTemplateRotation()));
250 auto rotation_map = 0.01 * qRound(100 * georef.getGrivation());
251 QCOMPARE(rotation_template, rotation_map);
252
253 // Test boundingRect for TemplateImage
254 QCOMPARE(temp->boundingRect().center(), center(temp));
255 }
256
257
258 void templatePathTest()

Callers

nothing calls this directly

Calls 15

centerFunction · 0.85
getStateMethod · 0.80
getNumTemplatesMethod · 0.80
getTemplateStateMethod · 0.80
loadTemplateFilesMethod · 0.80
getTemplateRotationMethod · 0.80
getGrivationMethod · 0.80
centerMethod · 0.80
QDirClass · 0.50
loadFromMethod · 0.45

Tested by

no test coverage detected