summaryrefslogtreecommitdiff
path: root/tests/fute/timeCharts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fute/timeCharts')
-rw-r--r--tests/fute/timeCharts/main.cpp12
-rw-r--r--tests/fute/timeCharts/timeCharts.pro35
-rw-r--r--tests/fute/timeCharts/timeCharts_test.cpp58
-rw-r--r--tests/fute/timeCharts/timeCharts_test.h30
4 files changed, 135 insertions, 0 deletions
diff --git a/tests/fute/timeCharts/main.cpp b/tests/fute/timeCharts/main.cpp
new file mode 100644
index 0000000..3abb753
--- /dev/null
+++ b/tests/fute/timeCharts/main.cpp
@@ -0,0 +1,12 @@
+#include <QtWidgets>
+
+#include "timeCharts_test.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ TimeChartsTest mainWin;
+ mainWin.show();
+ return app.exec();
+}
+
diff --git a/tests/fute/timeCharts/timeCharts.pro b/tests/fute/timeCharts/timeCharts.pro
new file mode 100644
index 0000000..a570829
--- /dev/null
+++ b/tests/fute/timeCharts/timeCharts.pro
@@ -0,0 +1,35 @@
+TEMPLATE = app
+QT += widgets
+TARGET = timeCharts_test
+DEPENDPATH += .
+INCLUDEPATH += .
+QMAKE_CXXFLAGS += -std=gnu++11
+DESTDIR = ./
+
+win32: {
+ CONFIG += console
+ }
+
+HEADERS = \
+ timeCharts_test.h \
+ ../../../src/charts/Chart.h \
+ ../../../src/charts/TimeChart.h \
+ ../../../src/charts/DataPoint.h \
+ ../../../src/charts/ChartScene.h \
+ ../../../src/charts/ChartView.h \
+ ../../../src/charts/ChartAxes.h \
+ ../../../src/charts/ChartDataLine.h \
+ ../../../src/charts/ChartMarker.h \
+ ../../../src/charts/ChartToolTip.h
+
+SOURCES = \
+ main.cpp \
+ timeCharts_test.cpp \
+ ../../../src/charts/Chart.cpp \
+ ../../../src/charts/TimeChart.cpp \
+ ../../../src/charts/ChartScene.cpp \
+ ../../../src/charts/ChartView.cpp \
+ ../../../src/charts/ChartAxes.cpp \
+ ../../../src/charts/ChartDataLine.cpp \
+ ../../../src/charts/ChartMarker.cpp \
+ ../../../src/charts/ChartToolTip.cpp
diff --git a/tests/fute/timeCharts/timeCharts_test.cpp b/tests/fute/timeCharts/timeCharts_test.cpp
new file mode 100644
index 0000000..53f0921
--- /dev/null
+++ b/tests/fute/timeCharts/timeCharts_test.cpp
@@ -0,0 +1,58 @@
+#include "../../../src/charts/TimeChart.h"
+
+#include <cstdlib>
+#include <time.h>
+#include "timeCharts_test.h"
+
+TimeChartsTest::TimeChartsTest()
+{
+ srand(time(NULL));
+ createUi();
+ changeDataSet();
+}
+
+void TimeChartsTest::changeDataSet()
+{
+ int daysNum = periodBox->value();
+ yValuesStr = "Values: ";
+ dates.clear();
+ for (int i = 0; i < daysNum; i++)
+ addDataPoint(i);
+ chart->setDates(dates, daysNum, 1);
+ valuesLabel->setText(yValuesStr);
+}
+
+void TimeChartsTest::addDataPoint(int index)
+{
+ QDateTime date = QDateTime::currentDateTime().addDays(index);
+ int dayCardsNum = rand() % 50;
+ for(int i = 0; i < dayCardsNum; i++)
+ dates << date;
+ yValuesStr += QString::number(dayCardsNum) + ", ";
+}
+
+void TimeChartsTest::createUi()
+{
+ QPushButton* newBtn = new QPushButton(tr("New chart"));
+ connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet()));
+
+ valuesLabel = new QLabel;
+ valuesLabel->setMaximumWidth(750);
+
+ periodBox = new QSpinBox;
+ periodBox->setRange(7, 5000);
+
+ chart = new TimeChart;
+ chart->setLabels(tr("Date"), tr("Cards"));
+
+ QHBoxLayout* controlLt = new QHBoxLayout;
+ controlLt->addWidget(periodBox);
+ controlLt->addWidget(newBtn);
+
+ QVBoxLayout* mainLt = new QVBoxLayout;
+ mainLt->addLayout(controlLt);
+ mainLt->addWidget(valuesLabel);
+ mainLt->addWidget(chart);
+ setLayout(mainLt);
+ resize(800, 500);
+}
diff --git a/tests/fute/timeCharts/timeCharts_test.h b/tests/fute/timeCharts/timeCharts_test.h
new file mode 100644
index 0000000..49d6346
--- /dev/null
+++ b/tests/fute/timeCharts/timeCharts_test.h
@@ -0,0 +1,30 @@
+#ifndef CHARTS_TEST_H
+#define CHARTS_TEST_H
+
+#include <QtCore>
+#include <QtWidgets>
+
+class TimeChart;
+
+class TimeChartsTest: public QWidget
+{
+ Q_OBJECT
+public:
+ TimeChartsTest();
+
+private:
+ void createUi();
+ void addDataPoint(int index);
+
+private slots:
+ void changeDataSet();
+
+private:
+ QString yValuesStr;
+ TimeChart* chart;
+ QList<QDateTime> dates;
+ QLabel* valuesLabel;
+ QSpinBox* periodBox;
+};
+
+#endif