@@ -1,215 +1,215 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "barchartitem_p.h" |
|
21 | #include "barchartitem_p.h" | |
22 | #include "bar_p.h" |
|
22 | #include "bar_p.h" | |
23 | #include "qbarset.h" |
|
23 | #include "qbarset.h" | |
24 | #include "qbarset_p.h" |
|
24 | #include "qbarset_p.h" | |
25 | #include "qbarseries.h" |
|
25 | #include "qbarseries.h" | |
26 | #include "qbarseries_p.h" |
|
26 | #include "qbarseries_p.h" | |
27 | #include "qchart.h" |
|
27 | #include "qchart.h" | |
28 | #include "chartpresenter_p.h" |
|
28 | #include "chartpresenter_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 | #include "chartdataset_p.h" |
|
30 | #include "chartdataset_p.h" | |
31 | #include <QPainter> |
|
31 | #include <QPainter> | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
34 | |||
35 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : |
|
35 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |
36 | ChartItem(presenter), |
|
36 | ChartItem(presenter), | |
37 | m_series(series) |
|
37 | m_series(series) | |
38 | { |
|
38 | { | |
39 | setFlag(ItemClipsChildrenToShape); |
|
39 | setFlag(ItemClipsChildrenToShape); | |
40 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
40 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); | |
41 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); |
|
41 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); | |
42 | connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(labelsVisibleChanged(bool))); |
|
42 | connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(labelsVisibleChanged(bool))); | |
43 | setZValue(ChartPresenter::BarSeriesZValue); |
|
43 | setZValue(ChartPresenter::BarSeriesZValue); | |
44 | dataChanged(); |
|
44 | dataChanged(); | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | BarChartItem::~BarChartItem() |
|
47 | BarChartItem::~BarChartItem() | |
48 | { |
|
48 | { | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
51 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
52 | { |
|
52 | { | |
53 | Q_UNUSED(painter); |
|
53 | Q_UNUSED(painter); | |
54 | Q_UNUSED(option); |
|
54 | Q_UNUSED(option); | |
55 | Q_UNUSED(widget); |
|
55 | Q_UNUSED(widget); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | QRectF BarChartItem::boundingRect() const |
|
58 | QRectF BarChartItem::boundingRect() const | |
59 | { |
|
59 | { | |
60 | return m_rect; |
|
60 | return m_rect; | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | void BarChartItem::dataChanged() |
|
63 | void BarChartItem::dataChanged() | |
64 | { |
|
64 | { | |
65 | foreach(QGraphicsItem *item, childItems()) { |
|
65 | foreach(QGraphicsItem *item, childItems()) { | |
66 | delete item; |
|
66 | delete item; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | m_bars.clear(); |
|
69 | m_bars.clear(); | |
70 | m_labels.clear(); |
|
70 | m_labels.clear(); | |
71 | m_layout.clear(); |
|
71 | m_layout.clear(); | |
72 |
|
72 | |||
73 | bool labelsVisible = m_series->isLabelsVisible(); |
|
73 | bool labelsVisible = m_series->isLabelsVisible(); | |
74 |
|
74 | |||
75 | // Create new graphic items for bars |
|
75 | // Create new graphic items for bars | |
76 | for (int c = 0; c < m_series->categoryCount(); c++) { |
|
76 | for (int c = 0; c < m_series->categoryCount(); c++) { | |
77 | QString category = m_series->d_func()->categoryName(c); |
|
77 | QString category = m_series->d_func()->categoryName(c); | |
78 | for (int s = 0; s < m_series->barsetCount(); s++) { |
|
78 | for (int s = 0; s < m_series->barsetCount(); s++) { | |
79 | QBarSet *set = m_series->d_func()->barsetAt(s); |
|
79 | QBarSet *set = m_series->d_func()->barsetAt(s); | |
80 |
|
80 | |||
81 | // Bars |
|
81 | // Bars | |
82 | Bar *bar = new Bar(set,category,this); |
|
82 | Bar *bar = new Bar(set,category,this); | |
83 | m_bars.append(bar); |
|
83 | m_bars.append(bar); | |
84 | connect(bar, SIGNAL(clicked(QBarSet*,QString)), m_series, SIGNAL(clicked(QBarSet*,QString))); |
|
84 | connect(bar, SIGNAL(clicked(QBarSet*,QString)), m_series, SIGNAL(clicked(QBarSet*,QString))); | |
85 | connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); |
|
85 | connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); | |
86 | m_layout.append(QRectF(0, 0, 0, 0)); |
|
86 | m_layout.append(QRectF(0, 0, 0, 0)); | |
87 |
|
87 | |||
88 | // Labels |
|
88 | // Labels | |
89 | QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this); |
|
89 | QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this); | |
90 | label->setVisible(labelsVisible); |
|
90 | label->setVisible(labelsVisible); | |
91 | m_labels.append(label); |
|
91 | m_labels.append(label); | |
92 | } |
|
92 | } | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | // TODO: Is this the right place to call it? |
|
95 | // TODO: Is this the right place to call it? | |
96 | // presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); |
|
96 | // presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | QVector<QRectF> BarChartItem::calculateLayout() |
|
99 | QVector<QRectF> BarChartItem::calculateLayout() | |
100 | { |
|
100 | { | |
101 | QVector<QRectF> layout; |
|
101 | QVector<QRectF> layout; | |
102 |
|
102 | |||
103 | // Use temporary qreals for accurancy |
|
103 | // Use temporary qreals for accurancy | |
104 | qreal categoryCount = m_series->categoryCount(); |
|
104 | qreal categoryCount = m_series->categoryCount(); | |
105 | qreal setCount = m_series->barsetCount(); |
|
105 | qreal setCount = m_series->barsetCount(); | |
106 | bool barsVisible = m_series->isVisible(); |
|
106 | bool barsVisible = m_series->isVisible(); | |
107 |
|
107 | |||
108 | // Domain: |
|
108 | // Domain: | |
109 | qreal width = geometry().width(); |
|
109 | qreal width = geometry().width(); | |
110 | qreal height = geometry().height(); |
|
110 | qreal height = geometry().height(); | |
111 | qreal rangeY = m_domainMaxY - m_domainMinY; |
|
111 | qreal rangeY = m_domainMaxY - m_domainMinY; | |
112 | qreal rangeX = m_domainMaxX - m_domainMinX; |
|
112 | qreal rangeX = m_domainMaxX - m_domainMinX; | |
113 | qreal scaleY = (height / rangeY); |
|
113 | qreal scaleY = (height / rangeY); | |
114 | qreal scaleX = (width / rangeX); |
|
114 | qreal scaleX = (width / rangeX); | |
115 | qreal categoryWidth = width / categoryCount; |
|
115 | qreal categoryWidth = width / categoryCount; | |
116 |
qreal barWidth = categoryWidth |
|
116 | qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin(); | |
117 |
|
117 | |||
118 | int itemIndex(0); |
|
118 | int itemIndex(0); | |
119 | for (int category = 0; category < categoryCount; category++) { |
|
119 | for (int category = 0; category < categoryCount; category++) { | |
120 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
120 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); | |
121 | for (int set = 0; set < setCount; set++) { |
|
121 | for (int set = 0; set < setCount; set++) { | |
122 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
122 | QBarSet* barSet = m_series->d_func()->barsetAt(set); | |
123 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; |
|
123 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
124 | qreal barHeight = barSet->at(category).y() * scaleY; |
|
124 | qreal barHeight = barSet->at(category).y() * scaleY; | |
125 |
|
125 | |||
126 | Bar* bar = m_bars.at(itemIndex); |
|
126 | Bar* bar = m_bars.at(itemIndex); | |
127 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
127 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |
128 |
|
128 | |||
129 | layout.append(rect); |
|
129 | layout.append(rect); | |
130 | bar->setPen(barSet->pen()); |
|
130 | bar->setPen(barSet->pen()); | |
131 | bar->setBrush(barSet->brush()); |
|
131 | bar->setBrush(barSet->brush()); | |
132 | bar->setVisible(barsVisible); |
|
132 | bar->setVisible(barsVisible); | |
133 |
|
133 | |||
134 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
134 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
135 |
|
135 | |||
136 | if (!qFuzzyIsNull(barSet->at(category).y())) { |
|
136 | if (!qFuzzyIsNull(barSet->at(category).y())) { | |
137 | label->setText(QString::number(barSet->at(category).y())); |
|
137 | label->setText(QString::number(barSet->at(category).y())); | |
138 | } else { |
|
138 | } else { | |
139 | label->setText(QString("")); |
|
139 | label->setText(QString("")); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
142 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |
143 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
143 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |
144 | label->setFont(barSet->labelFont()); |
|
144 | label->setFont(barSet->labelFont()); | |
145 |
|
145 | |||
146 | itemIndex++; |
|
146 | itemIndex++; | |
147 | } |
|
147 | } | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | return layout; |
|
150 | return layout; | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) |
|
153 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) | |
154 | { |
|
154 | { | |
155 | if (animator()) |
|
155 | if (animator()) | |
156 | animator()->updateLayout(this, m_layout, layout); |
|
156 | animator()->updateLayout(this, m_layout, layout); | |
157 | else |
|
157 | else | |
158 | setLayout(layout); |
|
158 | setLayout(layout); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | void BarChartItem::setLayout(const QVector<QRectF> &layout) |
|
161 | void BarChartItem::setLayout(const QVector<QRectF> &layout) | |
162 | { |
|
162 | { | |
163 | m_layout = layout; |
|
163 | m_layout = layout; | |
164 |
|
164 | |||
165 | for (int i=0; i < m_bars.count(); i++) |
|
165 | for (int i=0; i < m_bars.count(); i++) | |
166 | m_bars.at(i)->setRect(layout.at(i)); |
|
166 | m_bars.at(i)->setRect(layout.at(i)); | |
167 |
|
167 | |||
168 | update(); |
|
168 | update(); | |
169 | } |
|
169 | } | |
170 | //handlers |
|
170 | //handlers | |
171 |
|
171 | |||
172 | void BarChartItem::handleModelChanged() |
|
172 | void BarChartItem::handleModelChanged() | |
173 | { |
|
173 | { | |
174 | // dataChanged(); |
|
174 | // dataChanged(); | |
175 | presenter()->resetAllElements(); |
|
175 | presenter()->resetAllElements(); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
178 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) | |
179 | { |
|
179 | { | |
180 | m_domainMinX = minX; |
|
180 | m_domainMinX = minX; | |
181 | m_domainMaxX = maxX; |
|
181 | m_domainMaxX = maxX; | |
182 | m_domainMinY = minY; |
|
182 | m_domainMinY = minY; | |
183 | m_domainMaxY = maxY; |
|
183 | m_domainMaxY = maxY; | |
184 | handleLayoutChanged(); |
|
184 | handleLayoutChanged(); | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | void BarChartItem::handleGeometryChanged(const QRectF &rect) |
|
187 | void BarChartItem::handleGeometryChanged(const QRectF &rect) | |
188 | { |
|
188 | { | |
189 | prepareGeometryChange(); |
|
189 | prepareGeometryChange(); | |
190 | m_rect = rect; |
|
190 | m_rect = rect; | |
191 | handleLayoutChanged(); |
|
191 | handleLayoutChanged(); | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | void BarChartItem::handleLayoutChanged() |
|
194 | void BarChartItem::handleLayoutChanged() | |
195 | { |
|
195 | { | |
196 | if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) { |
|
196 | if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) { | |
197 | // rect size zero. |
|
197 | // rect size zero. | |
198 | return; |
|
198 | return; | |
199 | } |
|
199 | } | |
200 | QVector<QRectF> layout = calculateLayout(); |
|
200 | QVector<QRectF> layout = calculateLayout(); | |
201 | applyLayout(layout); |
|
201 | applyLayout(layout); | |
202 | update(); |
|
202 | update(); | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | void BarChartItem::labelsVisibleChanged(bool visible) |
|
205 | void BarChartItem::labelsVisibleChanged(bool visible) | |
206 | { |
|
206 | { | |
207 | foreach (QGraphicsSimpleTextItem* label, m_labels) { |
|
207 | foreach (QGraphicsSimpleTextItem* label, m_labels) { | |
208 | label->setVisible(visible); |
|
208 | label->setVisible(visible); | |
209 | } |
|
209 | } | |
210 | update(); |
|
210 | update(); | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | #include "moc_barchartitem_p.cpp" |
|
213 | #include "moc_barchartitem_p.cpp" | |
214 |
|
214 | |||
215 | QTCOMMERCIALCHART_END_NAMESPACE |
|
215 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,673 +1,607 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qbarseries.h> |
|
22 | #include <qbarseries.h> | |
23 | #include <qbarset.h> |
|
23 | #include <qbarset.h> | |
24 | #include <qchartview.h> |
|
24 | #include <qchartview.h> | |
25 | #include <qchart.h> |
|
25 | #include <qchart.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | Q_DECLARE_METATYPE(QBarSet*) |
|
29 | Q_DECLARE_METATYPE(QBarSet*) | |
30 |
|
30 | |||
31 | class tst_QBarSeries : public QObject |
|
31 | class tst_QBarSeries : public QObject | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 |
|
34 | |||
35 | public slots: |
|
35 | public slots: | |
36 | void initTestCase(); |
|
36 | void initTestCase(); | |
37 | void cleanupTestCase(); |
|
37 | void cleanupTestCase(); | |
38 | void init(); |
|
38 | void init(); | |
39 | void cleanup(); |
|
39 | void cleanup(); | |
40 |
|
40 | |||
41 | private slots: |
|
41 | private slots: | |
42 | void qbarseries_data(); |
|
42 | void qbarseries_data(); | |
43 | void qbarseries(); |
|
43 | void qbarseries(); | |
44 | void type_data(); |
|
44 | void type_data(); | |
45 | void type(); |
|
45 | void type(); | |
46 | void setCategories_data(); |
|
46 | void setCategories_data(); | |
47 | void setCategories(); |
|
47 | void setCategories(); | |
48 | void append_data(); |
|
48 | void append_data(); | |
49 | void append(); |
|
49 | void append(); | |
50 | void remove_data(); |
|
50 | void remove_data(); | |
51 | void remove(); |
|
51 | void remove(); | |
52 | void appendList_data(); |
|
52 | void appendList_data(); | |
53 | void appendList(); |
|
53 | void appendList(); | |
54 | void removeList_data(); |
|
54 | void removeList_data(); | |
55 | void removeList(); |
|
55 | void removeList(); | |
56 | void barsetCount_data(); |
|
56 | void barsetCount_data(); | |
57 | void barsetCount(); |
|
57 | void barsetCount(); | |
58 | void categoryCount_data(); |
|
58 | void categoryCount_data(); | |
59 | void categoryCount(); |
|
59 | void categoryCount(); | |
60 | void barSets_data(); |
|
60 | void barSets_data(); | |
61 | void barSets(); |
|
61 | void barSets(); | |
62 | void categories_data(); |
|
62 | void categories_data(); | |
63 | void categories(); |
|
63 | void categories(); | |
64 | void setLabelsVisible_data(); |
|
64 | void setLabelsVisible_data(); | |
65 | void setLabelsVisible(); |
|
65 | void setLabelsVisible(); | |
66 | void mouseclicked_data(); |
|
66 | void mouseclicked_data(); | |
67 | void mouseclicked(); |
|
67 | void mouseclicked(); | |
68 | void mousehovered_data(); |
|
68 | void mousehovered_data(); | |
69 | void mousehovered(); |
|
69 | void mousehovered(); | |
70 |
|
70 | |||
71 | private: |
|
71 | private: | |
72 | QBarSeries* m_barseries; |
|
72 | QBarSeries* m_barseries; | |
73 | QBarSeries* m_barseries_with_sets; |
|
73 | QBarSeries* m_barseries_with_sets; | |
74 |
|
74 | |||
75 | QList<QBarSet*> m_testSets; |
|
75 | QList<QBarSet*> m_testSets; | |
76 |
|
76 | |||
77 | QBarCategories m_categories; |
|
77 | QBarCategories m_categories; | |
78 | }; |
|
78 | }; | |
79 |
|
79 | |||
80 | void tst_QBarSeries::initTestCase() |
|
80 | void tst_QBarSeries::initTestCase() | |
81 | { |
|
81 | { | |
82 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
82 | qRegisterMetaType<QBarSet*>("QBarSet*"); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | void tst_QBarSeries::cleanupTestCase() |
|
85 | void tst_QBarSeries::cleanupTestCase() | |
86 | { |
|
86 | { | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void tst_QBarSeries::init() |
|
89 | void tst_QBarSeries::init() | |
90 | { |
|
90 | { | |
91 | m_categories << "category0" << "category1" << "category2"; |
|
91 | m_categories << "category0" << "category1" << "category2"; | |
92 | m_barseries = new QBarSeries(); |
|
92 | m_barseries = new QBarSeries(); | |
93 | m_barseries->setCategories(m_categories); |
|
93 | m_barseries->setCategories(m_categories); | |
94 | m_barseries_with_sets = new QBarSeries(); |
|
94 | m_barseries_with_sets = new QBarSeries(); | |
95 | m_barseries_with_sets->setCategories(m_categories); |
|
95 | m_barseries_with_sets->setCategories(m_categories); | |
96 |
|
96 | |||
97 | for (int i=0; i<5; i++) { |
|
97 | for (int i=0; i<5; i++) { | |
98 | m_testSets.append(new QBarSet("testset")); |
|
98 | m_testSets.append(new QBarSet("testset")); | |
99 | m_barseries_with_sets->append(m_testSets.at(i)); |
|
99 | m_barseries_with_sets->append(m_testSets.at(i)); | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | void tst_QBarSeries::cleanup() |
|
103 | void tst_QBarSeries::cleanup() | |
104 | { |
|
104 | { | |
105 | foreach(QBarSet* s, m_testSets) { |
|
105 | foreach(QBarSet* s, m_testSets) { | |
106 | m_barseries_with_sets->remove(s); |
|
106 | m_barseries_with_sets->remove(s); | |
107 | delete s; |
|
107 | delete s; | |
108 | } |
|
108 | } | |
109 | m_testSets.clear(); |
|
109 | m_testSets.clear(); | |
110 |
|
110 | |||
111 | delete m_barseries; |
|
111 | delete m_barseries; | |
112 | m_barseries = 0; |
|
112 | m_barseries = 0; | |
113 | delete m_barseries_with_sets; |
|
113 | delete m_barseries_with_sets; | |
114 | m_barseries_with_sets = 0; |
|
114 | m_barseries_with_sets = 0; | |
115 | m_categories.clear(); |
|
115 | m_categories.clear(); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void tst_QBarSeries::qbarseries_data() |
|
118 | void tst_QBarSeries::qbarseries_data() | |
119 | { |
|
119 | { | |
120 | QTest::addColumn<QBarCategories> ("categories"); |
|
120 | QTest::addColumn<QBarCategories> ("categories"); | |
121 | QBarCategories c; |
|
121 | QBarCategories c; | |
122 | c << "category0" << "category1" << "category2"; |
|
122 | c << "category0" << "category1" << "category2"; | |
123 | QTest::newRow("categories") << c; |
|
123 | QTest::newRow("categories") << c; | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | void tst_QBarSeries::qbarseries() |
|
126 | void tst_QBarSeries::qbarseries() | |
127 | { |
|
127 | { | |
128 | QFETCH(QBarCategories, categories); |
|
128 | QFETCH(QBarCategories, categories); | |
129 | QBarSeries *barseries = new QBarSeries(); |
|
129 | QBarSeries *barseries = new QBarSeries(); | |
130 | QVERIFY(barseries != 0); |
|
130 | QVERIFY(barseries != 0); | |
131 | barseries->setCategories(categories); |
|
131 | barseries->setCategories(categories); | |
132 | QBarCategories verifyCategories = barseries->categories(); |
|
132 | QBarCategories verifyCategories = barseries->categories(); | |
133 |
|
133 | |||
134 | QVERIFY(verifyCategories.count() == categories.count()); |
|
134 | QVERIFY(verifyCategories.count() == categories.count()); | |
135 | for (int i=0; i<categories.count(); i++) { |
|
135 | for (int i=0; i<categories.count(); i++) { | |
136 | QVERIFY(verifyCategories.at(i).compare(categories.at(i)) == 0); |
|
136 | QVERIFY(verifyCategories.at(i).compare(categories.at(i)) == 0); | |
137 | } |
|
137 | } | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | void tst_QBarSeries::type_data() |
|
140 | void tst_QBarSeries::type_data() | |
141 | { |
|
141 | { | |
142 |
|
142 | |||
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | void tst_QBarSeries::type() |
|
145 | void tst_QBarSeries::type() | |
146 | { |
|
146 | { | |
147 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); |
|
147 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | void tst_QBarSeries::setCategories_data() |
|
150 | void tst_QBarSeries::setCategories_data() | |
151 | { |
|
151 | { | |
152 | QTest::addColumn<QBarCategories> ("categories"); |
|
152 | QTest::addColumn<QBarCategories> ("categories"); | |
153 | QBarCategories categories; |
|
153 | QBarCategories categories; | |
154 | categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; |
|
154 | categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; | |
155 | QTest::newRow("cat") << categories; |
|
155 | QTest::newRow("cat") << categories; | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | void tst_QBarSeries::setCategories() |
|
158 | void tst_QBarSeries::setCategories() | |
159 | { |
|
159 | { | |
160 | QVERIFY(m_barseries->categories().count() == m_categories.count()); |
|
160 | QVERIFY(m_barseries->categories().count() == m_categories.count()); | |
161 |
|
161 | |||
162 | QFETCH(QBarCategories, categories); |
|
162 | QFETCH(QBarCategories, categories); | |
163 | m_barseries->setCategories(categories); |
|
163 | m_barseries->setCategories(categories); | |
164 |
|
164 | |||
165 | QVERIFY(m_barseries->categories().count() == categories.count()); |
|
165 | QVERIFY(m_barseries->categories().count() == categories.count()); | |
166 | for (int i=0; i<categories.count(); i++) { |
|
166 | for (int i=0; i<categories.count(); i++) { | |
167 | QVERIFY(m_barseries->categories().at(i).compare(categories.at(i)) == 0); |
|
167 | QVERIFY(m_barseries->categories().at(i).compare(categories.at(i)) == 0); | |
168 | } |
|
168 | } | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | void tst_QBarSeries::append_data() |
|
171 | void tst_QBarSeries::append_data() | |
172 | { |
|
172 | { | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | void tst_QBarSeries::append() |
|
175 | void tst_QBarSeries::append() | |
176 | { |
|
176 | { | |
177 | QVERIFY(m_barseries->barsetCount() == 0); |
|
177 | QVERIFY(m_barseries->barsetCount() == 0); | |
178 |
|
178 | |||
179 | bool ret = false; |
|
179 | bool ret = false; | |
180 |
|
180 | |||
181 | // Try adding barset |
|
181 | // Try adding barset | |
182 | QBarSet *barset = new QBarSet("testset"); |
|
182 | QBarSet *barset = new QBarSet("testset"); | |
183 | ret = m_barseries->append(barset); |
|
183 | ret = m_barseries->append(barset); | |
184 |
|
184 | |||
185 | QVERIFY(ret == true); |
|
185 | QVERIFY(ret == true); | |
186 | QVERIFY(m_barseries->barsetCount() == 1); |
|
186 | QVERIFY(m_barseries->barsetCount() == 1); | |
187 |
|
187 | |||
188 | // Try adding another set |
|
188 | // Try adding another set | |
189 | QBarSet *barset2 = new QBarSet("testset2"); |
|
189 | QBarSet *barset2 = new QBarSet("testset2"); | |
190 | ret = m_barseries->append(barset2); |
|
190 | ret = m_barseries->append(barset2); | |
191 |
|
191 | |||
192 | QVERIFY(ret == true); |
|
192 | QVERIFY(ret == true); | |
193 | QVERIFY(m_barseries->barsetCount() == 2); |
|
193 | QVERIFY(m_barseries->barsetCount() == 2); | |
194 |
|
194 | |||
195 | // Try adding same set again |
|
195 | // Try adding same set again | |
196 | ret = m_barseries->append(barset2); |
|
196 | ret = m_barseries->append(barset2); | |
197 | QVERIFY(ret == false); |
|
197 | QVERIFY(ret == false); | |
198 | QVERIFY(m_barseries->barsetCount() == 2); |
|
198 | QVERIFY(m_barseries->barsetCount() == 2); | |
199 |
|
199 | |||
200 | // Try adding null set |
|
200 | // Try adding null set | |
201 | ret = m_barseries->append(0); |
|
201 | ret = m_barseries->append(0); | |
202 | QVERIFY(ret == false); |
|
202 | QVERIFY(ret == false); | |
203 | QVERIFY(m_barseries->barsetCount() == 2); |
|
203 | QVERIFY(m_barseries->barsetCount() == 2); | |
204 |
|
204 | |||
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | void tst_QBarSeries::remove_data() |
|
207 | void tst_QBarSeries::remove_data() | |
208 | { |
|
208 | { | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | void tst_QBarSeries::remove() |
|
211 | void tst_QBarSeries::remove() | |
212 | { |
|
212 | { | |
213 | int count = m_testSets.count(); |
|
213 | int count = m_testSets.count(); | |
214 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
214 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
215 |
|
215 | |||
216 | // Try to remove null pointer (should not remove, should not crash) |
|
216 | // Try to remove null pointer (should not remove, should not crash) | |
217 | bool ret = false; |
|
217 | bool ret = false; | |
218 | ret = m_barseries_with_sets->remove(0); |
|
218 | ret = m_barseries_with_sets->remove(0); | |
219 | QVERIFY(ret == false); |
|
219 | QVERIFY(ret == false); | |
220 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
220 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
221 |
|
221 | |||
222 | // Try to remove invalid pointer (should not remove, should not crash) |
|
222 | // Try to remove invalid pointer (should not remove, should not crash) | |
223 | ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); |
|
223 | ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); | |
224 | QVERIFY(ret == false); |
|
224 | QVERIFY(ret == false); | |
225 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
225 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
226 |
|
226 | |||
227 | // remove some sets |
|
227 | // remove some sets | |
228 | ret = m_barseries_with_sets->remove(m_testSets.at(2)); |
|
228 | ret = m_barseries_with_sets->remove(m_testSets.at(2)); | |
229 | QVERIFY(ret == true); |
|
229 | QVERIFY(ret == true); | |
230 | ret = m_barseries_with_sets->remove(m_testSets.at(3)); |
|
230 | ret = m_barseries_with_sets->remove(m_testSets.at(3)); | |
231 | QVERIFY(ret == true); |
|
231 | QVERIFY(ret == true); | |
232 | ret = m_barseries_with_sets->remove(m_testSets.at(4)); |
|
232 | ret = m_barseries_with_sets->remove(m_testSets.at(4)); | |
233 | QVERIFY(ret == true); |
|
233 | QVERIFY(ret == true); | |
234 |
|
234 | |||
235 | QVERIFY(m_barseries_with_sets->barsetCount() == 2); |
|
235 | QVERIFY(m_barseries_with_sets->barsetCount() == 2); | |
236 |
|
236 | |||
237 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); |
|
237 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); | |
238 |
|
238 | |||
239 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); |
|
239 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); | |
240 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); |
|
240 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); | |
241 |
|
241 | |||
242 | // Try removing all sets again (should be ok, even if some sets have already been removed) |
|
242 | // Try removing all sets again (should be ok, even if some sets have already been removed) | |
243 | ret = false; |
|
243 | ret = false; | |
244 | for (int i=0; i<count; i++) { |
|
244 | for (int i=0; i<count; i++) { | |
245 | ret |= m_barseries_with_sets->remove(m_testSets.at(i)); |
|
245 | ret |= m_barseries_with_sets->remove(m_testSets.at(i)); | |
246 | } |
|
246 | } | |
247 |
|
247 | |||
248 | QVERIFY(ret == true); |
|
248 | QVERIFY(ret == true); | |
249 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
249 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
250 | } |
|
250 | } | |
251 |
|
251 | |||
252 | void tst_QBarSeries::appendList_data() |
|
252 | void tst_QBarSeries::appendList_data() | |
253 | { |
|
253 | { | |
254 |
|
254 | |||
255 | } |
|
255 | } | |
256 |
|
256 | |||
257 | void tst_QBarSeries::appendList() |
|
257 | void tst_QBarSeries::appendList() | |
258 | { |
|
258 | { | |
259 | int count = 5; |
|
259 | int count = 5; | |
260 | QVERIFY(m_barseries->barsetCount() == 0); |
|
260 | QVERIFY(m_barseries->barsetCount() == 0); | |
261 |
|
261 | |||
262 | QList<QBarSet*> sets; |
|
262 | QList<QBarSet*> sets; | |
263 | for (int i=0; i<count; i++) { |
|
263 | for (int i=0; i<count; i++) { | |
264 | sets.append(new QBarSet("testset")); |
|
264 | sets.append(new QBarSet("testset")); | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | // Append new sets (should succeed, count should match the count of sets) |
|
267 | // Append new sets (should succeed, count should match the count of sets) | |
268 | bool ret = false; |
|
268 | bool ret = false; | |
269 | ret = m_barseries->append(sets); |
|
269 | ret = m_barseries->append(sets); | |
270 | QVERIFY(ret == true); |
|
270 | QVERIFY(ret == true); | |
271 | QVERIFY(m_barseries->barsetCount() == count); |
|
271 | QVERIFY(m_barseries->barsetCount() == count); | |
272 |
|
272 | |||
273 | // Append same sets again (should fail, count should remain same) |
|
273 | // Append same sets again (should fail, count should remain same) | |
274 | ret = m_barseries->append(sets); |
|
274 | ret = m_barseries->append(sets); | |
275 | QVERIFY(ret == false); |
|
275 | QVERIFY(ret == false); | |
276 | QVERIFY(m_barseries->barsetCount() == count); |
|
276 | QVERIFY(m_barseries->barsetCount() == count); | |
277 |
|
277 | |||
278 | // Try append empty list (should succeed, but count should remain same) |
|
278 | // Try append empty list (should succeed, but count should remain same) | |
279 | QList<QBarSet*> invalidList; |
|
279 | QList<QBarSet*> invalidList; | |
280 | ret = m_barseries->append(invalidList); |
|
280 | ret = m_barseries->append(invalidList); | |
281 | QVERIFY(ret == true); |
|
281 | QVERIFY(ret == true); | |
282 | QVERIFY(m_barseries->barsetCount() == count); |
|
282 | QVERIFY(m_barseries->barsetCount() == count); | |
283 |
|
283 | |||
284 | // Try append list with one new and one existing set (should fail, count remains same) |
|
284 | // Try append list with one new and one existing set (should fail, count remains same) | |
285 | invalidList.append(new QBarSet("ok set")); |
|
285 | invalidList.append(new QBarSet("ok set")); | |
286 | invalidList.append(sets.at(0)); |
|
286 | invalidList.append(sets.at(0)); | |
287 | ret = m_barseries->append(invalidList); |
|
287 | ret = m_barseries->append(invalidList); | |
288 | QVERIFY(ret == false); |
|
288 | QVERIFY(ret == false); | |
289 | QVERIFY(m_barseries->barsetCount() == count); |
|
289 | QVERIFY(m_barseries->barsetCount() == count); | |
290 |
|
290 | |||
291 | // Try append list with null pointers (should fail, count remains same) |
|
291 | // Try append list with null pointers (should fail, count remains same) | |
292 | QList<QBarSet*> invalidList2; |
|
292 | QList<QBarSet*> invalidList2; | |
293 | invalidList2.append(0); |
|
293 | invalidList2.append(0); | |
294 | invalidList2.append(0); |
|
294 | invalidList2.append(0); | |
295 | invalidList2.append(0); |
|
295 | invalidList2.append(0); | |
296 | ret = m_barseries->append(invalidList2); |
|
296 | ret = m_barseries->append(invalidList2); | |
297 | QVERIFY(ret == false); |
|
297 | QVERIFY(ret == false); | |
298 | QVERIFY(m_barseries->barsetCount() == count); |
|
298 | QVERIFY(m_barseries->barsetCount() == count); | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | void tst_QBarSeries::removeList_data() |
|
301 | void tst_QBarSeries::removeList_data() | |
302 | { |
|
302 | { | |
303 |
|
303 | |||
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | void tst_QBarSeries::removeList() |
|
306 | void tst_QBarSeries::removeList() | |
307 | { |
|
307 | { | |
308 | int count = m_testSets.count(); |
|
308 | int count = m_testSets.count(); | |
309 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
309 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
310 |
|
310 | |||
311 | // Try removing empty list of sets (should return false, since no barsets were removed) |
|
311 | // Try removing empty list of sets (should return false, since no barsets were removed) | |
312 | bool ret = false; |
|
312 | bool ret = false; | |
313 | QList<QBarSet*> invalidList; |
|
313 | QList<QBarSet*> invalidList; | |
314 | ret = m_barseries_with_sets->remove(invalidList); |
|
314 | ret = m_barseries_with_sets->remove(invalidList); | |
315 | QVERIFY(ret == false); |
|
315 | QVERIFY(ret == false); | |
316 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
316 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
317 |
|
317 | |||
318 | // Add some null pointers to list |
|
318 | // Add some null pointers to list | |
319 | invalidList.append(0); |
|
319 | invalidList.append(0); | |
320 | invalidList.append(0); |
|
320 | invalidList.append(0); | |
321 | invalidList.append(0); |
|
321 | invalidList.append(0); | |
322 |
|
322 | |||
323 | // Try removing null pointers from list (should return false, should not crash, should not remove anything) |
|
323 | // Try removing null pointers from list (should return false, should not crash, should not remove anything) | |
324 | ret = m_barseries_with_sets->remove(invalidList); |
|
324 | ret = m_barseries_with_sets->remove(invalidList); | |
325 | QVERIFY(ret == false); |
|
325 | QVERIFY(ret == false); | |
326 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
326 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
327 |
|
327 | |||
328 | // remove all sets (should return true, since sets were removed) |
|
328 | // remove all sets (should return true, since sets were removed) | |
329 | ret = m_barseries_with_sets->remove(m_testSets); |
|
329 | ret = m_barseries_with_sets->remove(m_testSets); | |
330 | QVERIFY(ret == true); |
|
330 | QVERIFY(ret == true); | |
331 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
331 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
332 |
|
332 | |||
333 | // Try removing invalid list again (should return false, since no barsets were removed) |
|
333 | // Try removing invalid list again (should return false, since no barsets were removed) | |
334 | ret = m_barseries_with_sets->remove(invalidList); |
|
334 | ret = m_barseries_with_sets->remove(invalidList); | |
335 | QVERIFY(ret == false); |
|
335 | QVERIFY(ret == false); | |
336 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
336 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
337 |
|
337 | |||
338 | // remove all sets again (should return false, since barsets were already removed) |
|
338 | // remove all sets again (should return false, since barsets were already removed) | |
339 | ret = m_barseries_with_sets->remove(m_testSets); |
|
339 | ret = m_barseries_with_sets->remove(m_testSets); | |
340 | QVERIFY(ret == false); |
|
340 | QVERIFY(ret == false); | |
341 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
341 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 | void tst_QBarSeries::barsetCount_data() |
|
344 | void tst_QBarSeries::barsetCount_data() | |
345 | { |
|
345 | { | |
346 |
|
346 | |||
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | void tst_QBarSeries::barsetCount() |
|
349 | void tst_QBarSeries::barsetCount() | |
350 | { |
|
350 | { | |
351 | QVERIFY(m_barseries->barsetCount() == 0); |
|
351 | QVERIFY(m_barseries->barsetCount() == 0); | |
352 | QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); |
|
352 | QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | void tst_QBarSeries::categoryCount_data() |
|
355 | void tst_QBarSeries::categoryCount_data() | |
356 | { |
|
356 | { | |
357 |
|
357 | |||
358 | } |
|
358 | } | |
359 |
|
359 | |||
360 | void tst_QBarSeries::categoryCount() |
|
360 | void tst_QBarSeries::categoryCount() | |
361 | { |
|
361 | { | |
362 | QVERIFY(m_barseries->categoryCount() == m_categories.count()); |
|
362 | QVERIFY(m_barseries->categoryCount() == m_categories.count()); | |
363 | QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); |
|
363 | QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 | void tst_QBarSeries::barSets_data() |
|
366 | void tst_QBarSeries::barSets_data() | |
367 | { |
|
367 | { | |
368 |
|
368 | |||
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | void tst_QBarSeries::barSets() |
|
371 | void tst_QBarSeries::barSets() | |
372 | { |
|
372 | { | |
373 | QVERIFY(m_barseries->barSets().count() == 0); |
|
373 | QVERIFY(m_barseries->barSets().count() == 0); | |
374 |
|
374 | |||
375 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); |
|
375 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); | |
376 | QVERIFY(sets.count() == m_testSets.count()); |
|
376 | QVERIFY(sets.count() == m_testSets.count()); | |
377 |
|
377 | |||
378 | for (int i=0; i<m_testSets.count(); i++) { |
|
378 | for (int i=0; i<m_testSets.count(); i++) { | |
379 | QVERIFY(sets.at(i) == m_testSets.at(i)); |
|
379 | QVERIFY(sets.at(i) == m_testSets.at(i)); | |
380 | } |
|
380 | } | |
381 | } |
|
381 | } | |
382 |
|
382 | |||
383 | void tst_QBarSeries::categories_data() |
|
383 | void tst_QBarSeries::categories_data() | |
384 | { |
|
384 | { | |
385 |
|
385 | |||
386 | } |
|
386 | } | |
387 |
|
387 | |||
388 | void tst_QBarSeries::categories() |
|
388 | void tst_QBarSeries::categories() | |
389 | { |
|
389 | { | |
390 | QBarCategories categories = m_barseries->categories(); |
|
390 | QBarCategories categories = m_barseries->categories(); | |
391 |
|
391 | |||
392 | QVERIFY(categories.count() == m_categories.count()); |
|
392 | QVERIFY(categories.count() == m_categories.count()); | |
393 | for (int i=0; i<m_categories.count(); i++) { |
|
393 | for (int i=0; i<m_categories.count(); i++) { | |
394 | QVERIFY(categories.at(i).compare(m_categories.at(i)) == 0); |
|
394 | QVERIFY(categories.at(i).compare(m_categories.at(i)) == 0); | |
395 | } |
|
395 | } | |
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | void tst_QBarSeries::setLabelsVisible_data() |
|
398 | void tst_QBarSeries::setLabelsVisible_data() | |
399 | { |
|
399 | { | |
400 |
|
400 | |||
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | void tst_QBarSeries::setLabelsVisible() |
|
403 | void tst_QBarSeries::setLabelsVisible() | |
404 | { |
|
404 | { | |
405 | // labels should be invisible by default |
|
405 | // labels should be invisible by default | |
406 | QVERIFY(m_barseries->isLabelsVisible() == false); |
|
406 | QVERIFY(m_barseries->isLabelsVisible() == false); | |
407 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); |
|
407 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); | |
408 |
|
408 | |||
409 | // turn labels to visible |
|
409 | // turn labels to visible | |
410 | m_barseries_with_sets->setLabelsVisible(true); |
|
410 | m_barseries_with_sets->setLabelsVisible(true); | |
411 | // TODO: test the signal |
|
411 | // TODO: test the signal | |
412 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); |
|
412 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); | |
413 |
|
413 | |||
414 | // turn labels to invisible |
|
414 | // turn labels to invisible | |
415 | m_barseries_with_sets->setLabelsVisible(false); |
|
415 | m_barseries_with_sets->setLabelsVisible(false); | |
416 | // TODO: test the signal |
|
416 | // TODO: test the signal | |
417 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); |
|
417 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); | |
418 |
|
418 | |||
419 | // without parameter, should turn labels to visible |
|
419 | // without parameter, should turn labels to visible | |
420 | m_barseries_with_sets->setLabelsVisible(); |
|
420 | m_barseries_with_sets->setLabelsVisible(); | |
421 | // TODO: test the signal |
|
421 | // TODO: test the signal | |
422 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); |
|
422 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | void tst_QBarSeries::mouseclicked_data() |
|
425 | void tst_QBarSeries::mouseclicked_data() | |
426 | { |
|
426 | { | |
427 |
|
427 | |||
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | void tst_QBarSeries::mouseclicked() |
|
430 | void tst_QBarSeries::mouseclicked() | |
431 | { |
|
431 | { | |
432 | QBarSeries* series = new QBarSeries(); |
|
432 | QBarSeries* series = new QBarSeries(); | |
433 | QBarCategories categories; |
|
433 | QBarCategories categories; | |
434 | categories << "test1" << "test2" << "test3"; |
|
434 | categories << "test1" << "test2" << "test3"; | |
435 | series->setCategories(categories); |
|
435 | series->setCategories(categories); | |
436 |
|
436 | |||
437 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
437 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
438 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
438 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | |
439 | series->append(set1); |
|
439 | series->append(set1); | |
440 |
|
440 | |||
441 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
441 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
442 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
442 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | |
443 | series->append(set2); |
|
443 | series->append(set2); | |
444 |
|
444 | |||
445 | QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); |
|
|||
446 | QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); |
|
|||
447 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); |
|
445 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); | |
448 |
|
446 | |||
449 | QChartView view(new QChart()); |
|
447 | QChartView view(new QChart()); | |
450 | view.resize(400,300); |
|
448 | view.resize(400,300); | |
451 | view.chart()->addSeries(series); |
|
449 | view.chart()->addSeries(series); | |
452 | view.show(); |
|
450 | view.show(); | |
453 | QTest::qWaitForWindowShown(&view); |
|
451 | QTest::qWaitForWindowShown(&view); | |
454 |
|
452 | |||
455 | //==================================================================================== |
|
453 | //==================================================================================== | |
456 | // barset 1, category test1 |
|
454 | // barset 1, category test1 | |
457 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(10 |
|
455 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,142)); | |
458 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
456 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
459 |
|
457 | |||
460 | QCOMPARE(setSpy1.count(), 1); |
|
|||
461 | QCOMPARE(setSpy2.count(), 0); |
|
|||
462 | QCOMPARE(seriesSpy.count(), 1); |
|
458 | QCOMPARE(seriesSpy.count(), 1); | |
463 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
464 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
465 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
466 |
|
459 | |||
467 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
460 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
468 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
461 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
462 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
463 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
469 |
|
464 | |||
470 | //==================================================================================== |
|
465 | //==================================================================================== | |
471 | // barset 1, category test2 |
|
466 | // barset 1, category test2 | |
472 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
467 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,142)); | |
473 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
468 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
474 |
|
469 | |||
475 | QCOMPARE(setSpy1.count(), 1); |
|
|||
476 | QCOMPARE(setSpy2.count(), 0); |
|
|||
477 | QCOMPARE(seriesSpy.count(), 1); |
|
470 | QCOMPARE(seriesSpy.count(), 1); | |
478 | setSpyArg = setSpy1.takeFirst(); |
|
|||
479 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
480 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
481 |
|
471 | |||
482 | seriesSpyArg = seriesSpy.takeFirst(); |
|
472 | seriesSpyArg = seriesSpy.takeFirst(); | |
483 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
473 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
474 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
475 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
484 |
|
476 | |||
485 | //==================================================================================== |
|
477 | //==================================================================================== | |
486 | // barset 1, category test3 |
|
478 | // barset 1, category test3 | |
487 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(29 |
|
479 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(291,142)); | |
488 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
480 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
489 |
|
481 | |||
490 | QCOMPARE(setSpy1.count(), 1); |
|
|||
491 | QCOMPARE(setSpy2.count(), 0); |
|
|||
492 | QCOMPARE(seriesSpy.count(), 1); |
|
482 | QCOMPARE(seriesSpy.count(), 1); | |
493 | setSpyArg = setSpy1.takeFirst(); |
|
|||
494 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
495 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
496 |
|
483 | |||
497 | seriesSpyArg = seriesSpy.takeFirst(); |
|
484 | seriesSpyArg = seriesSpy.takeFirst(); | |
498 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
485 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
486 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
487 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | |||
499 |
|
488 | |||
500 | //==================================================================================== |
|
489 | //==================================================================================== | |
501 | // barset 2, category test1 |
|
490 | // barset 2, category test1 | |
502 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(14 |
|
491 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(134,142)); | |
503 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
492 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
504 |
|
493 | |||
505 | QCOMPARE(setSpy1.count(), 0); |
|
|||
506 | QCOMPARE(setSpy2.count(), 1); |
|
|||
507 | QCOMPARE(seriesSpy.count(), 1); |
|
494 | QCOMPARE(seriesSpy.count(), 1); | |
508 | setSpyArg = setSpy2.takeFirst(); |
|
|||
509 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
510 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
511 |
|
495 | |||
512 | seriesSpyArg = seriesSpy.takeFirst(); |
|
496 | seriesSpyArg = seriesSpy.takeFirst(); | |
513 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
497 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
498 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
499 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
514 |
|
500 | |||
515 | //==================================================================================== |
|
501 | //==================================================================================== | |
516 | // barset 2, category test2 |
|
502 | // barset 2, category test2 | |
517 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(2 |
|
503 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(227,142)); | |
518 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
504 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
519 |
|
505 | |||
520 | QCOMPARE(setSpy1.count(), 0); |
|
|||
521 | QCOMPARE(setSpy2.count(), 1); |
|
|||
522 | QCOMPARE(seriesSpy.count(), 1); |
|
506 | QCOMPARE(seriesSpy.count(), 1); | |
523 | setSpyArg = setSpy2.takeFirst(); |
|
|||
524 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
525 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
526 |
|
507 | |||
527 | seriesSpyArg = seriesSpy.takeFirst(); |
|
508 | seriesSpyArg = seriesSpy.takeFirst(); | |
528 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
509 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
510 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
511 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
529 |
|
512 | |||
530 | //==================================================================================== |
|
513 | //==================================================================================== | |
531 | // barset 2, category test3 |
|
514 | // barset 2, category test3 | |
532 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(3 |
|
515 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(319,142)); | |
533 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
516 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
534 |
|
517 | |||
535 | QCOMPARE(setSpy1.count(), 0); |
|
|||
536 | QCOMPARE(setSpy2.count(), 1); |
|
|||
537 | QCOMPARE(seriesSpy.count(), 1); |
|
518 | QCOMPARE(seriesSpy.count(), 1); | |
538 | setSpyArg = setSpy2.takeFirst(); |
|
|||
539 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
540 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
541 |
|
519 | |||
542 | seriesSpyArg = seriesSpy.takeFirst(); |
|
520 | seriesSpyArg = seriesSpy.takeFirst(); | |
543 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
521 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
544 |
|
522 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | ||
545 | //==================================================================================== |
|
523 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | |
546 | // no event cases |
|
|||
547 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets |
|
|||
548 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets |
|
|||
549 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(105,180)); // barset 1, category test1 |
|
|||
550 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(200,180)); // barset 1, category test2 |
|
|||
551 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(295,180)); // barset 1, category test3 |
|
|||
552 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(145,180)); // barset 2, category test1 |
|
|||
553 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(240,180)); // barset 2, category test2 |
|
|||
554 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(335,180)); // barset 2, category test3 |
|
|||
555 |
|
||||
556 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
|||
557 | QCOMPARE(setSpy1.count(), 0); |
|
|||
558 | QCOMPARE(setSpy2.count(), 0); |
|
|||
559 | QCOMPARE(seriesSpy.count(), 0); |
|
|||
560 | } |
|
524 | } | |
561 |
|
525 | |||
562 | void tst_QBarSeries::mousehovered_data() |
|
526 | void tst_QBarSeries::mousehovered_data() | |
563 | { |
|
527 | { | |
564 |
|
528 | |||
565 | } |
|
529 | } | |
566 |
|
530 | |||
567 | void tst_QBarSeries::mousehovered() |
|
531 | void tst_QBarSeries::mousehovered() | |
568 | { |
|
532 | { | |
569 | QBarSeries* series = new QBarSeries(); |
|
533 | QBarSeries* series = new QBarSeries(); | |
570 | QBarCategories categories; |
|
534 | QBarCategories categories; | |
571 | categories << "test1" << "test2" << "test3"; |
|
535 | categories << "test1" << "test2" << "test3"; | |
572 | series->setCategories(categories); |
|
536 | series->setCategories(categories); | |
573 |
|
537 | |||
574 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
538 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
575 | *set1 << QPointF(0.1,10) << QPointF(1.1,10) << QPointF(2.1,10); |
|
539 | *set1 << QPointF(0.1,10) << QPointF(1.1,10) << QPointF(2.1,10); | |
576 | series->append(set1); |
|
540 | series->append(set1); | |
577 |
|
541 | |||
578 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
542 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
579 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
543 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | |
580 | series->append(set2); |
|
544 | series->append(set2); | |
581 |
|
545 | |||
582 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); |
|
|||
583 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); |
|
|||
584 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); |
|
546 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); | |
585 |
|
547 | |||
586 | QChartView view(new QChart()); |
|
548 | QChartView view(new QChart()); | |
587 | view.resize(400,300); |
|
549 | view.resize(400,300); | |
588 | view.chart()->addSeries(series); |
|
550 | view.chart()->addSeries(series); | |
589 | view.show(); |
|
551 | view.show(); | |
590 | QTest::qWaitForWindowShown(&view); |
|
552 | QTest::qWaitForWindowShown(&view); | |
591 |
|
553 | |||
|
554 | //this is hack since view does not get events otherwise | |||
|
555 | view.setMouseTracking(true); | |||
|
556 | ||||
592 | //======================================================================= |
|
557 | //======================================================================= | |
593 | // move mouse to left border |
|
558 | // move mouse to left border | |
594 |
QTest::mouseMove(view.viewport(), QPoint(0, 1 |
|
559 | QTest::mouseMove(view.viewport(), QPoint(0, 142)); | |
595 |
|
560 | |||
596 | QVERIFY(setSpy1.count() == 0); |
|
|||
597 | QVERIFY(setSpy2.count() == 0); |
|
|||
598 | QVERIFY(seriesSpy.count() == 0); |
|
561 | QVERIFY(seriesSpy.count() == 0); | |
599 |
|
562 | |||
600 | //======================================================================= |
|
563 | //======================================================================= | |
601 | // move mouse on top of set1 |
|
564 | // move mouse on top of set1 | |
602 |
QTest::mouseMove(view.viewport(), QPoint(10 |
|
565 | QTest::mouseMove(view.viewport(), QPoint(106,142)); | |
603 |
|
566 | |||
604 | QVERIFY(setSpy1.count() == 1); |
|
|||
605 | QVERIFY(setSpy2.count() == 0); |
|
|||
606 | QVERIFY(seriesSpy.count() == 1); |
|
567 | QVERIFY(seriesSpy.count() == 1); | |
607 |
|
568 | |||
608 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
609 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
610 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
611 |
|
||||
612 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
569 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
613 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
570 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
571 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |||
|
572 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |||
614 |
|
573 | |||
615 | //======================================================================= |
|
574 | //======================================================================= | |
616 | // move mouse from top of set1 to top of set2 |
|
575 | // move mouse from top of set1 to top of set2 | |
617 |
QTest::mouseMove(view.viewport(), QPoint(14 |
|
576 | QTest::mouseMove(view.viewport(), QPoint(134,142)); | |
618 |
|
577 | |||
619 | QVERIFY(setSpy1.count() == 1); |
|
|||
620 | QVERIFY(setSpy2.count() == 1); |
|
|||
621 | QVERIFY(seriesSpy.count() == 2); |
|
578 | QVERIFY(seriesSpy.count() == 2); | |
622 |
|
579 | |||
623 | // should leave set1 |
|
580 | // should leave set1 | |
624 | setSpyArg = setSpy1.takeFirst(); |
|
|||
625 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
626 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
627 |
|
||||
628 | // should enter set2 |
|
|||
629 | setSpyArg = setSpy2.takeFirst(); |
|
|||
630 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
631 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
632 |
|
||||
633 | // should leave set1 |
|
|||
634 | seriesSpyArg = seriesSpy.takeFirst(); |
|
581 | seriesSpyArg = seriesSpy.takeFirst(); | |
635 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
582 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
636 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
583 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
637 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
584 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
638 |
|
585 | |||
639 | // should enter set2 |
|
586 | // should enter set2 | |
640 | seriesSpyArg = seriesSpy.takeFirst(); |
|
587 | seriesSpyArg = seriesSpy.takeFirst(); | |
641 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
588 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
642 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
589 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
643 | QVERIFY(seriesSpyArg.at(1).toBool() == true); |
|
590 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |
644 |
|
591 | |||
645 | //======================================================================= |
|
592 | //======================================================================= | |
646 | // move mouse from top of set2 to background |
|
593 | // move mouse from top of set2 to background | |
647 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
594 | QTest::mouseMove(view.viewport(), QPoint(134,0)); | |
648 |
|
||||
649 | QVERIFY(setSpy1.count() == 0); |
|
|||
650 | QVERIFY(setSpy2.count() == 1); |
|
|||
651 | QVERIFY(seriesSpy.count() == 1); |
|
595 | QVERIFY(seriesSpy.count() == 1); | |
652 |
|
596 | |||
653 |
// should leave set2 |
|
597 | // should leave set2 | |
654 | setSpyArg = setSpy2.takeFirst(); |
|
|||
655 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
656 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
657 |
|
||||
658 | // should leave set2 (event via series) |
|
|||
659 | seriesSpyArg = seriesSpy.takeFirst(); |
|
598 | seriesSpyArg = seriesSpy.takeFirst(); | |
660 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
599 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
661 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
600 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
662 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
601 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
663 | } |
|
602 | } | |
664 |
|
603 | |||
665 | /* |
|
|||
666 | bool setModel(QAbstractItemModel *model); |
|
|||
667 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
|||
668 | void setModelMappingRange(int first, int count = -1); |
|
|||
669 | */ |
|
|||
670 | QTEST_MAIN(tst_QBarSeries) |
|
604 | QTEST_MAIN(tst_QBarSeries) | |
671 |
|
605 | |||
672 | #include "tst_qbarseries.moc" |
|
606 | #include "tst_qbarseries.moc" | |
673 |
|
607 |
@@ -1,353 +1,289 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qgroupedbarseries.h> |
|
22 | #include <qgroupedbarseries.h> | |
23 | #include <qbarset.h> |
|
23 | #include <qbarset.h> | |
24 | #include <qchartview.h> |
|
24 | #include <qchartview.h> | |
25 | #include <qchart.h> |
|
25 | #include <qchart.h> | |
26 | #include <QBarModelMapper> |
|
26 | #include <QBarModelMapper> | |
27 | #include <QStandardItemModel> |
|
27 | #include <QStandardItemModel> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | Q_DECLARE_METATYPE(QBarSet*) |
|
31 | Q_DECLARE_METATYPE(QBarSet*) | |
32 |
|
32 | |||
33 | class tst_QGroupedBarSeries : public QObject |
|
33 | class tst_QGroupedBarSeries : public QObject | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 |
|
36 | |||
37 | public slots: |
|
37 | public slots: | |
38 | void initTestCase(); |
|
38 | void initTestCase(); | |
39 | void cleanupTestCase(); |
|
39 | void cleanupTestCase(); | |
40 | void init(); |
|
40 | void init(); | |
41 | void cleanup(); |
|
41 | void cleanup(); | |
42 |
|
42 | |||
43 | private slots: |
|
43 | private slots: | |
44 | void qgroupedbarseries_data(); |
|
44 | void qgroupedbarseries_data(); | |
45 | void qgroupedbarseries(); |
|
45 | void qgroupedbarseries(); | |
46 | void type_data(); |
|
46 | void type_data(); | |
47 | void type(); |
|
47 | void type(); | |
48 | void mouseclicked_data(); |
|
48 | void mouseclicked_data(); | |
49 | void mouseclicked(); |
|
49 | void mouseclicked(); | |
50 | void mousehovered_data(); |
|
50 | void mousehovered_data(); | |
51 | void mousehovered(); |
|
51 | void mousehovered(); | |
52 |
|
52 | |||
53 | private: |
|
53 | private: | |
54 | QGroupedBarSeries* m_barseries; |
|
54 | QGroupedBarSeries* m_barseries; | |
55 | }; |
|
55 | }; | |
56 |
|
56 | |||
57 | void tst_QGroupedBarSeries::initTestCase() |
|
57 | void tst_QGroupedBarSeries::initTestCase() | |
58 | { |
|
58 | { | |
59 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
59 | qRegisterMetaType<QBarSet*>("QBarSet*"); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | void tst_QGroupedBarSeries::cleanupTestCase() |
|
62 | void tst_QGroupedBarSeries::cleanupTestCase() | |
63 | { |
|
63 | { | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | void tst_QGroupedBarSeries::init() |
|
66 | void tst_QGroupedBarSeries::init() | |
67 | { |
|
67 | { | |
68 | m_barseries = new QGroupedBarSeries(); |
|
68 | m_barseries = new QGroupedBarSeries(); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void tst_QGroupedBarSeries::cleanup() |
|
71 | void tst_QGroupedBarSeries::cleanup() | |
72 | { |
|
72 | { | |
73 | delete m_barseries; |
|
73 | delete m_barseries; | |
74 | m_barseries = 0; |
|
74 | m_barseries = 0; | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | void tst_QGroupedBarSeries::qgroupedbarseries_data() |
|
77 | void tst_QGroupedBarSeries::qgroupedbarseries_data() | |
78 | { |
|
78 | { | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | void tst_QGroupedBarSeries::qgroupedbarseries() |
|
81 | void tst_QGroupedBarSeries::qgroupedbarseries() | |
82 | { |
|
82 | { | |
83 | QGroupedBarSeries *barseries = new QGroupedBarSeries(); |
|
83 | QGroupedBarSeries *barseries = new QGroupedBarSeries(); | |
84 | QVERIFY(barseries != 0); |
|
84 | QVERIFY(barseries != 0); | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | void tst_QGroupedBarSeries::type_data() |
|
87 | void tst_QGroupedBarSeries::type_data() | |
88 | { |
|
88 | { | |
89 |
|
89 | |||
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | void tst_QGroupedBarSeries::type() |
|
92 | void tst_QGroupedBarSeries::type() | |
93 | { |
|
93 | { | |
94 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeGroupedBar); |
|
94 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeGroupedBar); | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | void tst_QGroupedBarSeries::mouseclicked_data() |
|
97 | void tst_QGroupedBarSeries::mouseclicked_data() | |
98 | { |
|
98 | { | |
99 |
|
99 | |||
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | void tst_QGroupedBarSeries::mouseclicked() |
|
102 | void tst_QGroupedBarSeries::mouseclicked() | |
103 | { |
|
103 | { | |
104 | QGroupedBarSeries* series = new QGroupedBarSeries(); |
|
104 | QGroupedBarSeries* series = new QGroupedBarSeries(); | |
105 | QBarCategories categories; |
|
105 | QBarCategories categories; | |
106 | categories << "test1" << "test2" << "test3"; |
|
106 | categories << "test1" << "test2" << "test3"; | |
107 | series->setCategories(categories); |
|
107 | series->setCategories(categories); | |
108 |
|
108 | |||
109 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
109 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
110 | *set1 << 10 << 10 << 10; |
|
110 | *set1 << 10 << 10 << 10; | |
111 | series->append(set1); |
|
111 | series->append(set1); | |
112 |
|
112 | |||
113 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
113 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
114 | *set2 << 10 << 10 << 10; |
|
114 | *set2 << 10 << 10 << 10; | |
115 | series->append(set2); |
|
115 | series->append(set2); | |
116 |
|
116 | |||
117 | QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); |
|
|||
118 | QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); |
|
|||
119 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); |
|
117 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); | |
120 |
|
118 | |||
121 | QChartView view(new QChart()); |
|
119 | QChartView view(new QChart()); | |
122 | view.resize(400,300); |
|
120 | view.resize(400,300); | |
123 | view.chart()->addSeries(series); |
|
121 | view.chart()->addSeries(series); | |
124 | view.show(); |
|
122 | view.show(); | |
125 | QTest::qWaitForWindowShown(&view); |
|
123 | QTest::qWaitForWindowShown(&view); | |
126 |
|
124 | |||
127 | //==================================================================================== |
|
125 | //==================================================================================== | |
128 | // barset 1, category test1 |
|
126 | // barset 1, category test1 | |
129 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(9 |
|
127 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143)); | |
130 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
128 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
131 |
|
129 | |||
132 | QCOMPARE(setSpy1.count(), 1); |
|
|||
133 | QCOMPARE(setSpy2.count(), 0); |
|
|||
134 | QCOMPARE(seriesSpy.count(), 1); |
|
130 | QCOMPARE(seriesSpy.count(), 1); | |
135 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
136 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
137 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
138 |
|
131 | |||
139 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
132 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
140 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
133 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
134 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
135 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
141 |
|
136 | |||
142 | //==================================================================================== |
|
137 | //==================================================================================== | |
143 | // barset 1, category test2 |
|
138 | // barset 1, category test2 | |
144 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(18 |
|
139 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143)); | |
145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
140 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
146 |
|
141 | |||
147 | QCOMPARE(setSpy1.count(), 1); |
|
|||
148 | QCOMPARE(setSpy2.count(), 0); |
|
|||
149 | QCOMPARE(seriesSpy.count(), 1); |
|
142 | QCOMPARE(seriesSpy.count(), 1); | |
150 | setSpyArg = setSpy1.takeFirst(); |
|
|||
151 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
152 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
153 |
|
143 | |||
154 | seriesSpyArg = seriesSpy.takeFirst(); |
|
144 | seriesSpyArg = seriesSpy.takeFirst(); | |
155 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
145 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
146 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
147 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
156 |
|
148 | |||
157 | //==================================================================================== |
|
149 | //==================================================================================== | |
158 | // barset 1, category test3 |
|
150 | // barset 1, category test3 | |
159 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,1 |
|
151 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143)); | |
160 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
152 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
161 |
|
153 | |||
162 | QCOMPARE(setSpy1.count(), 1); |
|
|||
163 | QCOMPARE(setSpy2.count(), 0); |
|
|||
164 | QCOMPARE(seriesSpy.count(), 1); |
|
154 | QCOMPARE(seriesSpy.count(), 1); | |
165 | setSpyArg = setSpy1.takeFirst(); |
|
|||
166 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
167 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
168 |
|
155 | |||
169 | seriesSpyArg = seriesSpy.takeFirst(); |
|
156 | seriesSpyArg = seriesSpy.takeFirst(); | |
170 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
157 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
158 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
159 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | |||
171 |
|
160 | |||
172 | //==================================================================================== |
|
161 | //==================================================================================== | |
173 | // barset 2, category test1 |
|
162 | // barset 2, category test1 | |
174 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1 |
|
163 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143)); | |
175 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
164 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
176 |
|
165 | |||
177 | QCOMPARE(setSpy1.count(), 0); |
|
|||
178 | QCOMPARE(setSpy2.count(), 1); |
|
|||
179 | QCOMPARE(seriesSpy.count(), 1); |
|
166 | QCOMPARE(seriesSpy.count(), 1); | |
180 | setSpyArg = setSpy2.takeFirst(); |
|
|||
181 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
182 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
183 |
|
167 | |||
184 | seriesSpyArg = seriesSpy.takeFirst(); |
|
168 | seriesSpyArg = seriesSpy.takeFirst(); | |
185 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
169 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
170 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
171 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
186 |
|
172 | |||
187 | //==================================================================================== |
|
173 | //==================================================================================== | |
188 | // barset 2, category test2 |
|
174 | // barset 2, category test2 | |
189 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(2 |
|
175 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143)); | |
190 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
176 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
191 |
|
177 | |||
192 | QCOMPARE(setSpy1.count(), 0); |
|
|||
193 | QCOMPARE(setSpy2.count(), 1); |
|
|||
194 | QCOMPARE(seriesSpy.count(), 1); |
|
178 | QCOMPARE(seriesSpy.count(), 1); | |
195 | setSpyArg = setSpy2.takeFirst(); |
|
|||
196 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
197 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
198 |
|
179 | |||
199 | seriesSpyArg = seriesSpy.takeFirst(); |
|
180 | seriesSpyArg = seriesSpy.takeFirst(); | |
200 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
181 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
182 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | |||
|
183 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
201 |
|
184 | |||
202 | //==================================================================================== |
|
185 | //==================================================================================== | |
203 | // barset 2, category test3 |
|
186 | // barset 2, category test3 | |
204 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(3 |
|
187 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143)); | |
205 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
188 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
206 |
|
189 | |||
207 | QCOMPARE(setSpy1.count(), 0); |
|
|||
208 | QCOMPARE(setSpy2.count(), 1); |
|
|||
209 | QCOMPARE(seriesSpy.count(), 1); |
|
190 | QCOMPARE(seriesSpy.count(), 1); | |
210 | setSpyArg = setSpy2.takeFirst(); |
|
|||
211 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
212 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
213 |
|
191 | |||
214 | seriesSpyArg = seriesSpy.takeFirst(); |
|
192 | seriesSpyArg = seriesSpy.takeFirst(); | |
215 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
193 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
216 |
|
194 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); | ||
217 | //==================================================================================== |
|
195 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | |
218 | // no event cases |
|
|||
219 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets |
|
|||
220 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets |
|
|||
221 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(900,180)); // barset 1, category test1 |
|
|||
222 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(185,180)); // barset 1, category test2 |
|
|||
223 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(280,180)); // barset 1, category test3 |
|
|||
224 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(135,180)); // barset 2, category test1 |
|
|||
225 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(230,180)); // barset 2, category test2 |
|
|||
226 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(320,180)); // barset 2, category test3 |
|
|||
227 |
|
||||
228 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
|||
229 | QCOMPARE(setSpy1.count(), 0); |
|
|||
230 | QCOMPARE(setSpy2.count(), 0); |
|
|||
231 | QCOMPARE(seriesSpy.count(), 0); |
|
|||
232 | } |
|
196 | } | |
233 |
|
197 | |||
234 | void tst_QGroupedBarSeries::mousehovered_data() |
|
198 | void tst_QGroupedBarSeries::mousehovered_data() | |
235 | { |
|
199 | { | |
236 |
|
200 | |||
237 | } |
|
201 | } | |
238 |
|
202 | |||
239 | void tst_QGroupedBarSeries::mousehovered() |
|
203 | void tst_QGroupedBarSeries::mousehovered() | |
240 | { |
|
204 | { | |
241 | QGroupedBarSeries* series = new QGroupedBarSeries(); |
|
205 | QGroupedBarSeries* series = new QGroupedBarSeries(); | |
242 | QBarCategories categories; |
|
206 | QBarCategories categories; | |
243 | categories << "test1" << "test2" << "test3"; |
|
207 | categories << "test1" << "test2" << "test3"; | |
244 | series->setCategories(categories); |
|
208 | series->setCategories(categories); | |
245 |
|
209 | |||
246 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
210 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
247 | *set1 << 10 << 10 << 10; |
|
211 | *set1 << 10 << 10 << 10; | |
248 | series->append(set1); |
|
212 | series->append(set1); | |
249 |
|
213 | |||
250 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
214 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
251 | *set2 << 10 << 10 << 10; |
|
215 | *set2 << 10 << 10 << 10; | |
252 | series->append(set2); |
|
216 | series->append(set2); | |
253 |
|
217 | |||
254 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); |
|
|||
255 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); |
|
|||
256 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); |
|
218 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); | |
257 |
|
219 | |||
258 | QChartView view(new QChart()); |
|
220 | QChartView view(new QChart()); | |
259 | view.resize(400,300); |
|
221 | view.resize(400,300); | |
260 | view.chart()->addSeries(series); |
|
222 | view.chart()->addSeries(series); | |
261 | view.show(); |
|
223 | view.show(); | |
262 | QTest::qWaitForWindowShown(&view); |
|
224 | QTest::qWaitForWindowShown(&view); | |
263 | // QTest::qWait(1000*20); |
|
|||
264 |
|
225 | |||
265 | //this is hack since view does not get events otherwise |
|
226 | //this is hack since view does not get events otherwise | |
266 | view.setMouseTracking(true); |
|
227 | view.setMouseTracking(true); | |
267 |
|
228 | |||
268 | //======================================================================= |
|
229 | //======================================================================= | |
269 | // move mouse to left border |
|
230 | // move mouse to left border | |
270 | qDebug() << "move mouse to left border"; |
|
231 | qDebug() << "move mouse to left border"; | |
271 |
QTest::mouseMove(view.viewport(), QPoint(0, 1 |
|
232 | QTest::mouseMove(view.viewport(), QPoint(0, 143)); | |
272 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
233 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
273 |
|
234 | |||
274 | QVERIFY(setSpy1.count() == 0); |
|
|||
275 | QVERIFY(setSpy2.count() == 0); |
|
|||
276 | QVERIFY(seriesSpy.count() == 0); |
|
235 | QVERIFY(seriesSpy.count() == 0); | |
277 |
|
236 | |||
278 | //======================================================================= |
|
237 | //======================================================================= | |
279 | // move mouse on top of set1 |
|
238 | // move mouse on top of set1 | |
280 | qDebug() << "move mouse on top of set1"; |
|
239 | qDebug() << "move mouse on top of set1"; | |
281 |
QTest::mouseMove(view.viewport(), QPoint(9 |
|
240 | QTest::mouseMove(view.viewport(), QPoint(95,143)); | |
282 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
241 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); | |
283 |
|
242 | |||
284 | QVERIFY(setSpy1.count() == 1); |
|
|||
285 | QVERIFY(setSpy2.count() == 0); |
|
|||
286 | QVERIFY(seriesSpy.count() == 1); |
|
243 | QVERIFY(seriesSpy.count() == 1); | |
287 |
|
244 | |||
288 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
289 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
290 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
291 |
|
||||
292 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
245 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
293 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
246 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
247 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |||
|
248 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |||
294 |
|
249 | |||
295 | //======================================================================= |
|
250 | //======================================================================= | |
296 | // move mouse from top of set1 to top of set2 |
|
251 | // move mouse from top of set1 to top of set2 | |
297 | qDebug() << "move mouse from top of set1 to top of set2"; |
|
252 | qDebug() << "move mouse from top of set1 to top of set2"; | |
298 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
253 | QTest::mouseMove(view.viewport(), QPoint(118,143)); | |
299 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
254 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); | |
300 |
|
255 | |||
301 | QVERIFY(setSpy1.count() == 1); |
|
|||
302 | QVERIFY(setSpy2.count() == 1); |
|
|||
303 | QVERIFY(seriesSpy.count() == 2); |
|
256 | QVERIFY(seriesSpy.count() == 2); | |
304 |
|
257 | |||
305 | // should leave set1 |
|
258 | // should leave set1 | |
306 | setSpyArg = setSpy1.takeFirst(); |
|
|||
307 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
308 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
309 |
|
||||
310 | // should enter set2 |
|
|||
311 | setSpyArg = setSpy2.takeFirst(); |
|
|||
312 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
313 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
314 |
|
||||
315 | // should leave set1 |
|
|||
316 | seriesSpyArg = seriesSpy.takeFirst(); |
|
259 | seriesSpyArg = seriesSpy.takeFirst(); | |
317 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
260 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
318 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
261 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
319 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
262 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
320 |
|
263 | |||
321 | // should enter set2 |
|
264 | // should enter set2 | |
322 | seriesSpyArg = seriesSpy.takeFirst(); |
|
265 | seriesSpyArg = seriesSpy.takeFirst(); | |
323 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
266 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
324 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
267 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
325 | QVERIFY(seriesSpyArg.at(1).toBool() == true); |
|
268 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |
326 |
|
269 | |||
327 | //======================================================================= |
|
270 | //======================================================================= | |
328 | // move mouse from top of set2 to background |
|
271 | // move mouse from top of set2 to background | |
329 | qDebug() << "move mouse from top of set2 to background"; |
|
272 | qDebug() << "move mouse from top of set2 to background"; | |
330 |
|
273 | |||
331 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
274 | QTest::mouseMove(view.viewport(), QPoint(118,0)); | |
332 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
275 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); | |
333 |
|
276 | |||
334 | QVERIFY(setSpy1.count() == 0); |
|
|||
335 | QVERIFY(setSpy2.count() == 1); |
|
|||
336 | QVERIFY(seriesSpy.count() == 1); |
|
277 | QVERIFY(seriesSpy.count() == 1); | |
337 |
|
278 | |||
338 |
// should leave set2 |
|
279 | // should leave set2 | |
339 | setSpyArg = setSpy2.takeFirst(); |
|
|||
340 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
341 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
342 |
|
||||
343 | // should leave set2 (event via series) |
|
|||
344 | seriesSpyArg = seriesSpy.takeFirst(); |
|
280 | seriesSpyArg = seriesSpy.takeFirst(); | |
345 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
281 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
346 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
282 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
347 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
283 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
348 | } |
|
284 | } | |
349 |
|
285 | |||
350 | QTEST_MAIN(tst_QGroupedBarSeries) |
|
286 | QTEST_MAIN(tst_QGroupedBarSeries) | |
351 |
|
287 | |||
352 | #include "tst_qgroupedbarseries.moc" |
|
288 | #include "tst_qgroupedbarseries.moc" | |
353 |
|
289 |
@@ -1,344 +1,272 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qpercentbarseries.h> |
|
22 | #include <qpercentbarseries.h> | |
23 | #include <qbarset.h> |
|
23 | #include <qbarset.h> | |
24 | #include <qchartview.h> |
|
24 | #include <qchartview.h> | |
25 | #include <qchart.h> |
|
25 | #include <qchart.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | Q_DECLARE_METATYPE(QBarSet*) |
|
29 | Q_DECLARE_METATYPE(QBarSet*) | |
30 |
|
30 | |||
31 | class tst_QPercentBarSeries : public QObject |
|
31 | class tst_QPercentBarSeries : public QObject | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 |
|
34 | |||
35 | public slots: |
|
35 | public slots: | |
36 | void initTestCase(); |
|
36 | void initTestCase(); | |
37 | void cleanupTestCase(); |
|
37 | void cleanupTestCase(); | |
38 | void init(); |
|
38 | void init(); | |
39 | void cleanup(); |
|
39 | void cleanup(); | |
40 |
|
40 | |||
41 | private slots: |
|
41 | private slots: | |
42 | void qpercentbarseries_data(); |
|
42 | void qpercentbarseries_data(); | |
43 | void qpercentbarseries(); |
|
43 | void qpercentbarseries(); | |
44 | void type_data(); |
|
44 | void type_data(); | |
45 | void type(); |
|
45 | void type(); | |
46 | void mouseclicked_data(); |
|
46 | void mouseclicked_data(); | |
47 | void mouseclicked(); |
|
47 | void mouseclicked(); | |
48 | void mousehovered_data(); |
|
48 | void mousehovered_data(); | |
49 | void mousehovered(); |
|
49 | void mousehovered(); | |
50 |
|
50 | |||
51 | private: |
|
51 | private: | |
52 | QPercentBarSeries* m_barseries; |
|
52 | QPercentBarSeries* m_barseries; | |
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | void tst_QPercentBarSeries::initTestCase() |
|
55 | void tst_QPercentBarSeries::initTestCase() | |
56 | { |
|
56 | { | |
57 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
57 | qRegisterMetaType<QBarSet*>("QBarSet*"); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void tst_QPercentBarSeries::cleanupTestCase() |
|
60 | void tst_QPercentBarSeries::cleanupTestCase() | |
61 | { |
|
61 | { | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void tst_QPercentBarSeries::init() |
|
64 | void tst_QPercentBarSeries::init() | |
65 | { |
|
65 | { | |
66 | m_barseries = new QPercentBarSeries(); |
|
66 | m_barseries = new QPercentBarSeries(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void tst_QPercentBarSeries::cleanup() |
|
69 | void tst_QPercentBarSeries::cleanup() | |
70 | { |
|
70 | { | |
71 | delete m_barseries; |
|
71 | delete m_barseries; | |
72 | m_barseries = 0; |
|
72 | m_barseries = 0; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void tst_QPercentBarSeries::qpercentbarseries_data() |
|
75 | void tst_QPercentBarSeries::qpercentbarseries_data() | |
76 | { |
|
76 | { | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void tst_QPercentBarSeries::qpercentbarseries() |
|
79 | void tst_QPercentBarSeries::qpercentbarseries() | |
80 | { |
|
80 | { | |
81 | QPercentBarSeries *barseries = new QPercentBarSeries(); |
|
81 | QPercentBarSeries *barseries = new QPercentBarSeries(); | |
82 | QVERIFY(barseries != 0); |
|
82 | QVERIFY(barseries != 0); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | void tst_QPercentBarSeries::type_data() |
|
85 | void tst_QPercentBarSeries::type_data() | |
86 | { |
|
86 | { | |
87 |
|
87 | |||
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | void tst_QPercentBarSeries::type() |
|
90 | void tst_QPercentBarSeries::type() | |
91 | { |
|
91 | { | |
92 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar); |
|
92 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | void tst_QPercentBarSeries::mouseclicked_data() |
|
95 | void tst_QPercentBarSeries::mouseclicked_data() | |
96 | { |
|
96 | { | |
97 |
|
97 | |||
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void tst_QPercentBarSeries::mouseclicked() |
|
100 | void tst_QPercentBarSeries::mouseclicked() | |
101 | { |
|
101 | { | |
102 | QPercentBarSeries* series = new QPercentBarSeries(); |
|
102 | QPercentBarSeries* series = new QPercentBarSeries(); | |
103 | QBarCategories categories; |
|
103 | QBarCategories categories; | |
104 | categories << "test1" << "test2" << "test3"; |
|
104 | categories << "test1" << "test2" << "test3"; | |
105 | series->setCategories(categories); |
|
105 | series->setCategories(categories); | |
106 |
|
106 | |||
107 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
107 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
108 | *set1 << 10 << 10 << 10; |
|
108 | *set1 << 10 << 10 << 10; | |
109 | series->append(set1); |
|
109 | series->append(set1); | |
110 |
|
110 | |||
111 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
111 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
112 | *set2 << 10 << 10 << 10; |
|
112 | *set2 << 10 << 10 << 10; | |
113 | series->append(set2); |
|
113 | series->append(set2); | |
114 |
|
114 | |||
115 | QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); |
|
|||
116 | QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); |
|
|||
117 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); |
|
115 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); | |
118 |
|
116 | |||
119 | QChartView view(new QChart()); |
|
117 | QChartView view(new QChart()); | |
120 | view.resize(400,300); |
|
118 | view.resize(400,300); | |
121 | view.chart()->addSeries(series); |
|
119 | view.chart()->addSeries(series); | |
122 | view.show(); |
|
120 | view.show(); | |
123 | QTest::qWaitForWindowShown(&view); |
|
121 | QTest::qWaitForWindowShown(&view); | |
124 |
|
122 | |||
125 | //==================================================================================== |
|
123 | //==================================================================================== | |
126 | // barset 1, category test1 |
|
124 | // barset 1, category test1 | |
127 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1 |
|
125 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); | |
128 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
126 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
129 |
|
127 | |||
130 | QCOMPARE(setSpy1.count(), 1); |
|
|||
131 | QCOMPARE(setSpy2.count(), 0); |
|
|||
132 | QCOMPARE(seriesSpy.count(), 1); |
|
128 | QCOMPARE(seriesSpy.count(), 1); | |
133 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
134 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
135 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
136 |
|
129 | |||
137 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
130 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
138 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
131 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
132 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
139 |
|
133 | |||
140 | //==================================================================================== |
|
134 | //==================================================================================== | |
141 | // barset 1, category test2 |
|
135 | // barset 1, category test2 | |
142 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
136 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); | |
143 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
137 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
144 |
|
138 | |||
145 | QCOMPARE(setSpy1.count(), 1); |
|
|||
146 | QCOMPARE(setSpy2.count(), 0); |
|
|||
147 | QCOMPARE(seriesSpy.count(), 1); |
|
139 | QCOMPARE(seriesSpy.count(), 1); | |
148 | setSpyArg = setSpy1.takeFirst(); |
|
|||
149 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
150 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
151 |
|
140 | |||
152 | seriesSpyArg = seriesSpy.takeFirst(); |
|
141 | seriesSpyArg = seriesSpy.takeFirst(); | |
153 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
142 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
143 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
154 |
|
144 | |||
155 | //==================================================================================== |
|
145 | //==================================================================================== | |
156 | // barset 1, category test3 |
|
146 | // barset 1, category test3 | |
157 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
147 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); | |
158 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
148 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
159 |
|
149 | |||
160 | QCOMPARE(setSpy1.count(), 1); |
|
|||
161 | QCOMPARE(setSpy2.count(), 0); |
|
|||
162 | QCOMPARE(seriesSpy.count(), 1); |
|
150 | QCOMPARE(seriesSpy.count(), 1); | |
163 | setSpyArg = setSpy1.takeFirst(); |
|
|||
164 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
165 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
166 |
|
151 | |||
167 | seriesSpyArg = seriesSpy.takeFirst(); |
|
152 | seriesSpyArg = seriesSpy.takeFirst(); | |
168 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
153 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
154 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | |||
169 |
|
155 | |||
170 | //==================================================================================== |
|
156 | //==================================================================================== | |
171 | // barset 2, category test1 |
|
157 | // barset 2, category test1 | |
172 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1 |
|
158 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); | |
173 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
159 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
174 |
|
160 | |||
175 | QCOMPARE(setSpy1.count(), 0); |
|
|||
176 | QCOMPARE(setSpy2.count(), 1); |
|
|||
177 | QCOMPARE(seriesSpy.count(), 1); |
|
161 | QCOMPARE(seriesSpy.count(), 1); | |
178 | setSpyArg = setSpy2.takeFirst(); |
|
|||
179 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
180 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
181 |
|
162 | |||
182 | seriesSpyArg = seriesSpy.takeFirst(); |
|
163 | seriesSpyArg = seriesSpy.takeFirst(); | |
183 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
164 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
165 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
184 |
|
166 | |||
185 | //==================================================================================== |
|
167 | //==================================================================================== | |
186 | // barset 2, category test2 |
|
168 | // barset 2, category test2 | |
187 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
169 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); | |
188 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
170 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
189 |
|
171 | |||
190 | QCOMPARE(setSpy1.count(), 0); |
|
|||
191 | QCOMPARE(setSpy2.count(), 1); |
|
|||
192 | QCOMPARE(seriesSpy.count(), 1); |
|
172 | QCOMPARE(seriesSpy.count(), 1); | |
193 | setSpyArg = setSpy2.takeFirst(); |
|
|||
194 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
195 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
196 |
|
173 | |||
197 | seriesSpyArg = seriesSpy.takeFirst(); |
|
174 | seriesSpyArg = seriesSpy.takeFirst(); | |
198 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
175 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
176 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
199 |
|
177 | |||
200 | //==================================================================================== |
|
178 | //==================================================================================== | |
201 | // barset 2, category test3 |
|
179 | // barset 2, category test3 | |
202 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
180 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); | |
203 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
181 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
204 |
|
182 | |||
205 | QCOMPARE(setSpy1.count(), 0); |
|
|||
206 | QCOMPARE(setSpy2.count(), 1); |
|
|||
207 | QCOMPARE(seriesSpy.count(), 1); |
|
183 | QCOMPARE(seriesSpy.count(), 1); | |
208 | setSpyArg = setSpy2.takeFirst(); |
|
|||
209 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
210 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
211 |
|
184 | |||
212 | seriesSpyArg = seriesSpy.takeFirst(); |
|
185 | seriesSpyArg = seriesSpy.takeFirst(); | |
213 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
186 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
214 |
|
187 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | ||
215 | //==================================================================================== |
|
|||
216 | // no event cases |
|
|||
217 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets |
|
|||
218 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets |
|
|||
219 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1 |
|
|||
220 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2 |
|
|||
221 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3 |
|
|||
222 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1 |
|
|||
223 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2 |
|
|||
224 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3 |
|
|||
225 |
|
||||
226 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
|||
227 | QCOMPARE(setSpy1.count(), 0); |
|
|||
228 | QCOMPARE(setSpy2.count(), 0); |
|
|||
229 | QCOMPARE(seriesSpy.count(), 0); |
|
|||
230 | } |
|
188 | } | |
231 |
|
189 | |||
232 | void tst_QPercentBarSeries::mousehovered_data() |
|
190 | void tst_QPercentBarSeries::mousehovered_data() | |
233 | { |
|
191 | { | |
234 |
|
192 | |||
235 | } |
|
193 | } | |
236 |
|
194 | |||
237 | void tst_QPercentBarSeries::mousehovered() |
|
195 | void tst_QPercentBarSeries::mousehovered() | |
238 | { |
|
196 | { | |
239 | QPercentBarSeries* series = new QPercentBarSeries(); |
|
197 | QPercentBarSeries* series = new QPercentBarSeries(); | |
240 | QBarCategories categories; |
|
198 | QBarCategories categories; | |
241 | categories << "test1" << "test2" << "test3"; |
|
199 | categories << "test1" << "test2" << "test3"; | |
242 | series->setCategories(categories); |
|
200 | series->setCategories(categories); | |
243 |
|
201 | |||
244 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
202 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
245 | *set1 << 10 << 10 << 10; |
|
203 | *set1 << 10 << 10 << 10; | |
246 | series->append(set1); |
|
204 | series->append(set1); | |
247 |
|
205 | |||
248 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
206 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
249 | *set2 << 10 << 10 << 10; |
|
207 | *set2 << 10 << 10 << 10; | |
250 | series->append(set2); |
|
208 | series->append(set2); | |
251 |
|
209 | |||
252 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); |
|
|||
253 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); |
|
|||
254 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); |
|
210 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); | |
255 |
|
211 | |||
256 | QChartView view(new QChart()); |
|
212 | QChartView view(new QChart()); | |
257 | view.resize(400,300); |
|
213 | view.resize(400,300); | |
258 | view.chart()->addSeries(series); |
|
214 | view.chart()->addSeries(series); | |
259 | view.show(); |
|
215 | view.show(); | |
260 | QTest::qWaitForWindowShown(&view); |
|
216 | QTest::qWaitForWindowShown(&view); | |
261 |
|
217 | |||
|
218 | //this is hack since view does not get events otherwise | |||
|
219 | view.setMouseTracking(true); | |||
|
220 | ||||
262 | //======================================================================= |
|
221 | //======================================================================= | |
263 | // move mouse to left border |
|
222 | // move mouse to left border | |
264 |
QTest::mouseMove(view.viewport(), QPoint(0, |
|
223 | QTest::mouseMove(view.viewport(), QPoint(0, 190)); | |
265 |
|
||||
266 |
|
224 | |||
267 | QVERIFY(setSpy1.count() == 0); |
|
|||
268 | QVERIFY(setSpy2.count() == 0); |
|
|||
269 | QVERIFY(seriesSpy.count() == 0); |
|
225 | QVERIFY(seriesSpy.count() == 0); | |
270 |
|
226 | |||
271 | //======================================================================= |
|
227 | //======================================================================= | |
272 | // move mouse on top of set1 |
|
228 | // move mouse on top of set1 | |
273 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
229 | QTest::mouseMove(view.viewport(), QPoint(106,190)); | |
274 |
|
230 | |||
275 | QVERIFY(setSpy1.count() == 1); |
|
|||
276 | QVERIFY(setSpy2.count() == 0); |
|
|||
277 | QVERIFY(seriesSpy.count() == 1); |
|
231 | QVERIFY(seriesSpy.count() == 1); | |
278 |
|
232 | |||
279 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
280 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
281 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
282 |
|
||||
283 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
233 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
284 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
234 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
235 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |||
|
236 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |||
285 |
|
237 | |||
286 | //======================================================================= |
|
238 | //======================================================================= | |
287 | // move mouse from top of set1 to top of set2 |
|
239 | // move mouse from top of set1 to top of set2 | |
288 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
240 | QTest::mouseMove(view.viewport(), QPoint(106,95)); | |
289 |
|
241 | |||
290 | QVERIFY(setSpy1.count() == 1); |
|
|||
291 | QVERIFY(setSpy2.count() == 1); |
|
|||
292 | QVERIFY(seriesSpy.count() == 2); |
|
242 | QVERIFY(seriesSpy.count() == 2); | |
293 |
|
243 | |||
294 | // should leave set1 |
|
244 | // should leave set1 | |
295 | setSpyArg = setSpy1.takeFirst(); |
|
|||
296 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
297 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
298 |
|
||||
299 | // should enter set2 |
|
|||
300 | setSpyArg = setSpy2.takeFirst(); |
|
|||
301 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
302 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
303 |
|
||||
304 | // should leave set1 |
|
|||
305 | seriesSpyArg = seriesSpy.takeFirst(); |
|
245 | seriesSpyArg = seriesSpy.takeFirst(); | |
306 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
246 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
307 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
247 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
308 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
248 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
309 |
|
249 | |||
310 | // should enter set2 |
|
250 | // should enter set2 | |
311 | seriesSpyArg = seriesSpy.takeFirst(); |
|
251 | seriesSpyArg = seriesSpy.takeFirst(); | |
312 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
252 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
313 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
253 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
314 | QVERIFY(seriesSpyArg.at(1).toBool() == true); |
|
254 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |
315 |
|
255 | |||
316 | //======================================================================= |
|
256 | //======================================================================= | |
317 | // move mouse from top of set2 to background |
|
257 | // move mouse from top of set2 to background | |
318 |
QTest::mouseMove(view.viewport(), QPoint(0 |
|
258 | QTest::mouseMove(view.viewport(), QPoint(106,0)); | |
319 |
|
259 | |||
320 | QVERIFY(setSpy1.count() == 0); |
|
|||
321 | QVERIFY(setSpy2.count() == 1); |
|
|||
322 | QVERIFY(seriesSpy.count() == 1); |
|
260 | QVERIFY(seriesSpy.count() == 1); | |
323 |
|
261 | |||
324 |
// should leave set2 |
|
262 | // should leave set2 | |
325 | setSpyArg = setSpy2.takeFirst(); |
|
|||
326 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
327 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
328 |
|
||||
329 | // should leave set2 (event via series) |
|
|||
330 | seriesSpyArg = seriesSpy.takeFirst(); |
|
263 | seriesSpyArg = seriesSpy.takeFirst(); | |
331 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
264 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
332 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
265 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
333 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
266 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
334 | } |
|
267 | } | |
335 |
|
268 | |||
336 | /* |
|
|||
337 | bool setModel(QAbstractItemModel *model); |
|
|||
338 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
|||
339 | void setModelMappingRange(int first, int count = -1); |
|
|||
340 | */ |
|
|||
341 | QTEST_MAIN(tst_QPercentBarSeries) |
|
269 | QTEST_MAIN(tst_QPercentBarSeries) | |
342 |
|
270 | |||
343 | #include "tst_qpercentbarseries.moc" |
|
271 | #include "tst_qpercentbarseries.moc" | |
344 |
|
272 |
@@ -1,344 +1,272 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qstackedbarseries.h> |
|
22 | #include <qstackedbarseries.h> | |
23 | #include <qbarset.h> |
|
23 | #include <qbarset.h> | |
24 | #include <qchartview.h> |
|
24 | #include <qchartview.h> | |
25 | #include <qchart.h> |
|
25 | #include <qchart.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | Q_DECLARE_METATYPE(QBarSet*) |
|
29 | Q_DECLARE_METATYPE(QBarSet*) | |
30 |
|
30 | |||
31 | class tst_QStackedBarSeries : public QObject |
|
31 | class tst_QStackedBarSeries : public QObject | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 |
|
34 | |||
35 | public slots: |
|
35 | public slots: | |
36 | void initTestCase(); |
|
36 | void initTestCase(); | |
37 | void cleanupTestCase(); |
|
37 | void cleanupTestCase(); | |
38 | void init(); |
|
38 | void init(); | |
39 | void cleanup(); |
|
39 | void cleanup(); | |
40 |
|
40 | |||
41 | private slots: |
|
41 | private slots: | |
42 | void qstackedbarseries_data(); |
|
42 | void qstackedbarseries_data(); | |
43 | void qstackedbarseries(); |
|
43 | void qstackedbarseries(); | |
44 | void type_data(); |
|
44 | void type_data(); | |
45 | void type(); |
|
45 | void type(); | |
46 | void mouseclicked_data(); |
|
46 | void mouseclicked_data(); | |
47 | void mouseclicked(); |
|
47 | void mouseclicked(); | |
48 | void mousehovered_data(); |
|
48 | void mousehovered_data(); | |
49 | void mousehovered(); |
|
49 | void mousehovered(); | |
50 |
|
50 | |||
51 | private: |
|
51 | private: | |
52 | QStackedBarSeries* m_barseries; |
|
52 | QStackedBarSeries* m_barseries; | |
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | void tst_QStackedBarSeries::initTestCase() |
|
55 | void tst_QStackedBarSeries::initTestCase() | |
56 | { |
|
56 | { | |
57 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
57 | qRegisterMetaType<QBarSet*>("QBarSet*"); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void tst_QStackedBarSeries::cleanupTestCase() |
|
60 | void tst_QStackedBarSeries::cleanupTestCase() | |
61 | { |
|
61 | { | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void tst_QStackedBarSeries::init() |
|
64 | void tst_QStackedBarSeries::init() | |
65 | { |
|
65 | { | |
66 | m_barseries = new QStackedBarSeries(); |
|
66 | m_barseries = new QStackedBarSeries(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void tst_QStackedBarSeries::cleanup() |
|
69 | void tst_QStackedBarSeries::cleanup() | |
70 | { |
|
70 | { | |
71 | delete m_barseries; |
|
71 | delete m_barseries; | |
72 | m_barseries = 0; |
|
72 | m_barseries = 0; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void tst_QStackedBarSeries::qstackedbarseries_data() |
|
75 | void tst_QStackedBarSeries::qstackedbarseries_data() | |
76 | { |
|
76 | { | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void tst_QStackedBarSeries::qstackedbarseries() |
|
79 | void tst_QStackedBarSeries::qstackedbarseries() | |
80 | { |
|
80 | { | |
81 | QStackedBarSeries *barseries = new QStackedBarSeries(); |
|
81 | QStackedBarSeries *barseries = new QStackedBarSeries(); | |
82 | QVERIFY(barseries != 0); |
|
82 | QVERIFY(barseries != 0); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | void tst_QStackedBarSeries::type_data() |
|
85 | void tst_QStackedBarSeries::type_data() | |
86 | { |
|
86 | { | |
87 |
|
87 | |||
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | void tst_QStackedBarSeries::type() |
|
90 | void tst_QStackedBarSeries::type() | |
91 | { |
|
91 | { | |
92 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar); |
|
92 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | void tst_QStackedBarSeries::mouseclicked_data() |
|
95 | void tst_QStackedBarSeries::mouseclicked_data() | |
96 | { |
|
96 | { | |
97 |
|
97 | |||
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void tst_QStackedBarSeries::mouseclicked() |
|
100 | void tst_QStackedBarSeries::mouseclicked() | |
101 | { |
|
101 | { | |
102 | QStackedBarSeries* series = new QStackedBarSeries(); |
|
102 | QStackedBarSeries* series = new QStackedBarSeries(); | |
103 | QBarCategories categories; |
|
103 | QBarCategories categories; | |
104 | categories << "test1" << "test2" << "test3"; |
|
104 | categories << "test1" << "test2" << "test3"; | |
105 | series->setCategories(categories); |
|
105 | series->setCategories(categories); | |
106 |
|
106 | |||
107 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
107 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
108 | *set1 << 10 << 10 << 10; |
|
108 | *set1 << 10 << 10 << 10; | |
109 | series->append(set1); |
|
109 | series->append(set1); | |
110 |
|
110 | |||
111 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
111 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
112 | *set2 << 10 << 10 << 10; |
|
112 | *set2 << 10 << 10 << 10; | |
113 | series->append(set2); |
|
113 | series->append(set2); | |
114 |
|
114 | |||
115 | QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); |
|
|||
116 | QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); |
|
|||
117 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); |
|
115 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); | |
118 |
|
116 | |||
119 | QChartView view(new QChart()); |
|
117 | QChartView view(new QChart()); | |
120 | view.resize(400,300); |
|
118 | view.resize(400,300); | |
121 | view.chart()->addSeries(series); |
|
119 | view.chart()->addSeries(series); | |
122 | view.show(); |
|
120 | view.show(); | |
123 | QTest::qWaitForWindowShown(&view); |
|
121 | QTest::qWaitForWindowShown(&view); | |
124 |
|
122 | |||
125 | //==================================================================================== |
|
123 | //==================================================================================== | |
126 | // barset 1, category test1 |
|
124 | // barset 1, category test1 | |
127 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1 |
|
125 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); | |
128 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
126 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
129 |
|
127 | |||
130 | QCOMPARE(setSpy1.count(), 1); |
|
|||
131 | QCOMPARE(setSpy2.count(), 0); |
|
|||
132 | QCOMPARE(seriesSpy.count(), 1); |
|
128 | QCOMPARE(seriesSpy.count(), 1); | |
133 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
134 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
135 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
136 |
|
129 | |||
137 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
130 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
138 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
131 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
132 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
139 |
|
133 | |||
140 | //==================================================================================== |
|
134 | //==================================================================================== | |
141 | // barset 1, category test2 |
|
135 | // barset 1, category test2 | |
142 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
136 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); | |
143 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
137 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
144 |
|
138 | |||
145 | QCOMPARE(setSpy1.count(), 1); |
|
|||
146 | QCOMPARE(setSpy2.count(), 0); |
|
|||
147 | QCOMPARE(seriesSpy.count(), 1); |
|
139 | QCOMPARE(seriesSpy.count(), 1); | |
148 | setSpyArg = setSpy1.takeFirst(); |
|
|||
149 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
150 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
151 |
|
140 | |||
152 | seriesSpyArg = seriesSpy.takeFirst(); |
|
141 | seriesSpyArg = seriesSpy.takeFirst(); | |
153 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
142 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
143 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
154 |
|
144 | |||
155 | //==================================================================================== |
|
145 | //==================================================================================== | |
156 | // barset 1, category test3 |
|
146 | // barset 1, category test3 | |
157 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
147 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); | |
158 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
148 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
159 |
|
149 | |||
160 | QCOMPARE(setSpy1.count(), 1); |
|
|||
161 | QCOMPARE(setSpy2.count(), 0); |
|
|||
162 | QCOMPARE(seriesSpy.count(), 1); |
|
150 | QCOMPARE(seriesSpy.count(), 1); | |
163 | setSpyArg = setSpy1.takeFirst(); |
|
|||
164 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
165 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
166 |
|
151 | |||
167 | seriesSpyArg = seriesSpy.takeFirst(); |
|
152 | seriesSpyArg = seriesSpy.takeFirst(); | |
168 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
153 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
154 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | |||
169 |
|
155 | |||
170 | //==================================================================================== |
|
156 | //==================================================================================== | |
171 | // barset 2, category test1 |
|
157 | // barset 2, category test1 | |
172 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1 |
|
158 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); | |
173 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
159 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
174 |
|
160 | |||
175 | QCOMPARE(setSpy1.count(), 0); |
|
|||
176 | QCOMPARE(setSpy2.count(), 1); |
|
|||
177 | QCOMPARE(seriesSpy.count(), 1); |
|
161 | QCOMPARE(seriesSpy.count(), 1); | |
178 | setSpyArg = setSpy2.takeFirst(); |
|
|||
179 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
180 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); |
|
|||
181 |
|
162 | |||
182 | seriesSpyArg = seriesSpy.takeFirst(); |
|
163 | seriesSpyArg = seriesSpy.takeFirst(); | |
183 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
164 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
165 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); | |||
184 |
|
166 | |||
185 | //==================================================================================== |
|
167 | //==================================================================================== | |
186 | // barset 2, category test2 |
|
168 | // barset 2, category test2 | |
187 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
169 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); | |
188 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
170 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
189 |
|
171 | |||
190 | QCOMPARE(setSpy1.count(), 0); |
|
|||
191 | QCOMPARE(setSpy2.count(), 1); |
|
|||
192 | QCOMPARE(seriesSpy.count(), 1); |
|
172 | QCOMPARE(seriesSpy.count(), 1); | |
193 | setSpyArg = setSpy2.takeFirst(); |
|
|||
194 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
195 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); |
|
|||
196 |
|
173 | |||
197 | seriesSpyArg = seriesSpy.takeFirst(); |
|
174 | seriesSpyArg = seriesSpy.takeFirst(); | |
198 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
175 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
|
176 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); | |||
199 |
|
177 | |||
200 | //==================================================================================== |
|
178 | //==================================================================================== | |
201 | // barset 2, category test3 |
|
179 | // barset 2, category test3 | |
202 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint( |
|
180 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); | |
203 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
181 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
204 |
|
182 | |||
205 | QCOMPARE(setSpy1.count(), 0); |
|
|||
206 | QCOMPARE(setSpy2.count(), 1); |
|
|||
207 | QCOMPARE(seriesSpy.count(), 1); |
|
183 | QCOMPARE(seriesSpy.count(), 1); | |
208 | setSpyArg = setSpy2.takeFirst(); |
|
|||
209 | QVERIFY(setSpyArg.at(0).type() == QVariant::String); |
|
|||
210 | QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); |
|
|||
211 |
|
184 | |||
212 | seriesSpyArg = seriesSpy.takeFirst(); |
|
185 | seriesSpyArg = seriesSpy.takeFirst(); | |
213 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
186 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
214 |
|
187 | QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); | ||
215 | //==================================================================================== |
|
|||
216 | // no event cases |
|
|||
217 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets |
|
|||
218 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets |
|
|||
219 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1 |
|
|||
220 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2 |
|
|||
221 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3 |
|
|||
222 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1 |
|
|||
223 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2 |
|
|||
224 | QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3 |
|
|||
225 |
|
||||
226 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
|||
227 | QCOMPARE(setSpy1.count(), 0); |
|
|||
228 | QCOMPARE(setSpy2.count(), 0); |
|
|||
229 | QCOMPARE(seriesSpy.count(), 0); |
|
|||
230 | } |
|
188 | } | |
231 |
|
189 | |||
232 | void tst_QStackedBarSeries::mousehovered_data() |
|
190 | void tst_QStackedBarSeries::mousehovered_data() | |
233 | { |
|
191 | { | |
234 |
|
192 | |||
235 | } |
|
193 | } | |
236 |
|
194 | |||
237 | void tst_QStackedBarSeries::mousehovered() |
|
195 | void tst_QStackedBarSeries::mousehovered() | |
238 | { |
|
196 | { | |
239 | QStackedBarSeries* series = new QStackedBarSeries(); |
|
197 | QStackedBarSeries* series = new QStackedBarSeries(); | |
240 | QBarCategories categories; |
|
198 | QBarCategories categories; | |
241 | categories << "test1" << "test2" << "test3"; |
|
199 | categories << "test1" << "test2" << "test3"; | |
242 | series->setCategories(categories); |
|
200 | series->setCategories(categories); | |
243 |
|
201 | |||
244 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
202 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
245 | *set1 << 10 << 10 << 10; |
|
203 | *set1 << 10 << 10 << 10; | |
246 | series->append(set1); |
|
204 | series->append(set1); | |
247 |
|
205 | |||
248 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
206 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
249 | *set2 << 10 << 10 << 10; |
|
207 | *set2 << 10 << 10 << 10; | |
250 | series->append(set2); |
|
208 | series->append(set2); | |
251 |
|
209 | |||
252 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); |
|
|||
253 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); |
|
|||
254 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); |
|
210 | QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); | |
255 |
|
211 | |||
256 | QChartView view(new QChart()); |
|
212 | QChartView view(new QChart()); | |
257 | view.resize(400,300); |
|
213 | view.resize(400,300); | |
258 | view.chart()->addSeries(series); |
|
214 | view.chart()->addSeries(series); | |
259 | view.show(); |
|
215 | view.show(); | |
260 | QTest::qWaitForWindowShown(&view); |
|
216 | QTest::qWaitForWindowShown(&view); | |
261 |
|
217 | |||
|
218 | //this is hack since view does not get events otherwise | |||
|
219 | view.setMouseTracking(true); | |||
|
220 | ||||
262 | //======================================================================= |
|
221 | //======================================================================= | |
263 | // move mouse to left border |
|
222 | // move mouse to left border | |
264 |
QTest::mouseMove(view.viewport(), QPoint(0, |
|
223 | QTest::mouseMove(view.viewport(), QPoint(0, 190)); | |
265 |
|
224 | |||
266 | QVERIFY(setSpy1.count() == 0); |
|
|||
267 | QVERIFY(setSpy2.count() == 0); |
|
|||
268 | QVERIFY(seriesSpy.count() == 0); |
|
225 | QVERIFY(seriesSpy.count() == 0); | |
269 |
|
226 | |||
270 | //======================================================================= |
|
227 | //======================================================================= | |
271 | // move mouse on top of set1 |
|
228 | // move mouse on top of set1 | |
272 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
229 | QTest::mouseMove(view.viewport(), QPoint(106,190)); | |
273 |
|
230 | |||
274 | QVERIFY(setSpy1.count() == 1); |
|
|||
275 | QVERIFY(setSpy2.count() == 0); |
|
|||
276 | QVERIFY(seriesSpy.count() == 1); |
|
231 | QVERIFY(seriesSpy.count() == 1); | |
277 |
|
232 | |||
278 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
|||
279 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
280 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
281 |
|
||||
282 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
233 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
283 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
234 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
|
235 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |||
|
236 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |||
284 |
|
237 | |||
285 | //======================================================================= |
|
238 | //======================================================================= | |
286 | // move mouse from top of set1 to top of set2 |
|
239 | // move mouse from top of set1 to top of set2 | |
287 |
QTest::mouseMove(view.viewport(), QPoint(1 |
|
240 | QTest::mouseMove(view.viewport(), QPoint(106,95)); | |
288 |
|
241 | |||
289 | QVERIFY(setSpy1.count() == 1); |
|
|||
290 | QVERIFY(setSpy2.count() == 1); |
|
|||
291 | QVERIFY(seriesSpy.count() == 2); |
|
242 | QVERIFY(seriesSpy.count() == 2); | |
292 |
|
243 | |||
293 | // should leave set1 |
|
244 | // should leave set1 | |
294 | setSpyArg = setSpy1.takeFirst(); |
|
|||
295 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
296 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
297 |
|
||||
298 | // should enter set2 |
|
|||
299 | setSpyArg = setSpy2.takeFirst(); |
|
|||
300 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
301 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
|||
302 |
|
||||
303 | // should leave set1 |
|
|||
304 | seriesSpyArg = seriesSpy.takeFirst(); |
|
245 | seriesSpyArg = seriesSpy.takeFirst(); | |
305 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); |
|
246 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | |
306 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
247 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
307 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
248 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
308 |
|
249 | |||
309 | // should enter set2 |
|
250 | // should enter set2 | |
310 | seriesSpyArg = seriesSpy.takeFirst(); |
|
251 | seriesSpyArg = seriesSpy.takeFirst(); | |
311 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
252 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
312 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
253 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
313 | QVERIFY(seriesSpyArg.at(1).toBool() == true); |
|
254 | QVERIFY(seriesSpyArg.at(1).toBool() == true); | |
314 |
|
255 | |||
315 | //======================================================================= |
|
256 | //======================================================================= | |
316 | // move mouse from top of set2 to background |
|
257 | // move mouse from top of set2 to background | |
317 |
QTest::mouseMove(view.viewport(), QPoint(0 |
|
258 | QTest::mouseMove(view.viewport(), QPoint(106,0)); | |
318 |
|
259 | |||
319 | QVERIFY(setSpy1.count() == 0); |
|
|||
320 | QVERIFY(setSpy2.count() == 1); |
|
|||
321 | QVERIFY(seriesSpy.count() == 1); |
|
260 | QVERIFY(seriesSpy.count() == 1); | |
322 |
|
261 | |||
323 |
// should leave set2 |
|
262 | // should leave set2 | |
324 | setSpyArg = setSpy2.takeFirst(); |
|
|||
325 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
|||
326 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
|||
327 |
|
||||
328 | // should leave set2 (event via series) |
|
|||
329 | seriesSpyArg = seriesSpy.takeFirst(); |
|
263 | seriesSpyArg = seriesSpy.takeFirst(); | |
330 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); |
|
264 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | |
331 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); |
|
265 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | |
332 | QVERIFY(seriesSpyArg.at(1).toBool() == false); |
|
266 | QVERIFY(seriesSpyArg.at(1).toBool() == false); | |
333 | } |
|
267 | } | |
334 |
|
268 | |||
335 |
|
||||
336 | /* |
|
|||
337 | bool setModel(QAbstractItemModel *model); |
|
|||
338 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
|||
339 | void setModelMappingRange(int first, int count = -1); |
|
|||
340 | */ |
|
|||
341 | QTEST_MAIN(tst_QStackedBarSeries) |
|
269 | QTEST_MAIN(tst_QStackedBarSeries) | |
342 |
|
270 | |||
343 | #include "tst_qstackedbarseries.moc" |
|
271 | #include "tst_qstackedbarseries.moc" | |
344 |
|
272 |
General Comments 0
You need to be logged in to leave comments.
Login now