File: LiveDataTest.h

package info (click to toggle)
labplot 2.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,500 kB
  • sloc: cpp: 241,048; ansic: 6,324; python: 915; xml: 400; yacc: 237; sh: 221; awk: 35; makefile: 11
file content (93 lines) | stat: -rw-r--r-- 2,448 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
	File                 : LiveDataTest.cpp
	Project              : LabPlot
	Description          : Tests for reading live data from files
	--------------------------------------------------------------------
	SPDX-FileCopyrightText: 2024 Alexander Semke <alexander.semke@web.de>
	SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef LIVEDATATEST_H
#define LIVEDATATEST_H

#include "tests/CommonTest.h"

class QTcpServer;
class QUdpSocket;

class LiveDataTest : public CommonTest {
	Q_OBJECT

private:
	void initTestCase() override;
	void cleanupTestCase();

	template<typename T1, typename T2>
	bool waitForSignal(T1* sender, T2 signal) {
		QTimer timer(this);
		timer.setSingleShot(true);

		bool timeout = false;

		QEventLoop loop;
		QTimer::connect(&timer, &QTimer::timeout, [&loop, &timeout] {
			timeout = true;
			loop.quit();
		});

		connect(sender, signal, [&loop, &timer] {
			timer.stop();
			loop.quit();
		});
		timer.start(2000);
		loop.exec();

		return timeout;
	}

	QUdpSocket* m_udpSocket{nullptr};
	QTcpServer* m_tcpServer{nullptr};
	QTcpSocket* m_tcpSocket{nullptr};
	QTimer* m_tcpSendTimer{nullptr};

private Q_SLOTS:
	// Reading from files:

	// Continuous fixed - fixed amount of samples is processed starting from the beginning of the newly received data
	void testReadContinuousFixed00();
	void testReadContinuousFixed01();
	void testReadContinuousFixed02();
	void testReadContinuousFixedWithIndex();
	void testReadContinuousFixedWithTimestamp();
	void testReadContinuousFixedWithIndexTimestamp();

	// From End - fixed amount of samples is processed starting from the end of the newly received data
	void testReadFromEnd00();
	void testReadFromEnd01();
	void testReadFromEnd02();

	// Till the End - all newly received data is processed
	void testReadTillEnd00();
	void testReadTillEnd01();

	// Whole file - on every read the whole file is re-read completely and processed
	void testReadWholeFile00();
	void testReadWholeFile01();
	void testReadWholeFileSameContentSize();

	void testPlotting();

	// reading from TCP sockets:
	void testTcpReadContinuousFixed00();

	// reading from UDP sockets:
	void testUdpReadContinuousFixed00();

	void testLoadSaveLiveDataLinkedFile_FileExists();
	void testLoadSaveLiveDataLinkedFile_FileNotExists();
	void testLoadSaveLiveDataLinkedFile_FileNotExistsRemoveLivedata();
	void testLoadSaveLiveDataNoLinkedFile();
	// void testLoadSaveLiveDataSource();
};

#endif // LIVEDATATEST_H