[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Calligra] dc69e3e: Added unit tests for KoInputDevice
From:       Hanna Skott <hanna.et.scott () gmail ! com>
Date:       2011-01-15 21:42:20
Message-ID: 20110115214220.8E134A6092 () git ! kde ! org
[Download RAW message or body]

commit dc69e3ea385e9a19b725a9a8a104c1fe80917b57
branch master
Author: Hanna Skott <hanna.et.scott@gmail.com>
Date:   Sat Jan 15 21:25:04 2011 +0100

    Added unit tests for KoInputDevice

diff --git a/libs/flake/KoInputDevice.cpp b/libs/flake/KoInputDevice.cpp
index a12a538..bd1b235 100644
--- a/libs/flake/KoInputDevice.cpp
+++ b/libs/flake/KoInputDevice.cpp
@@ -74,7 +74,7 @@ bool KoInputDevice::isMouse() const
 {
     return d->mouse;
 }
-
+ 
 
 bool KoInputDevice::operator==(const KoInputDevice &other) const
 {
@@ -102,6 +102,7 @@ KoInputDevice KoInputDevice::mouse()
     KoInputDevice id;
     return id;
 }
+
 // static
 KoInputDevice KoInputDevice::stylus()
 {
diff --git a/libs/flake/tests/TestInputDevice.cpp \
b/libs/flake/tests/TestInputDevice.cpp index 8b5922f..d01b4e7 100644
--- a/libs/flake/tests/TestInputDevice.cpp
+++ b/libs/flake/tests/TestInputDevice.cpp
@@ -21,13 +21,77 @@
 #include "TestInputDevice.h"
 
 #include <qtest_kde.h>
+#include "KoInputDevice.h"
+
+
+void TestInputDevice::testTabletConstructor()
+{
+  QTabletEvent::TabletDevice parameterTabletDevice = QTabletEvent::Stylus;
+  QTabletEvent::PointerType parameterPointerType = QTabletEvent::Eraser; 
+  qint64 parameterUniqueTabletId = 0;
+  KoInputDevice toTest(parameterTabletDevice, parameterPointerType, \
parameterUniqueTabletId); +  bool isMouse = toTest.isMouse();
+  QVERIFY(!isMouse);
+}
+
+void TestInputDevice::testNoParameterConstructor()
+{
+  KoInputDevice toTest;
+  bool isMouse = toTest.isMouse();
+  qint64 theUniqueTabletId = toTest.uniqueTabletId();
+  qint64 toCompareWith = -1;
+  QVERIFY(isMouse);
+  QCOMPARE(theUniqueTabletId, toCompareWith);
+}
+
+void TestInputDevice::testConstructorWithSingleReference()
+{
+  QTabletEvent::TabletDevice parameterTabletDevice = QTabletEvent::Stylus;
+  QTabletEvent::PointerType parameterPointerType = QTabletEvent::Eraser; 
+  qint64 parameterUniqueTabletId = 0;
+  KoInputDevice parameterTabletDevice2(parameterTabletDevice, parameterPointerType, \
parameterUniqueTabletId); +  KoInputDevice toTest(parameterTabletDevice2);
+  bool isMouse = toTest.isMouse();
+  QVERIFY(!isMouse);
+  KoInputDevice parameterMouseDevice;
+  toTest = KoInputDevice(parameterMouseDevice);
+  isMouse = toTest.isMouse();
+  QVERIFY(isMouse);
+}
+
+void TestInputDevice::testEqualityCheckOperator()
+{
+  QTabletEvent::TabletDevice parameterTabletDevice = QTabletEvent::Stylus;
+  QTabletEvent::PointerType parameterPointerType = QTabletEvent::Eraser; 
+  qint64 parameterUniqueTabletId = 0;
+  KoInputDevice parameterTabletDevice2(parameterTabletDevice, parameterPointerType, \
parameterUniqueTabletId); +  KoInputDevice toTest(parameterTabletDevice2);
+  KoInputDevice copy = toTest;
+  KoInputDevice notSame;
+  QVERIFY(toTest==copy);
+  QVERIFY(toTest!=notSame);
+}
 
 void TestInputDevice::testMouse()
 {
-    int a = 2;
-    QVERIFY(true);
-    QCOMPARE(a, 2);
+  KoInputDevice toTest = KoInputDevice::mouse();
+  bool isMouse = toTest.isMouse();
+  QVERIFY(isMouse);
+    //QCOMPARE(a, 2);
 }
+void TestInputDevice::testStylus()
+{
+  KoInputDevice toTest = KoInputDevice::stylus();
+  bool isMouse = toTest.isMouse();
+  QVERIFY(!isMouse);
+}
+void TestInputDevice::testEraser()
+{
+  KoInputDevice toTest = KoInputDevice::eraser();
+  bool isMouse = toTest.isMouse();
+  QVERIFY(!isMouse);
+}
+
 
 QTEST_KDEMAIN(TestInputDevice, GUI)
 #include <TestInputDevice.moc>
diff --git a/libs/flake/tests/TestInputDevice.h b/libs/flake/tests/TestInputDevice.h
index 7e36aa9..aa1fd44 100644
--- a/libs/flake/tests/TestInputDevice.h
+++ b/libs/flake/tests/TestInputDevice.h
@@ -28,7 +28,14 @@ class TestInputDevice : public QObject
     Q_OBJECT
 private slots:
     // tests
+    void testTabletConstructor();
+    void testNoParameterConstructor();
+    void testConstructorWithSingleReference();
+    void testEqualityCheckOperator();
     void testMouse();
+    void testStylus();
+    void testEraser();
+    
 };
 
 #endif /* TESTINPUTDEVICE_H */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic