phoneengine/parserrecognizer/tsrc/ut_parserrecognizer/unit_tests.cpp
changeset 30 ebdbd102c78a
parent 21 92ab7f8d0eab
equal deleted inserted replaced
27:2f8f8080a020 30:ebdbd102c78a
    23 #include "pevirtualengine.h"
    23 #include "pevirtualengine.h"
    24 
    24 
    25 QString apiString;
    25 QString apiString;
    26 QString methodString;
    26 QString methodString;
    27 bool sendCalled;
    27 bool sendCalled;
       
    28 bool gSendRequestResult = true;
    28 
    29 
    29 class TestParserRecognizer : public QObject
    30 class TestParserRecognizer : public QObject
    30 {
    31 {
    31     Q_OBJECT
    32     Q_OBJECT
    32 public:
    33 public:
    48     void testActivateBTDebugMode();
    49     void testActivateBTDebugMode();
    49     void testShowIMEI();
    50     void testShowIMEI();
    50     void testShowVersion();
    51     void testShowVersion();
    51     void testShowWLANMacAddress();
    52     void testShowWLANMacAddress();
    52     void testSSRequestFailed();
    53     void testSSRequestFailed();
       
    54     void testSendRequestFail();
       
    55     void testSimultaneousRequests();
    53 
    56 
    54 private:
    57 private:
    55     ParserRecognizer *parserRecognizer; // class under test
    58     ParserRecognizer *parserRecognizer; // class under test
    56 };
    59 };
    57 
    60 
    60     Q_UNUSED(sync);
    63     Q_UNUSED(sync);
    61     apiString = api;
    64     apiString = api;
    62     methodString = method;
    65     methodString = method;
    63 }
    66 }
    64 
    67 
       
    68 bool XQServiceRequest::send()
       
    69 {
       
    70     sendCalled = true;
       
    71     return gSendRequestResult;
       
    72 }
       
    73 
    65 bool XQServiceRequest::send(QVariant& retValue)
    74 bool XQServiceRequest::send(QVariant& retValue)
    66 {
    75 {
    67     Q_UNUSED(retValue);
    76     Q_UNUSED(retValue);
    68     sendCalled = true;
    77     sendCalled = true;
    69     return true;
    78     return gSendRequestResult;
       
    79 }
       
    80 
       
    81 void XQServiceRequest::setSynchronous(const bool &synchronous)
       
    82 {
       
    83     Q_UNUSED(synchronous);
    70 }
    84 }
    71 
    85 
    72 XQServiceRequest::~XQServiceRequest()
    86 XQServiceRequest::~XQServiceRequest()
    73 {
    87 {
    74 }
    88 }
    92 void TestParserRecognizer::init ()
   106 void TestParserRecognizer::init ()
    93 {
   107 {
    94     apiString = "";
   108     apiString = "";
    95     methodString = "";
   109     methodString = "";
    96     sendCalled = false;
   110     sendCalled = false;
       
   111     gSendRequestResult = true;
    97     parserRecognizer = new ParserRecognizer;
   112     parserRecognizer = new ParserRecognizer;
    98 }
   113 }
    99 
   114 
   100 void TestParserRecognizer::cleanup ()
   115 void TestParserRecognizer::cleanup ()
   101 {
   116 {
   118     QCOMPARE(sendCalled, true);
   133     QCOMPARE(sendCalled, true);
   119 }
   134 }
   120 
   135 
   121 void TestParserRecognizer::testActivateWarrantyMode()
   136 void TestParserRecognizer::testActivateWarrantyMode()
   122 {
   137 {
       
   138     // Lifetimer is implemented by phone and should not be handled 
       
   139     // by the recognizer.
   123     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageActivateWarrantyMode, 0);
   140     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageActivateWarrantyMode, 0);
   124     QCOMPARE(apiString, QString("com.nokia.services.telephony"));
   141     QCOMPARE(apiString, QString(""));
   125     QCOMPARE(methodString, QString("activateWarrantyMode()"));
   142     QCOMPARE(methodString, QString(""));
   126     QCOMPARE(sendCalled, true);
   143     QCOMPARE(sendCalled, false);
   127 }
   144 }
   128 
   145 
   129 void TestParserRecognizer::testShowBTDeviceAddress()
   146 void TestParserRecognizer::testShowBTDeviceAddress()
   130 {
   147 {
   131     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowBTDeviceAddress, 0);
   148     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowBTDeviceAddress, 0);
   150     QCOMPARE(sendCalled, true);
   167     QCOMPARE(sendCalled, true);
   151 }
   168 }
   152 
   169 
   153 void TestParserRecognizer::testShowIMEI()
   170 void TestParserRecognizer::testShowIMEI()
   154 {
   171 {
       
   172     // IMEI code showing is implemented by phone and should not be handled 
       
   173     // by the recognizer.
   155     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowIMEI, 0);
   174     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowIMEI, 0);
   156     QCOMPARE(apiString, QString("com.nokia.services.telephony"));
   175     QCOMPARE(apiString, QString(""));
   157     QCOMPARE(methodString, QString("showIMEICode()"));
   176     QCOMPARE(methodString, QString(""));
   158     QCOMPARE(sendCalled, true);
   177     QCOMPARE(sendCalled, false);
   159 }
   178 }
   160 
   179 
   161 void TestParserRecognizer::testShowVersion()
   180 void TestParserRecognizer::testShowVersion()
   162 {
   181 {
   163     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowVersion, 0);
   182     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowVersion, 0);
   164     QCOMPARE(apiString, QString("com.nokia.services.telephony"));
   183     QCOMPARE(apiString, QString("com.nokia.services.devicemanager"));
   165     QCOMPARE(methodString, QString("showVersionNumber()"));
   184     QCOMPARE(methodString, QString("showVersionNumber()"));
   166     QCOMPARE(sendCalled, true);
   185     QCOMPARE(sendCalled, true);
   167 }
   186 }
   168 
   187 
   169 void TestParserRecognizer::testShowWLANMacAddress()
   188 void TestParserRecognizer::testShowWLANMacAddress()
   170 {
   189 {
       
   190     // WLAN address showing not supported currently (TB 10.1)
   171     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowWlanMacAddress, 0);
   191     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowWlanMacAddress, 0);
   172     QCOMPARE(apiString, QString("com.nokia.services.wlan"));
   192     QCOMPARE(apiString, QString(""));
   173     QCOMPARE(methodString, QString("showWLANMacAddress()"));
   193     QCOMPARE(methodString, QString(""));
   174     QCOMPARE(sendCalled, true);
   194     QCOMPARE(sendCalled, false);
   175 }
   195 }
   176 
   196 
   177 void TestParserRecognizer::testSSRequestFailed()
   197 void TestParserRecognizer::testSSRequestFailed()
   178 {
   198 {
   179     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageSSRequestFailed, 0);
   199     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageSSRequestFailed, 0);
   180     QCOMPARE(apiString, QString("com.nokia.services.telephony"));
   200     QCOMPARE(apiString, QString("com.nokia.services.telephony"));
   181     QCOMPARE(methodString, QString("supplementaryServiceRequestFailed()"));
   201     QCOMPARE(methodString, QString("supplementaryServiceRequestFailed()"));
   182     QCOMPARE(sendCalled, true);
   202     QCOMPARE(sendCalled, true);
   183 }
   203 }
   184 
   204 
       
   205 void TestParserRecognizer::testSendRequestFail()
       
   206 {
       
   207     gSendRequestResult = false;
       
   208     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowVersion, 0);
       
   209     QCOMPARE(apiString, QString("com.nokia.services.devicemanager"));
       
   210     QCOMPARE(methodString, QString("showVersionNumber()"));
       
   211     QCOMPARE(sendCalled, true);
       
   212 }
       
   213 
       
   214 void TestParserRecognizer::testSimultaneousRequests()
       
   215 {
       
   216     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowVersion, 0);
       
   217     QCOMPARE(apiString, QString("com.nokia.services.devicemanager"));
       
   218     QCOMPARE(methodString, QString("showVersionNumber()"));
       
   219     QCOMPARE(sendCalled, true);
       
   220     
       
   221     sendCalled = false;
       
   222     parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowVersion, 0);
       
   223     QCOMPARE(sendCalled, false);
       
   224 }
       
   225 
   185 QTEST_MAIN(TestParserRecognizer)
   226 QTEST_MAIN(TestParserRecognizer)
   186 #include "unit_tests.moc"
   227 #include "unit_tests.moc"