/** * @RDE_HEADER@ * Unit Tests for GraphicalObjects Module - Qt6 Migration * $Id$ * $HeadURL$ * $Author$ */ #include #include #include #include #include #include // Forward declarations for testing (actual implementation in GraphicalObjects) // These tests verify the Qt6 API compatibility of the modified classes namespace { // Test helper: Verify QPointF operations (used in GraphicalObjects) void testQPointF_Basic() { QPointF point1(10.5, 20.5); QPointF point2(30.5, 40.5); EXPECT_DOUBLE_EQ(point1.x(), 10.5); EXPECT_DOUBLE_EQ(point1.y(), 20.5); QPointF sum = point1 + point2; EXPECT_DOUBLE_EQ(sum.x(), 41.0); EXPECT_DOUBLE_EQ(sum.y(), 61.0); } // Test helper: Verify QPolygonF operations void testQPolygonF_Basic() { QPolygonF polygon; polygon << QPointF(0, 0) << QPointF(10, 0) << QPointF(10, 10) << QPointF(0, 10) << QPointF(0, 0); EXPECT_EQ(polygon.size(), 5); EXPECT_TRUE(polygon.isClosed()); QRectF boundingRect = polygon.boundingRect(); EXPECT_DOUBLE_EQ(boundingRect.x(), 0.0); EXPECT_DOUBLE_EQ(boundingRect.y(), 0.0); EXPECT_DOUBLE_EQ(boundingRect.width(), 10.0); EXPECT_DOUBLE_EQ(boundingRect.height(), 10.0); } // Test helper: Verify QColor operations void testQColor_Basic() { QColor color(255, 128, 64, 200); EXPECT_EQ(color.red(), 255); EXPECT_EQ(color.green(), 128); EXPECT_EQ(color.blue(), 64); EXPECT_EQ(color.alpha(), 200); QString hex = color.name(); EXPECT_EQ(hex, QStringLiteral("#ff8040")); } } // Test GraphicalObjects geometry operations TEST(GraphicalObjectsTest, Geometry_BasicOperations) { testQPointF_Basic(); testQPolygonF_Basic(); testQColor_Basic(); } // Test GraphicalObjects Qt6 API compatibility TEST(GraphicalObjectsTest, Qt6_API_Compatibility) { // Verify Qt6 QPointF API QPointF point(100.0, 200.0); EXPECT_DOUBLE_EQ(point.x(), 100.0); EXPECT_DOUBLE_EQ(point.y(), 200.0); // Verify Qt6 QPolygonF API QPolygonF poly; poly.append(QPointF(0, 0)); poly.append(QPointF(10, 10)); EXPECT_EQ(poly.size(), 2); // Verify Qt6 QColor API QColor color(Qt::red); EXPECT_EQ(color.red(), 255); EXPECT_EQ(color.green(), 0); EXPECT_EQ(color.blue(), 0); } // Test GraphicalObjects ArcGIS integration points TEST(GraphicalObjectsTest, ArcGIS_Integration_Points) { // These tests verify the integration points that were modified for ArcGIS SDK v300 // The actual ArcGIS objects require full SDK initialization, so we test the Qt types // Test coordinate conversion preparation QPointF qtPoint(45.5, -122.3); // Portland coordinates EXPECT_DOUBLE_EQ(qtPoint.x(), 45.5); EXPECT_DOUBLE_EQ(qtPoint.y(), -122.3); // Test polygon preparation for ArcGIS QPolygonF boundary; boundary << QPointF(-122.5, 45.4) << QPointF(-122.1, 45.4) << QPointF(-122.1, 45.6) << QPointF(-122.5, 45.6) << QPointF(-122.5, 45.4); // Close polygon by repeating first point EXPECT_EQ(boundary.size(), 5); EXPECT_TRUE(boundary.isClosed()); } // Test GraphicalObjects container operations (Qt6 QList/QVector) TEST(GraphicalObjectsTest, Container_Operations) { // Qt6: QList and QVector are identical QList points; points << QPointF(0, 0) << QPointF(10, 10) << QPointF(20, 20); EXPECT_EQ(points.size(), 3); EXPECT_EQ(points[0].x(), 0.0); EXPECT_EQ(points[1].x(), 10.0); EXPECT_EQ(points[2].x(), 20.0); // Test iteration int count = 0; for (const auto& point : points) { EXPECT_DOUBLE_EQ(point.x(), count * 10.0); ++count; } EXPECT_EQ(count, 3); }