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
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#include <QtTest>
#include "libvideostitch-gui/mainwindow/timeconverter.hpp"
class VideoStitchTimeConverterTest : public QObject {
Q_OBJECT
public:
VideoStitchTimeConverterTest();
private Q_SLOTS:
void testTimeConverterFrameString();
void testTimeConverterLongerThanHour();
void testTimeConverterInvalidTime();
void testTimeConverterFrameString_data();
void testTimeConverterLongerThanHour_data();
void testTimeConverterInvalidTime_data();
private:
VideoStitch::FrameRate frameRate = {100, 1};
};
VideoStitchTimeConverterTest::VideoStitchTimeConverterTest() {}
void VideoStitchTimeConverterTest::testTimeConverterFrameString() {
QFETCH(frameid_t, frame);
QFETCH(QString, expectedString);
QString s = TimeConverter::frameToTimeDisplay(frame, frameRate);
QCOMPARE(s, expectedString);
frameid_t f = TimeConverter::timeDisplayToFrame(expectedString, frameRate);
QCOMPARE(f, frame);
}
void VideoStitchTimeConverterTest::testTimeConverterLongerThanHour() {
QFETCH(frameid_t, fps);
QFETCH(bool, expected);
bool b = TimeConverter::isLongerThanAnHour(fps, frameRate);
QCOMPARE(b, expected);
}
void VideoStitchTimeConverterTest::testTimeConverterInvalidTime() {
QFETCH(QString, string);
QFETCH(frameid_t, expectedFrame);
frameid_t f = TimeConverter::timeDisplayToFrame(string, frameRate);
QCOMPARE(f, expectedFrame);
}
void VideoStitchTimeConverterTest::testTimeConverterFrameString_data() {
QTest::addColumn<frameid_t>("frame");
QTest::addColumn<QString>("expectedString");
QTest::newRow("frame 0 @100fps") << 0 << "00:00:00";
QTest::newRow("frame 10 @100fps") << 10 << "00:00:10";
QTest::newRow("frame 101 @100fps") << 101 << "00:01:01";
QTest::newRow("frame 2000 @100fps") << 2000 << "00:20:00";
}
void VideoStitchTimeConverterTest::testTimeConverterLongerThanHour_data() {
QTest::addColumn<frameid_t>("fps");
QTest::addColumn<bool>("expected");
QTest::newRow("frame 10 @100fps") << 10 << false;
QTest::newRow("frame 2000000 @100fps") << 2000000 << true; // 5:33:20:00
QTest::newRow("frame 359999 @100fps") << 359999 << false; // 59:59:99
QTest::newRow("frame 360000 @100fps") << 360000 << true; // 1:00:00:00
}
void VideoStitchTimeConverterTest::testTimeConverterInvalidTime_data() {
QTest::addColumn<QString>("string");
QTest::addColumn<frameid_t>("expectedFrame");
QTest::newRow("Input : : @100fps") << ": : :" << 0; // 00:00:00
QTest::newRow("Input 20: : @100fps") << "20::" << 120000; // 20:00:00
QTest::newRow("Input :20 : @100fps") << ":20:" << 2000; // 00:20:00
QTest::newRow("Input : :40 @100fps") << "::40" << 40; // 00:00:40
}
QTEST_APPLESS_MAIN(VideoStitchTimeConverterTest)
#include "timeConverterTest.moc"