homescreenapp/stateplugins/hsmenuworkerstateplugin/tsrc/t_hsmenuworkerstateplugin/src/t_hsdeletecollectionstate.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<qscopedpointer.h>
       
    19 #include<hbmessagebox.h>
       
    20 #include<hbaction.h>
       
    21 #include <HbParameterLengthLimiter>
       
    22 
       
    23 #include "hsdeletecollectionstate.h"
       
    24 #include "t_hsmenuworkerstateplugin.h"
       
    25 #include "hscontentservice.h"
       
    26 #include "hsshortcutservice.h"
       
    27 #include "hsmenuevent.h"
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 void MenuStatesTest::DeleteCollectionState_construction1()
       
    33 {
       
    34 #ifdef Q_OS_SYMBIAN
       
    35 #ifdef UT_MEMORY_CHECK
       
    36     __UHEAP_MARK;
       
    37 #endif//UT_MEMORY_CHECK
       
    38 #endif//Q_OS_SYMBIAN
       
    39     {
       
    40         QState parentState1;
       
    41         parentState1.setObjectName(tr("testName1"));
       
    42 
       
    43         HsDeleteCollectionState del1(&parentState1);
       
    44         QString s1 = del1.objectName();
       
    45         QVERIFY(s1 == tr("testName1/DeleteCollectionState"));
       
    46 
       
    47     }
       
    48 #ifdef Q_OS_SYMBIAN
       
    49 #ifdef UT_MEMORY_CHECK
       
    50     __UHEAP_MARKEND;
       
    51 #endif//UT_MEMORY_CHECK
       
    52 #endif//Q_OS_SYMBIAN
       
    53 }
       
    54 
       
    55 
       
    56 void MenuStatesTest::DeleteCollectionState_onEntry()
       
    57 {
       
    58 #ifdef Q_OS_SYMBIAN
       
    59 #ifdef UT_MEMORY_CHECK
       
    60     __UHEAP_MARK;
       
    61 #endif//UT_MEMORY_CHECK
       
    62 #endif//Q_OS_SYMBIAN
       
    63     {
       
    64         QState parentState;
       
    65         HsDeleteCollectionState del(&parentState);
       
    66 
       
    67         //test event
       
    68         QVariantMap params;
       
    69         const int testId = 1000;
       
    70         params.insert(Hs::itemIdKey, testId);
       
    71         QScopedPointer<HsMenuEvent> event(new HsMenuEvent(HsMenuEvent::DeleteCollection, params));
       
    72 
       
    73         del.onEntry(event.data());
       
    74         checkDialogController();
       
    75 
       
    76         QCOMPARE(del.mItemId, testId);
       
    77 
       
    78     }
       
    79 #ifdef Q_OS_SYMBIAN
       
    80 #ifdef UT_MEMORY_CHECK
       
    81     __UHEAP_MARKEND;
       
    82 #endif//UT_MEMORY_CHECK
       
    83 #endif//Q_OS_SYMBIAN
       
    84 }
       
    85 
       
    86 void MenuStatesTest::DeleteCollectionState_deleteCollection()
       
    87 {
       
    88 #ifdef Q_OS_SYMBIAN
       
    89 #ifdef UT_MEMORY_CHECK
       
    90     __UHEAP_MARK;
       
    91 #endif//UT_MEMORY_CHECK
       
    92 #endif//Q_OS_SYMBIAN
       
    93     {
       
    94         QScopedPointer<QStateMachine> machine(new QStateMachine(0));
       
    95 
       
    96         QState parentState;
       
    97         parentState.setObjectName(tr("testName"));
       
    98         HsDeleteCollectionState del(&parentState);
       
    99 
       
   100         machine->addState(&del);
       
   101         machine->setInitialState(&del);
       
   102 
       
   103         machine->start();
       
   104 
       
   105         const int newCollId = HsMenuService::createCollection("DeleteColl_test");
       
   106 
       
   107         del.mItemId = newCollId;
       
   108 
       
   109         del.deleteCollection();
       
   110 
       
   111         const QString nonExistingCollName = HsMenuService::getName(newCollId);
       
   112 
       
   113         QCOMPARE(nonExistingCollName, QString());
       
   114         machine->stop();
       
   115 
       
   116     }
       
   117 #ifdef Q_OS_SYMBIAN
       
   118 #ifdef UT_MEMORY_CHECK
       
   119     __UHEAP_MARKEND;
       
   120 #endif//UT_MEMORY_CHECK
       
   121 #endif//Q_OS_SYMBIAN
       
   122 }