taskswitcher/utils/tsrc/t_tsentrykeyhandling/t_tsentrykeyhandling.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     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 #include <QtTest/QtTest>
       
    18 
       
    19 #include "t_tsentrykeyhandling.h"
       
    20 #include "tsentrykey.h"
       
    21 #include "tsentrykeygenerator.h"
       
    22 void T_TsEntryKeyHandling::testKeyGeneration()
       
    23 {
       
    24     int errNo, iter;
       
    25     const int rootWindowGroupId(1);
       
    26     const int embApps(30);
       
    27     
       
    28     RWsSession::TWindowGroupChainInfo  item;
       
    29     RArray<RWsSession::TWindowGroupChainInfo> items(embApps);
       
    30     
       
    31     //generate root window
       
    32     item.iId = rootWindowGroupId;
       
    33     item.iParentId = -1;
       
    34     items.Append(item);
       
    35     
       
    36     //add some embedded windows
       
    37     for (iter = rootWindowGroupId; iter < rootWindowGroupId + embApps;) {
       
    38         item.iParentId = iter;
       
    39         item.iId = ++iter;
       
    40         items.Append(item);
       
    41     }
       
    42     TTsEntryKey root;
       
    43     errNo = TsEntryKeyGeneraror::Generate(root, rootWindowGroupId, items.Array());
       
    44     QCOMPARE(errNo, KErrNone);
       
    45     
       
    46     TTsEntryKey key;
       
    47     for (iter = 0; iter < items.Count(); ++iter) {
       
    48         errNo = TsEntryKeyGeneraror::Generate(key, items[iter].iId,
       
    49                                                          items.Array());
       
    50         QCOMPARE(errNo, KErrNone);
       
    51         QCOMPARE(key, root);
       
    52     }
       
    53     
       
    54     //bad handle
       
    55     items.Reset();
       
    56     item.iId = rootWindowGroupId;
       
    57     item.iParentId = rootWindowGroupId;
       
    58     items.Append(item);    
       
    59     TTsEntryKey bad;
       
    60     errNo = TsEntryKeyGeneraror::Generate(bad, rootWindowGroupId, items.Array());
       
    61     QCOMPARE(errNo, KErrBadHandle);
       
    62     
       
    63     //not found
       
    64     items.Reset();
       
    65     item.iId = rootWindowGroupId;
       
    66     item.iParentId = rootWindowGroupId;
       
    67     items.Append(item);    
       
    68     TTsEntryKey notFound;
       
    69     errNo = TsEntryKeyGeneraror::Generate(notFound, 15002900, items.Array());
       
    70     QCOMPARE(errNo, KErrNotFound);
       
    71     
       
    72     
       
    73 }
       
    74 
       
    75 QTEST_MAIN(T_TsEntryKeyHandling)