32 #include <xqkeycapture.h> |
32 #include <xqkeycapture.h> |
33 #include <QFile> |
33 #include <QFile> |
34 |
34 |
35 const int KAllFlagsOn = XQKeyCapture::CaptureBasic | |
35 const int KAllFlagsOn = XQKeyCapture::CaptureBasic | |
36 XQKeyCapture::CaptureCallHandlingExt | |
36 XQKeyCapture::CaptureCallHandlingExt | |
|
37 XQKeyCapture::CaptureSideKeys | |
37 XQKeyCapture::CaptureEnableRemoteExtEvents; |
38 XQKeyCapture::CaptureEnableRemoteExtEvents; |
38 const Qt::Key KNotSpecifiedKey = Qt::Key_F35; |
39 const Qt::Key KNotSpecifiedKey = Qt::Key_F35; |
39 |
40 |
40 class TestXQKeyCapture : public QObject |
41 class TestXQKeyCapture : public QObject |
41 { |
42 { |
57 void testCaptureKey(); |
58 void testCaptureKey(); |
58 |
59 |
59 void testCaptureKeyList_data(); |
60 void testCaptureKeyList_data(); |
60 void testCaptureKeyList(); |
61 void testCaptureKeyList(); |
61 |
62 |
62 void testCaptureKey_S60_data(); |
63 void testCaptureKey_S60_data(); |
63 void testCaptureKey_S60(); |
64 void testCaptureKey_S60(); |
64 |
65 |
65 void testCaptureKeyList_S60_data(); |
66 void testCaptureKeyList_S60_data(); |
66 void testCaptureKeyList_S60(); |
67 void testCaptureKeyList_S60(); |
67 |
68 |
68 void testCaptureKeyUpAndDowns_data(); |
69 void testCaptureKeyUpAndDowns_data(); |
69 void testCaptureKeyUpAndDowns(); |
70 void testCaptureKeyUpAndDowns(); |
70 |
71 |
71 void testCaptureKeyUpAndDownsList_data(); |
72 void testCaptureKeyUpAndDownsList_data(); |
153 void testCancelCaptureRemoteKeys(); |
154 void testCancelCaptureRemoteKeys(); |
154 |
155 |
155 |
156 |
156 void testErrorString(); |
157 void testErrorString(); |
157 void testErrorId(); |
158 void testErrorId(); |
158 |
159 |
159 void testKeyMapperFile(); |
160 void testKeyMapperFile(); |
160 |
161 |
161 private: |
162 private: |
162 QString clearString(const QString& line); |
163 QString clearString(const QString& line); |
163 QString clearString(const QString& line, const QString& prefix, const QString& comment); |
164 QString clearString(const QString& line, const QString& prefix, const QString& comment); |
164 void setProperKeys(bool extended); |
165 void setProperKeys(bool extended); |
165 |
166 |
166 private: |
167 private: |
167 XQKeyCapture* keyCapture; |
168 XQKeyCapture* keyCapture; |
168 |
169 |
169 Qt::Key aKey; |
170 Qt::Key aKey; |
331 << static_cast<unsigned int>(0) |
332 << static_cast<unsigned int>(0) |
332 << static_cast<long int>(12) |
333 << static_cast<long int>(12) |
333 << true |
334 << true |
334 << static_cast<unsigned int>(EKeyRightCtrl); |
335 << static_cast<unsigned int>(EKeyRightCtrl); |
335 |
336 |
336 QTest::newRow("meta_key") << static_cast<unsigned int>(Qt::Key_Super_R) |
337 QTest::newRow("meta_keyR") << static_cast<unsigned int>(Qt::Key_Super_R) |
337 << static_cast<unsigned int>(Qt::NoModifier) |
338 << static_cast<unsigned int>(Qt::NoModifier) |
338 << static_cast<unsigned int>(Qt::NoModifier) |
339 << static_cast<unsigned int>(Qt::NoModifier) |
339 << static_cast<unsigned int>(EKeyRightFunc) |
340 << static_cast<unsigned int>(EKeyRightFunc) |
340 << static_cast<unsigned int>(0) |
341 << static_cast<unsigned int>(0) |
341 << static_cast<unsigned int>(0) |
342 << static_cast<unsigned int>(0) |
342 << static_cast<long int>(12) |
343 << static_cast<long int>(12) |
343 << true |
344 << false |
344 << static_cast<unsigned int>(EKeyRightFunc); |
345 << static_cast<unsigned int>(0); |
|
346 QTest::newRow("meta_keyL") << static_cast<unsigned int>(Qt::Key_Super_L) |
|
347 << static_cast<unsigned int>(Qt::NoModifier) |
|
348 << static_cast<unsigned int>(Qt::NoModifier) |
|
349 << static_cast<unsigned int>(EKeyLeftFunc) |
|
350 << static_cast<unsigned int>(0) |
|
351 << static_cast<unsigned int>(0) |
|
352 << static_cast<long int>(12) |
|
353 << false |
|
354 << static_cast<unsigned int>(0); |
345 } |
355 } |
346 |
356 |
347 void TestXQKeyCapture::testCaptureKey() |
357 void TestXQKeyCapture::testCaptureKey() |
348 { |
358 { |
349 numOfArgs = 3; |
359 numOfArgs = 3; |
479 << static_cast<unsigned int>(Qt::NoModifier) |
489 << static_cast<unsigned int>(Qt::NoModifier) |
480 << static_cast<unsigned int>(EKeyRightCtrl) |
490 << static_cast<unsigned int>(EKeyRightCtrl) |
481 << static_cast<unsigned int>(0) |
491 << static_cast<unsigned int>(0) |
482 << static_cast<unsigned int>(0) |
492 << static_cast<unsigned int>(0) |
483 << static_cast<long int>(12) |
493 << static_cast<long int>(12) |
484 << true |
494 << false |
485 << static_cast<unsigned int>(EKeyRightFunc); |
495 << static_cast<unsigned int>(0); |
486 |
496 |
487 QTest::newRow("meta_key") << static_cast<unsigned int>(EKeyLeftCtrl) |
497 QTest::newRow("meta_key") << static_cast<unsigned int>(EKeyRightFunc) |
488 << static_cast<unsigned int>(Qt::NoModifier) |
498 << static_cast<unsigned int>(Qt::NoModifier) |
489 << static_cast<unsigned int>(Qt::NoModifier) |
499 << static_cast<unsigned int>(Qt::NoModifier) |
490 << static_cast<unsigned int>(EKeyLeftCtrl) |
500 << static_cast<unsigned int>(EKeyRightFunc) |
491 << static_cast<unsigned int>(0) |
501 << static_cast<unsigned int>(0) |
492 << static_cast<unsigned int>(0) |
502 << static_cast<unsigned int>(0) |
493 << static_cast<long int>(12) |
503 << static_cast<long int>(12) |
494 << true |
504 << false |
495 << static_cast<unsigned int>(EKeyLeftFunc); |
505 << static_cast<unsigned int>(0); |
496 |
506 QTest::newRow("meta_keyL") << static_cast<unsigned int>(EKeyLeftFunc) |
|
507 << static_cast<unsigned int>(Qt::NoModifier) |
|
508 << static_cast<unsigned int>(Qt::NoModifier) |
|
509 << static_cast<unsigned int>(EKeyLeftFunc) |
|
510 << static_cast<unsigned int>(0) |
|
511 << static_cast<unsigned int>(0) |
|
512 << static_cast<long int>(12) |
|
513 << false |
|
514 << static_cast<unsigned int>(0); |
497 |
515 |
498 } |
516 } |
499 |
517 |
500 void TestXQKeyCapture::testCaptureKey_S60() |
518 void TestXQKeyCapture::testCaptureKey_S60() |
501 { |
519 { |
524 |
542 |
525 additionalResults.clear(); |
543 additionalResults.clear(); |
526 additionalResults << additionalSymbianKey << symbianMask << symbianModifier; |
544 additionalResults << additionalSymbianKey << symbianMask << symbianModifier; |
527 |
545 |
528 MyTestWindowGroup::Instance()->setRequestNumber(reqNum); |
546 MyTestWindowGroup::Instance()->setRequestNumber(reqNum); |
|
547 |
529 keyCapture->captureKey(static_cast<TUint>(s60Key), Qt::KeyboardModifier(qtMask), Qt::KeyboardModifier(qtModifier)); |
548 keyCapture->captureKey(static_cast<TUint>(s60Key), Qt::KeyboardModifier(qtMask), Qt::KeyboardModifier(qtModifier)); |
530 } |
549 } |
531 |
550 |
532 void TestXQKeyCapture::testCaptureKeyList_S60_data() |
551 void TestXQKeyCapture::testCaptureKeyList_S60_data() |
533 { |
552 { |
1625 void TestXQKeyCapture::testCaptureRemoteKeys_data() |
1644 void TestXQKeyCapture::testCaptureRemoteKeys_data() |
1626 { |
1645 { |
1627 QTest::addColumn<unsigned int>("flags"); |
1646 QTest::addColumn<unsigned int>("flags"); |
1628 |
1647 |
1629 // there are 4 flags: |
1648 // there are 4 flags: |
1630 // XQKeyCapture::CaptureNone = 0x0 |
1649 // CaptureNone = 0x0, |
1631 // XQKeyCapture::CaptureBasic = 0x1 |
1650 // CaptureBasic = 0x1, |
1632 // XQKeyCapture::CaptureCallHandlingExt = 0x2 |
1651 // CaptureCallHandlingExt = 0x2, |
1633 // XQKeyCapture::CaptureEnableRemoteExtEvents = 0x4 |
1652 // CaptureSideKeys = 0x4, // for future use |
|
1653 // CaptureEnableRemoteExtEvents = 0x4000 |
1634 // so we should iterate through all combinations: |
1654 // so we should iterate through all combinations: |
1635 for(unsigned int i(0); i <= KAllFlagsOn; ++i) { |
1655 for(unsigned int i(0); i <= KAllFlagsOn; ++i) { |
1636 QString desc("flag:0x" + QString::number(i,16)); |
1656 QString desc("flag:0x" + QString::number(i,16)); |
1637 QTest::newRow(desc.toAscii()) << i ; |
1657 QTest::newRow(desc.toAscii()) << i ; |
1638 } |
1658 } |
|
1659 |
1639 } |
1660 } |
1640 |
1661 |
1641 void TestXQKeyCapture::testCaptureRemoteKeys() |
1662 void TestXQKeyCapture::testCaptureRemoteKeys() |
1642 { |
1663 { |
1643 QFETCH(unsigned int, flags); |
1664 QFETCH(unsigned int, flags); |
1982 QVERIFY(wgat == actionType); |
2003 QVERIFY(wgat == actionType); |
1983 QVERIFY(paramList.count() == numOfArgs); |
2004 QVERIFY(paramList.count() == numOfArgs); |
1984 |
2005 |
1985 for(int i = 0; i < numOfArgs; i++) |
2006 for(int i = 0; i < numOfArgs; i++) |
1986 { |
2007 { |
1987 if(additionalResult) |
2008 if(additionalResult) { |
1988 QVERIFY(paramList[i] == additionalResults[i]); |
2009 QVERIFY2(paramList[i] == additionalResults[i],QString("Unequal [1]: %1 != %2").arg(paramList[i]).arg(additionalResults[i]).toLatin1().data()); |
1989 else |
2010 } else { |
1990 QVERIFY(paramList[i] == results[i]); |
2011 QVERIFY2(paramList[i] == results[i], QString("Unequal [2]: %1 != %2").arg(paramList[i]).arg(results[i]).toLatin1().data()); |
|
2012 } |
1991 } |
2013 } |
1992 } |
2014 } |
1993 if(willBeAdditionalRequest){ |
2015 if(willBeAdditionalRequest){ |
1994 additionalResult = true; |
2016 additionalResult = true; |
1995 MyTestWindowGroup::Instance()->setRequestNumber(additionalRequestHandle); |
2017 MyTestWindowGroup::Instance()->setRequestNumber(additionalRequestHandle); |
2048 //////////////////////////////////////////////////////////////// |
2070 //////////////////////////////////////////////////////////////// |
2049 // MAIN |
2071 // MAIN |
2050 //main |
2072 //main |
2051 //////////////////////////////////////////////////////////////// |
2073 //////////////////////////////////////////////////////////////// |
2052 |
2074 |
|
2075 #define _XQKEYCAPTURE_UNITTEST_LOG_TO_C_ |
|
2076 |
2053 #ifdef _XQKEYCAPTURE_UNITTEST_LOG_TO_C_ |
2077 #ifdef _XQKEYCAPTURE_UNITTEST_LOG_TO_C_ |
2054 main(int argc, char* argv[]) |
2078 int main(int argc, char* argv[]) |
2055 { |
2079 { |
2056 QApplication app(argc, argv); |
2080 QApplication app(argc, argv); |
2057 TestXQKeyCapture tc; |
2081 TestXQKeyCapture tc; |
2058 int c = 3; |
2082 int c = 3; |
2059 char* v[] = {argv[0], "-o", "c:/test.txt"}; |
2083 char* v[] = {argv[0], "-o", "c:/test.txt"}; |