summaryrefslogtreecommitdiffstats
path: root/api/dead/test
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-09-18 22:53:37 +0200
committerPetr Mrázek <peterix@gmail.com>2016-09-18 22:53:37 +0200
commit69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91 (patch)
treea22a80b987212490371294f53e1f8bd698f1dad5 /api/dead/test
parenteb747e08b78d8630413b9bdb3a96108ccfcc2ac8 (diff)
downloadMultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar
MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar.gz
MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar.lz
MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.tar.xz
MultiMC-69f3ab019d4ef9e28d0c7e3c4ce3a609a6ff0a91.zip
NOISSUE delete dead code
Diffstat (limited to 'api/dead/test')
-rw-r--r--api/dead/test/tst_Resource.cpp116
1 files changed, 0 insertions, 116 deletions
diff --git a/api/dead/test/tst_Resource.cpp b/api/dead/test/tst_Resource.cpp
deleted file mode 100644
index 4bf41a03..00000000
--- a/api/dead/test/tst_Resource.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include <QTest>
-#include "TestUtil.h"
-
-#include "resources/Resource.h"
-#include "resources/ResourceHandler.h"
-#include "resources/ResourceObserver.h"
-
-class DummyStringResourceHandler : public ResourceHandler
-{
-public:
- explicit DummyStringResourceHandler(const QString &key)
- : m_key(key) {}
-
- void init(std::shared_ptr<ResourceHandler> &) override
- {
- setResult(m_key);
- }
-
- QString m_key;
-};
-class DummyObserver : public ResourceObserver
-{
-public:
- void resourceUpdated() override
- {
- values += get<QString>();
- }
-
- QStringList values;
-};
-class DummyObserverObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString property MEMBER property)
-
-public:
- explicit DummyObserverObject(QObject *parent = nullptr) : QObject(parent) {}
-
- QString property;
-};
-
-class ResourceTest : public QObject
-{
- Q_OBJECT
- private
- slots:
- void initTestCase()
- {
- Resource::registerHandler<DummyStringResourceHandler>("dummy");
- }
- void cleanupTestCase()
- {
- }
-
- void test_Then()
- {
- QString val;
- Resource::create("dummy:test_Then")
- ->then([&val](const QString &key) { val = key; });
- QCOMPARE(val, QStringLiteral("test_Then"));
- }
- void test_Object()
- {
- DummyObserver *observer = new DummyObserver;
- Resource::create("dummy:test_Object")->applyTo(observer);
- QCOMPARE(observer->values, QStringList() << "test_Object");
- }
- void test_QObjectProperty()
- {
- DummyObserverObject *object = new DummyObserverObject;
- Resource::create("dummy:test_QObjectProperty")->applyTo(object);
- QCOMPARE(object->property, QStringLiteral("test_QObjectProperty"));
- }
-
- void test_DontRequestPlaceholder()
- {
- // since dummy:asdf immediently gives a value we should not get the placeholder
- Resource::create("dummy:asdf", Resource::create("dummy:fdsa"))
- ->then([](const QString &key) { QCOMPARE(key, QStringLiteral("asdf")); });
- }
-
- void test_MergedResources()
- {
- auto r1 = Resource::create("dummy:asdf");
- auto r2 = Resource::create("dummy:asdf");
- auto r3 = Resource::create("dummy:fdsa");
- auto r4 = Resource::create("dummy:asdf");
-
- QCOMPARE(r1, r2);
- QCOMPARE(r1, r4);
- QVERIFY(r1 != r3);
- QVERIFY(r2 != r3);
- QVERIFY(r4 != r3);
- }
-
- void test_MergedResourceWithPlaceholder()
- {
- auto p1 = Resource::create("dummy:placeA");
- auto p2 = Resource::create("dummy:placeB");
-
- auto r1 = Resource::create("dummy:asdf");
- auto r2 = Resource::create("dummy:asdf", p1);
- auto r3 = Resource::create("dummy:asdf", p2);
- auto r4 = Resource::create("dummy:asdf", p1);
-
- QCOMPARE(r2, r4);
- QVERIFY(r1 != r2);
- QVERIFY(r1 != r3);
- QVERIFY(r1 != r4);
- QVERIFY(r2 != r3);
- }
-};
-
-QTEST_GUILESS_MAIN(ResourceTest)
-
-#include "tst_Resource.moc"