logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmainwindow.cpp
changeset 0 4a5361db8937
child 9 68f3171a5819
equal deleted inserted replaced
-1:000000000000 0:4a5361db8937
       
     1 /*
       
     2 * Copyright (c) 2009 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 //USER
       
    19 #include "ut_logsmainwindow.h"
       
    20 #include "logsmainwindow.h"
       
    21 #include "qthighway_stub_helper.h"
       
    22 #include "hbstubs_helper.h"
       
    23 
       
    24 //SYSTEM
       
    25 #include <QtTest/QtTest>
       
    26 #include <hbmainwindow.h>
       
    27 #include <QKeyEvent>
       
    28 
       
    29 void UT_LogsMainWindow::initTestCase()
       
    30 {
       
    31 
       
    32 }
       
    33 
       
    34 void UT_LogsMainWindow::cleanupTestCase()
       
    35 {
       
    36 
       
    37 }
       
    38 
       
    39 
       
    40 void UT_LogsMainWindow::init()
       
    41 {
       
    42     mMainWindow = new LogsMainWindow;
       
    43 }
       
    44 
       
    45 void UT_LogsMainWindow::cleanup()
       
    46 {
       
    47     delete mMainWindow;
       
    48     mMainWindow = 0;
       
    49 }
       
    50 
       
    51 void UT_LogsMainWindow::testKeyPressEvent()
       
    52 {
       
    53     QSignalSpy spy( mMainWindow, SIGNAL(callKeyPressed()) );
       
    54     // Not handled
       
    55     QKeyEvent event( QEvent::KeyPress, Qt::Key_Hangup, Qt::NoModifier);
       
    56     mMainWindow->keyPressEvent( &event );
       
    57     QVERIFY( spy.count() == 0 );
       
    58     
       
    59     // Handled
       
    60     QKeyEvent event2( QEvent::KeyPress, Qt::Key_Yes, Qt::NoModifier);
       
    61     mMainWindow->keyPressEvent( &event2 );
       
    62     QVERIFY( spy.count() == 1 );
       
    63     
       
    64 }
       
    65 
       
    66 void UT_LogsMainWindow::testSendAppToBackground()
       
    67 {
       
    68     QtHighwayStubHelper::reset();
       
    69     mMainWindow->sendAppToBackground();
       
    70     QVERIFY( QtHighwayStubHelper::utilToBackground() );  
       
    71     QVERIFY( !mMainWindow->isForeground() );
       
    72 }
       
    73 
       
    74 void UT_LogsMainWindow::testBringAppToForeground()
       
    75 {
       
    76     QtHighwayStubHelper::reset();
       
    77     HbStubHelper::reset();
       
    78     mMainWindow->bringAppToForeground();
       
    79     QVERIFY( HbStubHelper::isWidgetRaised() ); 
       
    80     QVERIFY( mMainWindow->isForeground() );
       
    81     
       
    82     // Subsequent call does not raise more
       
    83     HbStubHelper::reset();
       
    84     mMainWindow->bringAppToForeground();
       
    85     QVERIFY( !HbStubHelper::isWidgetRaised() ); 
       
    86     QVERIFY( mMainWindow->isForeground() );
       
    87 }
       
    88