homescreenapp/stateplugins/hsmenuworkerstateplugin/tsrc/t_hsmenuworkerstateplugin/src/t_hscollectionnamestate.cpp
changeset 96 458d8c8d9580
child 97 66b5fe3c07fd
equal deleted inserted replaced
92:6727c5d0afc7 96:458d8c8d9580
       
     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:  Main test class for hsHomeScreenStatePlugin library.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <hbaction>
       
    19 #include "hscollectionnamedialog.h"
       
    20 #include "hscollectionnamestate.h"
       
    21 
       
    22 #include "hsmenuevent.h"
       
    23 #include "t_hsmenuworkerstateplugin.h"
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 void MenuStatesTest::CollectionNameState_construction1()
       
    29 {
       
    30 #ifdef Q_OS_SYMBIAN
       
    31 #ifdef UT_MEMORY_CHECK
       
    32     __UHEAP_MARK;
       
    33 #endif//UT_MEMORY_CHECK
       
    34 #endif//Q_OS_SYMBIAN
       
    35     {
       
    36         QState parentState1;
       
    37         parentState1.setObjectName(tr("testName1"));
       
    38 
       
    39         HsCollectionNameState rename1(&parentState1);
       
    40         QString s1 = rename1.objectName();
       
    41         QVERIFY(s1 == tr("testName1/collectionnamestate"));
       
    42 
       
    43     }
       
    44 #ifdef Q_OS_SYMBIAN
       
    45 #ifdef UT_MEMORY_CHECK
       
    46     __UHEAP_MARKEND;
       
    47 #endif//UT_MEMORY_CHECK
       
    48 #endif//Q_OS_SYMBIAN
       
    49 }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void MenuStatesTest::CollectionNameState_onEntry()
       
    56 {
       
    57 #ifdef Q_OS_SYMBIAN
       
    58 #ifdef UT_MEMORY_CHECK
       
    59     __UHEAP_MARK;
       
    60 #endif//UT_MEMORY_CHECK
       
    61 #endif//Q_OS_SYMBIAN
       
    62     {
       
    63         QState parentState1;
       
    64         HsCollectionNameState rename1(&parentState1);
       
    65 
       
    66         // prepare input event
       
    67         QVariantMap params;
       
    68         params.insert(Hs::itemIdKey, 1000);
       
    69         QScopedPointer<QEvent> event (new HsMenuEvent(
       
    70                     HsMenuEvent::RenameCollection, params));
       
    71 
       
    72         rename1.onEntry(event.data());
       
    73 
       
    74         QVERIFY(rename1.mCollectionNameDialog);
       
    75         QVERIFY(rename1.mCollectionNameDialog->testAttribute(Qt::WA_DeleteOnClose));
       
    76 
       
    77         // disconnect to check if connection was done
       
    78         bool result = disconnect(rename1.mCollectionNameDialog, SIGNAL(finished(HbAction*)),
       
    79                    &rename1, SLOT(dialogFinished(HbAction*)));
       
    80         QVERIFY (result);
       
    81 
       
    82         rename1.mCollectionNameDialog->close();
       
    83 
       
    84     }
       
    85 #ifdef Q_OS_SYMBIAN
       
    86 #ifdef UT_MEMORY_CHECK
       
    87     __UHEAP_MARKEND;
       
    88 #endif//UT_MEMORY_CHECK
       
    89 #endif//Q_OS_SYMBIAN
       
    90 }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 void MenuStatesTest::CollectionNameState_dialogFinished()
       
    97 {
       
    98 #ifdef Q_OS_SYMBIAN
       
    99 #ifdef UT_MEMORY_CHECK
       
   100     __UHEAP_MARK;
       
   101 #endif//UT_MEMORY_CHECK
       
   102 #endif//Q_OS_SYMBIAN
       
   103     {
       
   104         QState parentState1;
       
   105         parentState1.setObjectName(tr("testName1"));
       
   106 
       
   107         HsCollectionNameState rename1(&parentState1);
       
   108         QString s1 = rename1.objectName();
       
   109         QVERIFY(s1 == tr("testName1/collectionnamestate"));
       
   110 
       
   111 
       
   112         rename1.mCollectionNameDialog = new HsCollectionNameDialog();
       
   113         rename1.dialogFinished(qobject_cast<HbAction*>(rename1.mCollectionNameDialog->actions().value(1)));
       
   114 
       
   115         QVERIFY(rename1.mCollectionNameDialog == NULL);
       
   116 
       
   117     }
       
   118 #ifdef Q_OS_SYMBIAN
       
   119 #ifdef UT_MEMORY_CHECK
       
   120     __UHEAP_MARKEND;
       
   121 #endif//UT_MEMORY_CHECK
       
   122 #endif//Q_OS_SYMBIAN
       
   123 }
       
   124