summaryrefslogtreecommitdiff
path: root/tests/fute/timeCharts/timeCharts_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fute/timeCharts/timeCharts_test.cpp')
-rw-r--r--tests/fute/timeCharts/timeCharts_test.cpp58
1 files changed, 58 insertions, 0 deletions
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);
+}