telutils/keysequencerecognitionservice/tsrc/ut_imeikeysequencehandler/ut_imeikeysequencehandler.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
       
     1 /*!
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtGui>
       
    19 #include <QtTest/QtTest>
       
    20 #include <qsysteminfo.h>
       
    21 #include <hbdevicemessagebox.h>
       
    22 #include "ut_imeikeysequencehandler.h"
       
    23 #include "imeikeysequencehandler.h"
       
    24 #include "keysequencerecognitionservicedefs.h"
       
    25 #include "qtestmains60.h"
       
    26 
       
    27 QTM_USE_NAMESPACE
       
    28 
       
    29 UT_ImeiKeySequenceHandler::UT_ImeiKeySequenceHandler()
       
    30     : 
       
    31     m_handler(0)
       
    32 {
       
    33     
       
    34 }
       
    35 
       
    36 
       
    37 UT_ImeiKeySequenceHandler::~UT_ImeiKeySequenceHandler()
       
    38 {
       
    39     delete m_handler;
       
    40 }
       
    41 
       
    42 
       
    43 void UT_ImeiKeySequenceHandler::init()
       
    44 {
       
    45     initialize();
       
    46     
       
    47     m_handler = new ImeiKeySequenceHandler();
       
    48 }
       
    49 
       
    50 
       
    51 void UT_ImeiKeySequenceHandler::cleanup()
       
    52 {
       
    53     reset();
       
    54     
       
    55     delete m_handler;
       
    56     m_handler = 0;
       
    57 }
       
    58 
       
    59 
       
    60 void UT_ImeiKeySequenceHandler::t_keySequenceValidator()
       
    61 {
       
    62     expect("KeySequenceHandler::setKeySequenceValidator")
       
    63         .with(QRegExp::escape(KCodeImei));
       
    64     
       
    65     QScopedPointer<ImeiKeySequenceHandler> handler(
       
    66         new ImeiKeySequenceHandler());
       
    67     
       
    68     QVERIFY(verify());
       
    69 }
       
    70 
       
    71 
       
    72 void UT_ImeiKeySequenceHandler::t_executeValidKeySequence()
       
    73 {
       
    74     const QString KSerialNumber = "1234567890";
       
    75     EXPECT(QtMobility::QSystemDeviceInfo, imei).returns(KSerialNumber);
       
    76     EXPECT(HbDeviceMessageBox, setTimeout).with(HbPopup::NoTimeout);
       
    77     EXPECT(HbDeviceMessageBox, show);
       
    78     bool handled = m_handler->executeKeySequence(KCodeImei);
       
    79     QCOMPARE(handled, true);
       
    80     QVERIFY(verify());
       
    81 }
       
    82 
       
    83 
       
    84 void UT_ImeiKeySequenceHandler::t_executeInvalidKeySequence()
       
    85 {
       
    86     const QString KUnknownSequence("123");
       
    87     bool handled = m_handler->executeKeySequence(KUnknownSequence);
       
    88     QCOMPARE(handled, false);
       
    89 }
       
    90 
       
    91 QTEST_MAIN_S60(UT_ImeiKeySequenceHandler)