mirror of https://github.com/qt/qtgraphs.git
Change swap to use QExplicitlySharedDataPointers swap instead of std::swap
Add tests for QGraphsLine Fixes: QTBUG-129497 Pick-to: 6.8 Change-Id: I02b8249235739210b48bdc784af1db80075a642a Reviewed-by: Sami Varanka <sami.varanka@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
8a13776f9c
commit
206904596b
|
|
@ -19,7 +19,7 @@ class QQuickGradient;
|
|||
class QGraphsThemePrivate;
|
||||
struct QGraphsLinePrivate;
|
||||
|
||||
QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QGraphsLinePrivate)
|
||||
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGraphsLinePrivate, Q_GRAPHS_EXPORT)
|
||||
|
||||
struct QGraphsThemeDirtyBitField
|
||||
{
|
||||
|
|
@ -95,10 +95,7 @@ public:
|
|||
QGraphsLine(QGraphsLine &&other) noexcept = default;
|
||||
Q_GRAPHS_EXPORT ~QGraphsLine();
|
||||
Q_GRAPHS_EXPORT QGraphsLine &operator=(const QGraphsLine &other);
|
||||
void swap(QGraphsLine &other) noexcept
|
||||
{
|
||||
std::swap(d, other.d);
|
||||
}
|
||||
void swap(QGraphsLine &other) noexcept { d.swap(other.d); }
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGraphsLine)
|
||||
|
||||
Q_GRAPHS_EXPORT QColor mainColor() const;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ private slots:
|
|||
|
||||
void initialProperties();
|
||||
void initializeProperties();
|
||||
void initializeGraphsLine();
|
||||
|
||||
private:
|
||||
QGraphsTheme *m_theme;
|
||||
|
|
@ -267,5 +268,66 @@ void tst_theme::initializeProperties()
|
|||
QCOMPARE(multiHighlightGradientSpy.size(), 1);
|
||||
}
|
||||
|
||||
void tst_theme::initializeGraphsLine()
|
||||
{
|
||||
QGraphsLine line;
|
||||
|
||||
QCOMPARE(line.mainColor(), QColor());
|
||||
QCOMPARE(line.subColor(), QColor());
|
||||
QCOMPARE(line.labelTextColor(), QColor());
|
||||
QCOMPARE(line.mainWidth(), 2.0f);
|
||||
QCOMPARE(line.subWidth(), 1.0f);
|
||||
|
||||
line.setMainColor(Qt::red);
|
||||
line.setSubColor(Qt::green);
|
||||
line.setLabelTextColor(Qt::gray);
|
||||
line.setMainWidth(25);
|
||||
line.setSubWidth(10);
|
||||
|
||||
QCOMPARE(line.mainColor(), Qt::red);
|
||||
QCOMPARE(line.subColor(), Qt::green);
|
||||
QCOMPARE(line.labelTextColor(), Qt::gray);
|
||||
QCOMPARE(line.mainWidth(), 25);
|
||||
QCOMPARE(line.subWidth(), 10);
|
||||
|
||||
QGraphsLine line2;
|
||||
|
||||
line2.setMainColor(Qt::green);
|
||||
line2.setSubColor(Qt::red);
|
||||
line2.setLabelTextColor(Qt::darkGray);
|
||||
line2.setMainWidth(30);
|
||||
line2.setSubWidth(5);
|
||||
|
||||
line = line2;
|
||||
|
||||
QCOMPARE(line.mainColor(), line2.mainColor());
|
||||
QCOMPARE(line.subColor(), line2.subColor());
|
||||
QCOMPARE(line.labelTextColor(), line2.labelTextColor());
|
||||
QCOMPARE(line.mainWidth(), line2.mainWidth());
|
||||
QCOMPARE(line.subWidth(), line2.subWidth());
|
||||
|
||||
QGraphsLine swapLine;
|
||||
|
||||
swapLine.setMainColor(Qt::darkRed);
|
||||
swapLine.setSubColor(Qt::darkGreen);
|
||||
swapLine.setLabelTextColor(Qt::darkYellow);
|
||||
swapLine.setMainWidth(5);
|
||||
swapLine.setSubWidth(2);
|
||||
|
||||
line.swap(swapLine);
|
||||
|
||||
QCOMPARE(line.mainColor(), Qt::darkRed);
|
||||
QCOMPARE(line.subColor(), Qt::darkGreen);
|
||||
QCOMPARE(line.labelTextColor(), Qt::darkYellow);
|
||||
QCOMPARE(line.mainWidth(), 5);
|
||||
QCOMPARE(line.subWidth(), 2);
|
||||
|
||||
QCOMPARE(swapLine.mainColor(), line2.mainColor());
|
||||
QCOMPARE(swapLine.subColor(), line2.subColor());
|
||||
QCOMPARE(swapLine.labelTextColor(), line2.labelTextColor());
|
||||
QCOMPARE(swapLine.mainWidth(), line2.mainWidth());
|
||||
QCOMPARE(swapLine.subWidth(), line2.subWidth());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_theme)
|
||||
#include "tst_theme.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue