summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoudhayan Gupta <me@BaloneyGeek.com>2015-09-25 22:55:22 (GMT)
committerBoudhayan Gupta <me@BaloneyGeek.com>2015-09-25 22:55:22 (GMT)
commit4c1a84e03e766fa942a34b11117447964b7d6afe (patch)
tree9734bc8c2202d7f37ab2c7cdeb3e002a8da5b9e6
parent0ad727fb51f049852b407c1ee4d39ef1c52bd79f (diff)
Add discinfo test
-rw-r--r--CMakeLists.txt1
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/testkcd.cpp70
3 files changed, 75 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f1e5712..2c92a93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@ include_directories(
)
add_subdirectory(src)
+add_subdirectory(tests)
# Additional
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..de55bbf
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,4 @@
+# test - sample test everything app
+
+add_executable(testkcd testkcd.cpp)
+target_link_libraries(testkcd KF5::CompactDisc)
diff --git a/tests/testkcd.cpp b/tests/testkcd.cpp
new file mode 100644
index 0000000..48182f6
--- /dev/null
+++ b/tests/testkcd.cpp
@@ -0,0 +1,70 @@
+#include <QObject>
+#include <QDebug>
+#include <QMetaObject>
+#include <QCoreApplication>
+#include <QtGlobal>
+
+#include <KCompactDisc/KCompactDisc>
+
+class TestKCD : public QObject
+{
+ Q_OBJECT
+
+ public:
+
+ explicit TestKCD(QObject *parent = 0) :
+ QObject(parent),
+ mKcd(new KCompactDisc(KCompactDisc::Asynchronous))
+ {}
+
+ virtual ~TestKCD()
+ {
+ mKcd->deleteLater();
+ }
+
+ public slots:
+
+ void doTest()
+ {
+ qDebug() << "Starting test";
+ qDebug() << "";
+
+ qDebug() << "We have" << mKcd->audioSystems().size() << "audo systems available:";
+ for (auto system: mKcd->audioSystems()) {
+ qDebug() << system;
+ }
+ qDebug() << "";
+
+ qDebug() << "We have" << mKcd->cdromDeviceNames().size() << "cdrom drives available:";
+ for (auto cdrom: mKcd->cdromDeviceNames()) {
+ qDebug() << cdrom;
+ }
+ qDebug() << "";
+
+ qDebug() << "The current cdrom drive loaded is:" << mKcd->deviceName();
+ qDebug() << "The disc device node url is:" << mKcd->deviceUrl();
+ qDebug() << "The disc status is" << mKcd->discStatus();
+ qDebug() << "Does the drive have a disc in it:" << !mKcd->isNoDisc();
+ qDebug() << "The number of tracks in the disc:" << mKcd->tracks();
+ qDebug() << "The current track no:" << mKcd->trackPosition();
+
+ qApp->exit();
+ }
+
+ private:
+
+ KCompactDisc *mKcd;
+};
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qDebug() << "Testing libKF5CompactDisc";
+ TestKCD test;
+ QMetaObject::invokeMethod(&test, "doTest", Qt::QueuedConnection);
+
+ return app.exec();
+}
+
+#include "testkcd.moc"