-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lockscreen call to system API, add more tests
- Loading branch information
Showing
14 changed files
with
216 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "test_Event_Device.h" | ||
|
||
#include <liboxide/event_device.h> | ||
|
||
test_Event_Device::test_Event_Device(){ } | ||
test_Event_Device::~test_Event_Device(){ } | ||
|
||
void test_Event_Device::test_create_device(){ | ||
auto ev = Oxide::event_device::create_event(0, 0, 0); | ||
QCOMPARE(ev.type, 0); | ||
QCOMPARE(ev.code, 0); | ||
QCOMPARE(ev.value, 0); | ||
ev = Oxide::event_device::create_event(1, 1, 1); | ||
QCOMPARE(ev.type, 1); | ||
QCOMPARE(ev.code, 1); | ||
QCOMPARE(ev.value, 1); | ||
} | ||
|
||
void test_Event_Device::test_event_device(){ | ||
Oxide::event_device event0("/dev/input/event0", O_RDWR); | ||
QCOMPARE(event0.device, "/dev/input/event0"); | ||
QVERIFY(!event0.locked); | ||
event0.lock(); | ||
QVERIFY(event0.locked); | ||
event0.unlock(); | ||
QVERIFY(!event0.locked); | ||
QVERIFY(event0.fd > 0); | ||
input_absinfo absInfo; | ||
memset(&absInfo, 0, sizeof(input_absinfo)); | ||
ioctl(event0.fd, EVIOCGABS(ABS_MT_POSITION_X), &absInfo); | ||
QCOMPARE(event0.abs_info(ABS_MT_POSITION_X).maximum, absInfo.maximum); | ||
// TODO - test ev_syn | ||
// TODO - test ev_dropped | ||
// TODO - test write | ||
event0.close(); | ||
QCOMPARE(event0.fd, 0); | ||
} | ||
|
||
DECLARE_TEST(test_Event_Device) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#pragma once | ||
#include "autotest.h" | ||
|
||
class test_Event_Device : public QObject{ | ||
Q_OBJECT | ||
|
||
public: | ||
test_Event_Device(); | ||
~test_Event_Device(); | ||
|
||
private slots: | ||
void test_create_device(); | ||
void test_event_device(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "test_Json.h" | ||
|
||
#include <liboxide/json.h> | ||
#include <QJsonObject> | ||
|
||
test_Json::test_Json(){ } | ||
test_Json::~test_Json(){ } | ||
|
||
void test_Json::test_decodeDBusArgument(){ | ||
// TODO - Oxide::JSON::decodeDBusArgument(); | ||
} | ||
|
||
void test_Json::test_sanitizeForJson(){ | ||
// TODO - Oxide::JSON::sanitizeForJson(); | ||
} | ||
|
||
void test_Json::test_toJson(){ | ||
QCOMPARE(Oxide::JSON::toJson(QVariant()), "null"); | ||
QCOMPARE(Oxide::JSON::toJson(true), "true"); | ||
QCOMPARE(Oxide::JSON::toJson(false), "false"); | ||
QCOMPARE(Oxide::JSON::toJson(10), "10"); | ||
QCOMPARE(Oxide::JSON::toJson(10.1), "10.1"); | ||
QCOMPARE(Oxide::JSON::toJson("10"), "\"10\""); | ||
QJsonObject obj; | ||
obj.insert("value", 10); | ||
QCOMPARE(Oxide::JSON::toJson(obj), "{\"value\":10}"); | ||
QCOMPARE(Oxide::JSON::toJson(obj, QJsonDocument::Indented), "{\n \"value\": 10\n}\n"); | ||
QJsonArray arr; | ||
arr.append(10); | ||
arr.append("10"); | ||
QCOMPARE(Oxide::JSON::toJson(arr), "[10,\"10\"]"); | ||
QCOMPARE(Oxide::JSON::toJson(arr, QJsonDocument::Indented), "[\n 10,\n \"10\"\n]\n"); | ||
} | ||
|
||
void test_Json::test_fromJson(){ | ||
QVariant variant = Oxide::JSON::fromJson("null"); | ||
QVERIFY(variant.isNull()); | ||
variant = Oxide::JSON::fromJson("true"); | ||
QVERIFY(variant.isValid()); | ||
QVERIFY(!variant.isNull()); | ||
QCOMPARE(variant.toBool(), true); | ||
variant = Oxide::JSON::fromJson("false"); | ||
QVERIFY(variant.isValid()); | ||
QVERIFY(!variant.isNull()); | ||
QCOMPARE(variant.toBool(), false); | ||
variant = Oxide::JSON::fromJson("1"); | ||
QVERIFY(variant.isValid()); | ||
QVERIFY(!variant.isNull()); | ||
QCOMPARE(variant.toInt(), 1); | ||
variant = Oxide::JSON::fromJson("\"1\""); | ||
QVERIFY(variant.isValid()); | ||
QVERIFY(!variant.isNull()); | ||
QCOMPARE(variant.toString(), "1"); | ||
variant = Oxide::JSON::fromJson("{\"value\": 10}"); | ||
QVERIFY(variant.isValid()); | ||
QVERIFY(!variant.isNull()); | ||
QJsonObject obj = variant.toJsonObject(); | ||
QVERIFY(obj.keys().contains("value")); | ||
QCOMPARE(obj.value("value"), 10); | ||
variant = Oxide::JSON::fromJson("[10, \"10\"]"); | ||
QVERIFY(variant.isValid()); | ||
QVERIFY(!variant.isNull()); | ||
QJsonArray arr = variant.toJsonArray(); | ||
QCOMPARE(arr.count(), 2); | ||
QJsonValue value = arr.first(); | ||
QVERIFY(value.isDouble()); | ||
QCOMPARE(value.toDouble(), 10); | ||
value = arr.last(); | ||
QVERIFY(value.isString()); | ||
QCOMPARE(value.toString(), "10"); | ||
} | ||
|
||
DECLARE_TEST(test_Json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#pragma once | ||
#include "autotest.h" | ||
|
||
class test_Json : public QObject{ | ||
Q_OBJECT | ||
|
||
public: | ||
test_Json(); | ||
~test_Json(); | ||
|
||
private slots: | ||
void test_decodeDBusArgument(); | ||
void test_sanitizeForJson(); | ||
void test_toJson(); | ||
void test_fromJson(); | ||
}; |