vmbx/vmbxcpplugin/tsrc/src/ut_customedit.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     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 <QFocusEvent>
       
    19 #include <HbMainWindow>
       
    20 #include <QEvent>
       
    21 #include <QEventLoop>
       
    22 #include "ut_customedit.h"
       
    23 #include "customedit.h"
       
    24 
       
    25 
       
    26 
       
    27 void Ut_CustomEdit::testFocusInEvent()
       
    28 {
       
    29     HbMainWindow *window = new HbMainWindow;
       
    30     QVERIFY(window);
       
    31     
       
    32     QGraphicsWidget *qGraphicsWidget = new QGraphicsWidget();
       
    33     QVERIFY(qGraphicsWidget != 0);
       
    34     CustomEdit *edit = new CustomEdit(qGraphicsWidget);
       
    35     QVERIFY(edit);
       
    36     
       
    37     QFocusEvent *event = new QFocusEvent(QEvent::FocusIn, 
       
    38         Qt::MouseFocusReason);  
       
    39     QVERIFY(event);
       
    40     edit->focusInEvent(event);
       
    41     delete event;
       
    42     event  = NULL;
       
    43     
       
    44     event = new QFocusEvent(QEvent::FocusOut, 
       
    45         Qt::MouseFocusReason);
       
    46     QVERIFY(event);
       
    47     edit->focusInEvent(event);
       
    48     // test for emitEditItemClicked    
       
    49     QEventLoop loop;
       
    50     QTimer timer;
       
    51     timer.start(150);
       
    52     connect( &timer,SIGNAL(timeout()),
       
    53         &loop,SLOT(quit()));
       
    54     loop.exec();
       
    55     delete event;
       
    56     event = NULL;
       
    57     delete edit;
       
    58     edit = NULL;
       
    59     QVERIFY(!edit);
       
    60     
       
    61     delete qGraphicsWidget;
       
    62     qGraphicsWidget = NULL;
       
    63 }