##// END OF EJS Templates
Simple UI testing added using mago(LDTP):...
ferdek -
r2132:45eed4d8b56a
parent child
Show More
@@ -0,0 +1,33
1 from mago import TestCase
2 import ldtp
3 from ldtputils import *
4 import ldtputils
5
6 class TestMinimal(TestCase):
7 launcher = '/home/ferdek/charts/bin/release/uitest'
8 window_name = 'flrRangeMinDown'
9
10 before = '/tmp/image1.png'
11 after = '/tmp/image2.png'
12
13 offsetX = 15
14 offsetY = 15
15 captureHeight = 200
16 captureWidth = 200
17
18 # helper functions
19 def capturechartbefore(self):
20 ldtp.imagecapture(self.window_name, self.before, self.offsetX, self.offsetY, self.captureWidth, self.captureHeight)
21
22 def capturechartafter(self):
23 ldtp.imagecapture(self.window_name, self.after, self.offsetX, self.offsetY, self.captureWidth, self.captureHeight)
24
25 def comparechart(self):
26 self.assertTrue(ldtputils.imagecompare(self.before, self.after) > 0)
27
28 # tests
29 def test_tickcountchange(self):
30 self.capturechartbefore()
31 ldtp.click(self.window_name, 'btnTickUp')
32 self.capturechartafter()
33 self.comparechart()
@@ -0,0 +1,11
1 #include <QtGui/QApplication>
2 #include "widget.h"
3
4 int main(int argc, char *argv[])
5 {
6 QApplication a(argc, argv);
7 Widget w;
8 w.show();
9
10 return a.exec();
11 }
@@ -0,0 +1,17
1 !include( ../tests.pri ) {
2 error( "Couldn't find the test.pri file!" )
3 }
4
5 QT += core gui
6 contains(QT_MAJOR_VERSION, 5) {
7 QT += widgets
8 }
9
10 TARGET = uitest
11 TEMPLATE = app
12
13
14 SOURCES += main.cpp\
15 widget.cpp
16
17 HEADERS += widget.h
@@ -0,0 +1,109
1 #include "widget.h"
2
3 // Qt
4 #include <QGridLayout>
5 #include <QVBoxLayout>
6 #include <QPushButton>
7
8 // Charts
9 #include <QChartView>
10 #include <QLineSeries>
11 #include <QValueAxis>
12
13 QTCOMMERCIALCHART_USE_NAMESPACE
14
15 Widget::Widget(QWidget *parent)
16 : QWidget(parent),
17 m_axisX(0),
18 m_axisY(0)
19 {
20 QChartView *chartView = new QChartView;
21 chartView->setAccessibleName("Chart");
22 QChart *chart = chartView->chart();
23
24 QLineSeries *series = new QLineSeries;
25 series->setName("Series 1");
26 series->append(1, 2);
27 series->append(3, 1);
28 series->append(5, 4);
29
30 chart->addSeries(series);
31 m_axisX = new QValueAxis;
32 m_axisY = new QValueAxis;
33 chart->setAxisX(m_axisX, series);
34 chart->setAxisY(m_axisY, series);
35
36 // buttons
37 QVBoxLayout *buttonsLayout = createButtons();
38 setAccessibleName("uitest");
39 window()->setAccessibleName("uitest");
40 setWindowTitle("uitest");
41
42 QGridLayout *mainLayout = new QGridLayout;
43 mainLayout->addWidget(chartView, 1, 1);
44 mainLayout->addLayout(buttonsLayout, 1, 2);
45 setLayout(mainLayout);
46 }
47
48 Widget::~Widget()
49 {
50
51 }
52
53 QVBoxLayout* Widget::createButtons()
54 {
55 QVBoxLayout *buttonsLayout = new QVBoxLayout;
56
57 QPushButton *button = new QPushButton("Tick+");
58 button->setAccessibleName("TickUp");
59 buttonsLayout->addWidget(button);
60 connect(button,SIGNAL(clicked()), this, SLOT(handleClick()));
61
62 button = new QPushButton("Tick-");
63 button->setAccessibleName("TickDown");
64 buttonsLayout->addWidget(button);
65 connect(button,SIGNAL(clicked()), this, SLOT(handleClick()));
66
67 button = new QPushButton("RangeMax+");
68 button->setAccessibleName("RangeMaxUp");
69 buttonsLayout->addWidget(button);
70 connect(button,SIGNAL(clicked()), this, SLOT(handleClick()));
71
72 button = new QPushButton("RangeMax-");
73 button->setAccessibleName("RangeMaxDown");
74 buttonsLayout->addWidget(button);
75 connect(button,SIGNAL(clicked()), this, SLOT(handleClick()));
76
77 button = new QPushButton("RangeMin+");
78 button->setAccessibleName("RangeMinUp");
79 buttonsLayout->addWidget(button);
80 connect(button,SIGNAL(clicked()), this, SLOT(handleClick()));
81
82 button = new QPushButton("RangeMin-");
83 button->setAccessibleName("RangeMinDown");
84 buttonsLayout->addWidget(button);
85 connect(button,SIGNAL(clicked()), this, SLOT(handleClick()));
86
87 buttonsLayout->addStretch();
88
89 return buttonsLayout;
90 }
91
92 void Widget::handleClick()
93 {
94 QPushButton *button = qobject_cast<QPushButton *>(sender());
95 QString buttonName = button->text();
96
97 if (buttonName == "Tick+")
98 m_axisX->setTickCount(m_axisX->tickCount() + 1);
99 else if (buttonName == "Tick-")
100 m_axisX->setTickCount(m_axisX->tickCount() - 1);
101 else if (buttonName == "RangeMax+")
102 m_axisX->setMax(m_axisX->max() + 1);
103 else if (buttonName == "RangeMax-")
104 m_axisX->setMax(m_axisX->max() - 1);
105 else if (buttonName == "RangeMin+")
106 m_axisX->setMin(m_axisX->min() + 1);
107 else if (buttonName == "RangeMin-")
108 m_axisX->setMin(m_axisX->min() - 1);
109 }
@@ -0,0 +1,33
1 #ifndef WIDGET_H
2 #define WIDGET_H
3
4 #include <QtGui/QWidget>
5 #include <QChartGlobal>
6
7 class QVBoxLayout;
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 class QValueAxis;
11 QTCOMMERCIALCHART_END_NAMESPACE
12
13 QTCOMMERCIALCHART_USE_NAMESPACE
14
15 class Widget : public QWidget
16 {
17 Q_OBJECT
18
19 public:
20 Widget(QWidget *parent = 0);
21 ~Widget();
22
23 public slots:
24 void handleClick();
25
26 private:
27 QVBoxLayout* createButtons();
28
29 QValueAxis *m_axisX;
30 QValueAxis *m_axisY;
31 };
32
33 #endif // WIDGET_H
@@ -6,7 +6,8 TEMPLATE = subdirs
6 6 SUBDIRS += \
7 7 auto \
8 8 qmlchartproperties \
9 qmlchartaxis
9 qmlchartaxis \
10 uitest
10 11
11 12 contains(QT_CONFIG, opengl) {
12 13 SUBDIRS += chartwidgettest \
General Comments 0
You need to be logged in to leave comments. Login now