diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-05-02 13:12:10 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-05-02 13:39:37 +0300 |
commit | 764230e0c100818773896ce8a1fcee94532797a3 (patch) | |
tree | a1f6527c723a101bb7d138d4753f797db470a7b6 /tests | |
parent | a5499c546bffba0a53fd36458e08c1ad5bd8b384 (diff) |
Implement index based removing/replacing points in series
Task-number: QTRD-1952
Change-Id: I50d374a07506814007d5bd9aeb8921165ea500fa
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'tests')
5 files changed, 31 insertions, 8 deletions
diff --git a/tests/auto/qxyseries/tst_qxyseries.cpp b/tests/auto/qxyseries/tst_qxyseries.cpp index d3c15a1b..b8af4b96 100644 --- a/tests/auto/qxyseries/tst_qxyseries.cpp +++ b/tests/auto/qxyseries/tst_qxyseries.cpp @@ -231,6 +231,20 @@ void tst_QXYSeries::remove_raw() m_series->remove(bunchOfPoints.at(i)); QTest::qWait(50); } + QCOMPARE(m_series->points().count(), 0); + + // Removal using index + for (int i = 0; i < 10; i++) + bunchOfPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); + m_series->replace(bunchOfPoints); + m_series->remove(5); + m_series->remove(0); + QCOMPARE(m_series->points().count(), (bunchOfPoints.count() - 2)); + for (int i = bunchOfPoints.count() - 3; i >= 0; i--) { + m_series->remove(i); + QCOMPARE(m_series->points().count(), i); + } + QCOMPARE(m_series->points().count(), 0); } void tst_QXYSeries::remove_chart_data() @@ -366,6 +380,15 @@ void tst_QXYSeries::replace_raw() m_series->replace(QPointF(23,23), otherPoints.at(1)); QCOMPARE(m_series->points().at(1).x(), otherPoints.at(1).x()); QCOMPARE(m_series->points().at(1).y(), otherPoints.at(1).y()); + + // Replace using index + m_series->append(otherPoints); + m_series->replace(0, QPointF(333, 333)); + m_series->replace(3, 444, 444); + m_series->replace(m_series->count() - 1, QPointF(555, 555)); + QCOMPARE(m_series->points().at(0), QPointF(333, 333)); + QCOMPARE(m_series->points().at(3), QPointF(444, 444)); + QCOMPARE(m_series->points().at(m_series->count() - 1), QPointF(555, 555)); } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml index 6cda7e01..bbbc1dfd 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml @@ -79,12 +79,12 @@ Flow { text: "replace point" onClicked: { var xyPoint = series.at(series.count - 1); - series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1); + series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); } } Button { text: "remove point" - onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y); + onClicked: series.remove(series.count - 1); } Button { text: "insert point" diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml index 565eb78b..ec007531 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml @@ -74,12 +74,12 @@ Flow { text: "replace point" onClicked: { var xyPoint = series.at(series.count - 1); - series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1); + series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); } } Button { text: "remove point" - onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y); + onClicked: series.remove(series.count - 1); } Button { text: "insert point" diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml b/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml index 9669be1b..ac1e2fc5 100644 --- a/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml +++ b/tests/quick2chartproperties/qml/quick2chartproperties/LineEditor.qml @@ -79,12 +79,12 @@ Flow { text: "replace point" onClicked: { var xyPoint = series.at(series.count - 1); - series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1); + series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); } } Button { text: "remove point" - onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y); + onClicked: series.remove(series.count - 1); } Button { text: "insert point" diff --git a/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml b/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml index 2e9239c7..bd996b03 100644 --- a/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml +++ b/tests/quick2chartproperties/qml/quick2chartproperties/ScatterEditor.qml @@ -74,12 +74,12 @@ Flow { text: "replace point" onClicked: { var xyPoint = series.at(series.count - 1); - series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1); + series.replace(series.count - 1, xyPoint.x, xyPoint.y + 0.1); } } Button { text: "remove point" - onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y); + onClicked: series.remove(series.count - 1); } Button { text: "insert point" |