Changeset View
Changeset View
Standalone View
Standalone View
autotests/testedid.cpp
- This file was added.
1 | /************************************************************************************* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 by Frederik Gladhorn <gladhorn@kde.org> * | ||||
3 | * * | ||||
4 | * This library is free software; you can redistribute it and/or * | ||||
5 | * modify it under the terms of the GNU Lesser General Public * | ||||
6 | * License as published by the Free Software Foundation; either * | ||||
7 | * version 2.1 of the License, or (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This library is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | ||||
12 | * Lesser General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU Lesser General Public * | ||||
15 | * License along with this library; if not, write to the Free Software * | ||||
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | ||||
17 | *************************************************************************************/ | ||||
18 | | ||||
19 | #include <QCoreApplication> | ||||
20 | #include <QtTest> | ||||
21 | #include <QObject> | ||||
22 | | ||||
23 | #include "../src/edid.h" | ||||
24 | | ||||
25 | using namespace KScreen; | ||||
26 | | ||||
27 | class TestEdid : public QObject | ||||
28 | { | ||||
29 | Q_OBJECT | ||||
30 | | ||||
31 | private Q_SLOTS: | ||||
32 | void testInvalid(); | ||||
33 | void testEdidParser_data(); | ||||
34 | void testEdidParser(); | ||||
35 | }; | ||||
36 | | ||||
37 | void TestEdid::testInvalid() | ||||
38 | { | ||||
39 | QScopedPointer<Edid> e(new Edid()); | ||||
40 | QCOMPARE(e->isValid(), false); | ||||
41 | QCOMPARE(e->name(), QString()); | ||||
42 | | ||||
43 | QScopedPointer<Edid> e2(e->clone()); | ||||
44 | QCOMPARE(e2->isValid(), false); | ||||
45 | QCOMPARE(e2->name(), QString()); | ||||
46 | | ||||
47 | QScopedPointer<Edid> e3(new Edid("some random data")); | ||||
48 | QCOMPARE(e3->isValid(), false); | ||||
49 | } | ||||
50 | | ||||
51 | void TestEdid::testEdidParser_data() | ||||
52 | { | ||||
53 | // The raw edid data | ||||
54 | QTest::addColumn<QByteArray>("raw_edid"); | ||||
55 | QTest::addColumn<QString>("deviceId"); | ||||
56 | QTest::addColumn<QString>("name"); | ||||
57 | QTest::addColumn<QString>("pnpId"); | ||||
58 | // List of potential vendor names, this depends on the availablility | ||||
59 | // of pnp.ids, otherwise it will be a three letter abbreviation. | ||||
60 | QTest::addColumn<QStringList>("vendor"); | ||||
61 | QTest::addColumn<QString>("serial"); | ||||
62 | QTest::addColumn<QString>("eisaId"); | ||||
63 | QTest::addColumn<QString>("hash"); | ||||
64 | QTest::addColumn<int>("width"); | ||||
65 | QTest::addColumn<int>("height"); | ||||
66 | QTest::addColumn<qreal>("gamma"); | ||||
67 | | ||||
68 | QTest::addColumn<QQuaternion>("red"); | ||||
69 | QTest::addColumn<QQuaternion>("green"); | ||||
70 | QTest::addColumn<QQuaternion>("blue"); | ||||
71 | QTest::addColumn<QQuaternion>("white"); | ||||
72 | | ||||
73 | QTest::addRow("cor") | ||||
74 | << QByteArray::fromBase64("AP///////wAN8iw0AAAAABwVAQOAHRB4CoPVlFdSjCccUFQAAAABAQEBAQEBAQEBAQEBAQEBEhtWWlAAGTAwIDYAJaQQAAAYEhtWWlAAGTAwIDYAJaQQAAAYAAAA/gBBVU8KICAgICAgICAgAAAA/gBCMTMzWFcwMyBWNCAKAIc=") | ||||
75 | << QStringLiteral("xrandr-unknown") | ||||
76 | << QStringLiteral("") | ||||
77 | << QStringLiteral("COR") | ||||
78 | << QStringList({QStringLiteral("COR"), QStringLiteral("Corollary Inc")}) | ||||
79 | << QStringLiteral("") | ||||
80 | << QStringLiteral("B133XW03 V4") | ||||
81 | << QStringLiteral("82266089b3f9da3a8c48de1ec81b09e1") | ||||
82 | << 29 << 16 << 2.2 | ||||
83 | << QQuaternion(1, QVector3D(0.580078, 0.339844, 0)) | ||||
84 | << QQuaternion(1, QVector3D(0.320313, 0.549805, 0)) | ||||
85 | << QQuaternion(1, QVector3D(0.155273, 0.110352, 0)) | ||||
86 | << QQuaternion(1, QVector3D(0.313477, 0.329102, 0)); | ||||
87 | | ||||
88 | QTest::addRow("dell") | ||||
89 | << QByteArray::fromBase64("AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHowK0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg==") | ||||
90 | << QStringLiteral("xrandr-DELL U2410-F525M245AKLL") | ||||
91 | << QStringLiteral("DELL U2410") | ||||
92 | << QStringLiteral("DEL") | ||||
93 | << QStringList({QStringLiteral("DEL"), QStringLiteral("Dell Inc.")}) | ||||
94 | << QStringLiteral("F525M245AKLL") | ||||
95 | << QStringLiteral("") | ||||
96 | << QStringLiteral("be55eeb5fcc1e775f321c1ae3aa02ef0") | ||||
97 | << 52 << 32 << 2.2 | ||||
98 | << QQuaternion(1, QVector3D(0.679688, 0.308594, 0)) | ||||
99 | << QQuaternion(1, QVector3D(0.206055, 0.693359, 0)) | ||||
100 | << QQuaternion(1, QVector3D(0.151367, 0.0546875, 0)) | ||||
101 | << QQuaternion(1, QVector3D(0.313477, 0.329102, 0)); | ||||
102 | | ||||
103 | QTest::addRow("samsung") << QByteArray::fromBase64("AP///////wBMLcMFMzJGRQkUAQMOMx14Ku6Ro1RMmSYPUFQjCACBAIFAgYCVAKlAswABAQEBAjqAGHE4LUBYLEUA/h8RAAAeAAAA/QA4PB5REQAKICAgICAgAAAA/ABTeW5jTWFzdGVyCiAgAAAA/wBIOU1aMzAyMTk2CiAgAC4=") | ||||
104 | << QStringLiteral("xrandr-SyncMaster-H9MZ302196") | ||||
105 | << QStringLiteral("SyncMaster") | ||||
106 | << QStringLiteral("SAM") | ||||
107 | << QStringList({QStringLiteral("SAM"), QStringLiteral("Samsung Electric Company")}) | ||||
108 | << QStringLiteral("H9MZ302196") | ||||
109 | << QStringLiteral("") | ||||
110 | << QStringLiteral("9384061b2b87ad193f841e07d60e9e1a") | ||||
111 | << 51 << 29 << 2.2 | ||||
112 | << QQuaternion(1, QVector3D(0.639648, 0.328125, 0)) | ||||
113 | << QQuaternion(1, QVector3D(0.299805, 0.599609, 0)) | ||||
114 | << QQuaternion(1, QVector3D(0.150391, 0.0595703, 0)) | ||||
115 | << QQuaternion(1, QVector3D(0.3125, 0.329102, 0)); | ||||
116 | | ||||
117 | QTest::newRow("sharp") | ||||
118 | << QByteArray::fromBase64("AP///////wBNEEoUAAAAAB4ZAQSlHRF4Dt5Qo1RMmSYPUFQAAAABAQEBAQEBAQEBAQEBAQEBzZGAoMAINHAwIDUAJqUQAAAYpHSAoMAINHAwIDUAJqUQAAAYAAAA/gBSWE40OYFMUTEzM1oxAAAAAAACQQMoABIAAAsBCiAgAMw=") | ||||
119 | << QStringLiteral("xrandr-unknown") | ||||
120 | << QString() // unsure why, this screen reports no name | ||||
121 | << QStringLiteral("SHP") | ||||
122 | << QStringList({QStringLiteral("SHP"), QStringLiteral("Sharp Corporation")}) | ||||
123 | << QStringLiteral("") | ||||
124 | << QStringLiteral("RXN49\uFFFDLQ133Z1") | ||||
125 | << QStringLiteral("3627c3534e4c82871967b57237bf5b83") | ||||
126 | << 29 << 17 << 2.2 | ||||
127 | << QQuaternion(1, QVector3D(0.639648, 0.328125, 0)) | ||||
128 | << QQuaternion(1, QVector3D(0.299805, 0.599609, 0)) | ||||
129 | << QQuaternion(1, QVector3D(0.149414, 0.0595703, 0)) | ||||
130 | << QQuaternion(1, QVector3D(0.3125, 0.328125, 0)); | ||||
131 | } | ||||
132 | | ||||
133 | void TestEdid::testEdidParser() | ||||
134 | { | ||||
135 | QFETCH(QByteArray, raw_edid); | ||||
136 | QFETCH(QString, deviceId); | ||||
137 | QFETCH(QString, name); | ||||
138 | QFETCH(QString, pnpId); | ||||
139 | QFETCH(QStringList, vendor); | ||||
140 | QFETCH(QString, serial); | ||||
141 | QFETCH(QString, eisaId); | ||||
142 | QFETCH(QString, hash); | ||||
143 | QFETCH(int, width); | ||||
144 | QFETCH(int, height); | ||||
145 | QFETCH(qreal, gamma); | ||||
146 | QFETCH(QQuaternion, red); | ||||
147 | QFETCH(QQuaternion, green); | ||||
148 | QFETCH(QQuaternion, blue); | ||||
149 | QFETCH(QQuaternion, white); | ||||
150 | | ||||
151 | QScopedPointer<Edid> e(new Edid(raw_edid)); | ||||
152 | QCOMPARE(e->isValid(), true); | ||||
153 | | ||||
154 | // FIXME: we hard-code all deviceIds as xrandr-something, that makes no sense | ||||
155 | QCOMPARE(e->deviceId(), deviceId); | ||||
156 | QCOMPARE(e->name(), name); | ||||
157 | QCOMPARE(e->pnpId(), pnpId); | ||||
158 | // FIXME: needs to return at least the short ID | ||||
159 | // QVERIFY2(vendor.contains(e->vendor()), qPrintable(QString::fromLatin1("%1 not in list").arg(e->vendor()))); | ||||
160 | QCOMPARE(e->serial(), serial); | ||||
161 | QCOMPARE(e->eisaId(), eisaId); | ||||
162 | QCOMPARE(e->hash(), hash); | ||||
163 | QCOMPARE(e->width(), width); | ||||
164 | QCOMPARE(e->height(), height); | ||||
165 | QCOMPARE(e->gamma(), gamma); | ||||
166 | | ||||
167 | QVERIFY(qFuzzyCompare(e->red(), red)); | ||||
168 | QVERIFY(qFuzzyCompare(e->green(), green)); | ||||
169 | QVERIFY(qFuzzyCompare(e->blue(), blue)); | ||||
170 | QVERIFY(qFuzzyCompare(e->white(), white)); | ||||
171 | } | ||||
172 | | ||||
173 | QTEST_GUILESS_MAIN(TestEdid) | ||||
174 | | ||||
175 | #include "testedid.moc" |