summaryrefslogtreecommitdiff
path: root/tests/fute
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fute')
-rw-r--r--tests/fute/charts/charts.pro35
-rw-r--r--tests/fute/charts/charts_test.cpp52
-rw-r--r--tests/fute/charts/charts_test.h31
-rw-r--r--tests/fute/charts/main.cpp12
-rw-r--r--tests/fute/pieCharts/main.cpp12
-rw-r--r--tests/fute/pieCharts/pieCharts.pro29
-rw-r--r--tests/fute/pieCharts/pieCharts_test.cpp52
-rw-r--r--tests/fute/pieCharts/pieCharts_test.h34
-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
12 files changed, 392 insertions, 0 deletions
diff --git a/tests/fute/charts/charts.pro b/tests/fute/charts/charts.pro
new file mode 100644
index 0000000..613fee8
--- /dev/null
+++ b/tests/fute/charts/charts.pro
@@ -0,0 +1,35 @@
+TEMPLATE = app
+QT += widgets
+TARGET = charts_test
+DEPENDPATH += .
+INCLUDEPATH += .
+QMAKE_CXXFLAGS += -std=gnu++11
+DESTDIR = ./
+
+win32: {
+ CONFIG += console
+ }
+
+HEADERS = \
+ charts_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 \
+ charts_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/charts/charts_test.cpp b/tests/fute/charts/charts_test.cpp
new file mode 100644
index 0000000..0870027
--- /dev/null
+++ b/tests/fute/charts/charts_test.cpp
@@ -0,0 +1,52 @@
+#include "charts_test.h"
+#include "../../../src/charts/Chart.h"
+
+#include <cstdlib>
+#include <time.h>
+
+ChartsTest::ChartsTest()
+{
+ srand(time(NULL));
+ createUi();
+ changeDataSet();
+}
+
+void ChartsTest::changeDataSet()
+{
+ const int daysNum = 7;
+ yValuesStr = "Values: ";
+ dataSet.clear();
+ for (int i = 0; i < daysNum; i++)
+ addDataPoint(i);
+ chart->setDataSet(dataSet);
+ valuesLabel->setText(yValuesStr);
+}
+
+void ChartsTest::addDataPoint(int index)
+{
+ const int firstDay = 15;
+ QString xLabel = QString::number(firstDay + index) + ".11";
+ int yValue = rand() % 70;
+ dataSet << DataPoint(xLabel, yValue, xLabel);
+ yValuesStr += QString::number(yValue) + ", ";
+}
+
+void ChartsTest::createUi()
+{
+ QPushButton* newBtn = new QPushButton(tr("New chart"));
+ connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet()));
+
+ valuesLabel = new QLabel;
+ chart = new Chart;
+ chart->setLabels("Date", "Value");
+
+ QHBoxLayout* controlLt = new QHBoxLayout;
+ controlLt->addWidget(valuesLabel);
+ controlLt->addWidget(newBtn);
+
+ QVBoxLayout* mainLt = new QVBoxLayout;
+ mainLt->addLayout(controlLt);
+ mainLt->addWidget(chart);
+ setLayout(mainLt);
+ resize(800, 500);
+}
diff --git a/tests/fute/charts/charts_test.h b/tests/fute/charts/charts_test.h
new file mode 100644
index 0000000..3975444
--- /dev/null
+++ b/tests/fute/charts/charts_test.h
@@ -0,0 +1,31 @@
+#ifndef CHARTS_TEST_H
+#define CHARTS_TEST_H
+
+#include <QtCore>
+#include <QtWidgets>
+
+#include "../../../src/charts/DataPoint.h"
+
+class Chart;
+
+class ChartsTest: public QWidget
+{
+ Q_OBJECT
+public:
+ ChartsTest();
+
+private:
+ void createUi();
+ void addDataPoint(int index);
+
+private slots:
+ void changeDataSet();
+
+private:
+ QString yValuesStr;
+ Chart* chart;
+ QList<DataPoint> dataSet;
+ QLabel* valuesLabel;
+};
+
+#endif
diff --git a/tests/fute/charts/main.cpp b/tests/fute/charts/main.cpp
new file mode 100644
index 0000000..346133d
--- /dev/null
+++ b/tests/fute/charts/main.cpp
@@ -0,0 +1,12 @@
+#include <QtWidgets>
+
+#include "charts_test.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ChartsTest mainWin;
+ mainWin.show();
+ return app.exec();
+}
+
diff --git a/tests/fute/pieCharts/main.cpp b/tests/fute/pieCharts/main.cpp
new file mode 100644
index 0000000..ed7ce6e
--- /dev/null
+++ b/tests/fute/pieCharts/main.cpp
@@ -0,0 +1,12 @@
+#include <QtWidgets>
+
+#include "pieCharts_test.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ PieChartsTest mainWin;
+ mainWin.show();
+ return app.exec();
+}
+
diff --git a/tests/fute/pieCharts/pieCharts.pro b/tests/fute/pieCharts/pieCharts.pro
new file mode 100644
index 0000000..960dd59
--- /dev/null
+++ b/tests/fute/pieCharts/pieCharts.pro
@@ -0,0 +1,29 @@
+TEMPLATE = app
+QT += widgets
+TARGET = piecharts_test
+DEPENDPATH += .
+INCLUDEPATH += .
+QMAKE_CXXFLAGS += -std=gnu++11
+DESTDIR = ./
+
+win32: {
+ CONFIG += console
+ }
+
+HEADERS = \
+ pieCharts_test.h \
+ ../../../src/charts/PieChart.h \
+ ../../../src/charts/DataPoint.h \
+ ../../../src/charts/PieChartScene.h \
+ ../../../src/charts/ChartView.h \
+ ../../../src/charts/PieRound.h \
+ ../../../src/charts/PieLegend.h
+
+SOURCES = \
+ main.cpp \
+ pieCharts_test.cpp \
+ ../../../src/charts/PieChart.cpp \
+ ../../../src/charts/PieChartScene.cpp \
+ ../../../src/charts/ChartView.cpp \
+ ../../../src/charts/PieRound.cpp \
+ ../../../src/charts/PieLegend.cpp
diff --git a/tests/fute/pieCharts/pieCharts_test.cpp b/tests/fute/pieCharts/pieCharts_test.cpp
new file mode 100644
index 0000000..d88981a
--- /dev/null
+++ b/tests/fute/pieCharts/pieCharts_test.cpp
@@ -0,0 +1,52 @@
+#include "pieCharts_test.h"
+#include "../../../src/charts/PieChart.h"
+
+#include <cstdlib>
+#include <time.h>
+
+const QStringList PieChartsTest::Labels =
+ {"Studied", "Scheduled for today", "New"};
+
+PieChartsTest::PieChartsTest()
+{
+ srand(time(NULL));
+ createUi();
+ changeDataSet();
+}
+
+void PieChartsTest::changeDataSet()
+{
+ yValuesStr = "Values: ";
+ dataSet.clear();
+ for (int i = 0; i < 3; i++)
+ addDataPoint(i);
+ chart->setDataSet(dataSet);
+ valuesLabel->setText(yValuesStr);
+}
+
+void PieChartsTest::addDataPoint(int index)
+{
+ int yValue = rand() % 200;
+ dataSet << DataPoint(Labels[index], yValue, "");
+ yValuesStr += QString::number(yValue) + ", ";
+}
+
+void PieChartsTest::createUi()
+{
+ QPushButton* newBtn = new QPushButton(tr("New chart"));
+ connect(newBtn, SIGNAL(clicked()), SLOT(changeDataSet()));
+
+ valuesLabel = new QLabel;
+ chart = new PieChart;
+ chart->setColors({"#39c900", "#ece900", "#ff0000"});
+
+ QHBoxLayout* controlLt = new QHBoxLayout;
+ controlLt->addWidget(valuesLabel);
+ controlLt->addWidget(newBtn);
+
+ QVBoxLayout* mainLt = new QVBoxLayout;
+ mainLt->addLayout(controlLt);
+ mainLt->addWidget(chart);
+ setLayout(mainLt);
+ resize(800, 500);
+}
diff --git a/tests/fute/pieCharts/pieCharts_test.h b/tests/fute/pieCharts/pieCharts_test.h
new file mode 100644
index 0000000..835ff72
--- /dev/null
+++ b/tests/fute/pieCharts/pieCharts_test.h
@@ -0,0 +1,34 @@
+#ifndef PIE_CHARTS_TEST_H
+#define PIE_CHARTS_TEST_H
+
+#include <QtCore>
+#include <QtWidgets>
+
+#include "../../../src/charts/DataPoint.h"
+
+class PieChart;
+
+class PieChartsTest: public QWidget
+{
+ Q_OBJECT
+public:
+ static const QStringList Labels;
+
+public:
+ PieChartsTest();
+
+private:
+ void createUi();
+ void addDataPoint(int index);
+
+private slots:
+ void changeDataSet();
+
+private:
+ QString yValuesStr;
+ PieChart* chart;
+ QList<DataPoint> dataSet;
+ QLabel* valuesLabel;
+};
+
+#endif
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