125
|
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 "t_afactivitylauncher.h"
|
|
18 |
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include "afapplicationlauncher.h"
|
|
21 |
#include <afstorageclient.h>
|
|
22 |
#include "afactivitylauncher.h"
|
|
23 |
#include "afactivitylauncher_p.h"
|
|
24 |
|
|
25 |
|
|
26 |
void TestAfActivityLauncher::initTestCase()
|
|
27 |
{
|
|
28 |
QCOMPARE(mApaLsSession.Connect(), KErrNone);
|
|
29 |
QCOMPARE(mWsSession.Connect(), KErrNone);
|
|
30 |
}
|
|
31 |
|
|
32 |
void TestAfActivityLauncher::cleanupTestCase()
|
|
33 |
{
|
|
34 |
mApaLsSession.Close();
|
|
35 |
mWsSession.Close();
|
|
36 |
}
|
|
37 |
|
|
38 |
void TestAfActivityLauncher::init()
|
|
39 |
{
|
|
40 |
QT_TRAP_THROWING(mLauncher = CAfActivityLauncher::NewL(mApaLsSession, mWsSession));
|
|
41 |
}
|
|
42 |
|
|
43 |
void TestAfActivityLauncher::cleanup()
|
|
44 |
{
|
|
45 |
delete TAfApplicationLauncher::lastStartUri;
|
|
46 |
TAfApplicationLauncher::lastStartUri = 0;
|
|
47 |
TAfApplicationLauncher::lastStartAppId = 0;
|
|
48 |
|
|
49 |
delete CAfStorageClient::lastLaunchUri;
|
|
50 |
CAfStorageClient::lastLaunchUri = 0;
|
|
51 |
CAfStorageClient::lastLaunchAppId = 0;
|
|
52 |
|
|
53 |
delete mLauncher;
|
|
54 |
mLauncher = 0;
|
|
55 |
}
|
|
56 |
|
|
57 |
void TestAfActivityLauncher::testScheme()
|
|
58 |
{
|
|
59 |
TAfApplicationLauncher::expectedIsRunningResult = ETrue;
|
|
60 |
|
|
61 |
TInt error;
|
|
62 |
TRAP(error, mLauncher->launchActivityL(_L("appto://DEADBEEF")));
|
|
63 |
QCOMPARE(error, KErrNone);
|
|
64 |
|
|
65 |
TRAP(error, mLauncher->launchActivityL(_L("bzzzt://DEADBEEF")));
|
|
66 |
QCOMPARE(error, KErrArgument);
|
|
67 |
}
|
|
68 |
|
|
69 |
void TestAfActivityLauncher::testUidParsing()
|
|
70 |
{
|
|
71 |
TAfApplicationLauncher::expectedIsRunningResult = ETrue;
|
|
72 |
|
|
73 |
TInt error;
|
|
74 |
TRAP(error, mLauncher->launchActivityL(_L("appto://DEADBEEF")));
|
|
75 |
QCOMPARE(error, KErrNone);
|
|
76 |
|
|
77 |
TRAP(error, mLauncher->launchActivityL(_L("appto://INVALID")));
|
|
78 |
QCOMPARE(error, KErrGeneral);
|
|
79 |
}
|
|
80 |
|
|
81 |
void TestAfActivityLauncher::testRunningCase()
|
|
82 |
{
|
|
83 |
TAfApplicationLauncher::expectedIsRunningResult = ETrue;
|
|
84 |
|
|
85 |
_LIT(KActivityUri, "appto://DEADBEEF");
|
|
86 |
TRAPD(error, mLauncher->launchActivityL(KActivityUri));
|
|
87 |
QCOMPARE(error, KErrNone);
|
|
88 |
|
|
89 |
QCOMPARE(CAfStorageClient::lastLaunchAppId, TInt(0xDEADBEEF));
|
|
90 |
QVERIFY(CAfStorageClient::lastLaunchUri->Compare(KActivityUri()) == 0);
|
|
91 |
}
|
|
92 |
|
|
93 |
void TestAfActivityLauncher::testStartupCase()
|
|
94 |
{
|
|
95 |
TAfApplicationLauncher::expectedIsRunningResult = EFalse;
|
|
96 |
|
|
97 |
_LIT(KActivityUri, "appto://DEADBEEF");
|
|
98 |
TRAPD(error, mLauncher->launchActivityL(KActivityUri));
|
|
99 |
QCOMPARE(error, KErrNone);
|
|
100 |
|
|
101 |
QCOMPARE(TAfApplicationLauncher::lastStartAppId, TInt(0xDEADBEEF));
|
|
102 |
QVERIFY(TAfApplicationLauncher::lastStartUri->Compare(KActivityUri()) == 0);
|
|
103 |
}
|
|
104 |
|
|
105 |
void TestAfActivityLauncher::callUnusedCallbacks()
|
|
106 |
{
|
|
107 |
CAfActivityLauncherPrivate* imp = CAfActivityLauncherPrivate::NewL(mApaLsSession, mWsSession);
|
|
108 |
imp->waitActivityRequestCompleted(0, KNullDesC8());
|
|
109 |
imp->getThumbnailRequestCompleted(0, 0, 0);
|
|
110 |
imp->dataChangeNotificationCompleted(0);
|
|
111 |
delete imp;
|
|
112 |
}
|
|
113 |
|
|
114 |
QTEST_MAIN(TestAfActivityLauncher)
|