Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/tests/test_graphical_objects.cpp
T
torstenandCopilot 09c244ff18 refactor: clean up verbose migration comments
Remove redundant Qt6 migration comments that restate obvious API changes:
- QtConcurrent::run parameter order explanations (preserved where lambda wrapping needed)
- QStringRef/QStringView API changes (shortened to essential info)
- QComboBox::activated signal signature change
- QMap::unite() removal semantics
- QAction include path change
- QMouseEvent/QWheelEvent position() API
- QList/QVector equivalence in Qt6
- QFuture continuation API
- Code generation comments

Preserved comments explaining non-obvious Qt6 behavior or necessary
API migration details.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 12:05:23 +00:00

134 lines
3.8 KiB
C++

/**
* @RDE_HEADER@
* Unit Tests for GraphicalObjects Module - Qt6 Migration
* $Id$
* $HeadURL$
* $Author$
*/
#include <gtest/gtest.h>
#include <QCoreApplication>
#include <QPointF>
#include <QPolygonF>
#include <QColor>
#include <QString>
// 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)
{
QList<QPointF> 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);
}