|
1 /** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 * All rights reserved. |
|
3 * This component and the accompanying materials are made available |
|
4 * under the terms of "Eclipse Public License v1.0" |
|
5 * which accompanies this distribution, and is available |
|
6 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 * |
|
8 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * |
|
11 * Contributors: |
|
12 * |
|
13 * Description: |
|
14 * |
|
15 */ |
|
16 #include <QtTest/QtTest> |
|
17 #include <QPixmap> |
|
18 #include <e32std.h> |
|
19 #include <AknDef.h> |
|
20 #include <QString> |
|
21 #include <qdebug> |
|
22 #include <apgcli.h> |
|
23 #include <apacmdln.h> |
|
24 #include <apgtask.h> |
|
25 #include <eikenv.h> |
|
26 #include <s32strm.h> |
|
27 #include <S32MEM.H> |
|
28 #include <APGWGNAM.H> |
|
29 #include <FBS.H> |
|
30 #include "t_tsbackstepping.h" |
|
31 #include "tsbackstepping.h" |
|
32 #include <tsresourcemanager.h> |
|
33 #include <tswindowgroupsobserver.h> |
|
34 |
|
35 #include "tstestutils.h" |
|
36 |
|
37 const TUid KIconApplicationUid = {0xEd0b4e47}; |
|
38 const TUid KNoIconApplicationUid = {0xE453fc1b}; |
|
39 const TUid KHsApplicationUid = {0x20022F35}; |
|
40 |
|
41 namespace { |
|
42 const char KIconApplicationName[] = "appwithicon"; |
|
43 const char KNoIconApplicationName[] = "appwithouticon"; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // init and cleanup methods |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void TestBackStepping::initTestCase() |
|
51 { |
|
52 mResources = CTsResourceManager::NewL(); |
|
53 mMonitor = CTsWindowGroupsMonitor::NewL(*mResources); |
|
54 } |
|
55 |
|
56 void TestBackStepping::cleanupTestCase() |
|
57 { |
|
58 delete mMonitor; |
|
59 delete mResources; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // test cases |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void TestBackStepping::testBacksteppingMovesHomescreenToSecondPosition() |
|
67 { |
|
68 // start test applicationss |
|
69 quint64 iconAppId; |
|
70 quint64 noIconAppId; |
|
71 QVERIFY(TsTestUtils::startApplication(KIconApplicationName, iconAppId)); |
|
72 QVERIFY(TsTestUtils::startApplication(KNoIconApplicationName, noIconAppId)); |
|
73 |
|
74 // get window group list that will be passed to backstepping algorithm |
|
75 RArray<RWsSession::TWindowGroupChainInfo> windowGroupList; |
|
76 QCOMPARE(mResources->WsSession().WindowGroupList(0, &windowGroupList), KErrNone); |
|
77 |
|
78 // we don't test window server events monitor. manually force backstepping algorithm |
|
79 CTsBackstepping *backstepping = CTsBackstepping::NewL(*mMonitor); |
|
80 static_cast<MTsWindowGroupsObserver*>(backstepping)->HandleWindowGroupChanged(*mResources, windowGroupList.Array()); |
|
81 |
|
82 // read window group list list after backstepping |
|
83 QCOMPARE(mResources->WsSession().WindowGroupList(0, &windowGroupList), KErrNone); |
|
84 |
|
85 QCOMPARE(getUidForWgId(windowGroupList[0].iId), KNoIconApplicationUid); |
|
86 QCOMPARE(getUidForWgId(windowGroupList[1].iId), KHsApplicationUid); |
|
87 QCOMPARE(getUidForWgId(windowGroupList[2].iId), KIconApplicationUid); |
|
88 |
|
89 delete backstepping; |
|
90 windowGroupList.Close(); |
|
91 |
|
92 // close test applications |
|
93 QVERIFY(TsTestUtils::closeApplication(noIconAppId)); |
|
94 QVERIFY(TsTestUtils::closeApplication(iconAppId)); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // helper method |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TUid TestBackStepping::getUidForWgId(int wgId) const |
|
102 { |
|
103 CApaWindowGroupName *windowName = CApaWindowGroupName::NewLC(mResources->WsSession(), wgId); |
|
104 TUid appUid = windowName->AppUid(); |
|
105 CleanupStack::PopAndDestroy(windowName); |
|
106 return appUid; |
|
107 } |
|
108 |
|
109 QTEST_MAIN(TestBackStepping) |