contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/src/t_carunningappmonitor.cpp
/*
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include "t_carunningappmonitor.h"
#include "carunningappmonitortestutils.h"
#include "cadef.h"
#include "casrvplugin.h"
#include "castorageproxy.h"
#include "casrvengutils.h"
TUid KTestAppUid0 = {0x20022EF9};
TUid KTestAppUid1 = {0x20025FD9};
// phonebook 0x20022EF9 537014009
// control panel 0x20025FD9 537026521
// Bluetooth 0x10005951 268458321
// SW Update 0x2001FE2F 537001519
// notes 20029F80 537042816
// file mgr 2002BCC0 537050304
const TUid KTestedPluginUid = {0x200267B5};
void T_CaRunningAppMonitor::initTestCase()
{
}
void T_CaRunningAppMonitor::cleanupTestCase()
{
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void T_CaRunningAppMonitor::init()
{
//CA env
iTestUtils = CTestUtils::NewL();
iTestUtils->CopyDb();
iStorage = CCaStorageProxy::NewL();
iSrvEngUtils = CCaSrvEngUtils::NewL();
//Plugin itself
TPluginParams params = {iStorage, iSrvEngUtils};
iPlugin = CCaSrvPlugin::NewL(KTestedPluginUid, ¶ms);
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void T_CaRunningAppMonitor::cleanup( )
{
delete iPlugin; iPlugin = 0;
delete iSrvEngUtils; iSrvEngUtils = 0;
delete iStorage; iStorage = 0;
delete iTestUtils; iTestUtils = 0;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void T_CaRunningAppMonitor::T_Constuction()
{
//test if plugin will be loaded without proper initialization
TInt err(KErrNone);
CCaSrvPlugin* plugin(0);
TRAP(err, plugin = CCaSrvPlugin::NewL(KTestedPluginUid,0));
QVERIFY(err != KErrNone);
delete plugin; plugin = 0;
TPluginParams params = {0, 0};
TRAP(err, plugin = CCaSrvPlugin::NewL(KTestedPluginUid,¶ms));
QVERIFY(err != KErrNone);
delete plugin; plugin = 0;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void T_CaRunningAppMonitor::T_RunL()
{
TBool appIsRunning(EFalse);
TInt err(KErrNone);
TRAP(err, iTestUtils->LaunchApplicationL(KTestAppUid0));
QTest::qWait(5000);
QCOMPARE(err, KErrNone);
TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid0, *iStorage));
QCOMPARE(err, KErrNone);
QVERIFY(appIsRunning != EFalse);
TRAP(err, iTestUtils->TerminateApplicationL(KTestAppUid0));
QTest::qWait(10000);
QCOMPARE(err, KErrNone);
TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid0, *iStorage));
QTest::qWait(5000);
QCOMPARE(err, KErrNone);
QVERIFY(appIsRunning == EFalse);
TRAP(err, iTestUtils->LaunchApplicationL(KTestAppUid1));
QTest::qWait(10000);
QCOMPARE(err, KErrNone);
TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid1, *iStorage));
QCOMPARE(err, KErrNone);
QVERIFY(appIsRunning != EFalse);
TRAP(err, iTestUtils->TerminateApplicationL(KTestAppUid1));
QCOMPARE(err, KErrNone);
QTest::qWait(5000);
TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid1, *iStorage));
QCOMPARE(err, KErrNone);
QVERIFY(appIsRunning == EFalse);
}
QTEST_MAIN(T_CaRunningAppMonitor);
// END OF FILE