Commit 14f411da authored by Aleksey Kontsevich's avatar Aleksey Kontsevich

Select vertex functionality test

parent ce27d8fc
......@@ -219,3 +219,38 @@ void QGCMapPolygonTest::_testKMLLoad(void)
QVERIFY(!_mapPolygon->loadKMLOrSHPFile(QStringLiteral(":/unittest/PolygonBadCoordinatesNode.kml")));
checkExpectedMessageBox();
}
void QGCMapPolygonTest::_testSelectVertex(void)
{
// Create polygon
foreach (auto vertex, _polyPoints) {
_mapPolygon->appendVertex(vertex);
}
QVERIFY(_mapPolygon->selectedVertex() == -1);
QVERIFY(_mapPolygon->count() == _polyPoints.count());
// Test deselect
_mapPolygon->selectVertex(-1);
QVERIFY(_mapPolygon->selectedVertex() == -1);
// Test out of bounds
_mapPolygon->selectVertex(_polyPoints.count());
QVERIFY(_mapPolygon->selectedVertex() == -1);
// Simple select test
_mapPolygon->selectVertex(_polyPoints.count() - 1);
QVERIFY(_mapPolygon->selectedVertex() == _polyPoints.count() - 1);
// Keep selected test
_mapPolygon->selectVertex(0);
_mapPolygon->removeVertex(_polyPoints.count() - 1);
QVERIFY(_mapPolygon->selectedVertex() == 0);
// Deselect if selected vertex removed
_mapPolygon->appendVertex(_polyPoints[_polyPoints.count() - 1]);
_mapPolygon->selectVertex(_polyPoints.count() - 1);
_mapPolygon->removeVertex(_polyPoints.count() - 1);
QVERIFY(_mapPolygon->selectedVertex() == -1);
// Shift selected index down if removed index < selected index
_mapPolygon->appendVertex(_polyPoints[_polyPoints.count() - 1]);
_mapPolygon->selectVertex(_polyPoints.count() - 1);
_mapPolygon->removeVertex(0);
QVERIFY(_mapPolygon->selectedVertex() == _mapPolygon->count() - 1);
}
......@@ -17,18 +17,19 @@
class QGCMapPolygonTest : public UnitTest
{
Q_OBJECT
public:
QGCMapPolygonTest(void);
protected:
void init(void) final;
void cleanup(void) final;
private slots:
void _testDirty(void);
void _testVertexManipulation(void);
void _testKMLLoad(void);
void _testSelectVertex(void);
private:
enum {
......
......@@ -200,3 +200,38 @@ void QGCMapPolylineTest::_testKMLLoad(void)
checkExpectedMessageBox();
}
#endif
void QGCMapPolylineTest::_testSelectVertex(void)
{
// Create polyline
foreach (auto vertex, _linePoints) {
_mapPolyline->appendVertex(vertex);
}
QVERIFY(_mapPolyline->selectedVertex() == -1);
QVERIFY(_mapPolyline->count() == _linePoints.count());
// Test deselect
_mapPolyline->selectVertex(-1);
QVERIFY(_mapPolyline->selectedVertex() == -1);
// Test out of bounds
_mapPolyline->selectVertex(_linePoints.count());
QVERIFY(_mapPolyline->selectedVertex() == -1);
// Simple select test
_mapPolyline->selectVertex(_linePoints.count() - 1);
QVERIFY(_mapPolyline->selectedVertex() == _linePoints.count() - 1);
// Keep selected test
_mapPolyline->selectVertex(0);
_mapPolyline->removeVertex(_linePoints.count() - 1);
QVERIFY(_mapPolyline->selectedVertex() == 0);
// Deselect if selected vertex removed
_mapPolyline->appendVertex(_linePoints[_linePoints.count() - 1]);
_mapPolyline->selectVertex(_linePoints.count() - 1);
_mapPolyline->removeVertex(_linePoints.count() - 1);
QVERIFY(_mapPolyline->selectedVertex() == -1);
// Shift selected index down if removed index < selected index
_mapPolyline->appendVertex(_linePoints[_linePoints.count() - 1]);
_mapPolyline->selectVertex(_linePoints.count() - 1);
_mapPolyline->removeVertex(0);
QVERIFY(_mapPolyline->selectedVertex() == _mapPolyline->count() - 1);
}
......@@ -17,18 +17,19 @@
class QGCMapPolylineTest : public UnitTest
{
Q_OBJECT
public:
QGCMapPolylineTest(void);
protected:
void init(void) final;
void cleanup(void) final;
private slots:
void _testDirty(void);
void _testVertexManipulation(void);
// void _testKMLLoad(void);
void _testSelectVertex(void);
private:
enum {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment