--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/ctc.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,98 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2009 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:
+#
+
+#USAGE:
+# Usage: 101ctc.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+use Cwd;
+use Win32::Job;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ chdir("..");
+
+ my @testdirs = ( "tsrc\\unittest_activityclient" ,
+ "tsrc\\unittest_activitydatastorage" ,
+ "tsrc\\unittest_activitymanager" ,
+ "tsrc\\unittest_activityserviceplugin" );
+
+ if (($make eq "instrument") || ($make eq "all")) {
+ `for /R . %i IN (mon.*) DO del %i`;
+ system("del profile.txt");
+ `for /D %f IN (CTC*) DO rmdir /S /Q %f`;
+
+ system("call qmake -spec symbian-sbsv2");
+ system("call sbs reallyclean -c winscw_udeb");
+ system("call sbs -j 4 -c winscw_udeb");
+
+ my $cwd = cwd();
+ foreach my $testdir (@testdirs) {
+ chdir($testdir);
+ system("call qmake -config coverage");
+ system("call bldmake bldfiles");
+ system("call abld makefile winscw");
+ system("call abld reallyclean winscw");
+ system("ctcwrap -i fd -C EXCLUDE+moc_*.cpp,*/tsrc/* -C SOURCE_IDENTIFICATION=absolute abld build winscw udeb");
+ chdir($cwd);
+ }
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ foreach my $testdir (@testdirs) {
+ my $test = (split m/\\/ , $testdir)[-1];
+ print ("Running $test\n");
+ if ( run_for("\\epoc32\\release\\winscw\\udeb\\$test.exe", "$test.exe >C:\\testresult_$test.txt", 300) ) {
+ warn("$test execution timed out.");
+ }
+ }
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ my $coverageData = "";
+
+ foreach my $testdir (@testdirs) {
+ if (-e "$testdir\\MON.dat" && -e "$testdir\\MON.sym") {
+ $coverageData .= "$testdir\\MON.dat ";
+ }
+ }
+ if ( $coverageData ne "" ) {
+ system("call ctcpost -ff $coverageData -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -T 70 -fd $coverageData -p profile.txt");
+ system("call ctc2html -t 70 -nsb -i profile.txt -o CTCDECISION");
+ } else {
+ warn("No coverage data generated.");
+ }
+ }
+}
+
+print "END.\n";
+
+sub run_for {
+ my ($cmd, $args, $timeout) = @_;
+ my $job = Win32::Job->new() or die "Error creating job: $^E";
+ my $pid = $job->spawn($cmd, $args, { stdin => 'NUL', stdout => 'NUL', stderr => 'NUL' } ) or die "Error starting job $cmd: $^E";
+ $job->run($timeout);
+ my $stat = $job->status();
+ exists($stat->{$pid}) or die "No status for $pid ($cmd)";
+ return $stat->{$pid}->{exitcode};
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/mocks/inc/afstorageclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef AFSTORAGECLIENT_H
+#define AFSTORAGECLIENT_H
+
+#include <e32base.h>
+
+class CAfEntry;
+class MAfAsyncRequestObserver;
+
+class CAfStorageClient : public CBase
+{
+public:
+ static CAfStorageClient *NewL(MAfAsyncRequestObserver &observer);
+ virtual ~CAfStorageClient();
+
+private:
+ CAfStorageClient(MAfAsyncRequestObserver &observer);
+
+public:
+ int addActivity(const CAfEntry &entry, TInt imageHandle);
+ int updateActivity(const CAfEntry &entry, TInt imageHandle);
+ int saveActivity(const CAfEntry &entry, TInt imageHandle);
+ int removeActivity(const CAfEntry &entry);
+ int removeApplicationActivities(const CAfEntry &entry);
+ int activities(RPointerArray<CAfEntry> &dst);
+ int applicationActivities(RPointerArray<CAfEntry> &dst, const CAfEntry &entry);
+ int activityData(CAfEntry *&dst, const CAfEntry &entry);
+ int waitActivity();
+ int launchActivity(const CAfEntry &entry);
+ int getThumbnail(const TSize &size, const TDesC &imagePath, void *userData);
+ int notifyDataChange();
+
+private:
+ MAfAsyncRequestObserver &mObserver;
+
+private:
+ void updateLastEntry(const CAfEntry &entry);
+
+public:
+ void invokeWaitActivityCallback(int result, const TDesC8 &data);
+ void invokeGetThumbnailCallback(int result, int bitmapHandle, void *userData);
+ void invokeDataChangeCallback(int result);
+
+ static void clearLastCallInfo();
+
+public:
+ enum LastMethodCalled {
+ NoCall,
+ AddActivityMethod,
+ UpdateActivityMethod,
+ SaveActivityMethod,
+ RemoveActivityMethod,
+ RemoveApplicationActivitiesMethod,
+ ActivitiesMethod,
+ ApplicationActivitiesMethod,
+ ActivityDataMethod,
+ WaitActivityMethod,
+ LaunchActivityMethod,
+ GetThumbnailMethod,
+ NotifyDataChangeMethod,
+ };
+
+public:
+ static TInt constructorError;
+ static TInt expectedReturnCode;
+
+ static CAfEntry *lastCallEntry;
+ static TInt lastCallImageHandle;
+ static TSize lastCallThumbnailSize;
+ static HBufC *lastCallThumbnailPath;
+ static void *lastCallUserData;
+
+ static LastMethodCalled lastMethodCalled;
+};
+
+#endif //AFSTORAGECLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/mocks/inc/afstorageproxy.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef AFSTORAGEPROXY_H
+#define AFSTORAGEPROXY_H
+
+#include <QObject>
+#include <QVariant>
+#include <QStringList>
+
+class AfStorageProxy : public QObject
+{
+ Q_OBJECT
+
+public:
+ AfStorageProxy(QObject *parent = 0);
+ virtual ~AfStorageProxy();
+
+public:
+ bool addActivity(int applicationId, const QString &activityId, const QVariant &activityData, const QVariantHash &metadata, const QPixmap &screenshot);
+ bool updateActivity(int applicationId, const QString &activityId, const QVariant &activityData, const QVariantHash &metadata, const QPixmap &screenshot);
+ bool saveActivity(int applicationId, const QString &activityId, const QVariant &activityData, const QVariantHash &metadata, const QPixmap &screenshot);
+ bool removeActivity(int applicationId, const QString &activityId);
+ bool removeApplicationActivities(int applicationId);
+ bool activities(QList<QVariantHash> &list);
+ bool applicationActivities(QStringList &list, int applicationId);
+ bool activityData(QVariant &data, int applicationId, const QString &activityId);
+ bool activityMetaData(QVariantHash &metadata, int applicationId, const QString &activityId);
+ bool waitActivity();
+ bool launchActivity(int applicationId, const QString &activityUri);
+ bool getThumbnail(const QSize &size, const QString &imagePath, void *userData);
+ bool notifyDataChange();
+
+signals:
+ void activityRequested(const QString &activityUri);
+ void thumbnailRequested(const QPixmap &thumbnailPixmap, void *userData);
+ void dataChanged();
+
+public: // additional mocked implementation members
+ void emitActivityRequested(const QString &activityUri);
+
+ QVariantHash mLastCallParams;
+};
+
+#endif //AFSTORAGEPROXY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/mocks/inc/applicationlauncher_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef APPLICATIONLAUNCHER_P_H
+#define APPLICATIONLAUNCHER_P_H
+
+#include <QVariantHash>
+#include <QUrl>
+
+class ApplicationLauncherPrivate
+{
+
+public:
+ ApplicationLauncherPrivate();
+ ~ApplicationLauncherPrivate();
+
+public:
+ static ApplicationLauncherPrivate *instance;
+ static bool isRunningReturnValue;
+
+public:
+ bool isRunning(int applicationId);
+ void startApplication(int applicationId, const QUrl &uri);
+ void bringToForeground(int applicationId);
+
+public:
+ QList<QVariantHash> isRunningCalls;
+ QList<QVariantHash> startApplicationCalls;
+ QList<QVariantHash> bringToForegroundCalls;
+
+};
+
+#endif // APPLICATIONLAUNCHER_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/mocks/src/afstorageclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2009 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 "afstorageclient.h"
+
+#include <afentry.h>
+#include <afasyncrequestobserver.h>
+#include <fbs.h>
+
+TInt CAfStorageClient::constructorError(KErrNone);
+TInt CAfStorageClient::expectedReturnCode(KErrNone);
+
+CAfEntry *CAfStorageClient::lastCallEntry(0);
+TInt CAfStorageClient::lastCallImageHandle(0);
+TSize CAfStorageClient::lastCallThumbnailSize(0, 0);
+HBufC *CAfStorageClient::lastCallThumbnailPath(0);
+void *CAfStorageClient::lastCallUserData(0);
+CAfStorageClient::LastMethodCalled CAfStorageClient::lastMethodCalled = CAfStorageClient::NoCall;
+
+CAfStorageClient *CAfStorageClient::NewL(MAfAsyncRequestObserver &observer)
+{
+ User::LeaveIfError(CAfStorageClient::constructorError);
+ return new CAfStorageClient(observer);
+}
+
+CAfStorageClient::~CAfStorageClient()
+{
+ clearLastCallInfo();
+}
+
+CAfStorageClient::CAfStorageClient(MAfAsyncRequestObserver &observer) : mObserver(observer)
+{
+}
+
+int CAfStorageClient::addActivity(const CAfEntry &entry, TInt imageHandle)
+{
+ lastMethodCalled = CAfStorageClient::AddActivityMethod;
+ updateLastEntry(entry);
+ lastCallImageHandle = imageHandle;
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::updateActivity(const CAfEntry &entry, TInt imageHandle)
+{
+ lastMethodCalled = CAfStorageClient::UpdateActivityMethod;
+ updateLastEntry(entry);
+ lastCallImageHandle = imageHandle;
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::saveActivity(const CAfEntry &entry, TInt imageHandle)
+{
+ lastMethodCalled = CAfStorageClient::SaveActivityMethod;
+ updateLastEntry(entry);
+ lastCallImageHandle = imageHandle;
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::removeActivity(const CAfEntry &entry)
+{
+ lastMethodCalled = CAfStorageClient::RemoveActivityMethod;
+ updateLastEntry(entry);
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::removeApplicationActivities(const CAfEntry &entry)
+{
+ lastMethodCalled = CAfStorageClient::RemoveApplicationActivitiesMethod;
+ updateLastEntry(entry);
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::activities(RPointerArray<CAfEntry> &dst)
+{
+ if (lastMethodCalled == CAfStorageClient::SaveActivityMethod && CAfStorageClient::lastCallEntry) {
+ dst.Append(CAfStorageClient::lastCallEntry);
+ CAfStorageClient::lastCallEntry =0;
+ }
+ lastMethodCalled = CAfStorageClient::ActivitiesMethod;
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::applicationActivities(RPointerArray<CAfEntry> &dst, const CAfEntry &entry)
+{
+ if (lastMethodCalled == CAfStorageClient::SaveActivityMethod && CAfStorageClient::lastCallEntry) {
+ dst.Append(CAfStorageClient::lastCallEntry);
+ CAfStorageClient::lastCallEntry =0;
+ }
+ lastMethodCalled = CAfStorageClient::ApplicationActivitiesMethod;
+ updateLastEntry(entry);
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::activityData(CAfEntry *&dst, const CAfEntry &entry)
+{
+ if (lastMethodCalled == CAfStorageClient::SaveActivityMethod && CAfStorageClient::lastCallEntry) {
+ dst =CAfStorageClient::lastCallEntry;
+ CAfStorageClient::lastCallEntry =0;
+ }
+ lastMethodCalled = CAfStorageClient::ActivityDataMethod;
+ // @todo return something in dst
+ updateLastEntry(entry);
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::waitActivity()
+{
+ if(lastMethodCalled == CAfStorageClient::NoCall) {
+ lastMethodCalled = CAfStorageClient::WaitActivityMethod;
+ mObserver.waitActivityRequestCompleted(CAfStorageClient::expectedReturnCode, KNullDesC8);
+ }
+
+ lastMethodCalled = CAfStorageClient::WaitActivityMethod;
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::launchActivity(const CAfEntry &entry)
+{
+ lastMethodCalled = CAfStorageClient::LaunchActivityMethod;
+ updateLastEntry(entry);
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::getThumbnail(const TSize &size, const TDesC &imagePath, void *userData)
+{
+ lastMethodCalled = CAfStorageClient::GetThumbnailMethod;
+ lastCallThumbnailSize = size;
+ delete lastCallThumbnailPath;
+ lastCallThumbnailPath = imagePath.Alloc();
+ lastCallUserData = userData;
+ int result = KErrNone;
+ if(size.iHeight <=0 || size.iWidth <= 0 ){
+ mObserver.getThumbnailRequestCompleted(KErrArgument, -1, userData);
+ } else {
+ CFbsBitmap *bitmap = new (ELeave)CFbsBitmap();
+ CleanupStack::PushL(bitmap);
+ User::LeaveIfError(bitmap->Create(size, EColor4K));
+ mObserver.getThumbnailRequestCompleted(CAfStorageClient::expectedReturnCode, bitmap->Handle(), userData);
+ CleanupStack::PopAndDestroy(bitmap);
+ }
+
+ return CAfStorageClient::expectedReturnCode;
+}
+
+int CAfStorageClient::notifyDataChange()
+{
+ if(lastMethodCalled == CAfStorageClient::NoCall) {
+ lastMethodCalled = CAfStorageClient::NotifyDataChangeMethod;
+ mObserver.dataChangeNotificationCompleted(CAfStorageClient::expectedReturnCode);
+ }
+ lastMethodCalled = CAfStorageClient::NotifyDataChangeMethod;
+ return CAfStorageClient::expectedReturnCode;
+}
+
+// ---------------------------------------------------------------------------
+// Invoking callbacks
+// ---------------------------------------------------------------------------
+//
+void CAfStorageClient::invokeWaitActivityCallback(int result, const TDesC8 &data)
+{
+ mObserver.waitActivityRequestCompleted(result, data);
+}
+
+void CAfStorageClient::invokeGetThumbnailCallback(int result, int bitmapHandle, void *userData)
+{
+ mObserver.getThumbnailRequestCompleted(result, bitmapHandle, userData);
+}
+
+void CAfStorageClient::invokeDataChangeCallback(int result)
+{
+ mObserver.dataChangeNotificationCompleted(result);
+}
+
+// ---------------------------------------------------------------------------
+// Helper methods
+// ---------------------------------------------------------------------------
+//
+void CAfStorageClient::clearLastCallInfo()
+{
+ CAfStorageClient::constructorError = EFalse;
+ CAfStorageClient::expectedReturnCode = KErrNone;
+
+ delete CAfStorageClient::lastCallEntry;
+ CAfStorageClient::lastCallEntry = 0;
+
+ CAfStorageClient::lastCallImageHandle = 0;
+ CAfStorageClient::lastCallThumbnailSize = TSize(0,0);
+
+ delete CAfStorageClient::lastCallThumbnailPath;
+ CAfStorageClient::lastCallThumbnailPath = 0;
+
+ CAfStorageClient::lastCallUserData = 0;
+
+ lastMethodCalled = CAfStorageClient::NoCall;
+}
+
+void CAfStorageClient::updateLastEntry(const CAfEntry &entry)
+{
+ delete CAfStorageClient::lastCallEntry;
+
+ CAfStorageClient::lastCallEntry = CAfEntry::NewL(
+ entry.Flags(),
+ entry.ApplicationId(),
+ entry.ActivityId(),
+ entry.ImageSrc(),
+ entry.Data(CAfEntry::Private),
+ entry.Data(CAfEntry::Public)
+ );
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/mocks/src/afstorageproxy.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2009 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 "afstorageproxy.h"
+
+#include <QPixmap>
+
+AfStorageProxy::AfStorageProxy(QObject *parent) : QObject(parent)
+{
+}
+
+AfStorageProxy::~AfStorageProxy()
+{
+}
+
+bool AfStorageProxy::addActivity(int applicationId, const QString &activityId, const QVariant &activityData, const QVariantHash &metadata, const QPixmap &screenshot)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityId", activityId);
+ mLastCallParams.insert("activityData", activityData);
+ mLastCallParams.insert("metadata", metadata);
+ mLastCallParams.insert("screenshot", QVariant::fromValue<QPixmap>(screenshot));
+ return true;
+}
+
+bool AfStorageProxy::updateActivity(int applicationId, const QString &activityId, const QVariant &activityData, const QVariantHash &metadata, const QPixmap &screenshot)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityId", activityId);
+ mLastCallParams.insert("activityData", activityData);
+ mLastCallParams.insert("metadata", metadata);
+ mLastCallParams.insert("screenshot", QVariant::fromValue<QPixmap>(screenshot));
+ return true;
+}
+
+bool AfStorageProxy::saveActivity(int applicationId, const QString &activityId, const QVariant &activityData, const QVariantHash &metadata, const QPixmap &screenshot)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityId", activityId);
+ mLastCallParams.insert("activityData", activityData);
+ mLastCallParams.insert("metadata", metadata);
+ mLastCallParams.insert("screenshot", QVariant::fromValue<QPixmap>(screenshot));
+ return true;
+}
+
+bool AfStorageProxy::removeActivity(int applicationId, const QString &activityId)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityId", activityId);
+ return true;
+}
+
+bool AfStorageProxy::removeApplicationActivities(int applicationId)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ return true;
+}
+
+bool AfStorageProxy::activities(QList<QVariantHash> &list)
+{
+ Q_UNUSED(list);
+ mLastCallParams.clear();
+ return true;
+}
+
+bool AfStorageProxy::applicationActivities(QStringList &list, int applicationId)
+{
+ Q_UNUSED(list);
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ return true;
+}
+
+bool AfStorageProxy::activityData(QVariant &data, int applicationId, const QString &activityId)
+{
+ Q_UNUSED(data);
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityId", activityId);
+ return true;
+}
+
+bool AfStorageProxy::activityMetaData(QVariantHash &metadata, int applicationId, const QString &activityId)
+{
+ Q_UNUSED(metadata);
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityId", activityId);
+ return true;
+}
+
+bool AfStorageProxy::waitActivity()
+{
+ mLastCallParams.clear();
+ return true;
+}
+
+bool AfStorageProxy::launchActivity(int applicationId, const QString &activityUri)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("applicationId", applicationId);
+ mLastCallParams.insert("activityUri", activityUri);
+ return true;
+}
+
+bool AfStorageProxy::getThumbnail(const QSize &size, const QString &imagePath, void *userData)
+{
+ mLastCallParams.clear();
+ mLastCallParams.insert("size", size);
+ mLastCallParams.insert("imagePath", imagePath);
+ mLastCallParams.insert("userData", (uint)(userData));
+ emit thumbnailRequested(QPixmap(), userData);
+ return true;
+}
+
+bool AfStorageProxy::notifyDataChange()
+{
+ mLastCallParams.clear();
+ return true;
+}
+
+// ---------------------------------------------------------------------------
+// Mock implementation
+// ---------------------------------------------------------------------------
+//
+void AfStorageProxy::emitActivityRequested(const QString &activityId)
+{
+ emit activityRequested(activityId);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/mocks/src/applicationlauncher_p.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 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 "applicationlauncher_p.h"
+#include <QCoreApplication>
+
+ApplicationLauncherPrivate *ApplicationLauncherPrivate::instance = NULL;
+bool ApplicationLauncherPrivate::isRunningReturnValue = false;
+
+ApplicationLauncherPrivate::ApplicationLauncherPrivate()
+{
+ if (instance) {
+ delete instance;
+ }
+ instance = this;
+}
+
+ApplicationLauncherPrivate::~ApplicationLauncherPrivate()
+{
+ // create copy so we can check output even when original object is deleted
+ instance = new ApplicationLauncherPrivate(*this);
+}
+
+bool ApplicationLauncherPrivate::isRunning(int applicationId)
+{
+ QVariantHash call;
+ call.insert("applicationId", applicationId);
+ isRunningCalls.append(call);
+
+ return isRunningReturnValue;
+}
+
+void ApplicationLauncherPrivate::startApplication(int applicationId, const QUrl &uri)
+{
+ QVariantHash call;
+ call.insert("applicationId", applicationId);
+ call.insert("uri", uri);
+ startApplicationCalls.append(call);
+}
+
+void ApplicationLauncherPrivate::bringToForeground(int applicationId)
+{
+ QVariantHash call;
+ call.insert("applicationId", applicationId);
+ bringToForegroundCalls.append(call);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afactivation/inc/t_afactivation.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TESTAFACTIVATION_H
+#define TESTAFACTIVATION_H
+
+#include <QObject>
+#include <QSharedPointer>
+
+#include "afstorageproxy.h"
+class AfActivationPrivate;
+
+class TestAfActivation : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestAfActivation();
+
+private slots:
+ void init();
+ void cleanup();
+
+ void invokeActivationPublicInterface();
+
+ void testDefaultValuesAfterCreation();
+ void testSignalIsEmittedWhenActivityIsRequested();
+ void testValuesChangeWhenActivityIsRequested();
+ void testChangingActivityInBackground();
+
+private:
+ QSharedPointer<AfStorageProxy> mServiceProvider;
+ AfActivationPrivate *mActivationPrivate;
+ QString mDefaultActivityName;
+};
+
+#endif // TESTAFACTIVATION_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afactivation/src/t_afactivation.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2009 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_afactivation.h"
+
+#include <QtTest/QtTest>
+
+#include "afactivation.h"
+#include "afactivation_p.h"
+#include "applicationlauncher_p.h"
+
+TestAfActivation::TestAfActivation()
+{
+ mDefaultActivityName = QString("appto://EBADC0DE?%1=TestActivity&TestParam=TestValue").arg(Af::KActivityUriNameKey);
+}
+
+void TestAfActivation::init()
+{
+ mServiceProvider = QSharedPointer<AfStorageProxy>(new AfStorageProxy());
+ mActivationPrivate = new AfActivationPrivate(mServiceProvider);
+}
+
+void TestAfActivation::cleanup()
+{
+ delete mActivationPrivate;
+ mActivationPrivate = NULL;
+}
+
+void TestAfActivation::invokeActivationPublicInterface()
+{
+ // AfActivation is only responsible of correct creation of AfActivationPrivate and
+ // forwarding requests. Since it's impossible to verify the effects of the member
+ // calls, just invoke the methods.
+ AfActivation activation;
+
+ activation.parameters();
+ activation.reason();
+ activation.name();
+}
+
+void TestAfActivation::testDefaultValuesAfterCreation()
+{
+ QCOMPARE(mActivationPrivate->parameters(), QVariantHash());
+ QCOMPARE(mActivationPrivate->reason(), Af::ActivationReasonNormal);
+ QCOMPARE(mActivationPrivate->name(), QString());
+}
+
+void TestAfActivation::testSignalIsEmittedWhenActivityIsRequested()
+{
+ QSignalSpy activatedSpy(mActivationPrivate, SIGNAL(activated(Af::ActivationReason,QString,QVariantHash)));
+ QVERIFY(activatedSpy.isValid());
+
+ mServiceProvider->emitActivityRequested(mDefaultActivityName);
+ QCOMPARE(activatedSpy.count(), 1);
+}
+
+void TestAfActivation::testValuesChangeWhenActivityIsRequested()
+{
+ QSignalSpy activatedSpy(mActivationPrivate, SIGNAL(activated(Af::ActivationReason,QString,QVariantHash)));
+ QVERIFY(activatedSpy.isValid());
+
+ mServiceProvider->emitActivityRequested(mDefaultActivityName);
+ QCOMPARE(activatedSpy.count(), 1);
+
+ QCOMPARE(mActivationPrivate->reason(), Af::ActivationReasonActivity);
+ QCOMPARE(mActivationPrivate->name(), QString("TestActivity"));
+ QVERIFY(mActivationPrivate->parameters().contains("TestParam"));
+ QCOMPARE(mActivationPrivate->parameters().value("TestParam").toString(), QString("TestValue"));
+}
+
+void TestAfActivation::testChangingActivityInBackground()
+{
+ // bring to foreground is called by default
+ {
+ mServiceProvider->emitActivityRequested(mDefaultActivityName);
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher);
+ QCOMPARE(launcher->bringToForegroundCalls.count(), 1);
+ launcher->bringToForegroundCalls.clear();
+ }
+
+ // bring to foreground is not called if background parameter is present
+ {
+ mServiceProvider->emitActivityRequested(QString("appto://EBADC0DE?%1=TestActivity&%2=").arg(Af::KActivityUriNameKey).arg(Af::KActivityUriBackgroundKey));
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher);
+ QCOMPARE(launcher->bringToForegroundCalls.count(), 0);
+ }
+}
+
+QTEST_MAIN(TestAfActivation)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afactivation/t_afactivation.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+INCLUDEPATH += ./inc \
+ ../mocks/inc
+
+SOURCES += ./src/t_afactivation.cpp
+HEADERS += ./inc/t_afactivation.h
+
+SOURCES += ../../src/aflauncher.cpp \
+ ../../src/afactivation.cpp \
+ ../../src/afactivation_p.cpp \
+ ../../src/afcommandlineparser.cpp \
+ ../mocks/src/applicationlauncher_p.cpp \
+ ../mocks/src/afstorageproxy.cpp \
+
+HEADERS += ../../inc/aflauncher.h \
+ ../../../../homescreensrv_plat/activity_framework_api/afactivities_global.h \
+ ../../../../homescreensrv_plat/activity_framework_api/afactivation.h \
+ ../../inc/afactivation_p.h \
+ ../../inc/afcommandlineparser.h \
+ ../mocks/inc/applicationlauncher_p.h \
+ ../mocks/inc/afstorageproxy.h \
+
+include(../tsrc_common.pri)
+
+symbian:!coverage:CONFIG += symbian_test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afactivitystorage/inc/t_afactivitystorage.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TESTAFACTIVITYSTORAGE_H
+#define TESTAFACTIVITYSTORAGE_H
+
+#include <QObject>
+#include <QSharedPointer>
+#include "afstorageproxy.h"
+class AfActivityStoragePrivate;
+
+class TestAfActivityStorage : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+
+ void testSaveActivity();
+ void testRemoveActivity();
+ void testAllActivities();
+ void testActivityData();
+ void testActivityMetaData();
+
+private:
+ QSharedPointer<AfStorageProxy> mServiceProvider;
+ AfActivityStoragePrivate *mStorage;
+
+};
+
+#endif // TESTAFACTIVITYSTORAGE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afactivitystorage/src/t_afactivitystorage.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2009 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_afactivitystorage.h"
+
+#include <QtTest/QtTest>
+
+#include "afactivitystorage_p.h"
+
+const char DefaultActivityName [] = "DefaultTestActivityName";
+const char DefaultActivityPrivate [] = "DefaultTestActivityPrivateData";
+const char DefaultActivityPublic [] = "DefaultTestActivityPublicData";
+const char DefaultActivityPublicKey [] = "FakeData";
+
+void TestAfActivityStorage::init()
+{
+ mServiceProvider = QSharedPointer<AfStorageProxy>(new AfStorageProxy());
+ mStorage = new AfActivityStoragePrivate(mServiceProvider);
+}
+
+void TestAfActivityStorage::cleanup()
+{
+ delete mStorage;
+ mStorage = NULL;
+}
+
+void TestAfActivityStorage::testSaveActivity()
+{
+ const int applicationId(RProcess().SecureId().iId);
+ QString activityId(DefaultActivityName);
+ QVariant privateData(DefaultActivityPrivate);
+ QVariantHash publicData;
+ publicData.insert(DefaultActivityPublicKey, QVariant(DefaultActivityPublic));
+
+ mStorage->saveActivity(activityId, privateData, publicData);
+
+ QVERIFY(applicationId == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QVERIFY(activityId == mServiceProvider->mLastCallParams.value("activityId").toString());
+ QVERIFY(privateData == mServiceProvider->mLastCallParams.value("activityData"));
+ QVERIFY(publicData.count() <= mServiceProvider->mLastCallParams.value("metadata").toHash().count());
+}
+
+void TestAfActivityStorage::testRemoveActivity()
+{
+ const int applicationId(RProcess().SecureId().iId);
+ QString activityId(DefaultActivityName);
+
+ mStorage->removeActivity(activityId);
+
+ QVERIFY(applicationId == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QVERIFY(activityId == mServiceProvider->mLastCallParams.value("activityId").toString());
+}
+
+void TestAfActivityStorage::testAllActivities()
+{
+ const int applicationId(RProcess().SecureId().iId);
+
+ mStorage->allActivities();
+
+ QVERIFY(applicationId == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+}
+
+void TestAfActivityStorage::testActivityData()
+{
+ const int applicationId(RProcess().SecureId().iId);
+ QString activityId(DefaultActivityName);
+
+ mStorage->activityData(activityId);
+
+ QVERIFY(applicationId == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QVERIFY(activityId == mServiceProvider->mLastCallParams.value("activityId").toString());
+}
+
+void TestAfActivityStorage::testActivityMetaData()
+{
+ const int applicationId(RProcess().SecureId().iId);
+ QString activityId(DefaultActivityName);
+
+ mStorage->activityMetaData(activityId);
+
+ QVERIFY(applicationId == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QVERIFY(activityId == mServiceProvider->mLastCallParams.value("activityId").toString());
+}
+
+QTEST_MAIN(TestAfActivityStorage)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afactivitystorage/t_afactivitystorage.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2009 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:
+#
+
+INCLUDEPATH += ./inc \
+ ../mocks/inc
+
+SOURCES += ./src/t_afactivitystorage.cpp
+HEADERS += ./inc/t_afactivitystorage.h
+
+SOURCES += ../../src/afactivitystorage.cpp \
+ ../../src/afactivitystorage_p.cpp \
+ ../mocks/src/afstorageproxy.cpp \
+
+HEADERS += ../../../../homescreensrv_plat/activity_framework_api/afactivities_global.h \
+ ../../../../homescreensrv_plat/activity_framework_api/afactivitystorage.h \
+ ../../inc/afactivitystorage_p.h \
+ ../mocks/inc/afstorageproxy.h \
+
+include(../tsrc_common.pri)
+
+symbian:!coverage: CONFIG += symbian_test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afstorageproxy/inc/t_afstorageproxy.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TESTAFSTORAGEPROXY_H
+#define TESTAFSTORAGEPROXY_H
+
+#include <QObject>
+#include <QPixmap>
+
+class AfStorageProxy;
+
+class TestAfStorageProxy : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+
+// void testConstructorThrowsWhenStorageConstructionLeaves();
+// void testMethodsReturnFalseInCaseOfErrorsInStorage();
+
+ void testSaveActivityDataSerialization();
+ void testSaveActivityFlags();
+ void testSaveActivityScreenshotHandle();
+
+ void testDeprecatedAddAndUpdateMethods();
+
+ void testRemoveActivity();
+ void testRemoveApplicationActivities();
+ void testWaitActivity();
+ void testLaunchActivity();
+ void testGetThumbnail();
+ void testNotifyDataChange();
+ void testActivities();
+ void testApplicationActivities();
+ void testActivityData();
+ void testActivityMetaData();
+
+private:
+ QPixmap generateNonNullScreenshot();
+
+private:
+ AfStorageProxy *mProxy;
+};
+
+#endif // TESTAFSTORAGEPROXY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afstorageproxy/src/t_afstorageproxy.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,327 @@
+/*
+* Copyright (c) 2009 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_afstorageproxy.h"
+
+#include <QtTest/QtTest>
+#include <QPainter>
+#include <XQConversions>
+
+#include <afstorageglobals.h>
+#include <afentry.h>
+
+#include "afstorageclient.h"
+#include "afstorageproxy.h"
+#include "afserializer.h"
+
+namespace {
+ const int KApplicationId = 42;
+
+ const char KActivityId[] = "TestActivity";
+ const char KImagePath[] = "SomeFakePath";
+}
+
+void TestAfStorageProxy::init()
+{
+ mProxy = new AfStorageProxy();
+}
+
+void TestAfStorageProxy::cleanup()
+{
+ delete mProxy;
+ mProxy = NULL;
+}
+
+void TestAfStorageProxy::testSaveActivityDataSerialization()
+{
+ // check that data and metadata are properly serialized
+ QVariant data("Data");
+ QVariantHash metaData;
+ QString someKey("SomeKey");
+ QVariant someValue("SomeValue");
+ metaData.insert(someKey, someValue);
+
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->saveActivity(KApplicationId, KActivityId, data, metaData, QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::SaveActivityMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+
+ QVariantHash deserializedMetaData;
+ deserializedMetaData << entry->Data(CAfEntry::Public);
+ QVERIFY(deserializedMetaData.contains(someKey));
+ QCOMPARE(deserializedMetaData.value(someKey), someValue);
+
+ QVariantHash deserializedData;
+ deserializedData << entry->Data(CAfEntry::Private);
+ QVERIFY(deserializedData.contains(ActivityDataKeyword));
+ QCOMPARE(deserializedData.value(ActivityDataKeyword), data);
+}
+
+void TestAfStorageProxy::testSaveActivityFlags()
+{
+ // test that activities are visible and non-persistent by default
+ {
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::SaveActivityMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+
+ QVERIFY(!(entry->Flags() & CAfEntry::Persistent));
+ QVERIFY(!(entry->Flags() & CAfEntry::Invisible));
+ CAfStorageClient::clearLastCallInfo();
+ }
+
+ // test persistency flag is properly set
+ {
+ QVariantHash metaData;
+ metaData.insert(ActivityPersistence, true);
+
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), metaData, QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::SaveActivityMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+
+ QVERIFY(entry->Flags() & CAfEntry::Persistent);
+ CAfStorageClient::clearLastCallInfo();
+ }
+
+ // test visibility flag is properly set
+ {
+ QVariantHash metaData;
+ metaData.insert(ActivityVisibility, false);
+
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), metaData, QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::SaveActivityMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+
+ QVERIFY(entry->Flags() & CAfEntry::Invisible);
+ CAfStorageClient::clearLastCallInfo();
+ }
+}
+
+void TestAfStorageProxy::testSaveActivityScreenshotHandle()
+{
+ // in case of null pixmap -1 handle will be sent to server
+ {
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::SaveActivityMethod);
+
+ QCOMPARE(CAfStorageClient::lastCallImageHandle, -1);
+ CAfStorageClient::clearLastCallInfo();
+ }
+
+ // proper handle is sent for non-null pixmap
+ {
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), generateNonNullScreenshot());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::SaveActivityMethod);
+
+ QVERIFY(CAfStorageClient::lastCallImageHandle != -1);
+ CAfStorageClient::clearLastCallInfo();
+ }
+}
+
+void TestAfStorageProxy::testDeprecatedAddAndUpdateMethods()
+{
+ // we don't test those methods thoroughly, because a) it's basically the
+ // same code as saveActivity b) those methods are deprecated and will be
+ // removed soon.
+
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+
+ mProxy->addActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::AddActivityMethod);
+ mProxy->addActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), generateNonNullScreenshot());
+
+ mProxy->updateActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), QPixmap());
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::UpdateActivityMethod);
+ mProxy->updateActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), generateNonNullScreenshot());
+}
+
+void TestAfStorageProxy::testRemoveActivity()
+{
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->removeActivity(KApplicationId, KActivityId);
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::RemoveActivityMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+ QCOMPARE(entry->ApplicationId(), KApplicationId);
+ QScopedPointer<HBufC> activityIdAsDesc(XQConversions::qStringToS60Desc(QString(KActivityId)));
+ QVERIFY(entry->ActivityId().Compare(*activityIdAsDesc.data()) == 0);
+}
+
+void TestAfStorageProxy::testRemoveApplicationActivities()
+{
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->removeApplicationActivities(KApplicationId);
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::RemoveApplicationActivitiesMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+ QCOMPARE(entry->ApplicationId(), KApplicationId);
+}
+
+void TestAfStorageProxy::testWaitActivity()
+{
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+
+ CAfStorageClient::expectedReturnCode = KErrCancel;
+ mProxy->waitActivity();
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::WaitActivityMethod);
+
+ CAfStorageClient::lastMethodCalled = CAfStorageClient::NoCall;
+ CAfStorageClient::expectedReturnCode = KErrNone;
+ mProxy->waitActivity();
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::WaitActivityMethod);
+}
+
+void TestAfStorageProxy::testLaunchActivity()
+{
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+ mProxy->launchActivity(KApplicationId, KActivityId);
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::LaunchActivityMethod);
+
+ CAfEntry *entry = CAfStorageClient::lastCallEntry;
+ QVERIFY(entry);
+ QCOMPARE(entry->ApplicationId(), KApplicationId);
+ QScopedPointer<HBufC> activityIdAsDesc(XQConversions::qStringToS60Desc(QString(KActivityId)));
+ QVERIFY(entry->ActivityId().Compare(*activityIdAsDesc.data()) == 0);
+}
+
+void TestAfStorageProxy::testGetThumbnail()
+{
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+
+ CAfStorageClient::expectedReturnCode = KErrNone;
+ mProxy->getThumbnail(QSize(100, 50), QString(KImagePath), this);
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::GetThumbnailMethod);
+ QCOMPARE(CAfStorageClient::lastCallThumbnailSize.iWidth, 100);
+ QCOMPARE(CAfStorageClient::lastCallThumbnailSize.iHeight, 50);
+ QScopedPointer<HBufC> pathAsDesc(XQConversions::qStringToS60Desc(QString(KImagePath)));
+ QVERIFY(CAfStorageClient::lastCallThumbnailPath->Compare(*pathAsDesc.data()) == 0);
+ QVERIFY(CAfStorageClient::lastCallUserData == this);
+
+ CAfStorageClient::expectedReturnCode = KErrNone;
+ mProxy->getThumbnail(QSize(0, 0), QString(KImagePath), this);
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::GetThumbnailMethod);
+ QCOMPARE(CAfStorageClient::lastCallThumbnailSize.iWidth, 0);
+ QCOMPARE(CAfStorageClient::lastCallThumbnailSize.iHeight,0);
+ QVERIFY(CAfStorageClient::lastCallThumbnailPath->Compare(*pathAsDesc.data()) == 0);
+ QVERIFY(CAfStorageClient::lastCallUserData == this);
+
+ CAfStorageClient::expectedReturnCode = KErrAccessDenied;
+ mProxy->getThumbnail(QSize(100, 50), QString(KImagePath), this);
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::GetThumbnailMethod);
+ QCOMPARE(CAfStorageClient::lastCallThumbnailSize.iWidth, 100);
+ QCOMPARE(CAfStorageClient::lastCallThumbnailSize.iHeight,50);
+ QVERIFY(CAfStorageClient::lastCallThumbnailPath->Compare(*pathAsDesc.data()) == 0);
+ QVERIFY(CAfStorageClient::lastCallUserData == this);
+
+}
+
+void TestAfStorageProxy::testNotifyDataChange()
+{
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NoCall);
+
+ CAfStorageClient::expectedReturnCode = KErrCancel;
+ mProxy->notifyDataChange();
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NotifyDataChangeMethod);
+
+ CAfStorageClient::lastMethodCalled = CAfStorageClient::NoCall;
+ CAfStorageClient::expectedReturnCode = KErrNone;
+ mProxy->notifyDataChange();
+ QCOMPARE(CAfStorageClient::lastMethodCalled, CAfStorageClient::NotifyDataChangeMethod);
+}
+
+// ---------------------------------------------------------------------------
+void TestAfStorageProxy::testActivities()
+{
+ mProxy->removeApplicationActivities(KApplicationId);
+
+ QList< QVariantHash > result;
+ QVERIFY(mProxy->activities(result));
+ QVERIFY(result.count() >= 0);
+
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), generateNonNullScreenshot());
+ QVERIFY(mProxy->activities(result));
+ QVERIFY(result.count() > 0);
+}
+
+// ---------------------------------------------------------------------------
+void TestAfStorageProxy::testApplicationActivities()
+{
+ mProxy->removeApplicationActivities(KApplicationId);
+
+ QStringList result;
+ QVERIFY(mProxy->applicationActivities(result, KApplicationId));
+ QCOMPARE(result.count(), 0);
+
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(), QVariantHash(), generateNonNullScreenshot());
+ QVERIFY(mProxy->applicationActivities(result, KApplicationId));
+ QCOMPARE(result.count(), 1);
+}
+
+// ---------------------------------------------------------------------------
+void TestAfStorageProxy::testActivityData()
+{
+ mProxy->removeApplicationActivities(KApplicationId);
+
+ QVariant result;
+ QVERIFY(!mProxy->activityData(result, KApplicationId, KActivityId));
+
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(KApplicationId), QVariantHash(), generateNonNullScreenshot());
+ QVERIFY(mProxy->activityData(result, KApplicationId, KActivityId));
+ QCOMPARE(result, QVariant(KApplicationId));
+}
+
+void TestAfStorageProxy::testActivityMetaData()
+{
+ QVariantHash result;
+ QVERIFY(!mProxy->activityMetaData(result, KApplicationId, KActivityId));
+
+ mProxy->saveActivity(KApplicationId, KActivityId, QVariant(KApplicationId), QVariantHash(), generateNonNullScreenshot());
+ QVERIFY(mProxy->activityMetaData(result, KApplicationId, KActivityId));
+}
+
+// ---------------------------------------------------------------------------
+// helper methods
+// ---------------------------------------------------------------------------
+//
+QPixmap TestAfStorageProxy::generateNonNullScreenshot()
+{
+ QPixmap screenshot(10, 10);
+ {
+ QPainter painter(&screenshot);
+ painter.setBrush(Qt::black);
+ painter.drawRect(screenshot.rect());
+ painter.setBrush(QColor::fromHsv(0, 255, 255));
+ painter.drawEllipse(screenshot.rect());
+ }
+ return screenshot;
+}
+
+QTEST_MAIN(TestAfStorageProxy)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/t_afstorageproxy/t_afstorageproxy.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+# NOTE: the order of those directories is important
+INCLUDEPATH += ./inc \
+ ../../inc \ # use afstorageproxy.h from actual soruces, not mocks
+ ../mocks/inc \ # use afstorageclient.h from mocks, not the one exported by afstorageclient.dll
+ ../../../inc \ # use afasyncrequestobserver.h exported by afstorageclient.dll
+
+SOURCES += ./src/t_afstorageproxy.cpp
+HEADERS += ./inc/t_afstorageproxy.h
+
+SOURCES += ../../src/afstorageproxy.cpp \
+ ../../s60/src/afstorageproxy_p.cpp \
+ ../../s60/src/afserializer.cpp \
+ ../mocks/src/afstorageclient.cpp \
+
+HEADERS += ../../inc/afstorageproxy.h \
+ ../../s60/inc/afstorageproxy_p.h \
+ ../../s60/inc/afserializer.h \
+ ../mocks/inc/afstorageclient.h \
+
+include(../tsrc_common.pri)
+
+LIBS += -lxqutils \
+ -lafstoragecommon.lib \
+ -lfbscli \
+ -lestor \
+
+symbian:!coverage:CONFIG += symbian_test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS += unittest_activityserviceplugin
+SUBDIRS += unittest_activitymanager
+SUBDIRS += unittest_activityclient
+SUBDIRS += unittest_commandlineparser
+SUBDIRS += t_afactivation
+SUBDIRS += t_afactivitystorage
+SUBDIRS += t_afstorageproxy
+
+symbian {
+ SUBDIRS += ../../../internal/tsapps/testapp
+ SUBDIRS += ../../../internal/tstestutils
+ SUBDIRS += unittest_applicationluncher
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/tsrc_common.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2009 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(../activityserviceplugin.pri)
+
+CONFIG += qtestlib console
+
+INCLUDEPATH *= $$PWD/../inc
+DEPENDPATH *= $$PWD/../inc
+
+DEFINES += AFACTIVITIES_TEST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityclient/inc/unittest_activityclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+
+class TestActivityClient : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testAllMethods();
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityclient/src/unittest_activityclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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 "unittest_activityclient.h"
+
+#include <QtTest/QtTest>
+#include <QVariant>
+
+#include "afclient.h"
+#include "afactivitystorage.h"
+#include "afactivation.h"
+
+const char DefaultActivityName [] = "DefaultTestActivityName";
+const char DefaultActivityPrivate [] = "DefaultTestActivityPrivateData";
+const char DefaultActivityPublic [] = "DefaultTestActivityPublicData";
+const char DefaultActivityPublicKey [] = "FakeData";
+
+void TestActivityClient::testAllMethods()
+{
+ // prepare test data
+ RProcess process;
+ const int applicationId(process.SecureId().iId);
+ QString activityId(DefaultActivityName);
+ QVariant privateData(DefaultActivityPrivate);
+ QVariantHash publicData;
+ publicData.insert(DefaultActivityPublicKey, QVariant(DefaultActivityPublic));
+
+ // create object under test
+ AfClient *mClient = new AfClient(QSharedPointer<AfActivityStorage>(new AfActivityStorage()), QSharedPointer<AfActivation>(new AfActivation()));
+
+ // invoke all methods
+ mClient->addActivity(activityId, privateData, publicData);
+ mClient->updateActivity(activityId, privateData, publicData);
+ mClient->removeActivity(activityId);
+ mClient->activities();
+ mClient->activityData(activityId);
+
+ delete mClient;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityclient/src/unittest_main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include <QVariant>
+#include "unittest_activityclient.h"
+
+Q_DECLARE_METATYPE(QVariant)
+int main(int argc, char *argv[])
+{
+ qRegisterMetaType<QVariant>("QVariant");
+ QApplication app(argc, argv);
+
+ TestActivityClient tc;
+ return QTest::qExec(&tc, argc, argv);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityclient/unittest_activityclient.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,54 @@
+#
+# Copyright (c) 2009 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:
+#
+
+INCLUDEPATH += ./inc \
+ ../mocks/inc \
+
+SOURCES += ./src/unittest_activityclient.cpp \
+ ./src/unittest_main.cpp \
+
+HEADERS += ./inc/unittest_activityclient.h \
+
+SOURCES += ../../src/afclient.cpp \
+ ../../src/aflauncher.cpp \
+ ../../src/afactivitystorage.cpp \
+ ../../src/afactivitystorage_p.cpp \
+ ../../src/afactivation.cpp \
+ ../../src/afactivation_p.cpp \
+ ../../src/afcommandlineparser.cpp \
+ ../mocks/src/applicationlauncher_p.cpp \
+ ../mocks/src/afstorageproxy.cpp \
+
+HEADERS += ../../inc/afclient.h \
+ ../../inc/aflauncher.h \
+ ../../../../homescreensrv_plat/activity_framework_api/afactivities_global.h \
+ ../../../../homescreensrv_plat/activity_framework_api/afactivitystorage.h \
+ ../../inc/afactivitystorage_p.h \
+ ../../../../homescreensrv_plat/activity_framework_api/afactivation.h \
+ ../../inc/afactivation_p.h \
+ ../../inc/afcommandlineparser.h \
+ ../mocks/inc/applicationlauncher_p.h \
+ ../mocks/inc/afstorageproxy.h \
+
+include(../tsrc_common.pri)
+
+DEFINES += ACTIVITY_LIB
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ LIBS += -lthumbnailmanagerqt
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activitymanager/inc/unittest_activitymanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+#include <QSharedPointer>
+
+#include "afstorageproxy.h"
+class AfManager;
+
+class TestActivityManager : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void cleanup();
+
+ void testActivityList();
+ void testLaunchStartupCaseWithoutUri();
+ void testLaunchRunningCaseWithoutUri();
+ void testLaunchStartupCaseUsingUris();
+ void testLaunchRunningCaseUsingUris();
+ void testLaunchRequestsWithInvalidUris();
+ void testStartApplicationWithoutActivity();
+ void testSwitchApplicationToForegroundWithoutActivity();
+ void testGetThumbnail();
+ void testUriWithTestRangeUid();
+
+private:
+ QSharedPointer<AfStorageProxy> mServiceProvider;
+ AfManager *mManager;
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activitymanager/src/unittest_activitymanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,183 @@
+/*
+* Copyright (c) 2009 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 "unittest_activitymanager.h"
+
+#include <QtTest/QtTest>
+#include <QVariant>
+#include <QTimer>
+
+#include "afactivities_global.h"
+#include "applicationlauncher_p.h"
+#include "afmanager.h"
+
+const char DefaultActivityName [] = "DefaultTestActivityName";
+
+void TestActivityManager::init()
+{
+ mServiceProvider = QSharedPointer<AfStorageProxy>(new AfStorageProxy());
+ mManager = new AfManager(mServiceProvider);
+}
+
+void TestActivityManager::cleanup()
+{
+ delete mManager;
+ mManager = NULL;
+}
+
+
+void TestActivityManager::testActivityList()
+{
+ mManager->activitiesList();
+}
+
+void TestActivityManager::testLaunchStartupCaseWithoutUri()
+{
+ RProcess process;
+ const int applicationId(process.SecureId().iId);
+ QString activityId(DefaultActivityName);
+
+ mManager->launchActivity(applicationId, activityId);
+
+ // verify output
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 1);
+ QCOMPARE(launcher->startApplicationCalls.first().value("applicationId").toUInt(), QVariant(applicationId).toUInt());
+ QCOMPARE(launcher->startApplicationCalls.first().value("uri").toUrl().queryItemValue(Af::KActivityUriNameKey), activityId);
+}
+
+void TestActivityManager::testLaunchRunningCaseWithoutUri()
+{
+ ApplicationLauncherPrivate::isRunningReturnValue = true;
+ RProcess process;
+ const int applicationId(process.SecureId().iId);
+ QString activityId(DefaultActivityName);
+
+ mManager->launchActivity(applicationId, activityId);
+
+ QVERIFY(applicationId == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QCOMPARE(QUrl(mServiceProvider->mLastCallParams.value("activityUri").toString()).queryItemValue(Af::KActivityUriNameKey), activityId);
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 0);
+}
+
+void TestActivityManager::testLaunchStartupCaseUsingUris()
+{
+ ApplicationLauncherPrivate::isRunningReturnValue = false;
+
+ mManager->launchActivity(QUrl(QString("appto://EEEE0000?%1=TestName").arg(Af::KActivityUriNameKey)));
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 1);
+ QCOMPARE(launcher->startApplicationCalls.first().value("applicationId").toUInt(), QVariant(0xEEEE0000).toUInt());
+ QCOMPARE(launcher->startApplicationCalls.first().value("uri").toUrl().queryItemValue(Af::KActivityUriNameKey), QString("TestName"));
+}
+
+void TestActivityManager::testLaunchRunningCaseUsingUris()
+{
+ ApplicationLauncherPrivate::isRunningReturnValue = true;
+
+ mManager->launchActivity(QUrl(QString("appto://EEEE0000?%1=TestName").arg(Af::KActivityUriNameKey)));
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 0);
+
+ QVERIFY(0xEEEE0000 == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QCOMPARE(QUrl(mServiceProvider->mLastCallParams.value("activityUri").toString()).queryItemValue(Af::KActivityUriNameKey), QString("TestName"));
+}
+
+void TestActivityManager::testLaunchRequestsWithInvalidUris()
+{
+ // neither of the launchActivity() calls in this test should succeed, so the ActivityLauncher mock
+ // won't be created and we can expect that ApplicationLauncherPrivate::instance will return the
+ // same object through entire test.
+ ApplicationLauncherPrivate *expectedLauncherInstance = ApplicationLauncherPrivate::instance;
+
+ mManager->launchActivity(QUrl());
+ QVERIFY(ApplicationLauncherPrivate::instance == expectedLauncherInstance);
+
+ mManager->launchActivity(QUrl("arrr://DEADDEAD?pirates=yes"));
+ QVERIFY(ApplicationLauncherPrivate::instance == expectedLauncherInstance);
+
+ mManager->launchActivity(QUrl("appto://kaboom"));
+ QVERIFY(ApplicationLauncherPrivate::instance == expectedLauncherInstance);
+
+ mManager->launchActivity(QUrl(QString("appto://?%1=TestName").arg(Af::KActivityUriNameKey)));
+ QVERIFY(ApplicationLauncherPrivate::instance == expectedLauncherInstance);
+}
+
+void TestActivityManager::testStartApplicationWithoutActivity()
+{
+ ApplicationLauncherPrivate::isRunningReturnValue = false;
+
+ mManager->launchActivity(QUrl("appto://DEADBEEF"));
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 1);
+ QCOMPARE(launcher->bringToForegroundCalls.count(), 0);
+
+ QCOMPARE(launcher->startApplicationCalls.first().value("applicationId").toUInt(), QVariant(0xDEADBEEF).toUInt());
+ QCOMPARE(launcher->startApplicationCalls.first().value("uri").toUrl().queryItems().count(), 0);
+}
+
+void TestActivityManager::testSwitchApplicationToForegroundWithoutActivity()
+{
+ ApplicationLauncherPrivate::isRunningReturnValue = true;
+
+ mManager->launchActivity(QUrl("appto://DEADBEEF"));
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 0);
+
+ QVERIFY(0xDEADBEEF == mServiceProvider->mLastCallParams.value("applicationId").toInt());
+ QCOMPARE(QUrl(mServiceProvider->mLastCallParams.value("activityUri").toString()).queryItemValue(Af::KActivityUriNameKey), QString());
+}
+
+void TestActivityManager::testGetThumbnail()
+{
+ QSignalSpy spy(mManager, SIGNAL(thumbnailReady(QPixmap, void *)));
+ QEventLoop loop;
+ connect(mManager,
+ SIGNAL(thumbnailReady(QPixmap, void *)),
+ &loop,
+ SLOT(quit()));
+ //mManager->getThumbnail(23459821);
+ mManager->getThumbnail(QSize(128, 128), "somestring");
+ QTimer::singleShot(3000, &loop, SLOT(quit()));
+ loop.exec();
+ QVERIFY(1==spy.count());
+}
+
+void TestActivityManager::testUriWithTestRangeUid()
+{
+ ApplicationLauncherPrivate::isRunningReturnValue = false;
+
+ mManager->launchActivity(QUrl(QString("appto://EBADC0DE?%1=TestName").arg(Af::KActivityUriNameKey)));
+
+ ApplicationLauncherPrivate *launcher = ApplicationLauncherPrivate::instance;
+ QVERIFY(launcher); //sanity check
+ QCOMPARE(launcher->startApplicationCalls.count(), 1);
+ QCOMPARE(launcher->startApplicationCalls.first().value("applicationId").toUInt(), QVariant(0xEBADC0DE).toUInt());
+}
+
+QTEST_MAIN(TestActivityManager)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activitymanager/unittest_activitymanager.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+INCLUDEPATH += ./inc \
+ ../mocks/inc
+
+
+SOURCES += ./src/unittest_activitymanager.cpp
+HEADERS += ./inc/unittest_activitymanager.h
+
+SOURCES += ../../src/afmanager.cpp \
+ ../../src/aflauncher.cpp \
+ ../mocks/src/applicationlauncher_p.cpp \
+ ../mocks/src/afstorageproxy.cpp \
+
+
+HEADERS += ../../inc/afmanager.h \
+ ../../inc/aflauncher.h \
+ ../mocks/inc/applicationlauncher_p.h \
+ ../mocks/inc/afstorageproxy.h \
+
+include(../tsrc_common.pri)
+
+DEFINES += ACTIVITY_LIB
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ LIBS += -lthumbnailmanagerqt
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityserviceplugin/inc/unittest_activityserviceplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+
+#include "afserviceplugin.h"
+
+class ActivityInterface;
+
+class TestActivityServicePlugin : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void testActivityClientCreation();
+ void testActivityManagerCreation();
+ void testInvalidInterfaceCreation();
+ void testActivityManagerEmitsDataChangeSignalAfterSavingThroughStorage();
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityserviceplugin/src/unittest_activityserviceplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2009 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 "unittest_activityserviceplugin.h"
+
+#include <QtTest/QtTest>
+#include <QScopedPointer>
+#include <QDebug>
+
+#include <qservicemanager.h>
+
+#include <afstorageglobals.h>
+
+#include <tstestutils.h>
+
+void TestActivityServicePlugin::initTestCase()
+{
+ QServiceManager manager;
+ if (!manager.findServices().contains("ActivityService")) {
+ qDebug() << "ActivityService not found";
+ QVERIFY(QFile::exists(":/activityserviceplugin.xml"));
+ if (!manager.addService(":/activityserviceplugin.xml")) {
+ QFAIL(qPrintable(QString("Failed to add ActivityService: %1").arg(manager.error())));
+ }
+ QVERIFY(manager.findServices().contains("ActivityService"));
+ }
+}
+
+void TestActivityServicePlugin::testActivityClientCreation()
+{
+ QServiceManager manager;
+ QObject *activityClient = manager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ if (!activityClient) qDebug() << "error:" << manager.error();
+ QVERIFY(activityClient);
+ QCOMPARE(activityClient->metaObject()->className(), "AfClient");
+ delete activityClient;
+}
+
+void TestActivityServicePlugin::testActivityManagerCreation()
+{
+ QServiceManager manager;
+ QObject *activityManager = manager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!activityManager) qDebug() << "error:" << manager.error();
+ QVERIFY(activityManager);
+ QCOMPARE(activityManager->metaObject()->className(), "AfManager");
+ delete activityManager;
+}
+
+void TestActivityServicePlugin::testInvalidInterfaceCreation()
+{
+ QServiceManager manager;
+ QObject *invalidInterface = manager.loadInterface("com.nokia.qt.activities.BlahBlahBlah");
+ QVERIFY(!invalidInterface);
+}
+
+void TestActivityServicePlugin::testActivityManagerEmitsDataChangeSignalAfterSavingThroughStorage()
+{
+ QServiceManager manager;
+ QScopedPointer<QObject> activityManager(manager.loadInterface("com.nokia.qt.activities.ActivityManager"));
+ QVERIFY(activityManager.data());
+
+ QScopedPointer<QObject> activityStorage(manager.loadInterface("com.nokia.qt.activities.Storage"));
+ QVERIFY(activityStorage.data());
+
+ QSignalSpy dataChangedSpy(activityManager.data(), SIGNAL(dataChanged()));
+ QVERIFY(dataChangedSpy.isValid());
+ QCOMPARE(dataChangedSpy.count(), 0);
+
+ {
+ QPixmap screenshot(128, 128);
+ screenshot.fill(Qt::red);
+ QVERIFY(!screenshot.isNull());
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+
+ bool invokeResult;
+ bool saveResult;
+ invokeResult = QMetaObject::invokeMethod(
+ activityStorage.data(),
+ "saveActivity",
+ Q_RETURN_ARG(bool, saveResult),
+ Q_ARG(QString, "Test"),
+ Q_ARG(QVariant, "TestData"),
+ Q_ARG(QVariantHash, metadata));
+
+ QVERIFY(invokeResult);
+ QVERIFY(saveResult);
+ }
+
+ QVERIFY(dataChangedSpy.count() > 0 || TsTestUtils::waitForSignal(activityManager.data(), SIGNAL(dataChanged()), 1500));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityserviceplugin/src/unittest_main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 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 "unittest_activityserviceplugin.h"
+
+#include <QtTest/QtTest>
+QTEST_MAIN(TestActivityServicePlugin)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityserviceplugin/unittest_activityserviceplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2009 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(../tsrc_common.pri)
+
+SOURCES += ./src/unittest_activityserviceplugin.cpp \
+ ./src/unittest_main.cpp
+HEADERS += ./inc/unittest_activityserviceplugin.h
+
+RESOURCES += unittest_activityserviceplugin.qrc
+
+plugin.path = debug
+plugin.files = ../../debug/activityserviceplugin.dll
+plugin.CONFIG = no_link no_dependencies explicit_dependencies no_build combine ignore_no_exist no_clean
+INSTALLS += plugin
+build_pass:ALL_DEPS+=install_plugin
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+}
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_activityserviceplugin/unittest_activityserviceplugin.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/" >
+ <file alias="activityserviceplugin.xml">../../data/afservice.xml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_applicationluncher/inc/unittest_applicationluncher.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+
+#include <W32STD.H>
+
+#include <QUrl>
+
+class AfLauncher;
+
+class TestApplicationLuncher : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void testIsRunning();
+ void testStartApp();
+ void testbringToForeground();
+
+ void testLaunchActivity_data();
+ void testLaunchActivity();
+
+ void testGracefulHandlingOfInvalidUid();
+ void testGracefulHandlingOfCorruptedApplication();
+
+private:
+ bool sendToBackground(const TUid &uid);
+ TUid getForegroundAppUid();
+ QUrl buildUri(const TUid &uid, const QString &activityName);
+
+private:
+ RWsSession mWsSession;
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_applicationluncher/src/unittest_applicationluncher.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,199 @@
+/** Copyright (c) 2009 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 "unittest_applicationluncher.h"
+
+#include <e32std.h>
+#include <apgcli.h>
+#include <apacmdln.h>
+#include <apgtask.h>
+#include <APGWGNAM.H>
+#include <eikenv.h>
+#include <AknDef.h>
+
+#include <QtTest/QtTest>
+#include <QString>
+#include <QSystemSemaphore>
+
+#include <qvaluespacesubscriber.h>
+
+#include "tstestutils.h"
+
+#include "afactivities_global.h"
+#include "aflauncher.h"
+
+const TUid KIconApplicationUid = {0xEd0b4e47};
+const TUid KActivityApplicationUid = {0xEBADF00D};
+const TUid KInvalidUid = {0xDEADBEEF};
+const TUid KCorruptedApplicationUid = {0xE5C3B14E};
+
+namespace {
+ const char KIconApplicationName[] = "appwithicon";
+}
+
+QTM_USE_NAMESPACE
+
+// ---------------------------------------------------------------------------
+// Test cases
+// ---------------------------------------------------------------------------
+//
+void TestApplicationLuncher::initTestCase()
+{
+ QCOMPARE(mWsSession.Connect(), KErrNone);
+}
+
+void TestApplicationLuncher::cleanupTestCase()
+{
+ mWsSession.Close();
+}
+
+void TestApplicationLuncher::testIsRunning()
+{
+ AfLauncher launcher;
+
+ QVERIFY(!launcher.isRunning(KIconApplicationUid.iUid));
+
+ quint64 iconAppId;
+ QVERIFY(TsTestUtils::startApplication(KIconApplicationName, iconAppId));
+ QVERIFY(launcher.isRunning(KIconApplicationUid.iUid));
+
+ QVERIFY(TsTestUtils::closeApplication(iconAppId));
+ QVERIFY(!launcher.isRunning(KIconApplicationUid.iUid));
+}
+
+void TestApplicationLuncher::testStartApp()
+{
+ QSystemSemaphore semaphore("PublishActivityApp");
+ AfLauncher launcher;
+
+ QVERIFY(!launcher.isRunning(KActivityApplicationUid.iUid));
+
+ launcher.startApplication(KActivityApplicationUid.iUid, QString());
+ QVERIFY(semaphore.acquire());
+
+ QVERIFY(TsTestUtils::closeApplication(KActivityApplicationUid));
+ QVERIFY(!launcher.isRunning(KActivityApplicationUid.iUid));
+}
+
+void TestApplicationLuncher::testbringToForeground()
+{
+ AfLauncher launcher;
+
+ quint64 iconAppId;
+ QVERIFY(TsTestUtils::startApplication(KIconApplicationName, iconAppId));
+ QVERIFY(launcher.isRunning(KIconApplicationUid.iUid));
+
+ QVERIFY(sendToBackground(KIconApplicationUid));
+ QVERIFY(getForegroundAppUid() != KIconApplicationUid);
+ QTest::qWait(3000); // for some reason if there is no timeout, the test application will restart itself after kill
+
+ launcher.bringToForeground(KIconApplicationUid.iUid);
+ QVERIFY(getForegroundAppUid() == KIconApplicationUid);
+ QTest::qWait(3000); // for some reason if there is no timeout, the test application will restart itself after kill
+
+ QVERIFY(TsTestUtils::closeApplication(iconAppId));
+ QVERIFY(!launcher.isRunning(KIconApplicationUid.iUid));
+}
+
+// ---------------------------------------------------------------
+
+void TestApplicationLuncher::testLaunchActivity_data()
+{
+ QTest::addColumn<QString>("activityName");
+
+ QTest::newRow("normal") << "blahblahblah";
+ QTest::newRow("special characters") << "asd $&+,/:;=?@ \"<>#%{}|\\^~[]`asd";
+}
+
+void TestApplicationLuncher::testLaunchActivity()
+{
+ QSystemSemaphore semaphore("PublishActivityApp");
+
+ AfLauncher launcher;
+ QVERIFY(!launcher.isRunning(KActivityApplicationUid.iUid));
+
+ QFETCH(QString, activityName);
+ launcher.startApplication(KActivityApplicationUid.iUid, buildUri(KActivityApplicationUid, activityName));
+ semaphore.acquire();
+
+ QCOMPARE(QValueSpaceSubscriber("/PublishActivityApp/ActivityName").value().toString(), activityName);
+
+ QVERIFY(TsTestUtils::closeApplication(KActivityApplicationUid));
+ QVERIFY(!launcher.isRunning(KIconApplicationUid.iUid));
+}
+
+// ---------------------------------------------------------------
+
+void TestApplicationLuncher::testGracefulHandlingOfInvalidUid()
+{
+ AfLauncher launcher;
+ launcher.startApplication(KInvalidUid.iUid, QString());
+}
+
+void TestApplicationLuncher::testGracefulHandlingOfCorruptedApplication()
+{
+ AfLauncher launcher;
+
+ // We're going to test Launcher behavior when someone tries to start
+ // application with missing executable file
+ launcher.startApplication(KCorruptedApplicationUid.iUid, QString());
+}
+
+// ---------------------------------------------------------------------------
+// Helper methods
+// ---------------------------------------------------------------------------
+//
+QUrl TestApplicationLuncher::buildUri(const TUid &uid, const QString &activityName)
+{
+ QUrl uri;
+ uri.setScheme("appto");
+ uri.setHost(QString("%1").arg(static_cast<uint>(uid.iUid), 8, 16, QChar('0')));
+ uri.addQueryItem(Af::KActivityUriNameKey, activityName);
+ return uri;
+}
+
+bool TestApplicationLuncher::sendToBackground(const TUid &uid)
+{
+ TApaTaskList taskList(mWsSession);
+ TApaTask task = taskList.FindApp(uid);
+ bool taskExists = task.Exists();
+ if (taskExists) {
+ task.SendToBackground();
+ }
+ return taskExists;
+}
+
+TUid TestApplicationLuncher::getForegroundAppUid()
+{
+ RWsSession wsSession;
+ // get all window groups
+ RArray<RWsSession::TWindowGroupChainInfo> windowGroupList;
+ CleanupClosePushL(windowGroupList);
+ User::LeaveIfError(mWsSession.WindowGroupList(0, &windowGroupList));
+
+ if (windowGroupList.Count() == 0) {
+ User::Leave(KErrNotFound);
+ }
+
+ // get uid of first window group
+ CApaWindowGroupName* windowGroupName = CApaWindowGroupName::NewLC(mWsSession, windowGroupList[0].iId);
+ TUid foregroundAppUid = windowGroupName->AppUid();
+ CleanupStack::PopAndDestroy(windowGroupName);
+ CleanupStack::PopAndDestroy(&windowGroupList);
+
+ return foregroundAppUid;
+}
+
+QTEST_MAIN(TestApplicationLuncher)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_applicationluncher/unittest_applicationluncher.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2009 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(../tsrc_common.pri)
+
+CONFIG *= mobility
+MOBILITY *= publishsubscribe
+
+SOURCES += ./src/unittest_applicationluncher.cpp
+HEADERS += ./inc/unittest_applicationluncher.h
+
+SOURCES += ../../s60/src/applicationlauncher_p.cpp \
+ ../../src/aflauncher.cpp \
+
+HEADERS += ../../s60/inc/applicationlauncher_p.h \
+ ../../inc/aflauncher.h \
+
+LIBS += -lxqutils
+LIBS += -lws32.dll
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.CAPABILITY = ALL -TCB
+
+ LIBS += -lapgrfx \ # for TApaTaskList
+ -lapparc \ # for TApaAppInfo
+ -lcone \ # for CCoeEnv
+
+}
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_commandlineparser/inc/unittest_commandlineparser.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+
+class TestCommandLineParser : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testActivityUriParsingAllOk();
+ void testActivityUriParsingEmptyActivityName();
+ void testActivityUriParsingNoActivityName();
+ void testActivityUriParsingNoArgumentAfterMarker();
+ void testActivityUriParsingNoMarker();
+ void testActivityUriParsingNoUriAfterMarker();
+ void testNormalStartParsingEmpty();
+ void testNormalStartParsingSomeParameters();
+ void testNormalStartParsingOneParameter();
+ void testServiceParsing();
+ void testServiceParsingEmbedded();
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_commandlineparser/src/unittest_commandlineparser.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,206 @@
+/*
+* Copyright (c) 2009 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 "unittest_commandlineparser.h"
+
+#include <QtTest/QtTest>
+#include <QVariant>
+#include <QString>
+#include <QStringList>
+
+#include "afactivities_global.h"
+#include "afcommandlineparser.h"
+
+void TestCommandLineParser::testActivityUriParsingAllOk()
+{
+ QStringList commandLine;
+ commandLine << "Appname" << "-activity" << QString("appto://DEADBEEF?%1=TestActivity1").arg(Af::KActivityUriNameKey);
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 1);
+ QVERIFY(activityParams.contains(Af::KActivityUriNameKey));
+ QCOMPARE(activityParams.value(Af::KActivityUriNameKey), QVariant("TestActivity1"));
+ QCOMPARE(name, QString("TestActivity1"));
+ QCOMPARE(reason, Af::ActivationReasonActivity);
+}
+
+void TestCommandLineParser::testActivityUriParsingEmptyActivityName()
+{
+ QStringList commandLine;
+ commandLine << "Appname" << "-activity" << QString("appto://DEADBEEF?%1=&someKey=someValue").arg(Af::KActivityUriNameKey);
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testActivityUriParsingNoActivityName()
+{
+ QStringList commandLine;
+ commandLine << "Appname" << "-activity" << "appto://DEADBEEF?someKey=someValue";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testActivityUriParsingNoArgumentAfterMarker()
+{
+ QStringList commandLine;
+ commandLine << "Appname" << "-activity";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testActivityUriParsingNoMarker()
+{
+ QStringList commandLine;
+ commandLine << "Appname";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testActivityUriParsingNoUriAfterMarker()
+{
+ QStringList commandLine;
+ commandLine << "Appname"<< "-activity" << "adsasdasd";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testNormalStartParsingEmpty()
+{
+ QStringList commandLine;
+ commandLine << "Appname";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testNormalStartParsingSomeParameters()
+{
+ QStringList commandLine;
+ commandLine << "Appname" << "test1" << "test2";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testNormalStartParsingOneParameter()
+{
+ QStringList commandLine;
+ commandLine << "Appname" << "test1%&^test2";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 0);
+ QVERIFY(name.isEmpty());
+ QCOMPARE(reason, Af::ActivationReasonNormal);
+}
+
+void TestCommandLineParser::testServiceParsing()
+{
+ QStringList commandLine;
+ commandLine << "Appname " << "service=yes" << "intf=IntName" << "oper=Operation";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 2);
+ QCOMPARE(activityParams.value("oper"), QVariant("Operation"));
+ QCOMPARE(name, QString("IntName"));
+ QCOMPARE(reason, Af::ActivationReasonService);
+}
+
+void TestCommandLineParser::testServiceParsingEmbedded()
+{
+ QStringList commandLine;
+ commandLine << "Appname " << "embedded=yes" << "service=yes" << "intf=IntName" << "oper=Operation";
+
+ QVariantHash activityParams = QVariantHash();
+ QString name = QString();
+ Af::ActivationReason reason = Af::ActivationReasonNormal;
+
+ AfCommandLineParser::parseCommandLine(commandLine, reason, name, activityParams);
+
+ QCOMPARE(activityParams.count(), 3);
+ QCOMPARE(activityParams.value("oper"), QVariant("Operation"));
+ QCOMPARE(activityParams.value("embedded"), QVariant(true));
+ QCOMPARE(name, QString("IntName"));
+ QCOMPARE(reason, Af::ActivationReasonService);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_commandlineparser/src/unittest_main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include <QVariant>
+#include "unittest_commandlineparser.h"
+
+Q_DECLARE_METATYPE(QVariant)
+int main(int argc, char *argv[])
+{
+ qRegisterMetaType<QVariant>("QVariant");
+ QApplication app(argc, argv);
+
+ TestCommandLineParser tc;
+ return QTest::qExec(&tc, argc, argv);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/activityserviceplugin/tsrc/unittest_commandlineparser/unittest_commandlineparser.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2009 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:
+#
+
+INCLUDEPATH += ./inc \
+ ../../inc \
+ ../mocks/inc
+
+
+SOURCES += ./src/unittest_commandlineparser.cpp \
+ ./src/unittest_main.cpp
+HEADERS += ./inc/unittest_commandlineparser.h
+
+SOURCES += ../../src/afcommandlineparser.cpp
+
+HEADERS += ../../../../homescreensrv_plat/activity_framework_api/afactivities_global.h \
+ ../../inc/afcommandlineparser.h
+
+include(../tsrc_common.pri)
+
+DEFINES += ACTIVITY_LIB
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ LIBS += -lthumbnailmanagerqt
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/afactivitylauncher.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+symbian {
+ BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"group/bld.inf\""
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/bwins/afactivitylauncheru.def Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+EXPORTS
+ ?NewLC@CAfActivityLauncher@@SAPAV1@AAVRApaLsSession@@AAVRWsSession@@@Z @ 1 NONAME ; class CAfActivityLauncher * CAfActivityLauncher::NewLC(class RApaLsSession &, class RWsSession &)
+ ?launchActivityL@CAfActivityLauncherPrivate@@QAEXABVTDesC16@@@Z @ 2 NONAME ; void CAfActivityLauncherPrivate::launchActivityL(class TDesC16 const &)
+ ?launchActivityL@CAfActivityLauncher@@QAEXABVTDesC16@@@Z @ 3 NONAME ; void CAfActivityLauncher::launchActivityL(class TDesC16 const &)
+ ?NewL@CAfActivityLauncher@@SAPAV1@AAVRApaLsSession@@AAVRWsSession@@@Z @ 4 NONAME ; class CAfActivityLauncher * CAfActivityLauncher::NewL(class RApaLsSession &, class RWsSession &)
+ ??1CAfActivityLauncher@@UAE@XZ @ 5 NONAME ; CAfActivityLauncher::~CAfActivityLauncher(void)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/eabi/afactivitylauncheru.def Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,14 @@
+EXPORTS
+ _ZN19CAfActivityLauncher15launchActivityLERK7TDesC16 @ 1 NONAME
+ _ZN19CAfActivityLauncher4NewLER13RApaLsSessionR10RWsSession @ 2 NONAME
+ _ZN19CAfActivityLauncher5NewLCER13RApaLsSessionR10RWsSession @ 3 NONAME
+ _ZN19CAfActivityLauncherD0Ev @ 4 NONAME
+ _ZN19CAfActivityLauncherD1Ev @ 5 NONAME
+ _ZN19CAfActivityLauncherD2Ev @ 6 NONAME
+ _ZTI19CAfActivityLauncher @ 7 NONAME
+ _ZTI26CAfActivityLauncherPrivate @ 8 NONAME
+ _ZTI8CAfEntry @ 9 NONAME
+ _ZTV19CAfActivityLauncher @ 10 NONAME
+ _ZTV26CAfActivityLauncherPrivate @ 11 NONAME
+ _ZTV8CAfEntry @ 12 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/group/afactivitylauncher.mmp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+TARGET afactivitylauncher.dll
+TARGETTYPE dll
+UID 0x1000008d 0x20026784
+SECUREID 0x20026784
+
+CAPABILITY ALL -TCB
+
+
+EPOCHEAPSIZE 0x100000 0x600000 // 1MB - 6MB
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+SYSTEMINCLUDE ../../inc
+
+SOURCEPATH ../src
+SOURCE afactivitylauncher.cpp
+SOURCE afactivitylauncher_p.cpp
+SOURCE afapplicationlauncher.cpp
+
+LIBRARY euser.lib
+LIBRARY inetprotutil.lib
+LIBRARY apgrfx.lib
+LIBRARY cone.lib
+LIBRARY apparc.lib
+LIBRARY estor.lib
+LIBRARY afstorageclient.lib
+STATICLIBRARY afstoragecommon.lib
+
+DEBUGLIBRARY flogger.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/group/bld.inf Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+afactivitylauncher.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/inc/afactivitylauncher_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef AFACTIVITYLAUNCHERPRIVATE_H
+#define AFACTIVITYLAUNCHERPRIVATE_H
+
+#include <e32base.h>
+
+#include <afasyncrequestobserver.h>
+#include "afapplicationlauncher.h"
+
+class CAfStorageClient;
+
+class CAfActivityLauncherPrivate : public CBase, public MAfAsyncRequestObserver
+{
+
+public:
+ static CAfActivityLauncherPrivate *NewL(RApaLsSession &apaLsSession, RWsSession &wsSession);
+ ~CAfActivityLauncherPrivate();
+
+private:
+ CAfActivityLauncherPrivate(RApaLsSession &apaLsSession, RWsSession &wsSession);
+ void ConstructL();
+
+public: // from MAfAsyncRequestObserver
+ virtual void waitActivityRequestCompleted(int result, const TDesC8 &data);
+ virtual void getThumbnailRequestCompleted(int result, int bitmapHandle, void *userData);
+ virtual void dataChangeNotificationCompleted(int result);
+
+public:
+ IMPORT_C void launchActivityL(const TDesC &uriDesc);
+
+private:
+ CAfStorageClient *mActivitiesClient;
+ TAfApplicationLauncher mApplicationLauncher;
+
+};
+
+#endif // AFACTIVITYLAUNCHERPRIVATE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/inc/afapplicationlauncher.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef AFAPPLICATIONLAUNCHER_H
+#define AFAPPLICATIONLAUNCHER_H
+
+#include <e32base.h>
+#include <apgcli.h>
+#include <w32std.h>
+
+class TAfApplicationLauncher
+{
+public:
+ TAfApplicationLauncher(RApaLsSession &apaLsSession, RWsSession &wsSession);
+
+public:
+ TBool isRunning(TUid applicationId);
+ void startApplicationL(TUid applicationId, const TDesC &uri);
+
+private:
+ RApaLsSession &mApaLsSession;
+ RWsSession &mWsSession;
+
+};
+
+#endif // AFAPPLICATIONLAUNCHER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/src/afactivitylauncher.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 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 "afactivitylauncher.h"
+#include "afactivitylauncher_p.h"
+
+// -----------------------------------------------------------------------------
+// Public part of construction, destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CAfActivityLauncher *CAfActivityLauncher::NewL(RApaLsSession &apaLsSession, RWsSession &wsSession)
+{
+ CAfActivityLauncher *self = CAfActivityLauncher::NewLC(apaLsSession, wsSession);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+EXPORT_C CAfActivityLauncher *CAfActivityLauncher::NewLC(RApaLsSession &apaLsSession, RWsSession &wsSession)
+{
+ CAfActivityLauncher *self = new (ELeave) CAfActivityLauncher();
+ CleanupStack::PushL(self);
+ self->ConstructL(apaLsSession, wsSession);
+ return self;
+}
+
+EXPORT_C CAfActivityLauncher::~CAfActivityLauncher()
+{
+ delete mImplementation;
+}
+
+// -----------------------------------------------------------------------------
+// Private part of construction
+// -----------------------------------------------------------------------------
+//
+CAfActivityLauncher::CAfActivityLauncher()
+{
+}
+
+void CAfActivityLauncher::ConstructL(RApaLsSession &apaLsSession, RWsSession &wsSession)
+{
+ mImplementation = CAfActivityLauncherPrivate::NewL(apaLsSession, wsSession);
+}
+
+// -----------------------------------------------------------------------------
+// Actual activity launching
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C void CAfActivityLauncher::launchActivityL(const TDesC &uriDesc)
+{
+ mImplementation->launchActivityL(uriDesc);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/src/afactivitylauncher_p.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2009 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 "afactivitylauncher_p.h"
+
+#include <uri16.h>
+#include <delimitedquery16.h>
+
+#include <afstorageclient.h>
+#include <afentry.h>
+
+// -----------------------------------------------------------------------------
+// Public part of construction, destructor
+// -----------------------------------------------------------------------------
+//
+CAfActivityLauncherPrivate *CAfActivityLauncherPrivate::NewL(RApaLsSession &apaLsSession, RWsSession &wsSession)
+{
+ CAfActivityLauncherPrivate *self = new (ELeave)CAfActivityLauncherPrivate(apaLsSession, wsSession);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+CAfActivityLauncherPrivate::~CAfActivityLauncherPrivate()
+{
+ delete mActivitiesClient;
+}
+
+// -----------------------------------------------------------------------------
+// Private part of construction
+// -----------------------------------------------------------------------------
+//
+CAfActivityLauncherPrivate::CAfActivityLauncherPrivate(RApaLsSession &apaLsSession, RWsSession &wsSession) : mApplicationLauncher(apaLsSession, wsSession)
+{
+}
+
+void CAfActivityLauncherPrivate::ConstructL()
+{
+ mActivitiesClient = CAfStorageClient::NewL(*this);
+}
+
+// -----------------------------------------------------------------------------
+// Implementation of MAfAsyncRequestObserver interface. We don't need any
+// notifications, but we have to pass an instance of this interface to
+// CAfStorageClient constructor.
+// -----------------------------------------------------------------------------
+//
+void CAfActivityLauncherPrivate::waitActivityRequestCompleted(int /*result*/, const TDesC8 &/*data*/)
+{
+}
+
+void CAfActivityLauncherPrivate::getThumbnailRequestCompleted(int /*result*/, int /*bitmapHandle*/, void */*userData*/)
+{
+}
+
+void CAfActivityLauncherPrivate::dataChangeNotificationCompleted(int /*result*/)
+{
+}
+
+// -----------------------------------------------------------------------------
+// Actual activity launching
+// -----------------------------------------------------------------------------
+//
+
+void CAfActivityLauncherPrivate::launchActivityL(const TDesC &uriDesc)
+{
+ TUriParser16 parser;
+ parser.Parse(uriDesc);
+
+ if (parser.Extract(EUriScheme).Compare(_L("appto")) == 0) {
+ TLex16 uidParser(parser.Extract(EUriHost));
+ TUint uid;
+ User::LeaveIfError(uidParser.Val(uid, EHex));
+
+ if (mApplicationLauncher.isRunning(TUid::Uid(uid))) {
+ CAfEntry *launchRequest = CAfEntry::NewLC(0, uid, uriDesc, KNullDesC(), KNullDesC8(), KNullDesC8());
+ User::LeaveIfError(mActivitiesClient->launchActivity(*launchRequest));
+ CleanupStack::PopAndDestroy(launchRequest);
+ } else {
+ mApplicationLauncher.startApplicationL(TUid::Uid(uid), uriDesc);
+ }
+ } else {
+ User::Leave(KErrArgument);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/src/afapplicationlauncher.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 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 "afapplicationlauncher.h"
+
+#include <apacmdln.h>
+#include <eikenv.h>
+#include <apgtask.h>
+
+// -----------------------------------------------------------------------------
+// Construction
+// -----------------------------------------------------------------------------
+//
+TAfApplicationLauncher::TAfApplicationLauncher(RApaLsSession &apaLsSession, RWsSession &wsSession) : mApaLsSession(apaLsSession), mWsSession(wsSession)
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TBool TAfApplicationLauncher::isRunning(TUid applicationId)
+{
+ TApaTaskList taskList(mWsSession);
+ TApaTask task = taskList.FindApp(applicationId);
+ return task.Exists();
+}
+
+void TAfApplicationLauncher::startApplicationL(TUid applicationId, const TDesC &uri)
+{
+ _LIT(KActivityMarker, "-activity ");
+ RBuf commandLine;
+ CleanupClosePushL(commandLine);
+ commandLine.ReAllocL(KActivityMarker().Length() + uri.Length());
+ commandLine.Append(KActivityMarker());
+ commandLine.Append(uri);
+
+ TApaAppInfo appInfo;
+ User::LeaveIfError(mApaLsSession.GetAppInfo(appInfo, applicationId));
+
+ RProcess application;
+ CleanupClosePushL(application);
+ User::LeaveIfError(application.Create(appInfo.iFullName, commandLine));
+ application.Resume();
+
+ CleanupStack::PopAndDestroy(&application);
+ CleanupStack::PopAndDestroy(&commandLine);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/inc/t_afactivitylauncher.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_AFACTIVITYLAUNCHER_H
+#define T_AFACTIVITYLAUNCHER_H
+
+#include <QObject>
+
+#include <apgcli.h>
+#include <w32std.h>
+
+class CAfActivityLauncher;
+
+class TestAfActivityLauncher : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void init();
+ void cleanup();
+
+ void testScheme();
+ void testUidParsing();
+ void testRunningCase();
+ void testStartupCase();
+
+ void callUnusedCallbacks();
+
+private:
+ CAfActivityLauncher *mLauncher;
+
+ RApaLsSession mApaLsSession;
+ RWsSession mWsSession;
+
+};
+
+#endif // T_AFACTIVITYLAUNCHER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/mocks/inc/afapplicationlauncher.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef AFAPPLICATIONLAUNCHER_H
+#define AFAPPLICATIONLAUNCHER_H
+
+#include <e32base.h>
+
+class RApaLsSession;
+class RWsSession;
+
+class TAfApplicationLauncher
+{
+
+public:
+ TAfApplicationLauncher(RApaLsSession &apaLsSession, RWsSession &wsSession);
+
+public:
+ TBool isRunning(TUid applicationId);
+ void startApplicationL(TUid applicationId, const TDesC &uri);
+
+public:
+ static TBool expectedIsRunningResult;
+
+ static TInt lastStartAppId;
+ static HBufC *lastStartUri;
+
+};
+
+#endif // AFAPPLICATIONLAUNCHER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/mocks/inc/afstorageclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef AFSTORAGECLIENT_H
+#define AFSTORAGECLIENT_H
+
+#include "afasyncrequestobserver.h"
+
+class CAfEntry;
+
+class CAfStorageClient : public CBase
+{
+public:
+ static CAfStorageClient *NewL(MAfAsyncRequestObserver &observer);
+ static CAfStorageClient *NewLC(MAfAsyncRequestObserver &observer);
+ virtual ~CAfStorageClient();
+
+private:
+ CAfStorageClient();
+
+public:
+ int launchActivity(const CAfEntry &entry);
+
+public:
+ static TInt lastLaunchAppId;
+ static HBufC *lastLaunchUri;
+
+};
+
+#endif //AFSTORAGECLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/mocks/src/afapplicationlauncher.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 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 "afapplicationlauncher.h"
+
+TBool TAfApplicationLauncher::expectedIsRunningResult = EFalse;
+TInt TAfApplicationLauncher::lastStartAppId = 0;
+HBufC* TAfApplicationLauncher::lastStartUri = 0;
+
+// -----------------------------------------------------------------------------
+// Public part of Construction, destructor
+// -----------------------------------------------------------------------------
+//
+TAfApplicationLauncher::TAfApplicationLauncher(RApaLsSession &/*apaLsSession*/, RWsSession &/*wsSession*/)
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TBool TAfApplicationLauncher::isRunning(TUid /*applicationId*/)
+{
+ return expectedIsRunningResult;
+}
+
+void TAfApplicationLauncher::startApplicationL(TUid applicationId, const TDesC &uri)
+{
+ lastStartAppId = applicationId.iUid;
+ lastStartUri = uri.Alloc();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/mocks/src/afstorageclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 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 "afstorageclient.h"
+
+#include <afentry.h>
+
+TInt CAfStorageClient::lastLaunchAppId = 0;
+HBufC* CAfStorageClient::lastLaunchUri = 0;
+
+CAfStorageClient *CAfStorageClient::NewL(MAfAsyncRequestObserver &observer)
+{
+ CAfStorageClient *self = CAfStorageClient::NewLC(observer);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+CAfStorageClient *CAfStorageClient::NewLC(MAfAsyncRequestObserver &/*observer*/)
+{
+ CAfStorageClient *self = new (ELeave) CAfStorageClient();
+ CleanupStack::PushL(self);
+ return self;
+}
+
+CAfStorageClient::~CAfStorageClient()
+{
+ delete lastLaunchUri;
+ lastLaunchUri = 0;
+}
+
+CAfStorageClient::CAfStorageClient()
+{
+}
+
+int CAfStorageClient::launchActivity(const CAfEntry &entry)
+{
+ lastLaunchAppId = entry.ApplicationId();
+ lastLaunchUri = entry.ActivityId().Alloc();
+
+ return KErrNone;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/src/t_afactivitylauncher.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2009 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_afactivitylauncher.h"
+
+#include <QtTest/QtTest>
+#include "afapplicationlauncher.h"
+#include <afstorageclient.h>
+#include "afactivitylauncher.h"
+#include "afactivitylauncher_p.h"
+
+
+void TestAfActivityLauncher::initTestCase()
+{
+ QCOMPARE(mApaLsSession.Connect(), KErrNone);
+ QCOMPARE(mWsSession.Connect(), KErrNone);
+}
+
+void TestAfActivityLauncher::cleanupTestCase()
+{
+ mApaLsSession.Close();
+ mWsSession.Close();
+}
+
+void TestAfActivityLauncher::init()
+{
+ QT_TRAP_THROWING(mLauncher = CAfActivityLauncher::NewL(mApaLsSession, mWsSession));
+}
+
+void TestAfActivityLauncher::cleanup()
+{
+ delete TAfApplicationLauncher::lastStartUri;
+ TAfApplicationLauncher::lastStartUri = 0;
+ TAfApplicationLauncher::lastStartAppId = 0;
+
+ delete CAfStorageClient::lastLaunchUri;
+ CAfStorageClient::lastLaunchUri = 0;
+ CAfStorageClient::lastLaunchAppId = 0;
+
+ delete mLauncher;
+ mLauncher = 0;
+}
+
+void TestAfActivityLauncher::testScheme()
+{
+ TAfApplicationLauncher::expectedIsRunningResult = ETrue;
+
+ TInt error;
+ TRAP(error, mLauncher->launchActivityL(_L("appto://DEADBEEF")));
+ QCOMPARE(error, KErrNone);
+
+ TRAP(error, mLauncher->launchActivityL(_L("bzzzt://DEADBEEF")));
+ QCOMPARE(error, KErrArgument);
+}
+
+void TestAfActivityLauncher::testUidParsing()
+{
+ TAfApplicationLauncher::expectedIsRunningResult = ETrue;
+
+ TInt error;
+ TRAP(error, mLauncher->launchActivityL(_L("appto://DEADBEEF")));
+ QCOMPARE(error, KErrNone);
+
+ TRAP(error, mLauncher->launchActivityL(_L("appto://INVALID")));
+ QCOMPARE(error, KErrGeneral);
+}
+
+void TestAfActivityLauncher::testRunningCase()
+{
+ TAfApplicationLauncher::expectedIsRunningResult = ETrue;
+
+ _LIT(KActivityUri, "appto://DEADBEEF");
+ TRAPD(error, mLauncher->launchActivityL(KActivityUri));
+ QCOMPARE(error, KErrNone);
+
+ QCOMPARE(CAfStorageClient::lastLaunchAppId, TInt(0xDEADBEEF));
+ QVERIFY(CAfStorageClient::lastLaunchUri->Compare(KActivityUri()) == 0);
+}
+
+void TestAfActivityLauncher::testStartupCase()
+{
+ TAfApplicationLauncher::expectedIsRunningResult = EFalse;
+
+ _LIT(KActivityUri, "appto://DEADBEEF");
+ TRAPD(error, mLauncher->launchActivityL(KActivityUri));
+ QCOMPARE(error, KErrNone);
+
+ QCOMPARE(TAfApplicationLauncher::lastStartAppId, TInt(0xDEADBEEF));
+ QVERIFY(TAfApplicationLauncher::lastStartUri->Compare(KActivityUri()) == 0);
+}
+
+void TestAfActivityLauncher::callUnusedCallbacks()
+{
+ CAfActivityLauncherPrivate* imp = CAfActivityLauncherPrivate::NewL(mApaLsSession, mWsSession);
+ imp->waitActivityRequestCompleted(0, KNullDesC8());
+ imp->getThumbnailRequestCompleted(0, 0, 0);
+ imp->dataChangeNotificationCompleted(0);
+ delete imp;
+}
+
+QTEST_MAIN(TestAfActivityLauncher)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_afactivitylauncher/t_afactivitylauncher.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console
+
+INCLUDEPATH += ./inc \
+ mocks/inc/ \
+ ../../inc \
+ ../../../inc \
+
+HEADERS += ./inc/t_afactivitylauncher.h
+
+SOURCES += mocks/src/afapplicationlauncher.cpp \
+ ./src/t_afactivitylauncher.cpp \
+ ../../src/afactivitylauncher.cpp \
+ ../../src/afactivitylauncher_p.cpp \
+ mocks/src/afstorageclient.cpp \
+
+
+
+LIBS += -linetprotutil \
+ -lafstoragecommon.lib \
+ -lestor \
+ -lapgrfx \
+ -lws32 \
+
+symbian:!coverage: CONFIG += symbian_test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_tapplicationlauncher/inc/t_tapplicationlauncher.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef TESTTAPPLICATIONLAUNCHER_H
+#define TESTTAPPLICATIONLAUNCHER_H
+
+#include <QObject>
+
+#include <apgcli.h>
+#include <w32std.h>
+
+#include <QUrl>
+
+class TestTApplicationLauncher : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void testIsRunning();
+ void testStartApp();
+
+ void testLaunchActivity_data();
+ void testLaunchActivity();
+
+ void testLeaveWhenUriIsInvalid();
+ void testLeaveWhenApplicationIsCorrupted();
+
+private:
+ bool sendToBackground(const TUid &uid);
+ TUid getForegroundAppUid();
+ QUrl buildUri(const TUid &uid, const QString &activityName);
+
+private:
+ RApaLsSession mApaLsSession;
+ RWsSession mWsSession;
+
+};
+
+#endif TESTTAPPLICATIONLAUNCHER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_tapplicationlauncher/src/t_tapplicationlauncher.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,183 @@
+/** Copyright (c) 2009 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_tapplicationlauncher.h"
+
+#include <apgwgnam.h>
+#include <apgtask.h>
+
+#include <QtTest/QtTest>
+#include <QString>
+#include <QSystemSemaphore>
+
+#include <XQConversions>
+#include <qvaluespacesubscriber.h>
+
+#include <afactivities_global.h>
+#include <tstestutils.h>
+
+#include "afapplicationlauncher.h"
+
+const TUid KIconApplicationUid = {0xEd0b4e47};
+const TUid KActivityApplicationUid = {0xEBADF00D};
+const TUid KInvalidUid = {0xDEADBEEF};
+const TUid KCorruptedApplicationUid = {0xE5C3B14E};
+
+namespace {
+ const char KIconApplicationName[] = "appwithicon";
+}
+
+QTM_USE_NAMESPACE
+
+// ---------------------------------------------------------------------------
+// Test cases
+// ---------------------------------------------------------------------------
+//
+void TestTApplicationLauncher::initTestCase()
+{
+ QCOMPARE(mApaLsSession.Connect(), KErrNone);
+ QCOMPARE(mWsSession.Connect(), KErrNone);
+}
+
+void TestTApplicationLauncher::cleanupTestCase()
+{
+ mApaLsSession.Close();
+ mWsSession.Close();
+}
+
+void TestTApplicationLauncher::testIsRunning()
+{
+ TAfApplicationLauncher launcher(mApaLsSession, mWsSession);
+
+ QVERIFY(!launcher.isRunning(KIconApplicationUid));
+
+ quint64 iconAppId;
+ QVERIFY(TsTestUtils::startApplication(KIconApplicationName, iconAppId));
+ QVERIFY(launcher.isRunning(KIconApplicationUid));
+
+ QVERIFY(TsTestUtils::closeApplication(iconAppId));
+ QVERIFY(!launcher.isRunning(KIconApplicationUid));
+}
+
+void TestTApplicationLauncher::testStartApp()
+{
+ QSystemSemaphore semaphore("PublishActivityApp");
+ TAfApplicationLauncher launcher(mApaLsSession, mWsSession);
+
+ QVERIFY(!launcher.isRunning(KActivityApplicationUid));
+
+ TRAPD(startError, launcher.startApplicationL(KActivityApplicationUid, KNullDesC()));
+ QCOMPARE(startError, KErrNone);
+
+ QVERIFY(semaphore.acquire());
+
+ QVERIFY(TsTestUtils::closeApplication(KActivityApplicationUid));
+ QVERIFY(!launcher.isRunning(KActivityApplicationUid));
+}
+
+// ---------------------------------------------------------------
+
+void TestTApplicationLauncher::testLaunchActivity_data()
+{
+ QTest::addColumn<QString>("activityName");
+
+ QTest::newRow("normal") << "blahblahblah";
+ QTest::newRow("special characters") << "asd $&+,/:;=?@ \"<>#%{}|\\^~[]`asd";
+}
+
+void TestTApplicationLauncher::testLaunchActivity()
+{
+ QSystemSemaphore semaphore("PublishActivityApp");
+
+ TAfApplicationLauncher launcher(mApaLsSession, mWsSession);
+ QVERIFY(!launcher.isRunning(KActivityApplicationUid));
+
+ QFETCH(QString, activityName);
+ HBufC *uriDescriptor = XQConversions::qStringToS60Desc(QString(buildUri(KActivityApplicationUid, activityName).toEncoded()));
+ TRAPD(startError, launcher.startApplicationL(KActivityApplicationUid, *uriDescriptor));
+ delete uriDescriptor;
+ QCOMPARE(startError, KErrNone);
+ semaphore.acquire();
+
+ QCOMPARE(QValueSpaceSubscriber("/PublishActivityApp/ActivityName").value().toString(), activityName);
+
+ QVERIFY(TsTestUtils::closeApplication(KActivityApplicationUid));
+ QVERIFY(!launcher.isRunning(KIconApplicationUid));
+}
+
+// ---------------------------------------------------------------
+
+void TestTApplicationLauncher::testLeaveWhenUriIsInvalid()
+{
+ TAfApplicationLauncher launcher(mApaLsSession, mWsSession);
+ TRAPD(startError, launcher.startApplicationL(KInvalidUid, KNullDesC()));
+ QCOMPARE(startError, KErrNotFound);
+}
+
+void TestTApplicationLauncher::testLeaveWhenApplicationIsCorrupted()
+{
+ TAfApplicationLauncher launcher(mApaLsSession, mWsSession);
+
+ // We're going to test Launcher behavior when someone tries to start
+ // application with missing executable file
+ TRAPD(startError, launcher.startApplicationL(KCorruptedApplicationUid, KNullDesC()));
+ QCOMPARE(startError, KErrNotFound);
+}
+
+// ---------------------------------------------------------------------------
+// Helper methods
+// ---------------------------------------------------------------------------
+//
+QUrl TestTApplicationLauncher::buildUri(const TUid &uid, const QString &activityName)
+{
+ QUrl uri;
+ uri.setScheme("appto");
+ uri.setHost(QString("%1").arg(static_cast<uint>(uid.iUid), 8, 16, QChar('0')));
+ uri.addQueryItem(Af::KActivityUriNameKey, activityName);
+ return uri;
+}
+
+bool TestTApplicationLauncher::sendToBackground(const TUid &uid)
+{
+ TApaTaskList taskList(mWsSession);
+ TApaTask task = taskList.FindApp(uid);
+ bool taskExists = task.Exists();
+ if (taskExists) {
+ task.SendToBackground();
+ }
+ return taskExists;
+}
+
+TUid TestTApplicationLauncher::getForegroundAppUid()
+{
+ // get all window groups
+ RArray<RWsSession::TWindowGroupChainInfo> windowGroupList;
+ CleanupClosePushL(windowGroupList);
+ User::LeaveIfError(mWsSession.WindowGroupList(0, &windowGroupList));
+
+ if (windowGroupList.Count() == 0) {
+ User::Leave(KErrNotFound);
+ }
+
+ // get uid of first window group
+ CApaWindowGroupName* windowGroupName = CApaWindowGroupName::NewLC(mWsSession, windowGroupList[0].iId);
+ TUid foregroundAppUid = windowGroupName->AppUid();
+ CleanupStack::PopAndDestroy(windowGroupName);
+ CleanupStack::PopAndDestroy(&windowGroupList);
+
+ return foregroundAppUid;
+}
+
+QTEST_MAIN(TestTApplicationLauncher)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/t_tapplicationlauncher/t_tapplicationlauncher.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console
+
+CONFIG *= mobility
+MOBILITY *= publishsubscribe
+
+INCLUDEPATH += inc \
+
+SOURCES += ./src/t_tapplicationlauncher.cpp
+HEADERS += ./inc/t_tapplicationlauncher.h
+
+SOURCES += ../../src/afapplicationlauncher.cpp \
+
+HEADERS += ../../inc/afapplicationlauncher.h \
+
+LIBS +=
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.CAPABILITY = ALL -TCB
+
+ LIBS += -lapgrfx \ # for TApaTaskList
+ -lapparc \ # for TApaAppInfo
+ -lcone \ # for CCoeEnv
+ -lws32 \ # for RWsSession
+ -lxqutils \ # for XQConversions
+
+}
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/afactivitylauncher/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+
+SUBDIRS += t_afactivitylauncher \
+
+SUBDIRS += ../../../internal/tsapps/testapp \
+ ../../../internal/tstestutils \
+ t_tapplicationlauncher \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/src/hbcore/activity/activity.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+#
+#############################################################################
+##
+## Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+## All rights reserved.
+## Contact: Nokia Corporation (developer.feedback@nokia.com)
+##
+## This file is part of the UI Extensions for Mobile.
+##
+## GNU Lesser General Public License Usage
+## This file may be used under the terms of the GNU Lesser General Public
+## License version 2.1 as published by the Free Software Foundation and
+## appearing in the file LICENSE.LGPL included in the packaging of this file.
+## Please review the following information to ensure the GNU Lesser General
+## Public License version 2.1 requirements will be met:
+## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+##
+## In addition, as a special exception, Nokia gives you certain additional
+## rights. These rights are described in the Nokia Qt LGPL Exception
+## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+##
+## If you have questions regarding the use of this file, please contact
+## Nokia at developer.feedback@nokia.com.
+##
+#############################################################################
+
+
+INCLUDEPATH += $$PWD
+DEPENDPATH += $$PWD
+
+PUBLIC_HEADERS += $$PWD/hbactivitymanager.h
+
+INTERNAL_HEADERS += $$PWD/hbactivitymanager_p.h \
+ $$PWD/hbactivityplugininterface_p.h \
+
+SOURCES += $$PWD/hbactivitymanager.cpp \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/src/hbcore/activity/hbactivitymanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,297 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (developer.feedback@nokia.com)
+**
+** This file is part of the HbCore module of the UI Extensions for Mobile.
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at developer.feedback@nokia.com.
+**
+****************************************************************************/
+
+#include "hbactivitymanager.h"
+#include "hbactivitymanager_p.h"
+
+#include <QPluginLoader>
+#include <QLibrary>
+#include <QDir>
+
+#include "hbmainwindow.h"
+#include "hbinstance.h"
+#include "hbactivityplugininterface_p.h"
+
+/*!
+ @beta
+ @hbcore
+ \class HbActivityManager
+ \brief HbActivityManager is an access point for Activities features.
+
+ Activities can be described as stored application states (for example bookmarks
+ in web browser) or actions that can be performed using application (play next
+ song, start new game).
+
+ The HbActivityManager class allows to use Activities features in Hb application.
+ It can be used to access, add, remove and modify activities. It also notifies the
+ application about activity change requests from other applications.
+*/
+
+/*!
+\internal
+*/
+HbActivityManagerPrivate::HbActivityManagerPrivate(HbActivityManager *q) : q(q), mActivityPlugin(0)
+{
+}
+
+/*!
+\internal
+*/
+HbActivityManagerPrivate::~HbActivityManagerPrivate()
+{
+}
+
+/*!
+\internal
+*/
+HbActivityPluginInterface *HbActivityManagerPrivate::activityPlugin() const
+{
+ if (!mActivityPlugin) {
+ foreach (const QString &path, QCoreApplication::libraryPaths()) {
+ QString pluginPath;
+
+ QString libPath = QDir::toNativeSeparators(path) + QDir::separator() + QLatin1String("hbactivityplugin");
+#ifdef Q_OS_SYMBIAN
+ libPath += QLatin1String(".qtplugin");
+ QLibrary library(libPath);
+ if (QFile::exists(libPath) && library.load()) {
+ library.unload();
+ pluginPath = libPath;
+ }
+#else
+ QLibrary library(libPath);
+ if (library.load()) {
+ library.unload();
+ pluginPath = library.fileName();
+ }
+#endif
+
+ QPluginLoader loader(pluginPath);
+ QObject *pluginInstance = loader.instance();
+ if (pluginInstance) {
+ mActivityPlugin = qobject_cast<HbActivityPluginInterface*>(pluginInstance);
+ if (mActivityPlugin) {
+ q->connect(pluginInstance, SIGNAL(activityRequested(QString)), q, SIGNAL(activityRequested(QString)));
+ } else {
+#if defined(Q_OS_SYMBIAN)
+ qWarning("Cannot load activity plugin. Features related to activities won't be available.");
+#endif
+ loader.unload();
+ }
+ }
+ }
+ }
+ return mActivityPlugin;
+}
+
+/*!
+\internal
+*/
+bool HbActivityManagerPrivate::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ bool result(false);
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ result = plugin->addActivity(activityId, data, parameters);
+ }
+ return result;
+}
+
+/*!
+\internal
+*/
+bool HbActivityManagerPrivate::removeActivity(const QString &activityId)
+{
+ bool result(false);
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ result = plugin->removeActivity(activityId);
+ }
+ return result;
+}
+
+/*!
+\internal
+*/
+QList<QVariantHash> HbActivityManagerPrivate::activities() const
+{
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ return plugin->activities();
+ } else {
+ return QList<QVariantHash>();
+ }
+}
+
+/*!
+\internal
+*/
+bool HbActivityManagerPrivate::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ bool result(false);
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ result = plugin->updateActivity(activityId, data, parameters);
+ }
+ return result;
+}
+
+/*!
+\internal
+*/
+QVariant HbActivityManagerPrivate::activityData(const QString &activityId) const
+{
+ QVariant result;
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ result = plugin->activityData(activityId);
+ }
+ return result;
+}
+
+/*!
+\internal
+*/
+bool HbActivityManagerPrivate::waitActivity()
+{
+ bool result(false);
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ result = plugin->waitActivity();
+ }
+ return result;
+}
+
+/*!
+\internal
+*/
+void HbActivityManagerPrivate::parseCommandLine(const QStringList &commandLineParams, Hb::ActivationReason &reason, QString &id, QVariantHash ¶ms) const
+{
+ HbActivityPluginInterface *plugin = activityPlugin();
+ if (plugin) {
+ QVariantHash activityParams = plugin->parseCommandLine(commandLineParams);
+ if (!activityParams.isEmpty()) {
+ reason = Hb::ActivationReasonActivity;
+ id = activityParams.value("activityname").toString();
+ params = activityParams;
+ }
+ }
+}
+
+/*!
+ Constructor
+ \a parent. Parent of this object.
+ */
+HbActivityManager::HbActivityManager(QObject *parent) : QObject(parent), d_ptr(new HbActivityManagerPrivate(this))
+{
+}
+
+/*!
+ Destructor
+ */
+HbActivityManager::~HbActivityManager()
+{
+ delete d_ptr;
+}
+
+/*!
+ Allows to save activity.
+ \a activityId. Activity name used as identifier of activities
+ \a data. Activity data that should be stored. It will allow application to restore its state later
+ \a parameters. Activity properties: screenshot, localized name, hidden flag, etc.
+ Returns true if activity was succesfully saved, otherwise returns false.
+ */
+bool HbActivityManager::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ Q_D(HbActivityManager);
+ return d->addActivity(activityId, data, parameters);
+}
+
+/*!
+ Allows to delete activity.
+ \a activityId. Activity name used as identifier of activities
+ Returns true if activity was succesfully deleted, otherwise returns false.
+ */
+bool HbActivityManager::removeActivity(const QString &activityId)
+{
+ Q_D(HbActivityManager);
+ return d->removeActivity(activityId);
+}
+
+/*!
+ Allows to update saved activity.
+ \a activityId. Activity name used as identifier of activities
+ \a data. Activity data that should be stored. It will allow application to restore its state later
+ \a parameters. Activity properties: screenshot, localized name, hidden flag, etc.
+ Returns true if activity was succesfully updated, otherwise returns false.
+ */
+bool HbActivityManager::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ Q_D(HbActivityManager);
+ return d->updateActivity(activityId, data, parameters);
+}
+
+/*!
+ Returns activities list. It returns activities as name and screenshot.
+ */
+QList<QVariantHash> HbActivityManager::activities() const
+{
+ Q_D(const HbActivityManager);
+ return d->activities();
+}
+
+/*!
+ Returns data of activity specified by \a activityId
+ */
+QVariant HbActivityManager::activityData(const QString &activityId) const
+{
+ Q_D(const HbActivityManager);
+ return d->activityData(activityId);
+}
+
+/*!
+ Subscribes to activity manager
+ */
+bool HbActivityManager::waitActivity()
+{
+ Q_D(HbActivityManager);
+ return d->waitActivity();
+}
+
+/*!
+ Searches \a commandLineArguments for pair of "-activity" marker and
+ activity URI, which should have following syntax:
+
+ appto://UID3?activityname=activity-name-value&key1=value
+
+ If both marker and valid URI are found, \a reason is set to
+ Hb::ActivationReasonActivity, and \a activityId and \a parameters are
+ filled with parsed values.
+*/
+void HbActivityManager::parseCommandLine(const QStringList &commandLineParams, Hb::ActivationReason &reason, QString &id, QVariantHash ¶ms) const
+{
+ Q_D(const HbActivityManager);
+ d->parseCommandLine(commandLineParams, reason, id, params);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/src/hbcore/activity/hbactivitymanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (developer.feedback@nokia.com)
+**
+** This file is part of the HbCore module of the UI Extensions for Mobile.
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at developer.feedback@nokia.com.
+**
+****************************************************************************/
+
+#ifndef HBACTIVITYMANAGER_H
+#define HBACTIVITYMANAGER_H
+
+#include <QObject>
+#include <QVariant>
+#include <QVariantHash>
+#include <QList>
+#include <QString>
+
+#include <hbglobal.h>
+#include <hbnamespace.h>
+
+class HbActivityManagerPrivate;
+
+class HB_CORE_EXPORT HbActivityManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit HbActivityManager(QObject *parent = 0);
+ virtual ~HbActivityManager();
+
+ bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ bool removeActivity(const QString &activityId);
+ bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ QList<QVariantHash> activities() const;
+ QVariant activityData(const QString &activityId) const;
+ bool waitActivity();
+ void parseCommandLine(const QStringList &commandLineParams, Hb::ActivationReason &reason, QString &id, QVariantHash ¶ms) const;
+
+signals:
+ void activityRequested(const QString &activityId);
+
+protected:
+ HbActivityManagerPrivate *d_ptr;
+
+private:
+ Q_DISABLE_COPY(HbActivityManager)
+ Q_DECLARE_PRIVATE_D(d_ptr, HbActivityManager)
+
+};
+
+#endif // HBACTIVITYMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/src/hbcore/activity/hbactivitymanager_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (developer.feedback@nokia.com)
+**
+** This file is part of the HbCore module of the UI Extensions for Mobile.
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at developer.feedback@nokia.com.
+**
+****************************************************************************/
+
+#ifndef HBACTIVITYMANAGER_P_H
+#define HBACTIVITYMANAGER_P_H
+
+class HbActivityManager;
+class HbActivityPluginInterface;
+
+class HbActivityManagerPrivate
+{
+public:
+ HbActivityManagerPrivate(HbActivityManager *q);
+ ~HbActivityManagerPrivate();
+
+public:
+ bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ bool removeActivity(const QString &activityId);
+ bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ QList<QVariantHash> activities() const;
+ QVariant activityData(const QString &activityId) const;
+ bool waitActivity();
+ void parseCommandLine(const QStringList &commandLineParams, Hb::ActivationReason &reason, QString &id, QVariantHash ¶ms) const;
+
+private:
+ HbActivityPluginInterface *activityPlugin() const;
+
+private:
+ HbActivityManager *q;
+ mutable HbActivityPluginInterface *mActivityPlugin;
+};
+
+#endif // HBACTIVITYMANAGER_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/src/hbcore/activity/hbactivityplugininterface_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (developer.feedback@nokia.com)
+**
+** This file is part of the HbCore module of the UI Extensions for Mobile.
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at developer.feedback@nokia.com.
+**
+****************************************************************************/
+
+#ifndef HBACTIVITYPLUGININTERFACE_P_H
+#define HBACTIVITYPLUGININTERFACE_P_H
+
+#include <QObject>
+#include <QtPlugin>
+#include <QVariant>
+#include <QString>
+#include <QList>
+#include <QVariantHash>
+
+class HbActivityPluginInterface : public QObject
+{
+ Q_OBJECT
+public:
+ HbActivityPluginInterface(QObject *parent = 0) : QObject(parent) {}
+
+public:
+ virtual bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) = 0;
+ virtual bool removeActivity(const QString &activityId) = 0;
+ virtual bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters) = 0;
+ virtual QList<QVariantHash> activities() = 0;
+ virtual QVariant activityData(const QString &activityId) = 0;
+ virtual bool waitActivity() = 0;
+ virtual QVariantHash parseCommandLine(const QStringList &commandLineParams) = 0;
+
+signals:
+ void activityRequested(const QString &activityId);
+};
+
+Q_DECLARE_INTERFACE(HbActivityPluginInterface, "HbActivityPluginInterface/1.0")
+
+#endif // HBACTIVITYPLUGININTERFACE_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/src/hbcore/core/hbapplication.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,418 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (developer.feedback@nokia.com)
+**
+** This file is part of the HbCore module of the UI Extensions for Mobile.
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at developer.feedback@nokia.com.
+**
+****************************************************************************/
+
+#include "hbapplication.h"
+#include "hbapplication_p.h"
+#include "hbsplashscreen_p.h"
+#include "hbactivitymanager.h"
+#include <QTime>
+#include <QUrl>
+
+#if defined(Q_OS_SYMBIAN)
+#include <qwindowsstyle.h>
+#include <qsymbianevent.h>
+#endif // Q_OS_SYMBIAN
+
+// ### TODO remove this and do it in mainwindow_p once QGestureManager problems are fixed
+#ifdef HB_GESTURE_FW
+#include "hbmousepangesturerecognizer_p.h"
+#include "hbswipegesturerecognizer_p.h"
+#include "hbtapgesturerecognizer_p.h"
+#include "hbtapandholdgesturerecognizer_p.h"
+#endif
+
+/*!
+ @stable
+ @hbcore
+ \class HbApplication
+ \brief The HbApplication class is a place for common functionality.
+
+ HbApplication class is a place for common functionality.
+
+ In each and every application using LibHb, the application object is
+ always instantiated in main() before creating any GUI controls. Later
+ when the GUI controls have been created and shown, the control is given
+ to the main event loop of the application:
+
+ \dontinclude graphicsitemdemo/main.cpp
+ \skip int main(
+ \until HbMainWindow
+ \skip show()
+ \until }
+
+ To support Hb-widgets with QApplication the actual implementation
+ of HbApplication is available in HbInstance.
+
+ Unless the Hb::NoSplash flag is passed, the HbApplication constructor will
+ try to show a suitable splash screen for the application. On some platforms
+ there will be no splash screens available at all and thus nothing will be
+ shown.
+
+ Applications that support the 'activities' concept may check the start-up
+ reason like this:
+
+ \code
+ HbApplication app(argc, argv);
+ if(app.activateReason() == HbApplication::activity) {
+ // start-up case
+ } else if (app.activateReason() == HbApplication::service) {
+ // service lauch
+ } else {
+ // normal launch
+ }
+
+ MyActivitiesEngine logic;
+ // connect to the application signal
+ QObject::connect(&app, SIGNAL(activate()), &logic, SLOT(openActivity()));
+ \endcode
+
+ When new activity needs to be activated signal is emited. Application might
+ observe it and start correct handling to return to saved state. Logic should
+ check what is the activity id and data to return to correct state.
+
+ \sa QApplication
+*/
+
+/*!
+ \fn void HbApplication::activate()
+
+ This signal is emitted when some activity needs to be shown.
+*/
+
+static int& preInitApp(int &argc)
+{
+ // This function contains code that needs to be executed before
+ // the QApplication constructor.
+
+#if defined(Q_OS_SYMBIAN)
+ // Disable legacy screen furniture.
+ QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes);
+
+ // Temporary solution until Hb specific style is ready.
+ QApplication::setStyle(new QWindowsStyle);
+#endif //Q_OS_SYMBIAN
+
+ return argc;
+}
+
+static void initSplash(Hb::ApplicationFlags flags)
+{
+ if (flags & Hb::NoSplash) {
+ return;
+ }
+
+ // Show the splash screen (start() also makes sure it is really drawn before
+ // continuing with anything else).
+
+ HbSplash::Flags splashFlags = HbSplash::Default;
+ if (flags & Hb::SplashFixedVertical) {
+ splashFlags |= HbSplash::FixedVertical;
+ } else if (flags & Hb::SplashFixedHorizontal) {
+ splashFlags |= HbSplash::FixedHorizontal;
+ }
+
+#ifdef Q_OS_SYMBIAN
+ QTime t;
+ t.start();
+#endif
+
+ HbSplashScreen::start(splashFlags);
+
+#ifdef Q_OS_SYMBIAN
+ qDebug("[hbsplash] %d ms", t.elapsed());
+#endif
+}
+
+static void initialize()
+{
+// ### TODO remove this and enable HbMainWindowPrivate::initGestures once
+// the QGestureManager problems are fixed.
+#ifdef HB_GESTURE_FW
+ QGestureRecognizer::unregisterRecognizer(Qt::TapGesture);
+ QGestureRecognizer::unregisterRecognizer(Qt::TapAndHoldGesture);
+ QGestureRecognizer::unregisterRecognizer(Qt::PanGesture);
+ QGestureRecognizer::unregisterRecognizer(Qt::SwipeGesture);
+
+ QGestureRecognizer::registerRecognizer(new HbTapGestureRecognizer);
+ QGestureRecognizer::registerRecognizer(new HbTapAndHoldGestureRecognizer);
+ QGestureRecognizer::registerRecognizer(new HbMousePanGestureRecognizer);
+ QGestureRecognizer::registerRecognizer(new HbSwipeGestureRecognizer);
+#endif
+}
+
+/*!
+ Constructs the application with \a argc and \a argv.
+*/
+HbApplication::HbApplication(int &argc, char *argv[], Hb::ApplicationFlags flags)
+ : QApplication(preInitApp(argc), argv)
+{
+ initSplash(flags); // must be the first thing we do here
+
+ d_ptr = new HbApplicationPrivate(this);
+
+ // No expensive operations allowed here, prefer performing such
+ // initialization as part of HbMainWindow's delayed construction instead.
+
+ initialize();
+}
+
+#if defined(Q_WS_S60)
+HbApplication::HbApplication(QApplication::QS60MainApplicationFactory factory,
+ int &argc, char *argv[], Hb::ApplicationFlags flags)
+ : QApplication(factory, preInitApp(argc), argv)
+{
+ initSplash(flags); // must be the first thing we do here
+
+ d_ptr = new HbApplicationPrivate(this);
+
+ // No expensive operations allowed here, prefer performing such
+ // initialization as part of HbMainWindow's delayed construction instead.
+
+ initialize();
+}
+#endif // Q_WS_S60
+
+/*!
+ Destructor.
+ */
+HbApplication::~HbApplication()
+{
+ hideSplash();
+}
+
+/*!
+ Hides the splash screen if it is visible. Normally this is done by
+ HbMainWindow but if an application does not create any HbMainWindow
+ instances then there may be a need to hide the splash screen manually.
+*/
+void HbApplication::hideSplash()
+{
+ HbSplashScreen::destroy();
+}
+
+#if defined(Q_WS_S60)
+#include <w32std.h>
+#include <coecntrl.h>
+#include <QDesktopWidget>
+#include <QStringList>
+#include <hbinstance.h>
+#include <hbinstance_p.h>
+#include <hbdeviceprofile.h>
+#include <hbdeviceprofilemanager_p.h>
+#include <hbs60events.h>
+#include <hbtextitem_p.h>
+#include <hbiconitem_p.h>
+#include <hbtoucharea_p.h>
+#include "hbgraphicsscene_p.h"
+
+#ifdef BUILD_HB_INTERNAL
+static void forceRefresh()
+{
+ foreach (HbMainWindow *window, hbInstance->allMainWindows()) {
+ QEvent event(QEvent::WindowActivate);
+ QApplication::sendEvent(window, &event);
+ }
+}
+#endif
+
+/*!
+ Handles the S60 events.
+ */
+bool HbApplication::symbianEventFilter(const QSymbianEvent *event)
+{
+ if (event->type() != QSymbianEvent::WindowServerEvent) {
+ return QApplication::symbianEventFilter(event);
+ }
+ const TWsEvent *aEvent = event->windowServerEvent();
+ switch (aEvent->Type()) {
+ // In case of EEventScreenDeviceChanged-event, the current screen
+ // ratio is checked and orientation is set accordingly.
+ case EEventScreenDeviceChanged:{
+
+ QList<HbMainWindow*> windows = hbInstance->allMainWindows();
+ RWindow *win = static_cast<RWindow *>(windows.at(0)->effectiveWinId()->DrawableWindow());
+
+ TSize rWinSize;
+ if (win)
+ rWinSize = win->Size();
+
+ // fix for emulator / changing modes
+ QSize nSize( (int)rWinSize.iWidth, (int)rWinSize.iHeight );
+ foreach (HbMainWindow* w, windows) {
+ w->resize(nSize);
+ }
+
+
+ }
+ return false; //continue handling in QApplication::s60ProcessEvent
+ case KChangeDirection:{
+ TUint8* dataptr = aEvent->EventData();
+ switch(*dataptr){
+ case 0:
+ HbApplication::setLayoutDirection(Qt::LeftToRight);
+ break;
+ case 1:
+ HbApplication::setLayoutDirection(Qt::RightToLeft);
+ break;
+ default:
+ qWarning("HbApplication::s60EventFilter: Unknown layout direction received");
+ break;
+ }
+ }
+ return false;
+ case KChangeOrientation:{
+ TUint8* dataptr = aEvent->EventData();
+ switch(*dataptr){
+ case 0:
+ hbInstance->setOrientation(Qt::Vertical);
+ break;
+ case 1:
+ hbInstance->setOrientation(Qt::Horizontal);
+ break;
+ default:
+ qWarning("HbApplication::s60EventFilter: Unknown orientation received");
+ break;
+ }
+ }
+ return false;
+ case KChangeDeviceProfile:{
+ TUint8* dataptr = aEvent->EventData();
+ QStringList names = HbDeviceProfile::profileNames();
+ if(*dataptr > names.count() - 1){
+ qWarning("HbApplication::s60EventFilter: Unknown device profile received");
+ }else{
+ HbDeviceProfile profile(names.value(*dataptr));
+ HbDeviceProfileManager::select(profile);
+ HbInstancePrivate::d_ptr()->setOrientation(profile.orientation(),false);
+ }
+ }
+ return false;
+#ifdef BUILD_HB_INTERNAL
+ case KChangeTouchAreaVis:{
+ TUint8* dataptr = aEvent->EventData();
+ HbTouchAreaPrivate::setOutlineDrawing(*dataptr == 1);
+ forceRefresh();
+ }
+ return false;
+ case KChangeTextItemVis:{
+ TUint8* dataptr = aEvent->EventData();
+ HbTextItemPrivate::outlinesEnabled = *dataptr == 1;
+ forceRefresh();
+ }
+ return false;
+ case KChangeIconItemVis:{
+ TUint8* dataptr = aEvent->EventData();
+ HbIconItemPrivate::outlinesEnabled = *dataptr == 1;
+ forceRefresh();
+ }
+ return false;
+ case KChangeFpsCounterVis:{
+ TUint8* dataptr = aEvent->EventData();
+ HbGraphicsScenePrivate::fpsCounterEnabled = *dataptr == 1;
+ forceRefresh();
+ }
+ return false;
+#endif
+ default:
+ return QApplication::symbianEventFilter(event);
+ }
+}
+
+#endif // Q_WS_S60
+
+HbApplicationPrivate::HbApplicationPrivate(HbApplication *parent)
+ : QObject(parent), q_ptr(parent), mActivateReason(Hb::ActivationReasonNormal)
+{
+ mActivityManager = new HbActivityManager(this);
+ connect(mActivityManager, SIGNAL(activityRequested(QString)), this, SLOT(prepareActivityData(QString)));
+ mActivityManager->parseCommandLine(qApp->arguments(), mActivateReason, mActivateId, mActivateParams);
+}
+
+HbApplicationPrivate::~HbApplicationPrivate()
+{
+}
+
+QVariant HbApplicationPrivate::activateData()
+{
+ if (!mActivateId.isNull() && !mActivateData.isValid()) {
+ mActivateData = mActivityManager->activityData(mActivateId);
+ }
+ return mActivateData;
+}
+
+void HbApplicationPrivate::prepareActivityData(const QString &activityId)
+{
+ mActivateReason = Hb::ActivationReasonActivity;
+ mActivateId = activityId;
+ mActivateData = QVariant();
+ mActivateParams = QVariantHash();
+
+ emit q_ptr->activate();
+}
+
+/*!
+ Returns instance of class responsible for activities handling.
+ */
+HbActivityManager *HbApplication::activityManager()
+{
+ Q_D(HbApplication);
+ return d->mActivityManager;
+}
+
+/*!
+ Returns activation parameters parsed from activation URI.
+ */
+QVariantHash HbApplication::activateParams() const
+{
+ Q_D(const HbApplication);
+ return d->mActivateParams;
+}
+
+/*!
+ Returns activate reason.
+ */
+Hb::ActivationReason HbApplication::activateReason() const
+{
+ Q_D(const HbApplication);
+ return d->mActivateReason;
+}
+
+/*!
+ Last activated activity id.
+ */
+QString HbApplication::activateId() const
+{
+ Q_D(const HbApplication);
+ return d->mActivateId;
+}
+
+/*!
+ Last activated activity data.
+ */
+QVariant HbApplication::activateData()
+{
+ Q_D(HbApplication);
+ return d->activateData();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/core.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,118 @@
+######################################################################
+# Unit tests that depend on HbCore
+######################################################################
+
+TEMPLATE = subdirs
+
+SUBDIRS += unittest_hbaction
+SUBDIRS += unittest_hbanchorlayout
+SUBDIRS += unittest_hbcolorscheme
+SUBDIRS += unittest_hbevent
+SUBDIRS += unittest_hbframedrawer
+SUBDIRS += unittest_hbframedrawerpool
+SUBDIRS += unittest_hbgesturefilter
+SUBDIRS += unittest_hbgraphicsscene
+SUBDIRS += unittest_hbicon
+SUBDIRS += unittest_hbiconanimationmanager
+SUBDIRS += unittest_hbiconitem
+SUBDIRS += unittest_hbinstance
+SUBDIRS += unittest_hbfeedbackengine
+SUBDIRS += unittest_hbfeedbackmanager
+SUBDIRS += unittest_hbfeedbackplugin
+SUBDIRS += unittest_hbfeedbackplugingroup
+SUBDIRS += unittest_hbmenu
+SUBDIRS += unittest_hbscrollarea
+SUBDIRS += unittest_hbscrollbar
+SUBDIRS += unittest_hbstackedlayout
+SUBDIRS += unittest_hbstackedwidget
+SUBDIRS += unittest_hbtheme
+SUBDIRS += unittest_hbtoolbutton
+SUBDIRS += unittest_hbtooltip
+SUBDIRS += unittest_hbwidget
+SUBDIRS += unittest_hbextendedlocale
+SUBDIRS += unittest_hbstringutil
+SUBDIRS += unittest_hbdirectorynamelocalizer
+SUBDIRS += unittest_hbnumbergrouping
+SUBDIRS += unittest_hbframebackground
+SUBDIRS += unittest_hbsmileytheme
+SUBDIRS += unittest_hblengthlimiter
+SUBDIRS += unittest_hbfindfile
+SUBDIRS += unittest_hbtranslator
+symbian:SUBDIRS += unittest_hbindicatorsymbian
+
+developer {
+ SUBDIRS += unittest_hbactivitymanager
+ SUBDIRS += unittest_hbapplication
+ SUBDIRS += unittest_hbbackgrounditem
+ SUBDIRS += unittest_hbbatteryindicator
+ #SUBDIRS += unittest_hbcolortheme # temporarily disabled due to CI failure
+ SUBDIRS += unittest_hbdecorator
+ SUBDIRS += unittest_hbdeviceprofile
+ SUBDIRS += unittest_hbdevicemodeinfo
+ effects {
+ SUBDIRS += unittest_hbeffectcontroller
+ SUBDIRS += unittest_hbeffectdata
+ SUBDIRS += unittest_hbeffectgroup
+ SUBDIRS += unittest_hbeffectrotate
+ SUBDIRS += unittest_hbeffectscale
+ SUBDIRS += unittest_hbeffectxmlparser
+ SUBDIRS += unittest_hbeffecttheme
+
+ SUBDIRS += unittest_hbvgbceffect
+ SUBDIRS += unittest_hbvgblureffect
+ SUBDIRS += unittest_hbvgchainedeffect
+ SUBDIRS += unittest_hbvgcolorizeeffect
+ SUBDIRS += unittest_hbvgeffect
+ SUBDIRS += unittest_hbvggloweffect
+ SUBDIRS += unittest_hbvghsleffect
+ SUBDIRS += unittest_hbvgoutlineeffect
+ SUBDIRS += unittest_hbvgreflectioneffect
+ SUBDIRS += unittest_hbvgshadoweffect
+ SUBDIRS += unittest_hbvgmaskeffect
+ }
+ SUBDIRS += unittest_hbfont
+ SUBDIRS += unittest_hbiconloader
+ SUBDIRS += unittest_hbicontheme
+ SUBDIRS += unittest_hbindicator
+ SUBDIRS += unittest_hbindicatorgroup
+ SUBDIRS += unittest_hbiniparser
+ SUBDIRS += unittest_hbmenuitem
+ SUBDIRS += unittest_hbmeshlayout
+ SUBDIRS += unittest_hbmemorymanager
+ SUBDIRS += unittest_hbdialog
+ SUBDIRS += unittest_hbrichtextitem
+# SUBDIRS += unittest_hbsensororientation
+ SUBDIRS += unittest_hbsharedcontainer_string
+ SUBDIRS += unittest_hbsharedcontainer_variant
+ SUBDIRS += unittest_hbsharedcontainer_vector
+ SUBDIRS += unittest_hbsignalindicator
+ SUBDIRS += unittest_hbsmartpointer
+ SUBDIRS += unittest_hbsplash
+ SUBDIRS += unittest_hbstyleloader
+ SUBDIRS += unittest_hbtextitem
+ SUBDIRS += unittest_hbmarqueeitem
+ SUBDIRS += unittest_hbtextutils
+ SUBDIRS += unittest_hbthemeutils
+ SUBDIRS += unittest_hbtimer
+ SUBDIRS += unittest_hbtitlebar
+ SUBDIRS += unittest_hbtitlepane
+ SUBDIRS += unittest_hbtoolbar
+ SUBDIRS += unittest_hbtoolbarextension
+ SUBDIRS += unittest_hbtypefacexmlparser
+ SUBDIRS += unittest_hbwidgetloader
+ SUBDIRS += unittest_hbtextitemprivate
+
+ win32|linux-* {
+ SUBDIRS += unittest_hbthemeclientqt
+
+ }
+
+ contains(DEFINES, HB_GESTURE_FW) {
+ SUBDIRS += unittest_hbtapgesturerecognizer
+
+ # Disabled until timer related issues solved
+ #SUBDIRS += unittest_hbtapandholdgesturerecognizer
+ }
+}
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/hb_unittests.iby Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,566 @@
+#ifndef __HBUNITTESTS_IBY__
+#define __HBUNITTESTS_IBY__
+
+#include <bldvariant.hrh>
+
+#define HB_UPGRADABLE_APP_REG_RSC(NAME) data=DATAZ_\PRIVATE\10003A3F\IMPORT\APPS\ ## NAME ## _reg.rsc Private\10003a3f\import\apps\ ## NAME ## _reg.rsc
+#define HB_PLUGIN_STUB(NAME, SUBDIR) data=\epoc32\data\z\resource\plugins\##SUBDIR##\##NAME##.qtplugin RESOURCE_FILES_DIR\plugins\##SUBDIR##\##NAME##.qtplugin
+
+file=ABI_DIR\BUILD_DIR\unittest_hbabstractbutton.exe SHARED_LIB_DIR\unittest_hbabstractbutton.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbabstractbutton)
+S60_APP_RESOURCE(unittest_hbabstractbutton)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbabstractslider.exe SHARED_LIB_DIR\unittest_hbabstractslider.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbabstractslider)
+S60_APP_RESOURCE(unittest_hbabstractslider)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbaction.exe SHARED_LIB_DIR\unittest_hbaction.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbaction)
+S60_APP_RESOURCE(unittest_hbaction)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbanchorlayout.exe SHARED_LIB_DIR\unittest_hbanchorlayout.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbanchorlayout)
+S60_APP_RESOURCE(unittest_hbanchorlayout)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdevicedialog.exe SHARED_LIB_DIR\unittest_hbdevicedialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdevicedialog)
+S60_APP_RESOURCE(unittest_hbdevicedialog)
+file=ABI_DIR\BUILD_DIR\hbdevicedialogunittestplugin.dll SHARED_LIB_DIR\hbdevicedialogunittestplugin.dll
+HB_PLUGIN_STUB(hbdevicedialogunittestplugin, devicedialogs)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffect.exe SHARED_LIB_DIR\unittest_hbeffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffect)
+S60_APP_RESOURCE(unittest_hbeffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffectcontroller.exe SHARED_LIB_DIR\unittest_hbeffectcontroller.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffectcontroller)
+S60_APP_RESOURCE(unittest_hbeffectcontroller)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffectdata.exe SHARED_LIB_DIR\unittest_hbeffectdata.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffectdata)
+S60_APP_RESOURCE(unittest_hbeffectdata)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffectgroup.exe SHARED_LIB_DIR\unittest_hbeffectgroup.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffectgroup)
+S60_APP_RESOURCE(unittest_hbeffectgroup)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffectrotate.exe SHARED_LIB_DIR\unittest_hbeffectrotate.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffectrotate)
+S60_APP_RESOURCE(unittest_hbeffectrotate)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffectscale.exe SHARED_LIB_DIR\unittest_hbeffectscale.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffectscale)
+S60_APP_RESOURCE(unittest_hbeffectscale)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffecttheme.exe SHARED_LIB_DIR\unittest_hbeffecttheme.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffecttheme)
+S60_APP_RESOURCE(unittest_hbeffecttheme)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbeffectxmlparser.exe SHARED_LIB_DIR\unittest_hbeffectxmlparser.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbeffectxmlparser)
+S60_APP_RESOURCE(unittest_hbeffectxmlparser)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdocumentloader.exe SHARED_LIB_DIR\unittest_hbdocumentloader.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdocumentloader)
+S60_APP_RESOURCE(unittest_hbdocumentloader)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbframedrawer.exe SHARED_LIB_DIR\unittest_hbframedrawer.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbframedrawer)
+S60_APP_RESOURCE(unittest_hbframedrawer)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbgesturefilter.exe SHARED_LIB_DIR\unittest_hbgesturefilter.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbgesturefilter)
+S60_APP_RESOURCE(unittest_hbgesturefilter)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbgraphicsscene.exe SHARED_LIB_DIR\unittest_hbgraphicsscene.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbgraphicsscene)
+S60_APP_RESOURCE(unittest_hbgraphicsscene)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbicon.exe SHARED_LIB_DIR\unittest_hbicon.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbicon)
+S60_APP_RESOURCE(unittest_hbicon)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbiniparser.exe SHARED_LIB_DIR\unittest_hbiniparser.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbiniparser)
+S60_APP_RESOURCE(unittest_hbiniparser)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbinstance.exe SHARED_LIB_DIR\unittest_hbinstance.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbinstance)
+S60_APP_RESOURCE(unittest_hbinstance)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbsearchpanel.exe SHARED_LIB_DIR\unittest_hbsearchpanel.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbsearchpanel)
+S60_APP_RESOURCE(unittest_hbsearchpanel)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblabel.exe SHARED_LIB_DIR\unittest_hblabel.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblabel)
+S60_APP_RESOURCE(unittest_hblabel)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblistlayout.exe SHARED_LIB_DIR\unittest_hblistlayout.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblistlayout)
+S60_APP_RESOURCE(unittest_hblistlayout)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblistmodel.exe SHARED_LIB_DIR\unittest_hblistmodel.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblistmodel)
+S60_APP_RESOURCE(unittest_hblistmodel)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblistview.exe SHARED_LIB_DIR\unittest_hblistview.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblistview)
+S60_APP_RESOURCE(unittest_hblistview)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblistviewitem.exe SHARED_LIB_DIR\unittest_hblistviewitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblistviewitem)
+S60_APP_RESOURCE(unittest_hblistviewitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbgridview.exe SHARED_LIB_DIR\unittest_hbgridview.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbgridview)
+S60_APP_RESOURCE(unittest_hbgridview)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbgridviewitem.exe SHARED_LIB_DIR\unittest_hbgridviewitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbgridviewitem)
+S60_APP_RESOURCE(unittest_hbgridviewitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblistwidget.exe SHARED_LIB_DIR\unittest_hblistwidget.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblistwidget)
+S60_APP_RESOURCE(unittest_hblistwidget)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblistwidgetitem.exe SHARED_LIB_DIR\unittest_hblistwidgetitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblistwidgetitem)
+S60_APP_RESOURCE(unittest_hblistwidgetitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbmainwindow.exe SHARED_LIB_DIR\unittest_hbmainwindow.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbmainwindow)
+S60_APP_RESOURCE(unittest_hbmainwindow)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbmenu.exe SHARED_LIB_DIR\unittest_hbmenu.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbmenu)
+S60_APP_RESOURCE(unittest_hbmenu)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbmenuitem.exe SHARED_LIB_DIR\unittest_hbmenuitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbmenuitem)
+S60_APP_RESOURCE(unittest_hbmenuitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdockwidget.exe SHARED_LIB_DIR\unittest_hbdockwidget.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdockwidget)
+S60_APP_RESOURCE(unittest_hbdockwidget)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbprogressslider.exe SHARED_LIB_DIR\unittest_hbprogressslider.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbprogressslider)
+S60_APP_RESOURCE(unittest_hbprogressslider)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbprogressbar.exe SHARED_LIB_DIR\unittest_hbprogressbar.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbprogressbar)
+S60_APP_RESOURCE(unittest_hbprogressbar)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtumbleview.exe SHARED_LIB_DIR\unittest_hbtumbleview.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtumbleview)
+S60_APP_RESOURCE(unittest_hbtumbleview)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdatetimepicker.exe SHARED_LIB_DIR\unittest_hbdatetimepicker.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdatetimepicker)
+S60_APP_RESOURCE(unittest_hbdatetimepicker)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbratingslider.exe SHARED_LIB_DIR\unittest_hbratingslider.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbratingslider)
+S60_APP_RESOURCE(unittest_hbratingslider)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbinputdialog.exe SHARED_LIB_DIR\unittest_hbinputdialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbinputdialog)
+S60_APP_RESOURCE(unittest_hbinputdialog)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbmessagebox.exe SHARED_LIB_DIR\unittest_hbmessagebox.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbmessagebox)
+S60_APP_RESOURCE(unittest_hbmessagebox)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbpushbutton.exe SHARED_LIB_DIR\unittest_hbpushbutton.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbpushbutton)
+S60_APP_RESOURCE(unittest_hbpushbutton)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbscrollbar.exe SHARED_LIB_DIR\unittest_hbscrollbar.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbscrollbar)
+S60_APP_RESOURCE(unittest_hbscrollbar)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbslider.exe SHARED_LIB_DIR\unittest_hbslider.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbslider)
+S60_APP_RESOURCE(unittest_hbslider)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbstackedlayout.exe SHARED_LIB_DIR\unittest_hbstackedlayout.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbstackedlayout)
+S60_APP_RESOURCE(unittest_hbstackedlayout)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbstackedwidget.exe SHARED_LIB_DIR\unittest_hbstackedwidget.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbstackedwidget)
+S60_APP_RESOURCE(unittest_hbstackedwidget)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtitlepane.exe SHARED_LIB_DIR\unittest_hbtitlepane.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtitlepane)
+S60_APP_RESOURCE(unittest_hbtitlepane)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtoolbar.exe SHARED_LIB_DIR\unittest_hbtoolbar.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtoolbar)
+S60_APP_RESOURCE(unittest_hbtoolbar)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtoolbarextension.exe SHARED_LIB_DIR\unittest_hbtoolbarextension.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtoolbarextension)
+S60_APP_RESOURCE(unittest_hbtoolbarextension)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbview.exe SHARED_LIB_DIR\unittest_hbview.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbview)
+S60_APP_RESOURCE(unittest_hbview)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblineedit.exe SHARED_LIB_DIR\unittest_hblineedit.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblineedit)
+S60_APP_RESOURCE(unittest_hblineedit)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbabstractedit.exe SHARED_LIB_DIR\unittest_hbabstractedit.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbabstractedit)
+S60_APP_RESOURCE(unittest_hbabstractedit)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtextedit.exe SHARED_LIB_DIR\unittest_hbtextedit.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtextedit)
+S60_APP_RESOURCE(unittest_hbtextedit)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbevent.exe SHARED_LIB_DIR\unittest_hbevent.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbevent)
+S60_APP_RESOURCE(unittest_hbevent)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtoolbutton.exe SHARED_LIB_DIR\unittest_hbtoolbutton.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtoolbutton)
+S60_APP_RESOURCE(unittest_hbtoolbutton)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbbatteryindicator.exe SHARED_LIB_DIR\unittest_hbbatteryindicator.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbbatteryindicator)
+S60_APP_RESOURCE(unittest_hbbatteryindicator)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdecorator.exe SHARED_LIB_DIR\unittest_hbdecorator.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdecorator)
+S60_APP_RESOURCE(unittest_hbdecorator)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbindicatorgroup.exe SHARED_LIB_DIR\unittest_hbindicatorgroup.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbindicatorgroup)
+S60_APP_RESOURCE(unittest_hbindicatorgroup)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbsignalindicator.exe SHARED_LIB_DIR\unittest_hbsignalindicator.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbsignalindicator)
+S60_APP_RESOURCE(unittest_hbsignalindicator)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbwidget.exe SHARED_LIB_DIR\unittest_hbwidget.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbwidget)
+S60_APP_RESOURCE(unittest_hbwidget)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbbackgrounditem.exe SHARED_LIB_DIR\unittest_hbbackgrounditem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbbackgrounditem)
+S60_APP_RESOURCE(unittest_hbbackgrounditem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbslidercontrol.exe SHARED_LIB_DIR\unittest_hbslidercontrol.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbslidercontrol)
+S60_APP_RESOURCE(unittest_hbslidercontrol)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbsliderhandle.exe SHARED_LIB_DIR\unittest_hbsliderhandle.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbsliderhandle)
+S60_APP_RESOURCE(unittest_hbsliderhandle)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbgroupbox.exe SHARED_LIB_DIR\unittest_hbgroupbox.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbgroupbox)
+S60_APP_RESOURCE(unittest_hbgroupbox)
+
+//This is HbStyle
+file=ABI_DIR\BUILD_DIR\unittest_hbstyle.exe SHARED_LIB_DIR\unittest_hbstyle.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbstyle)
+S60_APP_RESOURCE(unittest_hbstyle)
+file=ABI_DIR\BUILD_DIR\knobwidgetstyleplugin.dll SHARED_LIB_DIR\knobwidgetstyleplugin.dll UNPAGED
+file=ABI_DIR\BUILD_DIR\knobwidgetstyleplugin2.dll SHARED_LIB_DIR\knobwidgetstyleplugin2.dll UNPAGED
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtooltip.exe SHARED_LIB_DIR\unittest_hbtooltip.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtooltip)
+S60_APP_RESOURCE(unittest_hbtooltip)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbiconitem.exe SHARED_LIB_DIR\unittest_hbiconitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbiconitem)
+S60_APP_RESOURCE(unittest_hbiconitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfont.exe SHARED_LIB_DIR\unittest_hbfont.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfont)
+S60_APP_RESOURCE(unittest_hbfont)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcss.exe SHARED_LIB_DIR\unittest_hbcss.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcss)
+S60_APP_RESOURCE(unittest_hbcss)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtextutils.exe SHARED_LIB_DIR\unittest_hbtextutils.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtextutils)
+S60_APP_RESOURCE(unittest_hbtextutils)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbradiobuttonlist.exe SHARED_LIB_DIR\unittest_hbradiobuttonlist.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbradiobuttonlist)
+S60_APP_RESOURCE(unittest_hbradiobuttonlist)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcheckbox.exe SHARED_LIB_DIR\unittest_hbcheckbox.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcheckbox)
+S60_APP_RESOURCE(unittest_hbcheckbox)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbzoomsliderpopup.exe SHARED_LIB_DIR\unittest_hbzoomsliderpopup.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbzoomsliderpopup)
+S60_APP_RESOURCE(unittest_hbzoomsliderpopup)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbzoomslider.exe SHARED_LIB_DIR\unittest_hbzoomslider.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbzoomslider)
+S60_APP_RESOURCE(unittest_hbzoomslider)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbsliderpopup.exe SHARED_LIB_DIR\unittest_hbsliderpopup.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbsliderpopup)
+S60_APP_RESOURCE(unittest_hbsliderpopup)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvolumesliderpopup.exe SHARED_LIB_DIR\unittest_hbvolumesliderpopup.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvolumesliderpopup)
+S60_APP_RESOURCE(unittest_hbvolumesliderpopup)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvolumeslider.exe SHARED_LIB_DIR\unittest_hbvolumeslider.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvolumeslider)
+S60_APP_RESOURCE(unittest_hbvolumeslider)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdeviceprogressdialog.exe SHARED_LIB_DIR\unittest_hbdeviceprogressdialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdeviceprogressdialog)
+S60_APP_RESOURCE(unittest_hbdeviceprogressdialog)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdeviceprogressdialogsymbian.exe SHARED_LIB_DIR\unittest_hbdeviceprogressdialogsymbian.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdeviceprogressdialogsymbian)
+S60_APP_RESOURCE(unittest_hbdeviceprogressdialogsymbian)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdevicenotificationdialog.exe SHARED_LIB_DIR\unittest_hbdevicenotificationdialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdevicenotificationdialog)
+S60_APP_RESOURCE(unittest_hbdevicenotificationdialog)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdevicenotificationdialogsymbian.exe SHARED_LIB_DIR\unittest_hbdevicenotificationdialogsymbian.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdevicenotificationdialogsymbian)
+S60_APP_RESOURCE(unittest_hbdevicenotificationdialogsymbian)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdevicemessagebox.exe SHARED_LIB_DIR\unittest_hbdevicemessagebox.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdevicemessagebox)
+S60_APP_RESOURCE(unittest_hbdevicemessagebox)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdevicemessageboxsymbian.exe SHARED_LIB_DIR\unittest_hbdevicemessageboxsymbian.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdevicemessageboxsymbian)
+S60_APP_RESOURCE(unittest_hbdevicemessageboxsymbian)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcolordialog.exe SHARED_LIB_DIR\unittest_hbcolordialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcolordialog)
+S60_APP_RESOURCE(unittest_hbcolordialog)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcombobox.exe SHARED_LIB_DIR\unittest_hbcombobox.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcombobox)
+S60_APP_RESOURCE(unittest_hbcombobox)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbnotificationdialog.exe SHARED_LIB_DIR\unittest_hbnotificationdialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbnotificationdialog)
+S60_APP_RESOURCE(unittest_hbnotificationdialog)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtheme.exe SHARED_LIB_DIR\unittest_hbtheme.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtheme)
+S60_APP_RESOURCE(unittest_hbtheme)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbicontheme.exe SHARED_LIB_DIR\unittest_hbicontheme.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbicontheme)
+S60_APP_RESOURCE(unittest_hbicontheme)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcolorscheme.exe SHARED_LIB_DIR\unittest_hbcolorscheme.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcolorscheme)
+S60_APP_RESOURCE(unittest_hbcolorscheme)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcolortheme.exe SHARED_LIB_DIR\unittest_hbcolortheme.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcolortheme)
+S60_APP_RESOURCE(unittest_hbcolortheme)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbthemeutils.exe SHARED_LIB_DIR\unittest_hbthemeutils.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbthemeutils)
+S60_APP_RESOURCE(unittest_hbthemeutils)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdataform.exe SHARED_LIB_DIR\unittest_hbdataform.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdataform)
+S60_APP_RESOURCE(unittest_hbdataform)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdataformmodel.exe SHARED_LIB_DIR\unittest_hbdataformmodel.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdataformmodel)
+S60_APP_RESOURCE(unittest_hbdataformmodel)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdataformmodelitem.exe SHARED_LIB_DIR\unittest_hbdataformmodelitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdataformmodelitem)
+S60_APP_RESOURCE(unittest_hbdataformmodelitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdataformviewitem.exe SHARED_LIB_DIR\unittest_hbdataformviewitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdataformviewitem)
+S60_APP_RESOURCE(unittest_hbdataformviewitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbcssthemeinterface.exe SHARED_LIB_DIR\unittest_hbcssthemeinterface.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbcssthemeinterface)
+S60_APP_RESOURCE(unittest_hbcssthemeinterface)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblayeredstyleloader.exe SHARED_LIB_DIR\unittest_hblayeredstyleloader.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblayeredstyleloader)
+S60_APP_RESOURCE(unittest_hblayeredstyleloader)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbstyleloader.exe SHARED_LIB_DIR\unittest_hbstyleloader.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbstyleloader)
+S60_APP_RESOURCE(unittest_hbstyleloader)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbwidgetstyleloader.exe SHARED_LIB_DIR\unittest_hbwidgetstyleloader.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbwidgetstyleloader)
+S60_APP_RESOURCE(unittest_hbwidgetstyleloader)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtoucharea.exe SHARED_LIB_DIR\unittest_hbtoucharea.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtoucharea)
+S60_APP_RESOURCE(unittest_hbtoucharea)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtreeview.exe SHARED_LIB_DIR\unittest_hbtreeview.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtreeview)
+S60_APP_RESOURCE(unittest_hbtreeview)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtreeviewitem.exe SHARED_LIB_DIR\unittest_hbtreeviewitem.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtreeviewitem)
+S60_APP_RESOURCE(unittest_hbtreeviewitem)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbindicator.exe SHARED_LIB_DIR\unittest_hbindicator.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbindicator)
+S60_APP_RESOURCE(unittest_hbindicator)
+file=ABI_DIR\BUILD_DIR\codesnippetplugin.dll SHARED_LIB_DIR\codesnippetplugin.dll
+HB_PLUGIN_STUB(codesnippetplugin, indicators)
+file=ABI_DIR\BUILD_DIR\hbfirstindicatorplugin.dll SHARED_LIB_DIR\hbfirstindicatorplugin.dll
+HB_PLUGIN_STUB(hbfirstindicatorplugin, indicators)
+file=ABI_DIR\BUILD_DIR\hbsecondindicatorplugin.dll SHARED_LIB_DIR\hbsecondindicatorplugin.dll
+HB_PLUGIN_STUB(hbsecondindicatorplugin, indicators)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfeedbackplayer.exe SHARED_LIB_DIR\unittest_hbfeedbackplayer.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfeedbackplayer)
+S60_APP_RESOURCE(unittest_hbfeedbackplayer)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfeedbackengine.exe SHARED_LIB_DIR\unittest_hbfeedbackengine.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfeedbackengine)
+S60_APP_RESOURCE(unittest_hbfeedbackengine)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfeedbackplugingroup.exe SHARED_LIB_DIR\unittest_hbfeedbackplugingroup.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfeedbackplugingroup)
+S60_APP_RESOURCE(unittest_hbfeedbackplugingroup)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfeedbackmanager.exe SHARED_LIB_DIR\unittest_hbfeedbackmanager.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfeedbackmanager)
+S60_APP_RESOURCE(unittest_hbfeedbackmanager)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfeedbackplugin.exe SHARED_LIB_DIR\unittest_hbfeedbackplugin.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfeedbackplugin)
+S60_APP_RESOURCE(unittest_hbfeedbackplugin)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfeedbackwidgetsupport.exe SHARED_LIB_DIR\unittest_hbfeedbackwidgetsupport.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfeedbackwidgetsupport)
+S60_APP_RESOURCE(unittest_hbfeedbackwidgetsupport)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbextendedlocale.exe SHARED_LIB_DIR\unittest_hbextendedlocale.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbextendedlocale)
+S60_APP_RESOURCE(unittest_hbextendedlocale)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbstringutil.exe SHARED_LIB_DIR\unittest_hbstringutil.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbstringutil)
+S60_APP_RESOURCE(unittest_hbstringutil)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbdirectorynamelocalizer.exe SHARED_LIB_DIR\unittest_hbdirectorynamelocalizer.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbdirectorynamelocalizer)
+S60_APP_RESOURCE(unittest_hbdirectorynamelocalizer)
+
+// unittest_hbvg*effect may not be built in all configurations, they can be missing
+file=ABI_DIR\BUILD_DIR\unittest_hbvgeffect.exe SHARED_LIB_DIR\unittest_hbvgeffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgeffect)
+S60_APP_RESOURCE(unittest_hbvgeffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgbceffect.exe SHARED_LIB_DIR\unittest_hbvgbceffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgbceffect)
+S60_APP_RESOURCE(unittest_hbvgbceffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgblureffect.exe SHARED_LIB_DIR\unittest_hbvgblureffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgblureffect)
+S60_APP_RESOURCE(unittest_hbvgblureffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgchainedeffect.exe SHARED_LIB_DIR\unittest_hbvgchainedeffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgchainedeffect)
+S60_APP_RESOURCE(unittest_hbvgchainedeffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgcolorizeeffect.exe SHARED_LIB_DIR\unittest_hbvgcolorizeeffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgcolorizeeffect)
+S60_APP_RESOURCE(unittest_hbvgcolorizeeffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvggloweffect.exe SHARED_LIB_DIR\unittest_hbvggloweffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvggloweffect)
+S60_APP_RESOURCE(unittest_hbvggloweffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvghsleffect.exe SHARED_LIB_DIR\unittest_hbvghsleffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvghsleffect)
+S60_APP_RESOURCE(unittest_hbvghsleffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgoutlineeffect.exe SHARED_LIB_DIR\unittest_hbvgoutlineeffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgoutlineeffect)
+S60_APP_RESOURCE(unittest_hbvgoutlineeffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgshadoweffect.exe SHARED_LIB_DIR\unittest_hbvgshadoweffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgshadoweffect)
+S60_APP_RESOURCE(unittest_hbvgshadoweffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgmaskeffect.exe SHARED_LIB_DIR\unittest_hbvgmaskeffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgmaskeffect)
+S60_APP_RESOURCE(unittest_hbvgmaskeffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbvgreflectioneffect.exe SHARED_LIB_DIR\unittest_hbvgreflectioneffect.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbvgreflectioneffect)
+S60_APP_RESOURCE(unittest_hbvgreflectioneffect)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbnumbergrouping.exe SHARED_LIB_DIR\unittest_hbnumbergrouping.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbnumbergrouping)
+S60_APP_RESOURCE(unittest_hbnumbergrouping)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbformatdialog.exe SHARED_LIB_DIR\unittest_hbformatdialog.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbformatdialog)
+S60_APP_RESOURCE(unittest_hbformatdialog)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbindexfeedback.exe SHARED_LIB_DIR\unittest_hbindexfeedback.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbindexfeedback)
+S60_APP_RESOURCE(unittest_hbindexfeedback)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbmemorymanager.exe SHARED_LIB_DIR\unittest_hbmemorymanager.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbmemorymanager)
+S60_APP_RESOURCE(unittest_hbmemorymanager)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbgridlayout.exe SHARED_LIB_DIR\unittest_hbgridlayout.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbgridlayout)
+S60_APP_RESOURCE(unittest_hbgridlayout)
+
+file=ABI_DIR\BUILD_DIR\unittest_hblengthlimiter.exe SHARED_LIB_DIR\unittest_hblengthlimiter.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hblengthlimiter)
+S60_APP_RESOURCE(unittest_hblengthlimiter)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbtranslator.exe SHARED_LIB_DIR\unittest_hbtranslator.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbtranslator)
+S60_APP_RESOURCE(unittest_hbtranslator)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbfindfile.exe SHARED_LIB_DIR\unittest_hbfindfile.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbfindfile)
+S60_APP_RESOURCE(unittest_hbfindfile)
+
+data=\epoc32\release\winscw\udeb\z\resource\qt\translations\unittest_hbtranslator_en.qm resource\qt\translations\unittest_hbtranslator_en.qm
+data=\epoc32\release\winscw\udeb\z\resource\qt\translations\unittest_hbtranslator2_en.qm resource\qt\translations\unittest_hbtranslator2_en.qm
+data=\epoc32\winscw\c\resource\qt\custom\unittest_hbtranslator_custom_en.qm resource\qt\custom\unittest_hbtranslator_custom_en.qm
+data=\epoc32\release\winscw\udeb\z\resource\qt\translations\dummy_en.qm resource\qt\translations\dummy_en.qm
+data=\epoc32\release\winscw\udeb\z\resource\qt\custom\test.txt resource\qt\custom\test.txt
+data=\epoc32\winscw\c\resource\qt\custom\test2.txt resource\qt\custom\test2.txt
+
+
+file=ABI_DIR\BUILD_DIR\unittest_hbapplication.exe SHARED_LIB_DIR\unittest_hbapplication.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbapplication)
+S60_APP_RESOURCE(unittest_hbapplication)
+
+file=ABI_DIR\BUILD_DIR\unittest_hbactivitymanager.exe SHARED_LIB_DIR\unittest_hbactivitymanager.exe
+HB_UPGRADABLE_APP_REG_RSC(unittest_hbactivitymanager)
+S60_APP_RESOURCE(unittest_hbactivitymanager)
+
+file=ABI_DIR\BUILD_DIR\fake_hbactivityplugin.dll SHARED_LIB_DIR\fake_hbactivityplugin.dll
+data=\epoc32\data\z\resource\plugins\qt\testplugins\hbactivitypluginfake.qtplugin RESOURCE_FILES_DIR\qt\plugins\testplugins\hbactivitypluginfake.qtplugin
+
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbactivitymanager/fake_hbactivityplugin/fake_hbactivityplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+TEMPLATE = lib
+TARGET = hbactivityplugin
+
+CONFIG += plugin
+
+HEADERS += hbactivitypluginfake.h \
+..\..\..\..\src\hbcore\activity\hbactivityplugininterface_p.h
+
+SOURCES += hbactivitypluginfake.cpp
+
+win32 {
+ debug {
+ DESTDIR = ../unittest_hbactivitymanager/debug/testplugins
+ }
+ else {
+ DESTDIR = ../unittest_hbactivitymanager/release/testplugins
+ }
+}
+else {
+ DESTDIR = ../unittest_hbactivitymanager/testplugins
+}
+
+symbian {
+ load(data_caging_paths)
+ pluginDep.sources = hbactivitypluginfake.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/testplugins
+ DEPLOYMENT += pluginDep
+
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.CAPABILITY = ALL -TCB
+}
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbactivitymanager/fake_hbactivityplugin/hbactivitypluginfake.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,73 @@
+#include "hbactivitypluginfake.h"
+
+#include <QStringList>
+
+bool HbActivityPluginFake::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ if (mActivities.contains(activityId)) {
+ return false;
+ } else {
+ mActivities.insert(activityId, QPair<QVariantHash, QVariant>(parameters, data));
+ return true;
+ }
+}
+
+bool HbActivityPluginFake::removeActivity(const QString &activityId)
+{
+ if (mActivities.contains(activityId)) {
+ mActivities.remove(activityId);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool HbActivityPluginFake::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ if (mActivities.contains(activityId)) {
+ mActivities.insert(activityId, QPair<QVariantHash, QVariant>(parameters, data));
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QList<QVariantHash> HbActivityPluginFake::activities()
+{
+ QList<QVariantHash> result;
+ for (QHash<QString, QPair<QVariantHash, QVariant> >::const_iterator i = mActivities.constBegin(); i != mActivities.constEnd(); ++i) {
+ result.append(i->first);
+ }
+ return result;
+}
+
+QVariant HbActivityPluginFake::activityData(const QString &activityId)
+{
+ if (mActivities.contains(activityId)) {
+ return mActivities.value(activityId).second;
+ } else {
+ return QVariant();
+ }
+}
+
+bool HbActivityPluginFake::waitActivity()
+{
+ if (mActivities.isEmpty()) {
+ return false;
+ } else {
+ emit activityRequested(mActivities.keys().first());
+ return true;
+ }
+}
+
+QVariantHash HbActivityPluginFake::parseCommandLine(const QStringList &commandLineParams)
+{
+ QVariantHash fakeActivityParameters;
+ if (commandLineParams.count() == 1 && commandLineParams.first() == "UnitTest") {
+ fakeActivityParameters.insert("activityname", "TestActivity");
+ fakeActivityParameters.insert("fakeParam", "fakeValue");
+ }
+ return fakeActivityParameters;
+}
+
+Q_EXPORT_PLUGIN2(hbactivityplugin, HbActivityPluginFake)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbactivitymanager/fake_hbactivityplugin/hbactivitypluginfake.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#ifndef HBACTIVITYPLUGINFAKE_H
+#define HBACTIVITYPLUGINFAKE_H
+
+#include "hbactivityplugininterface_p.h"
+
+class HbActivityPluginFake : public HbActivityPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(HbActivityPluginInterface)
+
+public:
+ virtual bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ virtual bool removeActivity(const QString &activityId);
+ virtual bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ virtual QList<QVariantHash> activities();
+ virtual QVariant activityData(const QString &activityId);
+ virtual bool waitActivity();
+ virtual QVariantHash parseCommandLine(const QStringList &commandLineParams);
+
+private:
+ QHash<QString, QPair<QVariantHash, QVariant> > mActivities;
+
+};
+
+#endif // HBACTIVITYPLUGINFAKE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbactivitymanager/unittest_hbactivitymanager.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+#
+# ============================================================================
+# Name : unittest_hbactivitymanager.pro
+# Part of : LibHb / HbStyle
+# Description : Project definition file for project unittest_hbactivitymanager
+# Version : %version: 4 %
+#
+# Copyright © 2008 Nokia. All rights reserved.
+# This material, including documentation and any related computer
+# programs, is protected by copyright controlled by Nokia. All
+# rights are reserved. Copying, including reproducing, storing,
+# adapting or translating, any or all of this material requires the
+# prior written consent of Nokia. This material also contains
+# confidential information which may not be disclosed to others
+# without the prior written consent of Nokia.
+# ============================================================================
+#
+
+TEMPLATE = subdirs
+SUBDIRS += fake_hbactivityplugin
+SUBDIRS += unittest_hbactivitymanager
+CONFIG += ordered
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbactivitymanager/unittest_hbactivitymanager/unittest_hbactivitymanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,182 @@
+/*
+* ============================================================================
+* Name : unittest_hbactivitymanager.cpp
+* Part of : LibHb / HbActivityManager
+* Description : HbActivityManager unit tests
+* Version : %version: 5 %
+*
+* Copyright (c) 2008-2009 Nokia. All rights reserved.
+* This material, including documentation and any related computer
+* programs, is protected by copyright controlled by Nokia. All
+* rights are reserved. Copying, including reproducing, storing,
+* adapting or translating, any or all of this material requires the
+* prior written consent of Nokia. This material also contains
+* confidential information which may not be disclosed to others
+* without the prior written consent of Nokia.
+* ============================================================================
+*/
+
+#include <QtTest/QtTest>
+
+#include <hbapplication.h>
+#include <hbactivitymanager.h>
+#include <hbtest.h>
+
+class TestHbActivityManager : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void cleanup();
+
+private slots:
+ void testConstruction();
+ void testAddActivity();
+ void testRemoveActivity();
+ void testActivityData();
+ void testUpdateActivity();
+ void testWaitActivity();
+ void testActivities();
+ void testCommandLineParsing();
+ void testFalseAndEmptyValuesReturnedWhenPluginCannotBeLoaded();
+
+};
+
+
+void TestHbActivityManager::cleanup()
+{
+ HbActivityManager manager;
+ manager.removeActivity("TestActivity1");
+ manager.removeActivity("TestActivity2");
+}
+
+void TestHbActivityManager::testConstruction()
+{
+ HbActivityManager *manager = new HbActivityManager;
+ QVERIFY(manager);
+ delete manager;
+}
+
+void TestHbActivityManager::testAddActivity()
+{
+ HbActivityManager manager;
+ QVERIFY(manager.addActivity("TestActivity1", "TestData", QVariantHash()));
+ // cannot add same activity twice
+ QVERIFY(!manager.addActivity("TestActivity1", "TestData2", QVariantHash()));
+}
+
+void TestHbActivityManager::testRemoveActivity()
+{
+ HbActivityManager manager;
+ // activity have to be added before it's deleted
+ QVERIFY(!manager.removeActivity("TestActivity1"));
+ QVERIFY(manager.addActivity("TestActivity1", "TestData", QVariantHash()));
+ QVERIFY(manager.removeActivity("TestActivity1"));
+}
+
+void TestHbActivityManager::testActivityData()
+{
+ HbActivityManager manager;
+ // empty data is returned for non existing activity
+ QCOMPARE(manager.activityData("TestActivity1"), QVariant());
+
+ // correct data is returned for existing activity
+ QVERIFY(manager.addActivity("TestActivity1", "TestData", QVariantHash()));
+ QCOMPARE(manager.activityData("TestActivity1"), QVariant("TestData"));
+}
+
+void TestHbActivityManager::testUpdateActivity()
+{
+ HbActivityManager manager;
+ // activity have to be added before it's updated
+ QVERIFY(!manager.updateActivity("TestActivity1", "TestData", QVariantHash()));
+
+ // activity can be succesfully updated
+ QVERIFY(manager.addActivity("TestActivity1", "TestData", QVariantHash()));
+ QCOMPARE(manager.activityData("TestActivity1"), QVariant("TestData"));
+ QVERIFY(manager.updateActivity("TestActivity1", "TestData2", QVariantHash()));
+ QCOMPARE(manager.activityData("TestActivity1"), QVariant("TestData2"));
+}
+
+void TestHbActivityManager::testWaitActivity()
+{
+ HbActivityManager manager;
+ // mocked plugin returns false when there are no activities, so we have to add something
+ QVERIFY(manager.addActivity("TestActivity1", "TestData", QVariantHash()));
+ QVERIFY(manager.waitActivity());
+}
+
+void TestHbActivityManager::testActivities()
+{
+ HbActivityManager manager;
+ // empty list returned when there is no activities
+ QCOMPARE(manager.activities().count(), 0);
+
+ QVERIFY(manager.addActivity("TestActivity1", "TestData", QVariantHash()));
+ QCOMPARE(manager.activities().count(), 1);
+
+ QVERIFY(manager.addActivity("TestActivity2", "TestData", QVariantHash()));
+ QCOMPARE(manager.activities().count(), 2);
+}
+
+void TestHbActivityManager::testCommandLineParsing()
+{
+ HbActivityManager manager;
+ // fake activity plugin returns valid fake activity when QStringList with
+ // single "UnitTest" QString is used as argument
+
+ Hb::ActivationReason reason(Hb::ActivationReasonNormal);
+ QString id;
+ QVariantHash params;
+
+ manager.parseCommandLine(QStringList(), reason, id, params);
+ QCOMPARE(reason, Hb::ActivationReasonNormal);
+ QCOMPARE(id, QString());
+ QVERIFY(params.isEmpty());
+
+ manager.parseCommandLine(QStringList("UnitTest"), reason, id, params);
+ QCOMPARE(reason, Hb::ActivationReasonActivity);
+ QCOMPARE(id, QString("TestActivity"));
+ QCOMPARE(params.count(), 2);
+ QVERIFY(params.contains("activityname"));
+ QCOMPARE(params.value("activityname"), QVariant("TestActivity"));
+ QVERIFY(params.contains("fakeParam"));
+ QCOMPARE(params.value("fakeParam"), QVariant("fakeValue"));
+}
+
+void TestHbActivityManager::testFalseAndEmptyValuesReturnedWhenPluginCannotBeLoaded()
+{
+ QSKIP("This test can't be performed, because the plugin path is hardcoded into HbActivityManager", SkipAll);
+ QVERIFY(QFile::rename("/resource/qt/plugins/hbactivityplugin.qtplugin", "/resource/qt/plugins/hbactivityplugin.tmp"));
+
+ HbActivityManager manager;
+
+ // every method will return false or empty value
+ QVERIFY(!manager.addActivity("TestActivity1", "TestData2", QVariantHash()));
+ QVERIFY(!manager.removeActivity("TestActivity1"));
+ QCOMPARE(manager.activityData("TestActivity1"), QVariant());
+ QVERIFY(!manager.updateActivity("TestActivity1", "TestData", QVariantHash()));
+ QVERIFY(!manager.waitActivity());
+ QCOMPARE(manager.activities().count(), 0);
+
+ QVERIFY(QFile::rename("/resource/qt/plugins/hbactivityplugin.tmp", "/resource/qt/plugins/hbactivityplugin.qtplugin"));
+}
+
+int main(int argc, char *argv[])
+{
+#if defined(Q_OS_WIN32) || defined(Q_OS_LINUX)
+ QCoreApplication::addLibraryPath("testplugins/");
+#elif defined(Q_OS_SYMBIAN)
+ QCoreApplication::addLibraryPath("/resource/qt/plugins/testplugins/");
+#endif
+
+ HbApplication app(argc, argv);
+ TestHbActivityManager tc;
+ int ret = QTest::qExec(&tc, argc, argv);
+ QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection);
+ return ret;
+}
+
+
+
+#include "unittest_hbactivitymanager.moc"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbactivitymanager/unittest_hbactivitymanager/unittest_hbactivitymanager.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# ============================================================================
+# Name : unittest_hbactivitymanager.pro
+# Part of : LibHb / HbActivityManager
+# Description : Project definition file for project unittest_hbactivitymanager
+# Version : %version: 1 %
+#
+# Copyright © 2008 Nokia. All rights reserved.
+# This material, including documentation and any related computer
+# programs, is protected by copyright controlled by Nokia. All
+# rights are reserved. Copying, including reproducing, storing,
+# adapting or translating, any or all of this material requires the
+# prior written consent of Nokia. This material also contains
+# confidential information which may not be disclosed to others
+# without the prior written consent of Nokia.
+# ============================================================================
+#
+
+SOURCES += unittest_hbactivitymanager.cpp
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbapplication/fake_hbactivityplugin/fake_hbactivityplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+TEMPLATE = lib
+TARGET = hbactivityplugin
+
+CONFIG += plugin
+
+HEADERS += hbactivitypluginfake.h \
+..\..\..\..\src\hbcore\activity\hbactivityplugininterface_p.h
+
+SOURCES += hbactivitypluginfake.cpp
+
+win32 {
+ debug {
+ DESTDIR = ../unittest_hbapplication/debug/testplugins
+ }
+ else {
+ DESTDIR = ../unittest_hbapplication/release/testplugins
+ }
+}
+else {
+ DESTDIR = ../unittest_hbapplication/testplugins
+}
+
+symbian {
+ load(data_caging_paths)
+ pluginDep.sources = hbactivitypluginfake.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/testplugins
+ DEPLOYMENT += pluginDep
+
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.CAPABILITY = ALL -TCB
+}
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbapplication/fake_hbactivityplugin/hbactivitypluginfake.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,72 @@
+#include "hbactivitypluginfake.h"
+
+#include <QStringList>
+
+bool HbActivityPluginFake::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ if (mActivities.contains(activityId)) {
+ return false;
+ } else {
+ mActivities.insert(activityId, QPair<QVariantHash, QVariant>(parameters, data));
+ return true;
+ }
+}
+
+bool HbActivityPluginFake::removeActivity(const QString &activityId)
+{
+ if (mActivities.contains(activityId)) {
+ mActivities.remove(activityId);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool HbActivityPluginFake::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
+{
+ if (mActivities.contains(activityId)) {
+ mActivities.insert(activityId, QPair<QVariantHash, QVariant>(parameters, data));
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QList<QVariantHash> HbActivityPluginFake::activities()
+{
+ QList<QVariantHash> result;
+ for (QHash<QString, QPair<QVariantHash, QVariant> >::const_iterator i = mActivities.constBegin(); i != mActivities.constEnd(); ++i) {
+ result.append(i->first);
+ }
+ return result;
+}
+
+QVariant HbActivityPluginFake::activityData(const QString &activityId)
+{
+ if (mActivities.contains(activityId)) {
+ return mActivities.value(activityId).second;
+ } else {
+ return QVariant();
+ }
+}
+
+bool HbActivityPluginFake::waitActivity()
+{
+ if (mActivities.isEmpty()) {
+ return false;
+ } else {
+ emit activityRequested(mActivities.keys().first());
+ return true;
+ }
+}
+
+QVariantHash HbActivityPluginFake::parseCommandLine(const QStringList &commandLineParams)
+{
+ QVariantHash fakeActivityParameters;
+ if (commandLineParams.count() == 1 && commandLineParams.first() == "UnitTest") {
+ fakeActivityParameters.insert("activityname", "TestActivity");
+ fakeActivityParameters.insert("fakeParam", "fakeValue");
+ }
+ return fakeActivityParameters;
+}
+Q_EXPORT_PLUGIN2(hbactivityplugin, HbActivityPluginFake)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbapplication/fake_hbactivityplugin/hbactivitypluginfake.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#ifndef HBACTIVITYPLUGINFAKE_H
+#define HBACTIVITYPLUGINFAKE_H
+
+#include "hbactivityplugininterface_p.h"
+
+class HbActivityPluginFake : public HbActivityPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(HbActivityPluginInterface)
+
+public:
+ virtual bool addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ virtual bool removeActivity(const QString &activityId);
+ virtual bool updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters);
+ virtual QList<QVariantHash> activities();
+ virtual QVariant activityData(const QString &activityId);
+ virtual bool waitActivity();
+ virtual QVariantHash parseCommandLine(const QStringList &commandLineParams);
+
+private:
+ QHash<QString, QPair<QVariantHash, QVariant> > mActivities;
+
+};
+
+#endif // HBACTIVITYPLUGINFAKE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbapplication/unittest_hbapplication.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+#
+# ============================================================================
+# Name : unittest_hbapplication.pro
+# Part of : LibHb
+# Description : Project definition file for project unittest_hbapplication
+# Version : %version: 3 %
+#
+# Copyright © 2008 Nokia. All rights reserved.
+# This material, including documentation and any related computer
+# programs, is protected by copyright controlled by Nokia. All
+# rights are reserved. Copying, including reproducing, storing,
+# adapting or translating, any or all of this material requires the
+# prior written consent of Nokia. This material also contains
+# confidential information which may not be disclosed to others
+# without the prior written consent of Nokia.
+# ============================================================================
+#
+
+TEMPLATE = subdirs
+SUBDIRS += fake_hbactivityplugin
+SUBDIRS += unittest_hbapplication
+CONFIG += ordered
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbapplication/unittest_hbapplication/unittest_hbapplication.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* ============================================================================
+* Name : unittest_hbapplication.cpp
+* Part of : LibHb / HbApplication
+* Description : HbApplication unit tests
+* Version : %version: 4 %
+*
+* Copyright (c) 2008-2009 Nokia. All rights reserved.
+* This material, including documentation and any related computer
+* programs, is protected by copyright controlled by Nokia. All
+* rights are reserved. Copying, including reproducing, storing,
+* adapting or translating, any or all of this material requires the
+* prior written consent of Nokia. This material also contains
+* confidential information which may not be disclosed to others
+* without the prior written consent of Nokia.
+* ============================================================================
+*/
+
+#include <QtTest/QtTest>
+
+#include <hbapplication.h>
+#include <hbactivitymanager.h>
+#include <hbtest.h>
+
+class TestHbApplication : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void cleanup();
+
+private slots:
+ void testHideSplash();
+ void testActivityManager();
+ void testActivityGettersForNoActivity();
+ void testActivityGettersAfterActivitySignal();
+
+private:
+ HbApplication *hbApp() {return qobject_cast<HbApplication*>(qApp);}
+
+};
+
+
+void TestHbApplication::cleanup()
+{
+ HbActivityManager *manager = hbApp()->activityManager();
+ manager->removeActivity("TestActivity1");
+}
+
+void TestHbApplication::testHideSplash()
+{
+ HbApplication *app = static_cast<HbApplication *>(qApp);
+ app->hideSplash();
+ app->hideSplash();
+}
+
+void TestHbApplication::testActivityManager()
+{
+ QVERIFY(hbApp()->activityManager());
+}
+
+void TestHbApplication::testActivityGettersForNoActivity()
+{
+ HbApplication *app = hbApp();
+ QCOMPARE(app->activateReason(), Hb::ActivationReasonNormal);
+ QCOMPARE(app->activateId(), QString());
+ QCOMPARE(app->activateData(), QVariant());
+ QCOMPARE(app->activateParams(), QVariantHash());
+}
+
+void TestHbApplication::testActivityGettersAfterActivitySignal()
+{
+ HbApplication *app = hbApp();
+ HbActivityManager *manager = app->activityManager();
+
+ // our fake activity manager emits the activity singal immediately
+ // after wait, given that there is any activity added
+ QVERIFY(manager->addActivity("TestActivity1", "TestData", QVariantHash()));
+
+ QSignalSpy spy(app, SIGNAL(activate()));
+ QVERIFY(spy.isValid());
+
+ QVERIFY(manager->waitActivity());
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(app->activateReason(), Hb::ActivationReasonActivity);
+ QCOMPARE(app->activateId(), QString("TestActivity1"));
+ QCOMPARE(app->activateData(), QVariant("TestData"));
+}
+
+int main(int argc, char *argv[])
+{
+#if defined(Q_OS_WIN32) || defined(Q_OS_LINUX)
+ QCoreApplication::addLibraryPath("testplugins/");
+#elif defined(Q_OS_SYMBIAN)
+ QCoreApplication::addLibraryPath("/resource/qt/plugins/testplugins/");
+#endif
+
+ HbApplication app(argc, argv);
+ TestHbApplication tc;
+ int ret = QTest::qExec(&tc, argc, argv);
+ QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection);
+ return ret;
+}
+
+#include "unittest_hbapplication.moc"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/orbitintegration/hb/tsrc/unit/unittest_hbapplication/unittest_hbapplication/unittest_hbapplication.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# ============================================================================
+# Name : unittest_hbapplication.pro
+# Part of : LibHb / HbApplication
+# Description : Project definition file for project unittest_hbapplication
+# Version : %version: 1 %
+#
+# Copyright © 2008 Nokia. All rights reserved.
+# This material, including documentation and any related computer
+# programs, is protected by copyright controlled by Nokia. All
+# rights are reserved. Copying, including reproducing, storing,
+# adapting or translating, any or all of this material requires the
+# prior written consent of Nokia. This material also contains
+# confidential information which may not be disclosed to others
+# without the prior written consent of Nokia.
+# ============================================================================
+#
+
+SOURCES += unittest_hbapplication.cpp
+
+include($${HB_SOURCE_DIR}/tsrc/hbtest.pri)
Binary file activityfw/storage/client/t_afstorageclient/data/image_file_activitydbclient.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/client/t_afstorageclient/inc/t_activityclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 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: Test class for taskswitcher::TaskSwitcher
+*
+*/
+
+
+#include <QtTest/QtTest>
+#include "afasyncrequestobserver.h"
+#include "afasyncsession.h"
+
+class CFbsBitmap;
+
+/**
+* @test Test class
+*/
+class T_ActivityClient : public QObject,
+ public MAfAsyncSession,
+ public MAfAsyncRequestObserver
+{
+ Q_OBJECT
+public:
+ T_ActivityClient();
+ ~T_ActivityClient();
+
+public: //MAfAsyncRequestObserver
+ void waitActivityRequestCompleted(int result,
+ const TDesC8 &data);
+
+ void getThumbnailRequestCompleted(int result,
+ int bitmapHandle,
+ void* userData);
+
+ void dataChangeNotificationCompleted(int result);
+
+public: //MAfAsyncSession
+ void PushL(CBase* asyncTask);
+ void Pop(CBase* asyncTask);
+ void executeL(int function);
+ void sendAsync(int function, const TIpcArgs &args, TRequestStatus& status);
+ void getDataL(int id, TDes8& buffer);
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void testEntry();
+ void testAsyncRequest();
+ void testCreateClient();
+ void testAddActivity();
+ void testUpdateActivity();
+ void testSaveActivity();
+ void testRemoveActivity();
+ void testRemoveApplicationActivities();
+ void testActivities();
+ void testApplicationActivities();
+ void testGetData();
+ void testWaitLaunchActivity();
+ void testGetThumbnail();
+
+private:
+ CFbsBitmap *mBitmap;
+
+ HBufC *mData;
+
+ TInt mScreenshotHandle;
+ CFbsBitmap *mScreenshot;
+
+ CBase *mRunningTask;
+ void *mUserData;
+ int mExpectedResponse;
+ int mRealResponse;
+ QEventLoop mLoop;
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/client/t_afstorageclient/src/t_activityclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,552 @@
+/*
+* Copyright (c) 2009 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: Main test class for hsutils library.
+*
+*/
+
+#include "t_activityclient.h"
+
+#include <s32mem.h>
+#include <fbs.h>
+
+#include <QPainter>
+#include <QScopedPointer>
+
+#include <XQConversions>
+
+#include <afstorageglobals.h>
+#include <afentry.h>
+
+#include "afasyncrequest_p.h"
+#include "afthumbnailrequest_p.h"
+#include "afstorageclient.h"
+
+_LIT(KActivityName, "ActivityName");
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+T_ActivityClient::T_ActivityClient() : mBitmap(0), mData(0), mRunningTask(0), mScreenshot(0), mUserData(0)
+{
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+T_ActivityClient::~T_ActivityClient()
+{
+ delete mData;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::initTestCase()
+{
+ QPixmap screenshot(20, 20);
+ {
+ QPainter painter(&screenshot);
+ painter.setBrush(Qt::black);
+ painter.drawRect(screenshot.rect());
+ painter.setBrush(QColor::fromHsv(255, 255, 255));
+ painter.drawEllipse(screenshot.rect());
+ }
+
+ QScopedPointer<CFbsBitmap> bitmap(screenshot.toSymbianCFbsBitmap());
+
+ mBitmap = new CFbsBitmap();
+ QCOMPARE(mBitmap->Duplicate(bitmap->Handle()), KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::cleanupTestCase()
+{
+ delete mBitmap;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::waitActivityRequestCompleted(int result,
+ const TDesC8 &data)
+{
+ if (mData) {
+ delete mData;
+ }
+ RBuf converter;
+ converter.CreateMaxL(data.Length());
+ converter.Copy(data);
+ mData = converter.Alloc();
+ converter.Close();
+
+ mRealResponse = result;
+
+ if(mLoop.isRunning()) {
+ mLoop.exit();
+ }
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::getThumbnailRequestCompleted(int result,
+ int bitmapHandle,
+ void* userData)
+{
+ mScreenshotHandle = bitmapHandle;
+ mScreenshot = new CFbsBitmap();
+ mScreenshot->Duplicate(mScreenshotHandle);
+ mUserData = userData;
+
+ mRealResponse = result;
+ if(mLoop.isRunning()) {
+ mLoop.exit();
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::dataChangeNotificationCompleted(int result)
+{
+ mRealResponse = result;
+ if(mLoop.isRunning()) {
+ mLoop.exit();
+ }
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::PushL(CBase* asyncTask)
+{
+ mRunningTask = asyncTask;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::Pop(CBase* asyncTask)
+{
+ Q_UNUSED(asyncTask);
+ mRunningTask = 0;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::executeL(int function)
+{
+ Q_UNUSED(function);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::sendAsync(int function, const TIpcArgs &args, TRequestStatus& status)
+{
+ Q_UNUSED(function);
+ Q_UNUSED(args);
+ TRequestStatus *requestStatus(&status);
+ User::RequestComplete(requestStatus, mExpectedResponse);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::getDataL(int id, TDes8& buffer)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(buffer);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testEntry()
+{
+ const TInt KActivityFlags(qHash("Some activity flags"));
+ const TInt KApplicationId(qHash("Some application id"));
+ _LIT(KActivityId, "Some activity id");
+ _LIT(KActivityThumnail, "s:\\ome\\activity\\img.png");
+ _LIT8(KPrivateData, "Some private data");
+ _LIT8(KPublicData, "Some public data");
+
+ struct TestDataSet{
+ TInt mFlags;
+ TInt mAppId;
+ const TDesC& mActId;
+ const TDesC& mImgPath;
+ const TDesC8& mPriv;
+ const TDesC8& mPub;
+ } testData [] = {{KActivityFlags, KApplicationId, KActivityId(), KActivityThumnail(), KPrivateData(), KPublicData()},
+ {KActivityFlags, KApplicationId, KNullDesC, KActivityThumnail(), KPrivateData(), KPublicData()},
+ {KActivityFlags, KApplicationId, KActivityId(), KNullDesC, KPrivateData(), KPublicData()},
+ {KActivityFlags, KApplicationId, KActivityId(), KActivityThumnail(), KNullDesC8, KPublicData()},
+ {KActivityFlags, KApplicationId, KActivityId(), KActivityThumnail(), KPrivateData(), KNullDesC8()}};
+ const int count(sizeof(testData) / sizeof(TestDataSet));
+ CAfEntry * entry(0);
+ RBuf8 serializedEntry;
+ CleanupClosePushL(serializedEntry);
+ for (int i(0); i < count; ++i) {
+ entry = CAfEntry::NewL(testData[i].mFlags,
+ testData[i].mAppId,
+ testData[i].mActId,
+ testData[i].mImgPath,
+ testData[i].mPriv,
+ testData[i].mPub);
+ CleanupStack::PushL(entry);
+
+ QVERIFY(entry->Flags() == testData[i].mFlags);
+ QVERIFY(entry->ApplicationId() == testData[i].mAppId);
+ QVERIFY(0 == entry->ActivityId().Compare(testData[i].mActId));
+ QVERIFY(0 == entry->ImageSrc().Compare(testData[i].mImgPath));
+ QVERIFY(0 == entry->Data(CAfEntry::Private).Compare(testData[i].mPriv));
+ QVERIFY(0 == entry->Data(CAfEntry::Public).Compare(testData[i].mPub));
+
+ if(serializedEntry.MaxLength() < entry->Size()) {
+ serializedEntry.ReAllocL(entry->Size());
+ }
+ RDesWriteStream writer(serializedEntry);
+ CleanupClosePushL(writer);
+ writer << (*entry);
+ CleanupStack::PopAndDestroy(&writer);
+ CleanupStack::PopAndDestroy(entry);
+
+ entry = CAfEntry::NewL();
+ CleanupStack::PushL(entry);
+
+ RDesReadStream reader(serializedEntry);
+ CleanupClosePushL(reader);
+ reader >> (*entry);
+ CleanupStack::PopAndDestroy(&reader);
+
+ QVERIFY(entry->Flags() == testData[i].mFlags);
+ QVERIFY(entry->ApplicationId() == testData[i].mAppId);
+ QVERIFY(0 == entry->ActivityId().Compare(testData[i].mActId));
+ QVERIFY(0 == entry->ImageSrc().Compare(testData[i].mImgPath));
+ QVERIFY(0 == entry->Data(CAfEntry::Private).Compare(testData[i].mPriv));
+ QVERIFY(0 == entry->Data(CAfEntry::Public).Compare(testData[i].mPub));
+
+ CleanupStack::PopAndDestroy(entry);
+ }
+ CleanupStack::PopAndDestroy(&serializedEntry);
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testAsyncRequest()
+{
+ mExpectedResponse = KErrNone;
+ CAfAsyncRequestPrivate::NewLD(*this, *this, WaitActivity);
+ mLoop.exec();
+ QVERIFY(mExpectedResponse == mRealResponse);
+ QVERIFY(0 == mRunningTask);
+
+ mExpectedResponse = KErrGeneral;
+ CAfAsyncRequestPrivate::NewLD(*this, *this, WaitActivity);
+ mLoop.exec();
+ QVERIFY(mExpectedResponse == mRealResponse);
+ QVERIFY(0 == mRunningTask);
+
+ mExpectedResponse = KErrNone;
+ CAfAsyncRequestPrivate::NewLD(*this, *this, NotifyChange);
+ mLoop.exec();
+ QVERIFY(mExpectedResponse == mRealResponse);
+ QVERIFY(0 == mRunningTask);
+
+ mExpectedResponse = KErrGeneral;
+ CAfAsyncRequestPrivate::NewLD(*this, *this, NotifyChange);
+ mLoop.exec();
+ QVERIFY(mExpectedResponse == mRealResponse);
+ QVERIFY(0 == mRunningTask);
+
+
+ mExpectedResponse = KErrGeneral;
+ CAfThumbnailRequestPrivate::NewLD(*this, *this, TSize(), _L("f://ake//path.mif"), 0);
+ mLoop.exec();
+ QVERIFY(mExpectedResponse == mRealResponse);
+ QVERIFY(0 == mRunningTask);
+
+ mExpectedResponse = KErrNone;
+ CAfThumbnailRequestPrivate::NewLD(*this, *this, TSize(), _L("f://ake//path.mif"), 0);
+ mLoop.exec();
+ QVERIFY(mExpectedResponse == mRealResponse);
+ QVERIFY(0 == mRunningTask);
+
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testCreateClient()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testAddActivity()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+
+ QVERIFY(KErrNone == client->addActivity(*entry.data(), mBitmap->Handle()));
+ QVERIFY(KErrNone != client->addActivity(*entry.data(), mBitmap->Handle()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testUpdateActivity()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+ client->addActivity(*entry.data(), mBitmap->Handle());
+
+ QVERIFY(KErrNone == client->updateActivity(*entry.data(), mBitmap->Handle()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testSaveActivity()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+ QVERIFY(KErrNone == client->saveActivity(*entry.data(), mBitmap->Handle()));
+ QVERIFY(KErrNone == client->saveActivity(*entry.data(), mBitmap->Handle()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testRemoveActivity()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+ client->addActivity(*entry.data(), mBitmap->Handle());
+
+ QVERIFY(KErrNone == client->removeActivity(*entry.data()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testRemoveApplicationActivities()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+ client->addActivity(*entry.data(), mBitmap->Handle());
+
+ QVERIFY(KErrNone == client->removeApplicationActivities(*entry.data()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testActivities()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+
+ int activityCountBeforeAdding, activityCountAfterAdding;
+ {
+ RPointerArray<CAfEntry> results;
+ int callResult = client->activities(results);
+ activityCountBeforeAdding = results.Count();
+ results.ResetAndDestroy();
+
+ QVERIFY(KErrNone == callResult);
+ }
+
+ QVERIFY(KErrNone == client->addActivity(*entry.data(), mBitmap->Handle()));
+
+ {
+ RPointerArray<CAfEntry> results;
+ int callResult = client->activities(results);
+ activityCountAfterAdding = results.Count();
+ results.ResetAndDestroy();
+
+ QVERIFY(KErrNone == callResult);
+ }
+
+ QCOMPARE(activityCountAfterAdding, activityCountBeforeAdding + 1);
+
+ client->removeActivity(*entry.data());
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testApplicationActivities()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+ QVERIFY(KErrNone == client->removeApplicationActivities(*entry.data()));
+
+ const QString expectedActivityName("ActivityName%1");
+ const int activityCount(20);
+
+ {
+ RPointerArray<CAfEntry> results;
+ int callResult = client->applicationActivities(results, *entry.data());
+ int resultCount = results.Count();
+ results.ResetAndDestroy();
+
+ QVERIFY(KErrNone == callResult);
+ QCOMPARE(resultCount, 0);
+ }
+
+ for (int i=0; i < activityCount; ++i) {
+ QScopedPointer<HBufC> activityName(XQConversions::qStringToS60Desc(QString(expectedActivityName).arg(i)));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, *activityName.data(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+ client->addActivity(*entry.data(), mBitmap->Handle());
+ }
+
+ {
+ RPointerArray<CAfEntry> results;
+ int callResult = client->applicationActivities(results, *entry.data());
+ int resultCount = results.Count();
+ results.ResetAndDestroy();
+
+ QVERIFY(KErrNone == callResult);
+ QCOMPARE(resultCount, activityCount);
+ }
+
+ QVERIFY(KErrNone == client->removeApplicationActivities(*entry.data()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testGetData()
+{
+ _LIT8(KPrivateData, "My private data");
+ _LIT8(KPublicData, "My public data");
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, 1, KActivityName(), KNullDesC(), KPrivateData(), KPublicData()));
+
+ client->removeActivity(*entry.data());
+ QVERIFY(KErrNone == client->addActivity(*entry.data(), mBitmap->Handle()));
+
+ CAfEntry *result(0);
+ QVERIFY(0 == client->activityData(result, *entry.data()));
+
+ QScopedPointer<CAfEntry> guardedResult(result);
+ QVERIFY(0 == guardedResult->Data(CAfEntry::Private).Compare(KPrivateData()));
+ QVERIFY(0 == guardedResult->Data(CAfEntry::Public).Compare(KPublicData()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testWaitLaunchActivity()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfStorageClient> launcher(CAfStorageClient::NewL(*this));
+
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, RProcess().SecureId().iId, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ QVERIFY(KErrNone == client->waitActivity());
+ QVERIFY(KErrNone == launcher->launchActivity(*entry.data()));
+ mLoop.exec();
+
+ QVERIFY(mData);
+ QVERIFY(0 == mData->Compare(KActivityName()));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_ActivityClient::testGetThumbnail()
+{
+ QScopedPointer<CAfStorageClient> client(CAfStorageClient::NewL(*this));
+ QScopedPointer<CAfEntry> entry(CAfEntry::NewL(0, RProcess().SecureId().iId, KActivityName(), KNullDesC(), KNullDesC8(), KNullDesC8()));
+
+ client->removeActivity(*entry.data());
+ QVERIFY(KErrNone == client->addActivity(*entry.data(), mBitmap->Handle()));
+
+ RPointerArray<CAfEntry> results;
+ QVERIFY(KErrNone == client->activities(results));
+
+ QTimer timeout;
+ timeout.setSingleShot(true);
+ timeout.setInterval(5000);
+ mLoop.connect(&timeout, SIGNAL(timeout()), SLOT(quit()));
+
+ for (int iter=0; iter < results.Count(); ++iter) {
+ //valid thumbnail
+ QVERIFY(KErrNone == client->getThumbnail(TSize(50, 10), results[iter]->ImageSrc(), this));
+ timeout.start();
+ mLoop.exec();
+ QVERIFY(timeout.isActive());
+ timeout.stop();
+
+ QVERIFY(mScreenshotHandle >= 0);
+ {
+ QScopedPointer<CFbsBitmap> bitmap(new CFbsBitmap());
+ QCOMPARE(bitmap->Duplicate(mScreenshotHandle), KErrNone);
+ TSize bitmapSize = bitmap->SizeInPixels();
+ QVERIFY(50 >= bitmapSize.iWidth);
+ QVERIFY(10 >= bitmapSize.iHeight);
+ delete mScreenshot;
+ mScreenshot = 0;
+ }
+ QVERIFY(this == mUserData);
+
+ //invalid width
+ QVERIFY(KErrNone == client->getThumbnail(TSize(0, 10), results[iter]->ImageSrc(), this));
+ timeout.start();
+ mLoop.exec();
+ QVERIFY(timeout.isActive());
+ timeout.stop();
+ QVERIFY(mScreenshotHandle < 0);
+ QVERIFY(this == mUserData);
+
+ //invalid height
+ QVERIFY(KErrNone == client->getThumbnail(TSize(50, 0), results[iter]->ImageSrc(), this));
+ timeout.start();
+ mLoop.exec();
+ QVERIFY(timeout.isActive());
+ timeout.stop();
+ QVERIFY(mScreenshotHandle < 0);
+ QVERIFY(this == mUserData);
+
+ //invalid thumbnail
+ QVERIFY(KErrNone == client->getThumbnail(TSize(50, 10), _L("s:/ome/fake/path.mbm"), this));
+ timeout.start();
+ mLoop.exec();
+ QVERIFY(timeout.isActive());
+ timeout.stop();
+ QVERIFY(mScreenshotHandle < 0);
+ QVERIFY(this == mUserData);
+ }
+ results.ResetAndDestroy();
+}
+
+QTEST_MAIN(T_ActivityClient)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/client/t_afstorageclient/t_afstorageclient.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+CONFIG += console
+
+QT += testlib
+
+DEPENDPATH += .\
+ ./src
+
+INCLUDEPATH += .\
+ ./inc \
+ ../../inc \
+
+HEADERS += ../inc/afstorageclient.h \
+ ../inc/afasyncrequestobserver.h \
+ ../inc/afasyncrequest_p.h \
+ ../inc/afasyncsession.h \
+ ../inc/afstorageclientimp.h \
+ ../inc/afstorageclient_p.h \
+ ../inc/afthumbnailrequest_p.h \
+
+SOURCES += ../src/afstorageclient.cpp \
+ ../src/afasyncrequest_p.cpp \
+ ../src/afstorageclientimp.cpp \
+ ../src/afstorageclient_p.cpp \
+ ../src/afthumbnailrequest_p.cpp \
+
+HEADERS += ./inc/t_activityclient.h
+SOURCES += ./src/t_activityclient.cpp
+
+DEFINES += ACTIVITY_LIB
+
+symbian: {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.UID2 = 0x100039CE
+ TARGET.UID3 = 0xEfb7dc67
+ TARGET.CAPABILITY = CAP_APPLICATION AllFiles
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ export.sources = ./data/image_file_activitydbclient.png
+ export.path = c:/data/Images/Pictures/
+ DEPLOYMENT += export
+
+ LIBS += -lxqutils \
+ -lestor \
+ -lfbscli \
+ -lafstoragecommon.lib \
+
+}
Binary file activityfw/storage/server/tsrc/t_server/data/armv5/Hello.jar has changed
Binary file activityfw/storage/server/tsrc/t_server/data/armv5/sapiapp_S60_3_X_v_1_0_0.SISX has changed
Binary file activityfw/storage/server/tsrc/t_server/data/winscw/Hello.jar has changed
Binary file activityfw/storage/server/tsrc/t_server/data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/tsrc/t_server/t_installer.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2010 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: ?Description
+ *
+ */
+
+#include <usif/usifcommon.h>
+#include <usif/scr/screntries.h>
+
+#include "t_installer.h"
+
+using namespace Usif;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::~T_CaInstaller
+// ---------------------------------------------------------------------------
+//
+T_Installer::~T_Installer()
+ {
+ Cancel();
+ //iFs.Close();
+ delete iArguments;
+ delete iResults;
+ iInstaller.Close();
+ iSoftwareRegistry.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::NewL
+// ---------------------------------------------------------------------------
+//
+T_Installer *T_Installer::NewL(TInt aPriority)
+ {
+ T_Installer *self = new (ELeave) T_Installer(
+ aPriority );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::T_CaInstaller
+// ---------------------------------------------------------------------------
+//
+T_Installer::T_Installer( TInt aPriority ) :
+ CActive( aPriority ), iInstaller()
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::ConstructL
+// ---------------------------------------------------------------------------
+//
+void T_Installer::ConstructL()
+ {
+ iArguments = COpaqueNamedParams::NewL();
+ iResults = COpaqueNamedParams::NewL();
+
+ iArguments->AddIntL( KSifInParam_InstallInactive, ETrue );
+ iArguments->AddIntL( KSifInParam_InstallSilently, ETrue );
+
+ User::LeaveIfError( iInstaller.Connect() );
+ User::LeaveIfError( iSoftwareRegistry.Connect() );
+ //User::LeaveIfError( iFs.Connect() );
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstallOperation::ConstructL
+// ---------------------------------------------------------------------------
+//
+void T_Installer::InstallL( const TDesC& aFileName )
+ {
+ if (IsActive())
+ {
+ User::Leave(KErrInUse);
+ }
+
+ iInstaller.Install( aFileName, *iArguments, *iResults, iStatus );
+ SetActive();
+ iSchedulerWait.Start();
+ User::LeaveIfError(iStatus.Int());
+
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::UnistallL
+// ---------------------------------------------------------------------------
+//
+void T_Installer::UninstallL(TComponentId aComponentId)
+ {
+ if (IsActive())
+ {
+ User::Leave( KErrInUse );
+ }
+
+ if (aComponentId >= 1)
+ {
+ iInstaller.Uninstall( aComponentId, *iArguments, *iResults, iStatus );
+ SetActive();
+ iSchedulerWait.Start();
+ User::LeaveIfError(iStatus.Int());
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::UnistallL
+// ---------------------------------------------------------------------------
+//
+void T_Installer::UninstallL(const TDesC& aFileName)
+ {
+ UninstallL( GetComponentIdL(aFileName) );
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::UnistallL
+// ---------------------------------------------------------------------------
+//
+void T_Installer::UninstallL( TUint32 aUid )
+ {
+ UninstallL( GetComponentIdL( aUid ) );
+ }
+
+TComponentId T_Installer::GetComponentIdL( const TDesC& aFileName )
+ {
+ CComponentFilter* const fileNameFilter = CComponentFilter::NewLC();
+ fileNameFilter->SetFileL( aFileName );
+
+ RArray<TComponentId> componentIds;
+ CleanupClosePushL( componentIds );
+ iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter );
+
+ TComponentId componentId( 0 );
+
+ if ( componentIds.Count() == 1 )
+ {
+ componentId = componentIds[0];
+ }
+ else if ( componentIds.Count() >= 2 )
+ {
+ User::Leave( KErrGeneral );
+ }
+
+ CleanupStack::PopAndDestroy( &componentIds );
+ CleanupStack::PopAndDestroy( fileNameFilter );
+
+ return componentId;
+ }
+
+
+TComponentId T_Installer::GetComponentIdL( TInt32 aUid )
+ {
+ TUid uid;
+ TComponentId componentId = iSoftwareRegistry.GetComponentIdForAppL(
+ uid.Uid( aUid ) );;
+
+ if ( componentId <= 0 )
+ {
+ User::Leave( KErrGeneral );
+ }
+ return componentId;
+ }
+// ---------------------------------------------------------------------------
+// T_CaInstaller::RunL
+// ---------------------------------------------------------------------------
+//
+void T_Installer::RunL()
+ {
+ iSchedulerWait.AsyncStop();
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::DoCancel
+// ---------------------------------------------------------------------------
+//
+void T_Installer::DoCancel()
+ {
+ iInstaller.CancelOperation();
+ iSchedulerWait.AsyncStop();
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::RunError
+// ---------------------------------------------------------------------------
+//
+TInt T_Installer::RunError(TInt /*aError*/)
+ {
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/tsrc/t_server/t_installer.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2010 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: ?Description
+ *
+ */
+
+#ifndef T_CA_INSTALLER_H
+#define T_CA_INSTALLER_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <usif/sif/sif.h>
+#include <usif/scr/scr.h>
+
+/**
+ * Installer
+ *
+ */
+NONSHARABLE_CLASS(T_Installer): public CActive {
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~T_Installer();
+
+ /**
+ * Two-phased constructor. Leaves on failure.
+ * Allocates memory for and constructs an uninstaller object. After that
+ * starts asynchronous uninnstallation of the requested entry
+ * @param aFileName name of the file to be installed
+ * @param aPriority priority of the active scheduler responsible for handling
+ * asynchronous installation operation
+ * @return The constructed object.
+ */
+ static T_Installer *NewL( TInt aPriority = CActive::EPriorityStandard );
+
+ /**
+ * Starts asynchronous installation operation
+ * @param aFileName name of the file to be installed
+ * @param aComponentId placeholder for component id of the package after
+ * instalation is completed.
+ */
+ void InstallL(const TDesC& aFileName);
+ /**
+ * Uninstall operation
+ * @param aComponentId id of the component to be installed.
+ */
+ void UninstallL( Usif::TComponentId aComponentId );
+
+ /**
+ * Uninstall operation for package(s) based on filename
+ * for native and HS widgets.
+ * @param aFileName the file name installed with the package(s)
+ */
+ void UninstallL( const TDesC& aFileName );
+
+ /**
+ * Uninstall operation for java applications
+ * @param aUid ui
+ */
+ void UninstallL(TUint32 aUid);
+
+ /**
+ * Find component id for a file name
+ * @param aFileName the file name installed with the package(s)
+ * @return componentId for a requested file name
+ */
+ Usif::TComponentId GetComponentIdL( const TDesC& aFileName );
+
+ /**
+ * Find component id for a uid
+ * @param aUid ui
+ * @return componentId for a requested uid
+ */
+ Usif::TComponentId GetComponentIdL( TInt32 aUid );
+private:
+ // construction
+ /**
+ * Constructor.
+ * Starts active scheduler.
+ * @param aPriority priority of the active scheduler responsible for handling
+ * asynchronous installation operation
+ */
+ T_Installer(TInt aPriority);
+
+ /**
+ * Initializes the object and starts asynchronous uninstallation process.
+ */
+ void ConstructL();
+
+
+
+private:
+ // from CActive
+
+ void RunL();
+ void DoCancel();
+ TInt RunError( TInt aError );
+
+private:
+ Usif::COpaqueNamedParams* iArguments;
+ Usif::COpaqueNamedParams* iResults;
+ // RFs iFs;
+ Usif::RSoftwareInstall iInstaller;
+ Usif::RSoftwareComponentRegistry iSoftwareRegistry;
+ CActiveSchedulerWait iSchedulerWait;
+};
+
+#endif // T_CA_INSTALLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/tsrc/t_server/t_server.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,178 @@
+//Copyright (c) 2010 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:
+
+/////////////////////////////////////////////////////////////////////
+
+// INCLUDED FILES
+#include <QtTest/QtTest>
+#include <bautils.h>
+#include "t_server.h"
+#include "t_installer.h"
+#include "afserver.h"
+#include "afstorage.h"
+#include "afapplicationsmonitor.h"
+#include "afapplicationscollection.h"
+#include "afapplicationsengine.h"
+
+_LIT(KSisPackageFileName,"c:\\sapiapp_S60_3_X_v_1_0_0.sisx");
+_LIT(KSisAppFileName, "c:\\sys\\bin\\sapiapp.exe");
+const TUid KSisAppUid(TUid::Uid(0xe6bc1167));
+
+
+void T_Server::testStorage()
+{
+ _LIT(KDbName, "activity.db");
+ _LIT(KDbDrive, "c:");
+
+ RFs fileSession;
+ CleanupClosePushL(fileSession);
+ fileSession.Connect();
+
+ //remove database if exists
+ RBuf path;
+ CleanupClosePushL( path );
+ path.CreateL(256);
+ User::LeaveIfError(fileSession.PrivatePath(path ));
+ path.Append(KDbName);
+ path.Insert(0, KDbDrive);
+ BaflUtils::EnsurePathExistsL(fileSession, path);
+ if(BaflUtils::FileExists(fileSession, path)) {
+ fileSession.Delete(path);
+ }
+ CleanupStack::PopAndDestroy(&path);
+
+
+ //create storage when database doesnt exists
+ CAfStorage* storage = CAfStorage::NewL(fileSession);
+ delete storage;
+
+ //create storage when database already exists
+ storage = CAfStorage::NewL(fileSession);
+ delete storage;
+
+ CleanupStack::PopAndDestroy(&fileSession);
+}
+
+void T_Server::testMonitor()
+{
+ TInt errNo;
+ RApaLsSession session;
+ QVERIFY(KErrNone == session.Connect());
+ CAfApplicationsMonitor *monitor = CAfApplicationsMonitor::NewL(session, *this);
+ CleanupStack::PushL(monitor);
+ T_Installer *installer = T_Installer::NewL();
+ CleanupStack::PushL(installer);
+
+ //install application. sis file
+ mAppChanged = false;
+
+ TRAP(errNo, installer->InstallL(KSisPackageFileName));
+ if (KErrNone == errNo) {
+ if(!mAppChanged) {
+ QTimer::singleShot(5000, &mLoop, SLOT(quit()));
+ mLoop.exec();
+ }
+ QVERIFY(mAppChanged);
+ }
+
+ //uninstall application
+ mAppChanged = false;
+ TRAP(errNo, installer->UninstallL(installer->GetComponentIdL(KSisAppFileName)));
+ if (KErrNone == errNo) {
+ if(!mAppChanged) {
+ QTimer::singleShot(5000, &mLoop, SLOT(quit()));
+ mLoop.exec();
+ }
+ QVERIFY(mAppChanged);
+ }
+ CleanupStack::PopAndDestroy(installer);
+ CleanupStack::PopAndDestroy(monitor);
+ session.Close();
+}
+
+void T_Server::testCollection()
+{
+ TInt errNo, offset;
+ RApaLsSession session;
+ QVERIFY(KErrNone == session.Connect());
+
+ CAfApplicationsCollection *collection = CAfApplicationsCollection::NewL(session, this);
+ CleanupStack::PushL(collection);
+
+ CAfApplicationsMonitor *monitor = CAfApplicationsMonitor::NewL(session, *collection);
+ CleanupStack::PushL(monitor);
+
+ T_Installer *installer = T_Installer::NewL();
+ CleanupStack::PushL(installer);
+
+ //install application. sis file
+ mAppChanged = false;
+ TRAP(errNo, installer->InstallL(KSisPackageFileName));
+ if(KErrNone == errNo) {
+ if(!mAppChanged) {
+ QTimer::singleShot(10000, &mLoop, SLOT(quit()));
+ mLoop.exec();
+ }
+ QVERIFY(mAppChanged);
+ }
+
+ //uninstall application
+ mAppChanged = false;
+ TRAP(errNo, installer->UninstallL(installer->GetComponentIdL(KSisAppFileName)));
+ if(KErrNone == errNo) {
+ if(!mAppChanged) {
+ QTimer::singleShot(10000, &mLoop, SLOT(quit()));
+ mLoop.exec();
+ }
+ QVERIFY(mAppChanged);
+ TArray<TUid> removedApps(collection->removedApplications());
+ for (offset =0; offset < removedApps.Count(); ++offset) {
+ if (removedApps[offset] == KSisAppUid) {
+ break;
+ }
+ }
+ QVERIFY(offset < removedApps.Count());
+ }
+ CleanupStack::PopAndDestroy(installer);
+ CleanupStack::PopAndDestroy(monitor);
+ CleanupStack::PopAndDestroy(collection);
+ session.Close();
+}
+
+void T_Server::testEngine()
+{
+ RApaLsSession appSession;
+ CleanupClosePushL(appSession);
+ QVERIFY(KErrNone == appSession.Connect());
+ RFs fsSession;
+ CleanupClosePushL(fsSession);
+ QVERIFY(KErrNone == fsSession.Connect());
+ CAfStorage* storage = CAfStorage::NewL(fsSession);
+ CAfApplicationsEngine *engine = CAfApplicationsEngine::NewL(appSession, *storage);
+ QVERIFY(0 != engine);
+ delete engine;
+ delete storage;
+ CleanupStack::PopAndDestroy(&fsSession);
+ CleanupStack::PopAndDestroy(&appSession);
+}
+
+void T_Server::applicationsChanged()
+{
+ mAppChanged = true;
+ if (mLoop.isRunning()) {
+ mLoop.quit();
+ }
+}
+
+QTEST_MAIN(T_Server)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/tsrc/t_server/t_server.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+//Copyright (c) 2010 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:
+
+/////////////////////////////////////////////////////////////////////
+
+#ifndef T_SERVER_H
+#define T_SERVER_H
+#include <qobject.h>
+#include <qeventloop.h>
+#include "afapplicationsobserver.h"
+class T_Server: public QObject,
+ public MAfApplicationsObserver
+{
+Q_OBJECT
+private slots:
+ void testStorage();
+ void testMonitor();
+ void testCollection();
+ void testEngine();
+
+private:
+ void applicationsChanged();
+
+private:
+ QEventLoop mLoop;
+ bool mAppChanged;
+};
+
+#endif //T_SERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/tsrc/t_server/t_server.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,73 @@
+#
+# Copyright (c) 2009 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:
+#
+CONFIG += qtestlib console
+
+INCLUDEPATH += ./ \
+ ../../inc/ \
+ ../../../inc/ \
+ ../../../../../inc/
+
+HEADERS += ./t_server.h \
+ ./t_installer.h \
+ ../../inc/afserver.h \
+
+
+SOURCES += ./t_server.cpp \
+ ./t_installer.cpp \
+ ../../src/afserver.cpp \
+ ../../src/afsession.cpp \
+ ../../src/afstorage.cpp \
+ ../../src/afstoragesynctask.cpp \
+ ../../src/afstorageasynctask.cpp \
+ ../../src/afbroadcasttask.cpp \
+ ../../src/afdataprovidertask.cpp \
+ ../../src/afobservertask.cpp \
+ ../../src/afthumbnailtask.cpp \
+ ../../src/afapplicationsmonitor.cpp \
+ ../../src/afapplicationscollection.cpp \
+ ../../src/afapplicationsstorage.cpp \
+ ../../src/afapplicationsengine.cpp \
+ ../../src/afdatabasecleaner.cpp \
+
+LIBS += -lfbscli \
+ -ledbms \
+ -lestor \
+ -lbafl \
+ -ltsutils \
+ -lhash \
+ -lefsrv \
+ -lafstoragecommon.lib \
+ -lsif \
+ -lscrclient \
+ -lxqutils \
+ -lapgrfx \
+
+symbian {
+ CONFIG += symbian_test
+ TARGET.CAPABILITY = ALL -TCB
+ coverage: CONFIG -= symbian_test
+
+ BLD_INF_RULES.prj_testexports += "./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/" \
+ "./data/winscw/Hello.jar c:/"
+
+ BLD_INF_RULES.prj_exports += "./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/" \
+ "./data/winscw/Hello.jar c:/"
+
+ exportArmSis.sources += ./data/armv5/sapiapp_S60_3_X_v_1_0_0.sisx \
+ ./data/winscw/Hello.jar
+ exportArmSis.path = c:/
+ DEPLOYMENT += exportArmSis
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+SUBDIRS += t_server
+CONFIG += symbian_tests
+
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/activitydebuger.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,521 @@
+/*
+* Copyright (c) 2009 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 "activitydebuger.h"
+
+#include <QGridLayout>
+#include <HbLabel>
+#include <HbPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QList>
+#include <QVariantHash>
+#include <HbComboBox>
+#include <QBrush>
+#include <QPalette>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <e32std.h>
+#include <HbInstance>
+
+#include <qservicemanager.h>
+#include "activitydebugerconsole.h"
+
+const char ActivityApplicationKeyword [] = ":ApplicationId";
+const char ActivityActivityKeyword [] = ":ActivityName";
+const char ActivityScreenshotKeyword [] = "screenshot";
+
+QTM_USE_NAMESPACE
+
+ActivityDebuger::ActivityDebuger(QGraphicsItem *parent) : HbView(parent), mActivityClient(NULL), mByteArray(NULL)
+{
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ QServiceManager serviceManager;
+ serviceManager.addService(":/activityserviceplugin.xml");
+ mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ if (!mActivityClient) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityClient service.");
+ }
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service.");
+ }
+ mTimesLabel = new HbLabel("Times");
+ mBytesLabel = new HbLabel("Bytes");
+ mPixmapLabel = new HbLabel("Pixmap");
+ mSizeLabel = new HbLabel("Size(WxH)");
+
+ mPixmap = new QPixmap(":/images/wolf.bmp");
+ mPixmap2 = new QPixmap(":/images/bird.bmp");
+ mEmptyPixmap = new QPixmap();
+
+
+ mTimesCombo = new HbComboBox();
+ mLengthCombo = new HbComboBox();
+ mPixmapCombo = new HbComboBox();
+ mWidthCombo = new HbComboBox();
+ mHeightCombo = new HbComboBox();
+
+ mTimesCombo->addItem("1");
+ mTimesCombo->addItem("2");
+ mTimesCombo->addItem("4");
+ mTimesCombo->addItem("5");
+ mTimesCombo->addItem("10");
+ mTimesCombo->addItem("20");
+ mTimesCombo->addItem("40");
+ mTimesCombo->addItem("60");
+
+ QVariant variant;
+ variant = 10;
+ mLengthCombo->addItem("10 B", variant);
+ variant = 100;
+ mLengthCombo->addItem("100 B", variant);
+ variant = 1024;
+ mLengthCombo->addItem("1 KB", variant);
+ variant = 10240;
+ mLengthCombo->addItem("10 KB", variant);
+ variant = 102400;
+ mLengthCombo->addItem("100 KB", variant);
+ variant = 1024*1024;
+ mLengthCombo->addItem("1 MB", variant);
+
+ mWidthCombo->addItem("360");
+ mWidthCombo->addItem("180");
+ mWidthCombo->addItem("128");
+ mWidthCombo->addItem("90");
+
+ mHeightCombo->addItem("640");
+ mHeightCombo->addItem("320");
+ mHeightCombo->addItem("160");
+ mHeightCombo->addItem("128");
+
+
+ mPixmapCombo->addItem("no");
+ mPixmapCombo->addItem("yes");
+ mPixmapCombo->addItem("grab");
+
+ mSaveButton = new HbPushButton("Add");
+ mGetButton = new HbPushButton("Activities");
+ mDelButton = new HbPushButton("Delete");
+ mGetDataButton = new HbPushButton("Get data");
+ mUpdateButton = new HbPushButton("Update");
+ mThumbButton = new HbPushButton("Get pixmaps");
+ mClearButton = new HbPushButton("Clear");
+ mDelMyButton = new HbPushButton("Reserved");
+
+ mConsole = new ActivityDebugerConsole;
+
+ mLayout = new QGraphicsGridLayout();
+ mLayout->addItem(mConsole, 0, 0, 3, 6);
+ mLayout->addItem(mSizeLabel, 3, 0, 1, 2);
+ mLayout->addItem(mWidthCombo, 3, 2, 1, 2);
+ mLayout->addItem(mHeightCombo, 3, 4, 1, 2);
+ mLayout->addItem(mTimesLabel, 4, 0, 1, 2);
+ mLayout->addItem(mBytesLabel, 4, 2, 1, 2);
+ mLayout->addItem(mPixmapLabel, 4, 4, 1, 2);
+ mLayout->addItem(mTimesCombo, 5, 0, 1, 2);
+ mLayout->addItem(mLengthCombo, 5, 2, 1, 2);
+ mLayout->addItem(mPixmapCombo, 5, 4, 1, 2);
+ mLayout->addItem(mClearButton, 6, 0, 1, 3);
+ mLayout->addItem(mGetDataButton, 6, 3, 1, 3);
+ mLayout->addItem(mSaveButton, 7, 0, 1, 3);
+ mLayout->addItem(mUpdateButton, 7, 3, 1, 3);
+ mLayout->addItem(mGetButton, 8, 0, 1, 2);
+ mLayout->addItem(mThumbButton, 8, 2, 1, 4);
+ mLayout->addItem(mDelButton, 9, 0, 1, 3);
+ mLayout->addItem(mDelMyButton, 9, 3, 1, 3);
+
+
+
+ setLayout(mLayout);
+
+ connect(mSaveButton, SIGNAL(released()), this, SLOT(saveActivity()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(getActivity()));
+ connect(mDelButton, SIGNAL(released()), this, SLOT(deleteActivity()));
+ connect(mGetDataButton, SIGNAL(released()), this, SLOT(getActivityData()));
+ connect(mUpdateButton, SIGNAL(released()), this, SLOT(updateActivity()));
+ connect(mThumbButton, SIGNAL(released()), this, SLOT(getActivityThumb()));
+ connect(mClearButton, SIGNAL(released()), mConsole, SLOT(clear()));
+
+
+
+}
+
+ActivityDebuger::~ActivityDebuger()
+{
+ delete mEmptyPixmap;
+ delete mPixmap;
+ delete mPixmap2;
+ delete mActivityClient;
+ delete mActivityManager;
+}
+
+
+void ActivityDebuger::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void ActivityDebuger::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void ActivityDebuger::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+void ActivityDebuger::deleteActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Remove all:\n";
+ QList<QVariantHash> activities;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ bool retok = false;
+ int items = 0;
+ if (ok) {
+ QString actname;
+ for (int i=0; i<activities.count(); i++) {
+ actname = activities.at(i).value(ActivityActivityKeyword).toString();
+ ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, actname));
+ ok = ok*retok;
+
+ mItemMeaage += "*";
+ mItemMeaage += actname;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += res;
+
+ mItemMeaage += "*\n";
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ }
+ else
+ {
+ mItemMeaage += "*Failed*\n";
+ }
+
+ UpdateConsole();
+
+}
+
+void ActivityDebuger::getActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activities list:\n";
+ bool ok = false;
+ QList<QVariantHash> activities;
+ ok = QMetaObject::invokeMethod(mActivityManager, "activitiesList", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ if ( ok )
+ {
+ int items = 0;
+ for ( int i=0; i<activities.count(); i++)
+ {
+ QString actname = activities.at(i).value(ActivityActivityKeyword).toString();
+ int appid = activities.at(i).value(ActivityApplicationKeyword).toInt(&ok);
+ mItemMeaage += "*";
+ QString aid;
+ aid.setNum(appid);
+ mItemMeaage += aid;
+ mItemMeaage += "; ";
+ mItemMeaage += actname;
+ mItemMeaage += "; ";
+ QString pixfile = activities.at(i).value(ActivityScreenshotKeyword).toString();
+ mItemMeaage += pixfile;
+ QVariantHash::const_iterator node(activities.at(i).find("visible"));
+ QString visible;
+ if ( activities.at(i).end() != node )
+ {
+ bool vis = node.value().toBool();
+ visible.setNum(vis);
+ }
+ else
+ {
+ visible = "none";
+ }
+ mItemMeaage += "; ";
+ mItemMeaage += visible;
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += "; ";
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ }
+ else
+ {
+ mItemMeaage += "*Failed*\n";
+ }
+ UpdateConsole();
+}
+
+void ActivityDebuger::getActivityThumb()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activities pixmaps:\n";
+ UpdateConsole();
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ bool ok = false;
+ QList<QVariantHash> activities;
+
+ ok = QMetaObject::invokeMethod(mActivityManager, "activitiesList", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ if ( ok )
+ {
+ mThumbwait = activities.count();
+ int width = mWidthCombo->currentText().toInt();
+ int height = mHeightCombo->currentText().toInt();
+ QSize pixSize(width, height);
+ for ( int i=0; i<activities.count(); i++)
+ {
+ QString actname = activities.at(i).value(ActivityActivityKeyword).toString();
+ int appid = activities.at(i).value(ActivityApplicationKeyword).toInt(&ok);
+ QString pixfile;
+ if ( ok )
+ {
+ pixfile = activities.at(i).value(ActivityScreenshotKeyword).toString();
+ void* userdata = reinterpret_cast<void*>(i);
+ ok = QMetaObject::invokeMethod(mActivityManager, "getThumbnail", Q_ARG(QSize, pixSize), Q_ARG(QString, pixfile), Q_ARG(void*, userdata));
+ }
+
+ mItemMeaage = "*";
+ QString aid;
+ aid.setNum(appid);
+ mItemMeaage += aid;
+ mItemMeaage += "; ";
+ mItemMeaage += actname;
+ mItemMeaage += "; ";
+ QString locid = tr("locid=%1").arg(i);
+ mItemMeaage += locid;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+ UpdateConsole();
+ }
+ }
+ else
+ {
+ mItemMeaage += "*Failed*\n";
+ UpdateConsole();
+ }
+
+}
+
+
+
+void ActivityDebuger::saveActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Add:\n";
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+
+ QVariantHash metadata;
+ metadata.insert("screenshot", *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ bool retok = false;
+ int items = 0;
+ for (int i=0; i<times; i++) {
+ QString name;
+ name.setNum(i);
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, variant), Q_ARG(QVariantHash, metadata));
+ mItemMeaage += "*";
+ mItemMeaage += name;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok*retok);
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ UpdateConsole();
+}
+
+void ActivityDebuger::updateActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Update:\n";
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap2;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert("screenshot", *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ bool retok = false;
+ int items = 0;
+ for (int i=0; i<times; i++) {
+ QString name;
+ name.setNum(i);
+ ok = QMetaObject::invokeMethod(mActivityClient, "updateActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, variant), Q_ARG(QVariantHash, metadata));
+
+ mItemMeaage += "*";
+ mItemMeaage += name;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok*retok);
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ UpdateConsole();
+}
+
+void ActivityDebuger::getActivityData()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activities data:\n";
+ QList<QVariantHash> activities;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ if (ok) {
+ QString name;
+ QVariant data;
+ int items = 0;
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i).value(ActivityActivityKeyword).toString();
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ const char* type = data.typeName();
+ QString dtype(type);
+ items++;
+
+ mItemMeaage += "*";
+ mItemMeaage += name;
+ mItemMeaage += "; ";
+ mItemMeaage += dtype;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ }
+ else
+ {
+ mItemMeaage += "*Failed*\n";
+ }
+ UpdateConsole();
+}
+
+void ActivityDebuger::thumbnailReady(QPixmap pix, void * ptr)
+ {
+ mItemMeaage.clear();
+ QString pixsize;
+ if ( pix.isNull() )
+ {
+ mThumbnull++;
+ pixsize = "null";
+ }
+ else
+ {
+ QSize size = pix.size();
+ int w = size.width();
+ int h = size.height();
+ pixsize = tr("%1x%2").arg(w).arg(h);
+ }
+ int loc_id = reinterpret_cast<int>(ptr);
+ QString locid;
+ locid = tr("locid=%1").arg(loc_id);
+ mThumbcurrent++;
+
+ mItemMeaage += "*";
+ mItemMeaage += locid;
+ mItemMeaage += "; ";
+ mItemMeaage += pixsize;
+ mItemMeaage += "*\n";
+
+ if (mThumbcurrent == mThumbwait)
+ {
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ QString screennum = tr("*screennum: %1*\n").arg(mThumbwait);
+ mItemMeaage += screennum;
+ }
+ UpdateConsole();
+ }
+
+void ActivityDebuger::UpdateConsole()
+ {
+ mConsole->appendText(mItemMeaage);
+ mConsole->scrollToBotton();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/activitydebuger.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ACTIVITYDEBUGER_H
+#define ACTIVITYDEBUGER_H
+
+#include <QWidget>
+#include <HbView>
+
+class HbLabel;
+class QString;
+class ActivityClient;
+class QPixmap;
+class QByteArray;
+class QVariant;
+class HbComboBox;
+class QGraphicsGridLayout;
+class HbPushButton;
+class QByteArray;
+class ActivityDebugerConsole;
+
+class ActivityDebuger: public HbView
+{
+
+ Q_OBJECT
+
+public:
+ ActivityDebuger(QGraphicsItem *parent = 0);
+ ~ActivityDebuger();
+
+private slots:
+ void saveActivity();
+ void deleteActivity();
+ void getActivity();
+ void getActivityData();
+ void updateActivity();
+ void getActivityThumb();
+
+ void thumbnailReady(QPixmap pix, void * ptr);
+
+private:
+ void Before();
+ void After();
+ void Result();
+
+ void UpdateConsole();
+
+
+private:
+
+ HbLabel *mTimesLabel;
+ HbLabel *mPixmapLabel;
+ HbLabel *mBytesLabel;
+ HbLabel *mSizeLabel;
+ QString mItemMeaage;
+ QObject *mActivityClient;
+ QObject *mActivityManager;
+ QPixmap *mPixmap;
+ QPixmap *mPixmap2;
+ QPixmap *mEmptyPixmap;
+ HbComboBox *mTimesCombo;
+ HbComboBox *mLengthCombo;
+ HbComboBox *mPixmapCombo;
+ HbComboBox *mWidthCombo;
+ HbComboBox *mHeightCombo;
+ QGraphicsGridLayout *mLayout;
+ HbPushButton *mSaveButton;
+ HbPushButton *mDelButton;
+ HbPushButton *mDelMyButton;
+ HbPushButton *mGetButton;
+ HbPushButton *mGetDataButton;
+ HbPushButton *mUpdateButton;
+ HbPushButton *mThumbButton;
+ HbPushButton *mClearButton;
+ QByteArray *mByteArray;
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+ int mThumbwait;
+ int mThumbnull;
+ int mThumbcurrent;
+
+ ActivityDebugerConsole* mConsole;
+
+};
+
+#endif //ACTIVITYDEBUGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/activitydebuger.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/wolf.bmp</file>
+ <file>images/bird.bmp</file>
+ <file alias="activityserviceplugin.xml">../../activityserviceplugin/data/afservice.xml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/activitydebugerconsole.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 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 "activitydebugerconsole.h"
+#include <hbscrollarea.h>
+
+
+
+
+
+ActivityDebugerConsole::ActivityDebugerConsole(QGraphicsItem *parent):HbTextEdit(parent)
+{
+ setScrollable(true);
+ setReadOnly(true);
+ clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
+ clearContextMenuFlag(Hb::ShowTextContextMenuOnSelectionClicked);
+ connect( this, SIGNAL(contentsChanged()), this, SLOT(scrollToBotton()));
+}
+
+ActivityDebugerConsole::~ActivityDebugerConsole()
+{
+
+}
+
+
+void ActivityDebugerConsole::scrollToBotton()
+ {
+ HbScrollArea* scrollarea = scrollArea();
+ QSizeF size = scrollarea->contentWidget()->size();
+ QPointF point( 0, size.height() );
+ scrollarea->scrollContentsTo(point);
+ }
+
+void ActivityDebugerConsole::appendText(const QString& text)
+ {
+ setPlainText(toPlainText()+text);
+ }
+
+void ActivityDebugerConsole::clear()
+ {
+ setPlainText(QString());
+ }
+
+void ActivityDebugerConsole::mousePressEvent(QGraphicsSceneMouseEvent */*event*/)
+ {
+
+ }
+
+void ActivityDebugerConsole::focusInEvent(QFocusEvent */*event*/)
+ {
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/activitydebugerconsole.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ACTIVITYDEBUGERCONSOLE_H
+#define ACTIVITYDEBUGERCONSOLE_H
+
+
+#include <hbtextedit>
+
+
+
+class ActivityDebugerConsole: public HbTextEdit
+{
+
+ Q_OBJECT
+
+public:
+ ActivityDebugerConsole(QGraphicsItem *parent = 0);
+ ~ActivityDebugerConsole();
+ void appendText(const QString& text);
+
+
+public slots:
+ void clear();
+ void scrollToBotton();
+
+private:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void focusInEvent(QFocusEvent *event);
+
+};
+
+#endif //ACTIVITYDEBUGERCONSOLE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/activitydebugger.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = activitydebugger
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ activitydebuger.cpp \
+ activitydebugerconsole.cpp
+
+HEADERS += activitydebuger.h \
+ activitydebugerconsole.h
+
+RESOURCES += activitydebuger.qrc
+
+LIBS += -lafservice.dll \
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x2000000 // Min 2Mb, max 32Mb
+ TARGET.CAPABILITY = ALL -TCB
+}
Binary file activityfw/testapplications/activitydebugger/images/bird.bmp has changed
Binary file activityfw/testapplications/activitydebugger/images/wolf.bmp has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+
+#include "activitydebuger.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ ActivityDebuger *view = new ActivityDebuger;
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitydebugger/readme.txt Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+Clear - clear console
+
+Get data - activities data (only this app)
+Response format:
+act name; data type; ok
+
+Add - add activities
+Response format:
+act name; ok
+
+Update - update activities
+Response format:
+act name; ok
+
+Activities - activities list
+Response format:
+app id; act name; pixmap file; visibility flag; ok
+
+Get pixmaps - activities pizmaps
+Response format:
+app id; act name; loc id;; ok
+loc id; pixmap size
+
+Delete my - deletes this app activities
+Response format:
+ok
+
+Delete -deletes all activities
+Response format:
+app id; act name; ok
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytakeawhile/activitytakeawhile.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = activitytakeawhile
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+viewmanager.cpp \
+letterwidget.cpp
+
+HEADERS += viewmanager.h \
+letterwidget.h
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytakeawhile/letterwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2009 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 "letterwidget.h"
+#include <QRect>
+#include <QPainter>
+
+
+letterwidget::letterwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ mA = new HbPushButton("A");
+ mB = new HbPushButton("B");
+ mC = new HbPushButton("C");
+
+ mSave = new HbPushButton("Save");
+ mDel = new HbPushButton("Delete");
+ mWait = new HbPushButton("Wait 10 s");
+ mPanic = new HbPushButton("Panic client process");
+
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mA, 3, 0, 1, 1);
+ mGridLayout->addItem(mB, 3, 1, 1, 1);
+ mGridLayout->addItem(mC, 3, 2, 1, 1);
+ mGridLayout->addItem(mSave, 4, 0, 1, 1);
+ mGridLayout->addItem(mDel, 4, 1, 1, 1);
+ mGridLayout->addItem(mWait, 4, 2, 1, 1);
+ mGridLayout->addItem(mPanic, 5, 0, 1, 3);
+ mGridLayout->setRowStretchFactor(0, 1);
+ mGridLayout->setRowStretchFactor(1, 1);
+ mGridLayout->setRowStretchFactor(2, 1);
+ setLayout(mGridLayout);
+
+ connect(mA, SIGNAL(released()), this, SLOT(toA()));
+ connect(mB, SIGNAL(released()), this, SLOT(toB()));
+ connect(mC, SIGNAL(released()), this, SLOT(toC()));
+ connect(mWait, SIGNAL(released()), this, SLOT(wait()));
+ connect(mPanic, SIGNAL(released()), this, SLOT(panic()));
+
+ connect(mSave, SIGNAL(released()), this, SIGNAL(save()));
+ connect(mDel, SIGNAL(released()), this, SIGNAL(del()));
+
+ toA();
+
+}
+
+letterwidget::~letterwidget()
+{
+ // TODO Auto-generated destructor stub
+}
+
+void letterwidget::toA()
+{
+ mStatename = "A";
+ update();
+}
+
+void letterwidget::toB()
+{
+ mStatename = "B";
+ update();
+}
+
+void letterwidget::toC()
+{
+ mStatename = "C";
+ update();
+}
+
+void letterwidget::wait()
+ {
+ User::After(10000000); //10 s
+ }
+
+void letterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ HbWidget::paint(painter, option, widget);
+
+ if ( mStatename.isNull() ) {
+ return;
+ }
+ else if ( mStatename == "A" ) {
+ painter->setPen(Qt::red);
+ }
+ else if ( mStatename == "B" ) {
+ painter->setPen(Qt::green);
+ }
+ else {
+ painter->setPen(Qt::blue);
+ }
+
+ QFont font;
+ font.setPointSize(60);
+ painter->setFont(font);
+ painter->drawText(10, 140, mStatename);
+}
+
+QString letterwidget::state()
+{
+ return mStatename;
+}
+
+void letterwidget::setState( QString state )
+{
+ mStatename = state;
+ update();
+}
+
+void letterwidget::panic()
+{
+ User::Panic(_L("forced panic"), 122);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytakeawhile/letterwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LETTERWIDGET_H_
+#define LETTERWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+
+class letterwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ letterwidget(QGraphicsItem *parent = 0);
+ ~letterwidget();
+ QString state();
+ void setState( QString state );
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+ QGraphicsGridLayout *mGridLayout;
+
+ HbPushButton *mA;
+ HbPushButton *mB;
+ HbPushButton *mC;
+
+ HbPushButton *mSave;
+ HbPushButton *mDel;
+ HbPushButton *mWait;
+ HbPushButton *mPanic;
+
+signals:
+ void save();
+ void del();
+
+private slots:
+ void toA();
+ void toB();
+ void toC();
+ void wait();
+ void panic();
+
+private:
+ QString mStatename;
+
+};
+
+#endif /* LETTERWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytakeawhile/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytakeawhile/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2009 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 <qservicemanager.h>
+#include <HbInstance>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "letterwidget.h"
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+
+QTM_USE_NAMESPACE
+
+viewmanager::viewmanager():
+ HbMainWindow()
+{
+ QServiceManager serviceManager;
+ mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ if (!mActivityClient) {
+ qFatal("load plugin failed");
+ }
+
+ mLw = new letterwidget;
+ addView(mLw);
+
+ connect(mActivityClient, SIGNAL(activityRequested(QString)), this, SLOT(loadActivityData(QString)));
+
+
+
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "waitActivity", Q_RETURN_ARG(bool, retok));
+ if (!ok || !retok) {
+// qFatal("Subscribe failed");
+ }
+
+ //startup case
+ QStringList arglist = qApp->arguments();
+ QVariantHash actdata;
+ ok = QMetaObject::invokeMethod(mActivityClient, "parseCommandLine", Q_RETURN_ARG(QVariantHash, actdata), Q_ARG(QStringList, arglist));
+ if (!ok) {
+ qFatal("Startup failed");
+ }
+ QString actid = actdata.value("activityname").toString();
+ if ( !actid.isNull() )
+ {
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actid));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ loadActivityData(data);
+ }
+ //startup case end
+
+ connect(mLw, SIGNAL(save()), this, SLOT(save()));
+ connect(mLw, SIGNAL(del()), this, SLOT(del()));
+}
+
+viewmanager::~viewmanager()
+{
+}
+
+void viewmanager::save()
+{
+ mSaveVariant = mLw->state();
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert("screenshot", screenshot);
+
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mLw->state()));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mLw->state()), Q_ARG(QVariant, mSaveVariant), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ qFatal("Add failed");
+ }
+}
+void viewmanager::del()
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mLw->state()));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+}
+
+void viewmanager::loadActivityData(const QString &name)
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "waitActivity", Q_RETURN_ARG(bool, retok));
+ if (!ok || !retok) {
+ //qFatal("Resubscribe failed");
+ }
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ loadActivityData(data);
+}
+
+void viewmanager::loadActivityData(const QVariant &data)
+{
+ QString statename = data.toString();
+ mLw->setState(statename);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytakeawhile/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+class HbApplication;
+class QGraphicsGridLayout;
+class HbPushButton;
+class letterwidget;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager();
+ virtual ~viewmanager();
+ void initialize();
+
+
+
+private slots:
+
+ void save();
+ void del();
+
+public slots:
+ void loadActivityData(const QString &name);
+
+public:
+ void loadActivityData(const QVariant &data);
+
+private:
+
+
+ QObject *mActivityClient;
+ QVariant mSaveVariant;
+
+ letterwidget *mLw;
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestanimal/activitytestanimal.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = activitytestanimal
+
+CONFIG += console mobility
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ animalwidget.cpp \
+
+HEADERS += animalwidget.h \
+
+RESOURCES += activitytestanimal.qrc
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x800000 // Min 2Mb, max 8Mb
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestanimal/activitytestanimal.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/africaelephant.jpg</file>
+ <file>images/africatiger.jpg</file>
+ <file>images/indiaelephant.jpg</file>
+ <file>images/syberiantiger.jpg</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestanimal/animalwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2009 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 "animalwidget.h"
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QApplication>
+#include <qservicemanager.h>
+
+QTM_USE_NAMESPACE
+
+AnimalWidget::AnimalWidget(QWidget *parent) : QWidget(parent), mActivityClient(NULL)
+{
+ QServiceManager serviceManager;
+ mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ if (!mActivityClient) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityClient service.");
+ }
+ connect(mActivityClient, SIGNAL(activityRequested(QString)), this, SLOT(loadActivity(QString)));
+
+
+ bool retok = false;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "waitActivity", Q_RETURN_ARG(bool, retok));
+ if (!ok || !retok) {
+ // qFatal("Subscribe failed");
+ }
+
+
+ mAnimalLabel = new QLabel();
+ mFileNameLabel = new QLabel("No image loaded");
+ QPushButton *africanElephantButton = new QPushButton("African elephant");
+ QPushButton *africanTigerButton = new QPushButton("African tiger");
+ QPushButton *indiaElephantButton = new QPushButton("India elephant");
+ QPushButton *siberianTigerButton = new QPushButton("Siberian tiger");
+ QPushButton *saveActivityButton = new QPushButton("Save activity");
+ QPushButton *quitButton = new QPushButton("Quit");
+
+ QGridLayout *layout = new QGridLayout();
+
+ layout->addWidget(mAnimalLabel, 0, 0, 1, 2);
+ layout->addWidget(mFileNameLabel, 1, 0, 1, 2);
+ layout->addWidget(africanElephantButton, 2, 0);
+ layout->addWidget(africanTigerButton, 2, 1);
+ layout->addWidget(indiaElephantButton, 3, 0);
+ layout->addWidget(siberianTigerButton, 3, 1);
+ layout->addWidget(saveActivityButton, 4, 0);
+ layout->addWidget(quitButton, 4, 1);
+
+ connect(saveActivityButton, SIGNAL(clicked()), this, SLOT(saveActivity()));
+ connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+ QSignalMapper *mapper = new QSignalMapper(this);
+ mapper->setMapping(africanElephantButton, ":/images/africaelephant.jpg");
+ mapper->setMapping(africanTigerButton, ":/images/africatiger.jpg");
+ mapper->setMapping(indiaElephantButton, ":/images/indiaelephant.jpg");
+ mapper->setMapping(siberianTigerButton, ":/images/syberiantiger.jpg");
+ connect(africanElephantButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ connect(africanTigerButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ connect(indiaElephantButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ connect(siberianTigerButton, SIGNAL(clicked()), mapper, SLOT(map()));
+
+ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(changeAnimalImage(QString)));
+
+ setLayout(layout);
+
+ //startup case
+ QStringList arglist = qApp->arguments();
+ QVariantHash actdata;
+ ok = QMetaObject::invokeMethod(mActivityClient, "parseCommandLine", Q_RETURN_ARG(QVariantHash, actdata), Q_ARG(QStringList, arglist));
+ if (!ok) {
+ // qFatal("Startup failed");
+ }
+ QString actid = actdata.value("activityname").toString();
+ if ( !actid.isNull() )
+ {
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actid));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ changeAnimalImage(data.toString());
+ }
+ //startup case end
+}
+
+AnimalWidget::~AnimalWidget()
+{
+ delete mActivityClient;
+}
+
+void AnimalWidget::changeAnimalImage(const QString &image)
+{
+ mAnimalLabel->setPixmap(QPixmap(image).scaled(QSize( 200, 300), Qt::KeepAspectRatio));
+ mFileNameLabel->setText(image);
+ mCurrentImage = image;
+}
+
+void AnimalWidget::saveActivity()
+{
+ QVariantHash metadata;
+ metadata.insert("screenshot", *mAnimalLabel->pixmap());
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, "Activities - pure Qt"));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, "Activities - pure Qt"), Q_ARG(QVariant, QVariant(mCurrentImage)), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ qFatal("Add failed");
+ }
+}
+
+void AnimalWidget::loadActivity(const QString &name)
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "waitActivity", Q_RETURN_ARG(bool, retok));
+ if (!ok || !retok) {
+ // qFatal("Resubscribe failed");
+ }
+
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ changeAnimalImage(data.toString());
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestanimal/animalwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ANIMALWIDGET_H
+#define ANIMALWIDGET_H
+
+#include <QWidget>
+
+class QLabel;
+class QString;
+
+class AnimalWidget: public QWidget
+{
+
+ Q_OBJECT
+
+public:
+ AnimalWidget(QWidget *parent = 0);
+ ~AnimalWidget();
+
+private slots:
+ void changeAnimalImage(const QString &image);
+ void saveActivity();
+ void loadActivity(const QString &name);
+
+private:
+ QLabel *mAnimalLabel;
+ QLabel *mFileNameLabel;
+ QString mCurrentImage;
+ QObject *mActivityClient;
+};
+
+#endif //ANIMALWIDGET_H
Binary file activityfw/testapplications/activitytestanimal/images/africaelephant.jpg has changed
Binary file activityfw/testapplications/activitytestanimal/images/africatiger.jpg has changed
Binary file activityfw/testapplications/activitytestanimal/images/indiaelephant.jpg has changed
Binary file activityfw/testapplications/activitytestanimal/images/syberiantiger.jpg has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestanimal/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 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 <QApplication>
+
+#include "animalwidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ AnimalWidget widget;
+ widget.setMaximumSize(360,640);
+ widget.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ widget.showMaximized();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/activitytestfigure.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = activitytestfigure
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+squrewidget.cpp\
+trianglewidget.cpp\
+viewmanager.cpp\
+circlewidget.cpp\
+figurewidget.cpp
+
+HEADERS += squrewidget.h\
+trianglewidget.h\
+viewmanager.h\
+circlewidget.h\
+figurewidget.h
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/circlewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 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 "circlewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+
+
+circlewidget::circlewidget(QGraphicsItem *parent)
+ : figurewidget(parent)
+{
+ mGridLayout->addItem(mTriangle, 2, 0, 1, 1);
+ mGridLayout->addItem(mSqure, 2, 1, 1, 1);
+
+ mColor = "blue";
+
+ delete mCircle;
+ mCircle = NULL;
+}
+
+circlewidget::~circlewidget()
+{
+}
+
+void circlewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QRect rect(10, 10, 300, 300);
+ QPainterPath painterpath;
+ painterpath.addEllipse(rect);
+ painterpath.setFillRule(Qt::WindingFill);
+
+ painter->setPen(Qt::black);
+ if (mColor == "red") {
+ painter->setBrush(Qt::red);
+ } else if (mColor == "green") {
+ painter->setBrush(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setBrush(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+ painter->drawPath(painterpath);
+
+ figurewidget::paint(painter, option, widget);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/circlewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef CIRCLEWIDGET_H_
+#define CIRCLEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include "figurewidget.h"
+
+class circlewidget: public figurewidget
+{
+ Q_OBJECT
+public:
+ circlewidget(QGraphicsItem *parent = 0);
+ ~circlewidget();
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+};
+
+#endif /* CIRCLEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/figurewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2009 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 "figurewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+
+
+figurewidget::figurewidget(QGraphicsItem *parent)
+ : HbWidget(parent), mFailed(false)
+{
+ mTriangle = new HbPushButton("Triangle");
+ mSqure = new HbPushButton("Squre");
+ mCircle = new HbPushButton("Circle");
+ mRed = new HbPushButton("Red");
+ mGreen = new HbPushButton("Green");
+ mBlue = new HbPushButton("Blue");
+ mSave = new HbPushButton("Add");
+ mDelete = new HbPushButton("Delete");
+ mUpdate = new HbPushButton("Update");
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mRed, 3, 0, 1, 1);
+ mGridLayout->addItem(mGreen, 3, 1, 1, 1);
+ mGridLayout->addItem(mBlue, 3, 2, 1, 1);
+ mGridLayout->addItem(mSave, 4, 0, 1, 1);
+ mGridLayout->addItem(mUpdate, 4, 1, 1, 1);
+ mGridLayout->addItem(mDelete, 4, 2, 1, 1);
+ mGridLayout->setRowStretchFactor(0, 1);
+ mGridLayout->setRowStretchFactor(1, 1);
+ setLayout(mGridLayout);
+
+
+ connect(mRed, SIGNAL(released()), this, SLOT(red()));
+ connect(mGreen, SIGNAL(released()), this, SLOT(green()));
+ connect(mBlue, SIGNAL(released()), this, SLOT(blue()));
+
+ connect(mTriangle, SIGNAL(released()), this, SIGNAL(totriangle()));
+ connect(mSqure, SIGNAL(released()), this, SIGNAL(tosqure()));
+ connect(mCircle, SIGNAL(released()), this, SIGNAL(tocircle()));
+
+ connect(mSave, SIGNAL(released()), this, SIGNAL(save()));
+ connect(mUpdate, SIGNAL(released()), this, SIGNAL(updateAct()));
+ connect(mDelete, SIGNAL(released()), this, SIGNAL(del()));
+
+ connect(mRed, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mGreen, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mBlue, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mSqure, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mTriangle, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+
+}
+
+figurewidget::~figurewidget()
+{
+}
+
+void figurewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ HbWidget::paint(painter, option, widget);
+
+ if ( mFailed ) {
+ painter->setPen(Qt::gray);
+ QFont font;
+ font.setPointSize(38);
+ font.setBold(true);
+ painter->setFont(font);
+ painter->drawText(10, 120, "*FAIL*");
+ }
+}
+
+
+void figurewidget::red()
+{
+ mColor = "red";
+ update();
+}
+
+void figurewidget::green()
+{
+ mColor = "green";
+ update();
+}
+
+void figurewidget::blue()
+{
+ mColor = "blue";
+ update();
+}
+
+void figurewidget::setcolor(const QString &color)
+{
+ mColor = color;
+}
+
+QString figurewidget::color()
+{
+ return mColor;
+}
+
+void figurewidget::clearFailedFlag()
+ {
+ mFailed = false;
+ update();
+ }
+
+void figurewidget::setFailedFlag()
+ {
+ mFailed = true;
+ update();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/figurewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef FIGUREWIDGET_H_
+#define FIGUREWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class figurewidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ figurewidget(QGraphicsItem *parent = 0);
+ ~figurewidget();
+ void setcolor(const QString &color);
+ QString color();
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mTriangle;
+ HbPushButton *mSqure;
+ HbPushButton *mCircle;
+ HbPushButton *mRed;
+ HbPushButton *mGreen;
+ HbPushButton *mBlue;
+ HbPushButton *mSave;
+ HbPushButton *mDelete;
+ HbPushButton *mUpdate;
+ QString mColor;
+ bool mFailed;
+
+signals:
+ void tosqure();
+ void totriangle();
+ void tocircle();
+ void save();
+ void updateAct();
+ void del();
+
+protected slots:
+ void red();
+ void green();
+ void blue();
+
+public slots:
+ void clearFailedFlag();
+ void setFailedFlag();
+};
+
+#endif /* FIGUREWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "squrewidget.h"
+#include "trianglewidget.h"
+#include "viewmanager.h"
+
+//#define hbapinotreleased
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow(&app);
+ mainWindow.show();
+
+#ifndef hbapinotreleased
+ if (app.activateReason() == Hb::ActivationReasonActivity) {
+ // start-up case
+ QVariant data = app.activateData();
+ mainWindow.loadActivityData(data);
+ }
+#endif
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/squrewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2009 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 "squrewidget.h"
+#include <QRect>
+#include <QPainter>
+
+
+squrewidget::squrewidget(QGraphicsItem *parent)
+ : figurewidget(parent)
+{
+ mGridLayout->addItem(mTriangle, 2, 0, 1, 1);
+ mGridLayout->addItem(mCircle, 2, 1, 1, 1);
+
+ mColor = "red";
+
+ delete mSqure;
+ mSqure = NULL;
+}
+
+squrewidget::~squrewidget()
+{
+}
+
+void squrewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QRect rect(10, 10, 300, 300);
+ painter->setPen(Qt::black);
+ if (mColor == "red") {
+ painter->setBrush(Qt::red);
+ } else if (mColor == "green") {
+ painter->setBrush(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setBrush(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+ painter->drawRect(rect);
+
+ figurewidget::paint(painter, option, widget);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/squrewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef SQUREWIDGET_H_
+#define SQUREWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include "figurewidget.h"
+
+class squrewidget: public figurewidget
+{
+ Q_OBJECT
+public:
+ squrewidget(QGraphicsItem *parent = 0);
+ ~squrewidget();
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+};
+
+#endif /* SQUREWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/trianglewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 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 "trianglewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPolygon>
+
+
+trianglewidget::trianglewidget(QGraphicsItem *parent)
+ : figurewidget(parent)
+{
+ mGridLayout->addItem(mSqure, 2, 0, 1, 1);
+ mGridLayout->addItem(mCircle, 2, 1, 1, 1);
+
+ mColor = "green";
+
+ delete mTriangle;
+ mTriangle = NULL;
+}
+
+trianglewidget::~trianglewidget()
+{
+
+}
+
+void trianglewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QPolygon polygon;
+ polygon.putPoints(0, 3, 10,300, 150,10, 300,300);
+ painter->setPen(Qt::black);
+ if (mColor == "red") {
+ painter->setBrush(Qt::red);
+ } else if (mColor == "green") {
+ painter->setBrush(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setBrush(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+
+ painter->drawPolygon(polygon, Qt::WindingFill);
+
+ figurewidget::paint(painter, option, widget);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/trianglewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TRAINGLEWIDGET_H_
+#define TRAINGLEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include "figurewidget.h"
+
+class trianglewidget: public figurewidget
+{
+ Q_OBJECT
+public:
+ trianglewidget(QGraphicsItem *parent = 0);
+ ~trianglewidget();
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+};
+
+#endif /* TRAINGLEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2009 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 "viewmanager.h"
+#include <qservicemanager.h>
+#include <HbInstance>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbinstance.h>
+#include <hbapplication.h>
+#include <hbactivitymanager.h>
+#include <hbmainwindow.h>
+#include "squrewidget.h"
+#include "trianglewidget.h"
+#include "circlewidget.h"
+#include "figurewidget.h"
+#include <QEventLoop>
+
+QTM_USE_NAMESPACE
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+viewmanager::viewmanager(HbApplication *hbapp):
+ HbMainWindow(), mHbApp(hbapp)
+{
+
+ connect(hbApp->activityManager(), SIGNAL(activityRequested(QString)), this, SLOT(loadActivityData(QString)));
+
+
+ mSw = new squrewidget();
+ mTw = new trianglewidget();
+ mCw = new circlewidget();
+ mSView = addView(mSw);
+ mSView->setTitle("Squre");
+ mTView = addView(mTw);
+ mTView->setTitle("Triangle");
+ mCView = addView(mCw);
+ mCView->setTitle("Circle");
+ totriangle();
+ connect(mSw, SIGNAL(totriangle()), this, SLOT(totriangle()));
+ connect(mSw, SIGNAL(tocircle()), this, SLOT(tocircle()));
+
+ connect(mTw, SIGNAL(tocircle()), this, SLOT(tocircle()));
+ connect(mTw, SIGNAL(tosqure()), this, SLOT(tosqure()));
+
+ connect(mCw, SIGNAL(tosqure()), this, SLOT(tosqure()));
+ connect(mCw, SIGNAL(totriangle()), this, SLOT(totriangle()));
+
+ connect(mSw, SIGNAL(save()), this, SLOT(save()));
+ connect(mTw, SIGNAL(save()), this, SLOT(save()));
+ connect(mCw, SIGNAL(save()), this, SLOT(save()));
+ connect(mSw, SIGNAL(updateAct()), this, SLOT(updateAct()));
+ connect(mTw, SIGNAL(updateAct()), this, SLOT(updateAct()));
+ connect(mCw, SIGNAL(updateAct()), this, SLOT(updateAct()));
+ connect(mSw, SIGNAL(del()), this, SLOT(del()));
+ connect(mTw, SIGNAL(del()), this, SLOT(del()));
+ connect(mCw, SIGNAL(del()), this, SLOT(del()));
+
+}
+
+viewmanager::~viewmanager()
+{
+
+}
+
+void viewmanager::totriangle()
+{
+ setCurrentView(mTView);
+ mStatename = "triangle";
+}
+
+void viewmanager::tosqure()
+{
+ setCurrentView(mSView);
+ mStatename = "squre";
+}
+
+void viewmanager::tocircle()
+{
+ setCurrentView(mCView);
+ mStatename = "circle";
+}
+
+
+void viewmanager::save()
+{
+ QString color;
+ figurewidget* widget = currentWidget();
+ color = widget->color();
+
+ QStringList list;
+ list.append(mStatename);
+ list.append(color);
+ mSaveVariant.clear();
+ mSaveVariant = list;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert("screenshot", screenshot);
+
+ bool ok = hbApp->activityManager()->addActivity(mStatename, mSaveVariant, metadata);
+ if (!ok) {
+ widget->setFailedFlag();
+ }
+ else {
+ widget->clearFailedFlag();
+ }
+}
+
+void viewmanager::updateAct()
+{
+ QString color;
+ figurewidget* widget = currentWidget();
+ color = widget->color();
+
+ QStringList list;
+ list.append(mStatename);
+ list.append(color);
+ mSaveVariant.clear();
+ mSaveVariant = list;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert("screenshot", screenshot);
+
+ bool ok = hbApp->activityManager()->updateActivity(mStatename, mSaveVariant, metadata);
+ if (!ok) {
+ widget->setFailedFlag();
+ }
+ else {
+ widget->clearFailedFlag();
+ }
+}
+
+void viewmanager::del()
+{
+ bool ok = hbApp->activityManager()->removeActivity(mStatename);
+ figurewidget* widget = currentWidget();
+ if (!ok) {
+ widget->setFailedFlag();
+ }
+ else {
+ widget->clearFailedFlag();
+ }
+}
+
+void viewmanager::loadActivityData(const QString &name)
+{
+ QVariant data = hbApp->activityManager()->activityData( name );
+ loadActivityData( data );
+}
+
+void viewmanager::loadActivityData(const QVariant &data)
+{
+ HbView *oldView = currentView();
+ QStringList list = data.toStringList();
+ QString statename = list.at(0);
+ QString color = list.at(1);
+ if (statename == "squre") {
+ mSw->setcolor(color);
+ tosqure();
+ mSw->update();
+ } else if (statename == "triangle") {
+ mTw->setcolor(color);
+ totriangle();
+ mTw->update();
+ } else if (statename == "circle") {
+ mCw->setcolor(color);
+ tocircle();
+ mCw->update();
+ } else {
+ Q_ASSERT(false);
+ }
+
+ if (currentView() != oldView) {
+ QEventLoop loop;
+ loop.connect(this, SIGNAL(viewReady()), SLOT(quit()));
+ loop.exec();
+ }
+}
+
+figurewidget* viewmanager::currentWidget()
+ {
+ HbView* view = currentView();
+ QGraphicsWidget* gwidget = view->widget();
+ figurewidget* lwidget = qobject_cast<figurewidget*>(gwidget);
+ }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestfigure/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+class HbApplication;
+class figurewidget;
+
+#include <QFile>
+#include <QTextStream>
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager(HbApplication *hbapp);
+ virtual ~viewmanager();
+ figurewidget* currentWidget();
+
+private:
+ figurewidget *mSw;
+ figurewidget *mTw;
+ figurewidget *mCw;
+ HbView *mSView;
+ HbView *mTView;
+ HbView *mCView;
+
+private slots:
+ void totriangle();
+ void tosqure();
+ void tocircle();
+
+ void save();
+ void updateAct();
+ void del();
+
+public slots:
+ void loadActivityData(const QString &name);
+
+public:
+ void loadActivityData(const QVariant &data);
+
+private:
+ QString mStatename;
+ QVariant mSaveVariant;
+ HbApplication *mHbApp;
+
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/activitytestletter.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = activitytestletter
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+boldwidget.cpp\
+italicwidget.cpp\
+viewmanager.cpp\
+underlinewidget.cpp\
+letterwidget.cpp
+
+HEADERS += boldwidget.h\
+italicwidget.h\
+viewmanager.h\
+underlinewidget.h\
+letterwidget.h\
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0xEba3dff3
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/boldwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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 "boldwidget.h"
+#include <QRect>
+#include <QPainter>
+
+
+boldwidget::boldwidget(QGraphicsItem *parent)
+ : letterwidget(parent)
+{
+ mGridLayout->addItem(mItalic, 2, 0, 1, 1);
+ mGridLayout->addItem(mUnderline, 2, 1, 1, 1);
+
+ mColor = "red";
+ mNameCombo->addItem("Bold");
+
+ delete mBold;
+ mBold = NULL;
+}
+
+boldwidget::~boldwidget()
+{
+
+}
+
+void boldwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ letterwidget::paint(painter, option, widget);
+ QFont font;
+ font.setPointSize(45);
+ font.setBold(true);
+ painter->setFont(font);
+ painter->drawText(10, 140, "Bold");
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/boldwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef BOLDWIDGET_H_
+#define BOLDWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include "letterwidget.h"
+
+class boldwidget: public letterwidget
+{
+ Q_OBJECT
+public:
+ boldwidget(QGraphicsItem *parent = 0);
+ ~boldwidget();
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+};
+
+#endif /* BOLDWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/italicwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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 "italicwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPolygon>
+
+const QString KButtonString("to bold");
+
+italicwidget::italicwidget(QGraphicsItem *parent)
+ : letterwidget(parent)
+{
+ mGridLayout->addItem(mBold, 2, 0, 1, 1);
+ mGridLayout->addItem(mUnderline, 2, 1, 1, 1);
+
+ mColor = "green";
+ mNameCombo->addItem("Italic");
+
+ delete mItalic;
+ mItalic = NULL;
+}
+
+italicwidget::~italicwidget()
+{
+
+}
+
+void italicwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ letterwidget::paint(painter, option, widget);
+ QFont font;
+ font.setPointSize(45);
+ font.setItalic(true);
+ painter->setFont(font);
+ painter->drawText(10, 140, "Italic");
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/italicwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ITALICWIDGET_H_
+#define ITALICWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include "letterwidget.h"
+
+class italicwidget: public letterwidget
+{
+ Q_OBJECT
+public:
+ italicwidget(QGraphicsItem *parent = 0);
+ ~italicwidget();
+
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+};
+
+#endif /* ITALICWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/letterwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2009 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 "letterwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+
+letterwidget::letterwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ mItalic = new HbPushButton("Italic");
+ mBold = new HbPushButton("Bold");
+ mUnderline = new HbPushButton("Underline");
+ mRed = new HbPushButton("Red");
+ mGreen = new HbPushButton("Green");
+ mBlue = new HbPushButton("Blue");
+ mSave = new HbPushButton("Save activity");
+ mDelete = new HbPushButton("Delete activity");
+
+ mVisibilityLabel = new HbLabel("Visibility");
+ mVisibilityCombo = new HbComboBox();
+ mVisibilityCombo->addItem("none");
+ mVisibilityCombo->addItem("true");
+ mVisibilityCombo->addItem("false");
+
+ mPersistentLabel = new HbLabel("Persistence");
+ mPersistentCombo = new HbComboBox();
+ mPersistentCombo->addItem("none");
+ mPersistentCombo->addItem("true");
+ mPersistentCombo->addItem("false");
+
+ mNameLabel = new HbLabel("Name");
+ mNameCombo = new HbComboBox();
+ mNameCombo->addItem("none");
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mRed, 3, 0, 1, 1);
+ mGridLayout->addItem(mGreen, 3, 1, 1, 1);
+ mGridLayout->addItem(mBlue, 3, 2, 1, 1);
+ mGridLayout->addItem(mSave, 4, 0, 1, 1);
+ mGridLayout->addItem(mDelete, 4, 1, 1, 1);
+ mGridLayout->addItem(mVisibilityLabel, 5, 0, 1, 1);
+ mGridLayout->addItem(mVisibilityCombo, 5, 1, 1, 2);
+ mGridLayout->addItem(mPersistentLabel, 6, 0, 1, 1);
+ mGridLayout->addItem(mPersistentCombo, 6, 1, 1, 2);
+ mGridLayout->addItem(mNameLabel, 7, 0, 1, 1);
+ mGridLayout->addItem(mNameCombo, 7, 1, 1, 2);
+ mGridLayout->setRowStretchFactor(0, 1);
+ mGridLayout->setRowStretchFactor(1, 1);
+ setLayout(mGridLayout);
+
+
+ connect(mRed, SIGNAL(released()), this, SLOT(red()));
+ connect(mGreen, SIGNAL(released()), this, SLOT(green()));
+ connect(mBlue, SIGNAL(released()), this, SLOT(blue()));
+
+ connect(mItalic, SIGNAL(released()), this, SIGNAL(toitalic()));
+ connect(mBold, SIGNAL(released()), this, SIGNAL(tobold()));
+ connect(mUnderline, SIGNAL(released()), this, SIGNAL(tounderline()));
+
+ connect(mSave, SIGNAL(released()), this, SIGNAL(save()));
+ connect(mDelete, SIGNAL(released()), this, SIGNAL(del()));
+}
+
+void letterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ HbWidget::paint(painter, option, widget);
+
+ if (mColor == "red") {
+ painter->setPen(Qt::red);
+ } else if (mColor == "green") {
+ painter->setPen(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setPen(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+}
+
+letterwidget::~letterwidget()
+{
+}
+
+
+void letterwidget::red()
+{
+ mColor = "red";
+ update();
+}
+
+void letterwidget::green()
+{
+ mColor = "green";
+ update();
+}
+
+void letterwidget::blue()
+{
+ mColor = "blue";
+ update();
+}
+
+void letterwidget::setcolor(const QString &color)
+{
+ mColor = color;
+}
+
+QString letterwidget::color()
+{
+ return mColor;
+}
+
+QString letterwidget::visibility()
+{
+ return mVisibilityCombo->currentText();
+}
+
+QString letterwidget::persistent()
+{
+ return mPersistentCombo->currentText();
+}
+
+QString letterwidget::name()
+{
+ return mNameCombo->currentText();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/letterwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LETTERWIDGET_H_
+#define LETTERWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+
+class letterwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ letterwidget(QGraphicsItem *parent = 0);
+ ~letterwidget();
+ void setcolor(const QString &color);
+ QString color();
+ QString visibility();
+ QString persistent();
+ QString name();
+
+
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+protected:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mItalic;
+ HbPushButton *mBold;
+ HbPushButton *mUnderline;
+ HbPushButton *mRed;
+ HbPushButton *mGreen;
+ HbPushButton *mBlue;
+ HbPushButton *mSave;
+ HbPushButton *mDelete;
+ HbLabel* mVisibilityLabel;
+ HbLabel* mPersistentLabel;
+ HbLabel* mNameLabel;
+ HbComboBox *mVisibilityCombo;
+ HbComboBox *mPersistentCombo;
+ HbComboBox *mNameCombo;
+ QString mColor;
+
+signals:
+ void tobold();
+ void toitalic();
+ void tounderline();
+ void save();
+ void del();
+
+protected slots:
+ void red();
+ void green();
+ void blue();
+
+};
+
+#endif /* LETTERWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "boldwidget.h"
+#include "italicwidget.h"
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow(&app);
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/underlinewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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 "underlinewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+
+
+underlinewidget::underlinewidget(QGraphicsItem *parent)
+ : letterwidget(parent)
+{
+ mGridLayout->addItem(mItalic, 2, 0, 1, 1);
+ mGridLayout->addItem(mBold, 2, 1, 1, 1);
+
+ mColor = "blue";
+ mNameCombo->addItem("Underline");
+
+ delete mUnderline;
+ mUnderline = NULL;
+}
+
+underlinewidget::~underlinewidget()
+{
+
+}
+
+void underlinewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ letterwidget::paint(painter, option, widget);
+ QFont font;
+ font.setPointSize(40);
+ font.setUnderline(true);
+ painter->setFont(font);
+ painter->drawText(10, 120, "Under");
+ painter->drawText(10, 240, "line");
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/underlinewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef UNDERLINEWIDGET_H_
+#define UNDERLINEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include "letterwidget.h"
+
+class underlinewidget: public letterwidget
+{
+ Q_OBJECT
+public:
+ underlinewidget(QGraphicsItem *parent = 0);
+ ~underlinewidget();
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+};
+
+#endif /* UNDERLINEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,224 @@
+/*
+* Copyright (c) 2009 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 <qservicemanager.h>
+#include <HbInstance>
+#include <QEventLoop>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "boldwidget.h"
+#include "italicwidget.h"
+#include "underlinewidget.h"
+#include "letterwidget.h"
+#include "afstorageglobals.h"
+
+QTM_USE_NAMESPACE
+
+viewmanager::viewmanager(HbApplication *hbapp):
+ HbMainWindow(), mHbApp(hbapp)
+{
+ QServiceManager serviceManager;
+ mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ if (!mActivityClient) {
+ qFatal("load plugin failed");
+ }
+
+ connect(mActivityClient, SIGNAL(activityRequested(QString)), this, SLOT(loadActivityData(QString)));
+
+
+ mBoldWidget = new boldwidget();
+ mItalicWidget = new italicwidget();
+ mUnderlineWidget = new underlinewidget();
+ mBoldView = addView(mBoldWidget);
+ mBoldView->setTitle("Bold");
+ mItalicView = addView(mItalicWidget);
+ mItalicView->setTitle("Italic");
+ mUnderlineView = addView(mUnderlineWidget);
+ mUnderlineView->setTitle("Underline");
+ toitalic();
+ connect(mBoldWidget, SIGNAL(toitalic()), this, SLOT(toitalic()));
+ connect(mBoldWidget, SIGNAL(tounderline()), this, SLOT(tounderline()));
+
+ connect(mItalicWidget, SIGNAL(tounderline()), this, SLOT(tounderline()));
+ connect(mItalicWidget, SIGNAL(tobold()), this, SLOT(tobold()));
+
+ connect(mUnderlineWidget, SIGNAL(tobold()), this, SLOT(tobold()));
+ connect(mUnderlineWidget, SIGNAL(toitalic()), this, SLOT(toitalic()));
+
+ connect(mBoldWidget, SIGNAL(save()), this, SLOT(save()));
+ connect(mItalicWidget, SIGNAL(save()), this, SLOT(save()));
+ connect(mUnderlineWidget, SIGNAL(save()), this, SLOT(save()));
+ connect(mBoldWidget, SIGNAL(del()), this, SLOT(del()));
+ connect(mItalicWidget, SIGNAL(del()), this, SLOT(del()));
+ connect(mUnderlineWidget, SIGNAL(del()), this, SLOT(del()));
+
+
+ //startup case
+ QStringList arglist = qApp->arguments();
+ QVariantHash actdata;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "parseCommandLine", Q_RETURN_ARG(QVariantHash, actdata), Q_ARG(QStringList, arglist));
+ if (!ok) {
+ qFatal("Startup failed");
+ }
+ QString actid = actdata.value("activityname").toString();
+ if ( !actid.isNull() )
+ {
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actid));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ loadActivityData(data, true);
+ }
+ //startup case end
+}
+
+viewmanager::~viewmanager()
+{
+}
+
+void viewmanager::toitalic()
+{
+ setCurrentView(mItalicView);
+ mStatename = "italic";
+}
+
+void viewmanager::tobold()
+{
+ setCurrentView(mBoldView);
+ mStatename = "bold";
+}
+
+void viewmanager::tounderline()
+{
+ setCurrentView(mUnderlineView);
+ mStatename = "underline";
+}
+
+
+void viewmanager::save()
+{
+ QString color;
+ QString visible;
+ QString persistent;
+ QString name;
+ letterwidget* widget = currentWidget();
+ color = widget->color();
+ visible = widget->visibility();
+ persistent = widget->persistent();
+ name = widget->name();
+
+ QStringList list;
+ list.append(mStatename);
+ list.append(color);
+ mSaveVariant.clear();
+ mSaveVariant = list;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+ if ( visible == "true" )
+ {
+ metadata.insert(ActivityVisibility, true);
+ }
+ else if ( visible == "false" )
+ {
+ metadata.insert(ActivityVisibility, false);
+ }
+
+ if ( persistent == "true" )
+ {
+ metadata.insert(ActivityPersistence, true);
+ }
+ else if ( persistent == "false" )
+ {
+ metadata.insert(ActivityPersistence, false);
+ }
+
+ if ( name != "none" )
+ {
+ metadata.insert(ActivityApplicationName, name);
+ }
+
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mStatename));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mStatename), Q_ARG(QVariant, mSaveVariant), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ qFatal("Add failed");
+ }
+}
+void viewmanager::del()
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mStatename));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+}
+
+void viewmanager::loadActivityData(const QString &name)
+{
+ QVariant data;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ loadActivityData(data, false);
+}
+
+void viewmanager::loadActivityData(const QVariant &data, bool startup)
+{
+ HbView *oldView = currentView();
+
+ QStringList list = data.toStringList();
+ QString statename = list.at(0);
+ QString color = list.at(1);
+ if (statename == "bold") {
+ mBoldWidget->setcolor(color);
+ tobold();
+ mBoldWidget->update();
+ } else if (statename == "italic") {
+ mItalicWidget->setcolor(color);
+ toitalic();
+ mItalicWidget->update();
+ } else if (statename == "underline") {
+ mUnderlineWidget->setcolor(color);
+ tounderline();
+ mUnderlineWidget->update();
+ } else {
+ Q_ASSERT(false);
+ }
+
+ if (currentView() != oldView && !startup) {
+ QEventLoop loop;
+ loop.connect(this, SIGNAL(viewReady()), SLOT(quit()));
+ loop.exec();
+ }
+}
+
+letterwidget* viewmanager::currentWidget()
+ {
+ HbView* view = currentView();
+ QGraphicsWidget* gwidget = view->widget();
+ letterwidget* lwidget = qobject_cast<letterwidget*>(gwidget);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestletter/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+class HbApplication;
+class letterwidget;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager(HbApplication *hbapp);
+ virtual ~viewmanager();
+ void initialize();
+
+private:
+ letterwidget *mBoldWidget;
+ letterwidget *mItalicWidget;
+ letterwidget *mUnderlineWidget;
+ HbView *mBoldView;
+ HbView *mItalicView;
+ HbView *mUnderlineView;
+
+private slots:
+ void toitalic();
+ void tobold();
+ void tounderline();
+
+ void save();
+ void del();
+
+public slots:
+ void loadActivityData(const QString &name);
+
+public:
+ void loadActivityData(const QVariant &data, bool startup);
+ letterwidget* currentWidget();
+
+private:
+ QObject *mActivityClient;
+ QString mStatename;
+ QVariant mSaveVariant;
+ HbApplication *mHbApp;
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/activityhandler.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2009 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 "activityhandler.h"
+
+#include <qservicemanager.h>
+
+#include <QApplication>
+#include <HbMainWindow>
+#include <HbInstance>
+
+#include "iconsview.h"
+
+QTM_USE_NAMESPACE
+
+ActivityHandler::ActivityHandler(IconsView *iconsView) : mIconsView(iconsView), mActivityClient(NULL)
+{
+ QServiceManager serviceManager;
+ mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ Q_ASSERT(mActivityClient);
+
+ connect(mActivityClient, SIGNAL(activityRequested(QString)), this, SLOT(loadActivityData(QString)));
+
+ //startup case
+ QStringList arglist = qApp->arguments();
+ QVariantHash actdata;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "parseCommandLine", Q_RETURN_ARG(QVariantHash, actdata), Q_ARG(QStringList, arglist));
+ if (!ok) {
+ // qFatal("Startup failed");
+ }
+ QString actid = actdata.value("activityname").toString();
+ if ( !actid.isNull() )
+ {
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actid));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ mIconsView->loadActivity(data);
+ }
+ //startup case end
+
+ bool retok;
+ ok = QMetaObject::invokeMethod(mActivityClient, "waitActivity", Q_RETURN_ARG(bool, retok));
+ if (!ok || !retok) {
+ // qFatal("Subscribe failed");
+ }
+}
+
+ActivityHandler::~ActivityHandler()
+{
+ delete mActivityClient;
+}
+
+void ActivityHandler::handleSaveRequest(const QString &name)
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert("screenshot", screenshot);
+ QVariant data = mIconsView->generateActivityData();
+
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, data), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ qFatal("Add failed");
+ }
+}
+void ActivityHandler::loadActivityData(const QString &name)
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "waitActivity", Q_RETURN_ARG(bool, retok));
+ if (!ok || !retok) {
+ //qFatal("Resubscribe failed");
+ }
+
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ mIconsView->loadActivity(data);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/activityhandler.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ACTIVITYHANDLER_H
+#define ACTIVITYHANDLER_H
+
+#include <QObject>
+
+class IconsView;
+
+class ActivityHandler : public QObject
+{
+
+ Q_OBJECT
+
+public:
+ ActivityHandler(IconsView *iconsView);
+ ~ActivityHandler();
+
+public slots:
+ void handleSaveRequest(const QString &name);
+ void loadActivityData(const QString &name);
+
+private:
+ IconsView *mIconsView;
+ QObject *mActivityClient;
+
+};
+
+#endif // ACTIVITYHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/activitytestmodel.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES = iconsview.cpp \
+ main.cpp \
+ activityhandler.cpp \
+
+HEADERS = iconsview.h \
+ activityhandler.h \
+
+RESOURCES += activitytestmodel.qrc
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/activitytestmodel.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,12 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>data/img1.png</file>
+ <file>data/img2.png</file>
+ <file>data/img3.png</file>
+ <file>data/img4.png</file>
+ <file>data/img5.png</file>
+ <file>data/img6.png</file>
+ <file>data/img7.png</file>
+ <file>data/img8.png</file>
+ </qresource>
+</RCC>
Binary file activityfw/testapplications/activitytestmodel/data/img1.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img2.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img3.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img4.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img5.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img6.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img7.PNG has changed
Binary file activityfw/testapplications/activitytestmodel/data/img8.PNG has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/iconsview.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2009 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 "iconsview.h"
+
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include <QSignalMapper>
+
+#include <hblistwidget.h>
+#include <hblabel.h>
+#include <hbpushbutton.h>
+
+#include <QDebug>
+
+IconsView::IconsView(QGraphicsItem *parent) : HbView(parent)
+{
+ setTitle("Icons");
+
+ mModel = new QStandardItemModel(this);
+ for (int i=1; i<=8; ++i) {
+ addItemToModel(i);
+ }
+
+ mList = new HbListView(this);
+ mList->setModel(mModel);
+
+ QGraphicsGridLayout *buttonsLayout = new QGraphicsGridLayout();
+ HbPushButton *addItemButton = new HbPushButton("Add item");
+ connect(addItemButton, SIGNAL(clicked()), this, SLOT(addItem()));
+ buttonsLayout->addItem(addItemButton, 0, 0);
+
+ HbPushButton *removeItemButtom = new HbPushButton("Remove item");
+ connect(removeItemButtom, SIGNAL(clicked()), this, SLOT(removeItem()));
+ buttonsLayout->addItem(removeItemButtom, 0, 1);
+
+ HbPushButton *saveActivityAButton = new HbPushButton("Save State A");
+ buttonsLayout->addItem(saveActivityAButton, 1, 0);
+ HbPushButton *saveActivityBButton = new HbPushButton("Save State B");
+ buttonsLayout->addItem(saveActivityBButton, 1, 1);
+
+ buttonsLayout->setRowFixedHeight(0, 50);
+ buttonsLayout->setRowFixedHeight(1, 50);
+
+ QSignalMapper *saveActivityMapper = new QSignalMapper(this);
+ saveActivityMapper->setMapping(saveActivityAButton, "StateA");
+ saveActivityMapper->setMapping(saveActivityBButton, "StateB");
+ connect(saveActivityAButton, SIGNAL(clicked()), saveActivityMapper, SLOT(map()));
+ connect(saveActivityBButton, SIGNAL(clicked()), saveActivityMapper, SLOT(map()));
+ connect(saveActivityMapper, SIGNAL(mapped(QString)), this, SIGNAL(activitySaveRequested(QString)));
+
+ mItemCountLabel = new HbLabel();
+ mItemCountLabel->setAlignment(Qt::AlignCenter);
+ mItemCountLabel->setMaximumHeight(30);
+ updateCountLabel();
+
+ QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
+ mainLayout->addItem(mItemCountLabel);
+ mainLayout->addItem(mList);
+ mainLayout->addItem(buttonsLayout);
+
+ setLayout(mainLayout);
+}
+
+IconsView::~IconsView()
+{
+}
+
+void IconsView::addItemToModel(int number)
+{
+ QStandardItem *item = new QStandardItem(QIcon(QString(":data\\img%1").arg(number)), QString("Image %1").arg(number));
+ mModel->appendRow(item);
+}
+
+void IconsView::addItem()
+{
+ addItemToModel(qrand() % 8 + 1);
+ updateCountLabel();
+}
+
+void IconsView::removeItem()
+{
+ if (mModel->rowCount() > 0) {
+ mModel->removeRow(mModel->rowCount() - 1, QModelIndex());
+ }
+ updateCountLabel();
+}
+
+void IconsView::updateCountLabel()
+{
+ mItemCountLabel->setPlainText(QString("List contains %1 items").arg(mModel->rowCount()));
+}
+
+QVariant IconsView::generateActivityData()
+{
+ QByteArray serializedModel;
+ {
+ QDataStream stream(&serializedModel, QIODevice::WriteOnly | QIODevice::Append);
+ for (int row = 0; row < mModel->rowCount(); ++row) {
+ stream << *mModel->item(row);
+ }
+ }
+ return serializedModel;
+}
+
+void IconsView::loadActivity(const QVariant &data)
+{
+ mModel->clear();
+ QByteArray serializedModel = data.toByteArray();
+ {
+ QDataStream stream(&serializedModel, QIODevice::ReadOnly);
+ while (!stream.atEnd()) {
+ QStandardItem *item = new QStandardItem();
+ stream >> *item;
+ mModel->appendRow(item);
+ }
+ }
+ updateCountLabel();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/iconsview.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ICONSVIEW_H
+#define ICONSVIEW_H
+
+#include <hbview.h>
+
+class HbLabel;
+class QStandardItemModel;
+class HbListView;
+
+class IconsView : public HbView
+{
+ Q_OBJECT
+
+public:
+ IconsView(QGraphicsItem *parent = 0);
+ ~IconsView();
+
+private slots:
+ void addItem();
+ void removeItem();
+
+public slots:
+ void loadActivity(const QVariant &data);
+
+signals:
+ void activitySaveRequested(const QString &name);
+
+public:
+ QVariant generateActivityData();
+
+private:
+ void updateCountLabel();
+ void addItemToModel(int number);
+
+private:
+ QStandardItemModel *mModel;
+ HbLabel *mItemCountLabel;
+ HbListView *mList;
+};
+
+#endif // ICONSVIEW_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodel/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+#include <QSignalMapper>
+
+#include "iconsview.h"
+#include "activityhandler.h"
+
+
+int main(int argc, char *argv[])
+{
+ HbApplication app(argc, argv);
+
+ IconsView *view = new IconsView();
+
+ ActivityHandler handler(view);
+ QObject::connect(view, SIGNAL(activitySaveRequested(QString)), &handler, SLOT(handleSaveRequest(QString)));
+
+ QSignalMapper lastUseMapper;
+ lastUseMapper.setMapping(&app, "Autosave");
+ QObject::connect(&app, SIGNAL(aboutToQuit()), &lastUseMapper, SLOT(map()));
+ QObject::connect(&lastUseMapper, SIGNAL(mapped(QString)), &handler, SLOT(handleSaveRequest(QString)));
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodelhbintegration/activitytestmodel.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,12 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>data/img1.png</file>
+ <file>data/img2.png</file>
+ <file>data/img3.png</file>
+ <file>data/img4.png</file>
+ <file>data/img5.png</file>
+ <file>data/img6.png</file>
+ <file>data/img7.png</file>
+ <file>data/img8.png</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodelhbintegration/activitytestmodelhbintegration.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = activitytestmodelhbintegration
+
+CONFIG += console
+
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+SOURCES = iconsview.cpp \
+ main.cpp \
+
+HEADERS = iconsview.h \
+
+RESOURCES += activitytestmodel.qrc
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img1.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img2.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img3.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img4.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img5.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img6.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img7.PNG has changed
Binary file activityfw/testapplications/activitytestmodelhbintegration/data/img8.PNG has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodelhbintegration/iconsview.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,172 @@
+/*
+* Copyright (c) 2009 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 "iconsview.h"
+
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include <QSignalMapper>
+
+#include <hblistwidget.h>
+#include <hblabel.h>
+#include <hbpushbutton.h>
+#include <hbinstance.h>
+#include <hbapplication.h>
+#include <hbactivitymanager.h>
+#include <hbmainwindow.h>
+
+#include <QDebug>
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+IconsView::IconsView(QGraphicsItem *parent) : HbView(parent)
+{
+ setTitle("Activities -Hb Model");
+
+ mModel = new QStandardItemModel(this);
+ for (int i=1; i<=8; ++i) {
+ addItemToModel(i);
+ }
+
+ mList = new HbListView(this);
+ mList->setModel(mModel);
+
+ QGraphicsGridLayout *buttonsLayout = new QGraphicsGridLayout();
+ HbPushButton *addItemButton = new HbPushButton("Add item");
+ connect(addItemButton, SIGNAL(clicked()), this, SLOT(addItem()));
+ buttonsLayout->addItem(addItemButton, 0, 0);
+
+ HbPushButton *removeItemButtom = new HbPushButton("Remove item");
+ connect(removeItemButtom, SIGNAL(clicked()), this, SLOT(removeItem()));
+ buttonsLayout->addItem(removeItemButtom, 0, 1);
+
+ HbPushButton *saveActivityAButton = new HbPushButton("Save State A");
+ buttonsLayout->addItem(saveActivityAButton, 1, 0);
+ HbPushButton *saveActivityBButton = new HbPushButton("Save State B");
+ buttonsLayout->addItem(saveActivityBButton, 1, 1);
+
+ buttonsLayout->setRowFixedHeight(0, 50);
+ buttonsLayout->setRowFixedHeight(1, 50);
+
+ QSignalMapper *saveActivityMapper = new QSignalMapper(this);
+ saveActivityMapper->setMapping(saveActivityAButton, "State A");
+ saveActivityMapper->setMapping(saveActivityBButton, "State B");
+ connect(saveActivityAButton, SIGNAL(clicked()), saveActivityMapper, SLOT(map()));
+ connect(saveActivityBButton, SIGNAL(clicked()), saveActivityMapper, SLOT(map()));
+ connect(saveActivityMapper, SIGNAL(mapped(QString)), this, SLOT(saveActivity(QString)));
+
+ mItemCountLabel = new HbLabel();
+ mItemCountLabel->setAlignment(Qt::AlignCenter);
+ mItemCountLabel->setMaximumHeight(30);
+ updateCountLabel();
+
+ QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
+ mainLayout->addItem(mItemCountLabel);
+ mainLayout->addItem(mList);
+ mainLayout->addItem(buttonsLayout);
+
+ connect(hbApp->activityManager(), SIGNAL(activityRequested(QString)), this, SLOT(loadActivity(QString)));
+ bool ok = hbApp->activityManager()->waitActivity();
+ if (!ok) {
+ //qFatal("Subscribe failed");
+ }
+
+ setLayout(mainLayout);
+}
+
+IconsView::~IconsView()
+{
+}
+
+void IconsView::addItemToModel(int number)
+{
+ QStandardItem *item = new QStandardItem(QIcon(QString(":data\\img%1").arg(number)), QString("Image %1").arg(number));
+ mModel->appendRow(item);
+}
+
+void IconsView::addItem()
+{
+ addItemToModel(qrand() % 8 + 1);
+ updateCountLabel();
+}
+
+void IconsView::removeItem()
+{
+ if (mModel->rowCount() > 0) {
+ mModel->removeRow(mModel->rowCount() - 1, QModelIndex());
+ }
+ updateCountLabel();
+}
+
+void IconsView::updateCountLabel()
+{
+ mItemCountLabel->setPlainText(QString("List contains %1 items").arg(mModel->rowCount()));
+}
+
+QVariant IconsView::generateActivityData()
+{
+ QByteArray serializedModel;
+ {
+ QDataStream stream(&serializedModel, QIODevice::WriteOnly | QIODevice::Append);
+ for (int row = 0; row < mModel->rowCount(); ++row) {
+ stream << *mModel->item(row);
+ }
+ }
+ return serializedModel;
+}
+
+void IconsView::saveActivity(const QString &name)
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().value(0);
+ QVariantHash metadata;
+ metadata.insert("screenshot", QPixmap::grabWidget(mainWindow, mainWindow->rect()));
+ bool ok = hbApp->activityManager()->removeActivity(name);
+ if (!ok) {
+ //qFatal("Remove failed" );
+ }
+ ok = hbApp->activityManager()->addActivity(name, generateActivityData(), metadata);
+ if (!ok) {
+ qFatal("Add failed");
+ }
+}
+
+void IconsView::loadActivity(const QString &name)
+{
+ bool ok = hbApp->activityManager()->waitActivity();
+ if (!ok) {
+ //qFatal("Resubscribe failed");
+ }
+ QVariant data = hbApp->activityManager()->activityData(name);
+ loadActivity(data);
+}
+
+void IconsView::loadActivity(const QVariant &data)
+{
+ mModel->clear();
+ QByteArray serializedModel = data.toByteArray();
+ {
+ QDataStream stream(&serializedModel, QIODevice::ReadOnly);
+ while (!stream.atEnd()) {
+ QStandardItem *item = new QStandardItem();
+ stream >> *item;
+ mModel->appendRow(item);
+ }
+ }
+ updateCountLabel();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodelhbintegration/iconsview.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ICONSVIEW_H
+#define ICONSVIEW_H
+
+#include <hbview.h>
+
+class HbLabel;
+class QStandardItemModel;
+class HbListView;
+
+class IconsView : public HbView
+{
+ Q_OBJECT
+
+public:
+ IconsView(QGraphicsItem *parent = 0);
+ ~IconsView();
+
+private slots:
+ void addItem();
+ void removeItem();
+
+public slots:
+ void saveActivity(const QString &name);
+ void loadActivity(const QString &name);
+ void loadActivity(const QVariant &data);
+
+public:
+ QVariant generateActivityData();
+
+private:
+ void updateCountLabel();
+ void addItemToModel(int number);
+
+private:
+ QStandardItemModel *mModel;
+ HbLabel *mItemCountLabel;
+ HbListView *mList;
+};
+
+#endif // ICONSVIEW_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/activitytestmodelhbintegration/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+#include <QSignalMapper>
+
+#include "iconsview.h"
+
+int main(int argc, char *argv[])
+{
+ HbApplication app(argc, argv);
+
+ IconsView *view = new IconsView();
+
+ QSignalMapper lastUseMapper;
+ lastUseMapper.setMapping(&app, "Autosave");
+ QObject::connect(&app, SIGNAL(aboutToQuit()), &lastUseMapper, SLOT(map()));
+ QObject::connect(&lastUseMapper, SIGNAL(mapped(QString)), view, SLOT(saveActivity(QString)));
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+
+ if (app.activateReason() == Hb::ActivationReasonActivity) {
+ // start-up case
+ QVariant data = app.activateData();
+ view->loadActivity(data);
+
+ }
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/appactluncher/appactluncher.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = appactluncher
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+LIBS += -lxqutils
+LIBS += -lafactivitylauncher
+LIBS += -lapgrfx
+LIBS += -lws32
+
+HEADERS += lunchwidget.h
+
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/appactluncher/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QUrl>
+#include <qservicemanager.h>
+#include <afactivities_global.h>
+#include <hbcheckbox.h>
+#include <hbcombobox.h>
+#include <afactivitylauncher.h>
+#include <XQConversions>
+
+QTM_USE_NAMESPACE
+
+const QString KAppUid = "Efe0aa02";
+const QString KActUid = "Eba3ddd2";
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+
+ QServiceManager serviceManager;
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service.");
+ }
+ mBackgroundCheckBox = new HbCheckBox("background");
+ mBackgroundCheckBox->setCheckState(Qt::Unchecked);
+ mLunchButton = new HbPushButton("Lunch App");
+ mLunchButton1 = new HbPushButton("Lunch Act");
+ mResultLabel = new HbLabel;
+ mPlatformCombo = new HbComboBox();
+ mPlatformCombo->addItem("Qt");
+ mPlatformCombo->addItem("Symbian");
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mResultLabel, 0, 0, 1, 1);
+ mGridLayout->addItem(mLunchButton, 1, 0, 1, 1);
+ mGridLayout->addItem(mLunchButton1, 2, 0, 1, 1);
+ mGridLayout->addItem(mBackgroundCheckBox, 3, 0, 1, 1);
+ mGridLayout->addItem(mPlatformCombo, 4, 0, 1, 1);
+ setLayout(mGridLayout);
+
+
+ connect(mLunchButton, SIGNAL(released()), this, SLOT(lunchApp()));
+ connect(mLunchButton1, SIGNAL(released()), this, SLOT(lunchAct()));
+
+ User::LeaveIfError(mApaLsSession.Connect());
+ User::LeaveIfError(mWsSession.Connect());
+ mSymbianAL = CAfActivityLauncher::NewL(mApaLsSession, mWsSession) ;
+
+}
+
+lunchwidget::~lunchwidget()
+{
+ mApaLsSession.Close();
+ mWsSession.Close();
+ delete mSymbianAL;
+}
+
+void lunchwidget::lunchApp()
+{
+ QUrl url;
+ url.setScheme(Af::KActivityScheme);
+ url.setHost(KAppUid);
+ url.addQueryItem(Af::KActivityUriNameKey, "nonexist");
+ if (mBackgroundCheckBox->checkState() == Qt::Checked) {
+ url.addQueryItem(Af::KActivityUriBackgroundKey, "back");
+ }
+ url.addQueryItem("param1", "trompka");
+ QString debugString = url.toString();
+ lunch(url);
+}
+
+void lunchwidget::lunchAct()
+{
+ QUrl url;
+ url.setScheme(Af::KActivityScheme);
+ url.setHost(KActUid);
+ url.addQueryItem(Af::KActivityUriNameKey, "bold");
+ if (mBackgroundCheckBox->checkState() == Qt::Checked) {
+ url.addQueryItem(Af::KActivityUriBackgroundKey, "back");
+ }
+ url.addQueryItem("param1", "trompka");
+ QString debugString = url.toString();
+
+ lunch(url);
+}
+
+void lunchwidget::lunch(const QUrl& url)
+{
+ bool ok = true;
+ if(mPlatformCombo->currentText() == "Qt") {
+ ok = QMetaObject::invokeMethod(mActivityManager, "launchActivity", Q_ARG(QUrl, url) );
+ }
+ else {
+ HBufC *uriDescriptor = XQConversions::qStringToS60Desc(QString(url.toEncoded()));
+ TRAPD(err, mSymbianAL->launchActivityL(*uriDescriptor));
+ bool errbool = static_cast<bool>(err);
+ ok = !errbool;
+ delete uriDescriptor;
+ }
+
+ if ( ok ) {
+ mResultLabel->setPlainText( "ok" );
+ }
+ else {
+ mResultLabel->setPlainText( "fail" );
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/appactluncher/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCWIDGET_H_
+#define LUNCWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <APGCLI.H>
+#include <W32STD.H>
+
+class HbCheckBox;
+class HbComboBox;
+class CAfActivityLauncher;
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mLunchButton;
+ HbPushButton *mLunchButton1;
+ HbLabel* mResultLabel;
+ QObject *mActivityManager;
+ HbCheckBox* mBackgroundCheckBox;
+ HbComboBox *mPlatformCombo;
+
+ RApaLsSession mApaLsSession;
+ RWsSession mWsSession;
+ CAfActivityLauncher* mSymbianAL;
+
+private slots:
+ void lunchApp();
+ void lunchAct();
+
+private:
+ void lunch(const QUrl& url);
+};
+
+#endif /* LUNCWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/appactluncher/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "lunchwidget.h"
+
+
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/apptostart/apptostart.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = apptostart
+
+CONFIG += console
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+
+HEADERS += lunchwidget.h
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0xEfe0aa02
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/apptostart/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <hbapplication>
+#include <QStringList>
+
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+
+ mResultLabel = new HbLabel;
+ mResultLabel2 = new HbLabel;
+ mCountLabel = new HbLabel;
+ QStringList list = hbApp->arguments();
+ int count = list.count();
+ if ( count <= 1 ) {
+ mResultLabel->setPlainText("arg1: None");
+ mResultLabel2->setPlainText("arg2: None");
+ }
+ else if( count == 2 ) {
+ QString arg = list.at(1);
+ mResultLabel->setPlainText( tr("arg1: ") + arg );
+ mResultLabel2->setPlainText( "arg2: None" );
+ }
+ else {
+ QString arg1 = list.at(1);
+ mResultLabel->setPlainText( tr("arg1: ") + arg1 );
+ QString arg2 = list.at(2);
+ mResultLabel2->setPlainText( tr("arg2: ") + arg2 );
+ }
+
+ QString countstring;
+ countstring.setNum(count);
+ countstring = tr("arg count: ") + countstring;
+ mCountLabel->setPlainText(countstring);
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mResultLabel, 0, 0, 1, 1);
+ mGridLayout->addItem(mResultLabel2, 1, 0, 1, 1);
+ mGridLayout->addItem(mCountLabel, 2, 0, 1, 1);
+ setLayout(mGridLayout);
+
+
+}
+
+lunchwidget::~lunchwidget()
+{
+}
+
+void lunchwidget::lunch()
+{
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/apptostart/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCWIDGET_H_
+#define LUNCWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mLunchButton;
+ HbLabel* mResultLabel;
+ HbLabel* mResultLabel2;
+ HbLabel* mCountLabel;
+ QObject *mActivityManager;
+
+private slots:
+ void lunch();
+};
+
+#endif /* LUNCWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/apptostart/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "lunchwidget.h"
+
+
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/hbmeasuretest/hbmeasuretest.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,678 @@
+/*
+* Copyright (c) 2009 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 "hbmeasuretest.h"
+
+#include <QGridLayout>
+#include <HbLabel>
+#include <HbPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QList>
+#include <QVariantHash>
+#include <HbComboBox>
+#include <QBrush>
+#include <QPalette>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <QFile>
+#include <QTextStream>
+#include <e32std.h>
+#include <HbInstance>
+#include <qservicemanager.h>
+#include <HbScrollArea>
+
+const char ActivityApplicationKeyword [] = ":ApplicationId";
+const char ActivityActivityKeyword [] = ":ActivityName";
+const char ActivityScreenshotKeyword [] = "screenshot";
+
+QTM_USE_NAMESPACE
+
+MeasureTest::MeasureTest(QGraphicsItem *parent) : HbView(parent), mActivityClient(NULL), mByteArray(NULL)
+
+{
+ mFile = new QFile("c:\\measuretest.txt");
+ mFile->open(QIODevice::Append | QIODevice::Text);
+ mStream = new QTextStream(mFile);
+
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ QServiceManager serviceManager;
+ serviceManager.addService(":/activityserviceplugin.xml");
+ mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
+ if (!mActivityClient) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityClient service.");
+ }
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service.");
+ }
+
+ HbWidget* widget = new HbWidget;
+ HbScrollArea* scrollArea = new HbScrollArea;
+
+ mResultLabel = new HbLabel();
+ mItemLabel = new HbLabel();
+ mTimesLabel = new HbLabel("Times");
+ mBytesLabel = new HbLabel("Bytes");
+ mPixmapLabel = new HbLabel("Pixmap");
+ mSizeLabel = new HbLabel("Size(WxH)");
+
+ mPixmap = new QPixmap(":/images/wolf.bmp");
+ mEmptyPixmap = new QPixmap();
+
+
+ mTimesCombo = new HbComboBox();
+ mLengthCombo = new HbComboBox();
+ mPixmapCombo = new HbComboBox();
+ mWidthCombo = new HbComboBox();
+ mHeightCombo = new HbComboBox();
+
+ mTimesCombo->addItem("1");
+ mTimesCombo->addItem("2");
+ mTimesCombo->addItem("4");
+ mTimesCombo->addItem("5");
+ mTimesCombo->addItem("10");
+ mTimesCombo->addItem("20");
+ mTimesCombo->addItem("40");
+ mTimesCombo->addItem("60");
+
+ QVariant variant;
+ variant = 10;
+ mLengthCombo->addItem("10 B", variant);
+ variant = 100;
+ mLengthCombo->addItem("100 B", variant);
+ variant = 1024;
+ mLengthCombo->addItem("1 KB", variant);
+ variant = 10240;
+ mLengthCombo->addItem("10 KB", variant);
+ variant = 102400;
+ mLengthCombo->addItem("100 KB", variant);
+ variant = 1024*1024;
+ mLengthCombo->addItem("1 MB", variant);
+
+ mWidthCombo->addItem("360");
+ mWidthCombo->addItem("180");
+ mWidthCombo->addItem("128");
+ mWidthCombo->addItem("90");
+
+ mHeightCombo->addItem("640");
+ mHeightCombo->addItem("320");
+ mHeightCombo->addItem("160");
+ mHeightCombo->addItem("128");
+
+
+ mPixmapCombo->addItem("no");
+ mPixmapCombo->addItem("yes");
+ mPixmapCombo->addItem("grab");
+
+ mSaveButton = new HbPushButton("Add activities");
+ mGetButton = new HbPushButton("Get activities");
+ mDelButton = new HbPushButton("Delete activities");
+ mGetDataButton = new HbPushButton("Get activities data");
+ mUpdateButton = new HbPushButton("Update activities");
+ mThumbButton = new HbPushButton("Get act with thumb");
+ mGetDataTimesButton = new HbPushButton("Get data times");
+ mSaveTimesButton = new HbPushButton("Add act times");
+ mSave10TimesButton = new HbPushButton("Add 10 act times");;
+
+ mLayout = new QGraphicsGridLayout();
+ mLayout->addItem(mResultLabel, 0, 0, 1, 6);
+ mLayout->addItem(mItemLabel, 1, 0, 1, 6);
+ mLayout->addItem(mSizeLabel, 2, 0, 1, 2);
+ mLayout->addItem(mWidthCombo, 2, 2, 1, 2);
+ mLayout->addItem(mHeightCombo, 2, 4, 1, 2);
+ mLayout->addItem(mTimesLabel, 3, 0, 1, 2);
+ mLayout->addItem(mBytesLabel, 3, 2, 1, 2);
+ mLayout->addItem(mPixmapLabel, 3, 4, 1, 2);
+ mLayout->addItem(mTimesCombo, 4, 0, 1, 2);
+ mLayout->addItem(mLengthCombo, 4, 2, 1, 2);
+ mLayout->addItem(mPixmapCombo, 4, 4, 1, 2);
+ mLayout->addItem(mSaveButton, 5, 0, 1, 6);
+ mLayout->addItem(mGetButton, 6, 0, 1, 6);
+ mLayout->addItem(mDelButton, 7, 0, 1, 6);
+ mLayout->addItem(mGetDataButton, 8, 0, 1, 6);
+ mLayout->addItem(mUpdateButton, 9, 0, 1, 6);
+ mLayout->addItem(mThumbButton, 10, 0, 1, 6);
+ mLayout->addItem(mSaveTimesButton, 11, 0, 1, 6);
+ mLayout->addItem(mSave10TimesButton, 12, 0, 1, 6);
+ mLayout->addItem(mGetDataTimesButton, 13, 0, 1, 6);
+ widget->setLayout(mLayout);
+
+ scrollArea->setContentWidget(widget);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
+
+ connect(mSaveButton, SIGNAL(released()), this, SLOT(saveActivity()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(getActivity()));
+ connect(mDelButton, SIGNAL(released()), this, SLOT(deleteActivity()));
+ connect(mGetDataButton, SIGNAL(released()), this, SLOT(getActivityData()));
+ connect(mUpdateButton, SIGNAL(released()), this, SLOT(updateActivity()));
+ connect(mThumbButton, SIGNAL(released()), this, SLOT(getActivityThumb()));
+ connect(mGetDataTimesButton, SIGNAL(released()), this, SLOT(getTimesActivityData()));
+ connect(mSaveTimesButton, SIGNAL(released()), this, SLOT(saveTimes()));
+ connect(mSave10TimesButton, SIGNAL(released()), this, SLOT(save10actTimes()));
+
+ QGraphicsGridLayout* mainLayout = new QGraphicsGridLayout;
+ mainLayout->addItem(scrollArea, 0, 0, 1, 6);
+ setLayout(mainLayout);
+
+}
+
+MeasureTest::~MeasureTest()
+{
+ delete mFile;
+ delete mEmptyPixmap;
+ delete mPixmap;
+ delete mActivityClient;
+ delete mActivityManager;
+}
+
+
+void MeasureTest::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void MeasureTest::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void MeasureTest::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+void MeasureTest::deleteActivity()
+{
+ QList<QVariantHash> activities;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ bool retok = false;
+
+ if (ok) {
+ QString name;
+ Before();
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i).value(":ActivityName").toString();
+ ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name));
+ if (!ok || !retok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ }
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ if (!ok || !retok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mItemMessage = (tr("items: %1")).arg(activities.count());
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::getActivity()
+{
+ bool ok = false;
+ QList<QVariantHash> activities;
+ Before();
+ ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ After();
+ Result();
+ int count = activities.count();
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mItemMessage = (tr("items: %1")).arg(count);
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::getActivityThumb()
+{
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ bool ok = false;
+ QList<QVariantHash> activities;
+ Before();
+ ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ mThumbwait = activities.count();
+ int width = mWidthCombo->currentText().toInt();
+ int height = mHeightCombo->currentText().toInt();
+ QSize pixSize(width, height);
+ for ( int i=0; i<activities.count(); i++)
+ {
+ //QString app = activities.at(i).value(ActivityApplicationKeyword);
+ //QString act = activities.at(i).value(ActivityActivityKeyword);
+ QString pixfile = activities.at(i).value(ActivityScreenshotKeyword).toString();
+ ok = QMetaObject::invokeMethod(mActivityManager, "getThumbnail", Q_ARG(QSize, pixSize), Q_ARG(QString, pixfile), Q_ARG(void*, NULL));
+ if ( !ok )
+ {
+ break;
+ }
+ }
+
+ int count = activities.count();
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+ } else {
+ //connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ }
+
+
+}
+
+void MeasureTest::saveActivity()
+{
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert("screenshot", *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ bool retok = false;
+ Before();
+ for (int i=0; i<times; i++) {
+ QString name;
+ name.setNum(i);
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, variant), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok || !retok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::updateActivity()
+{
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert("screenshot", *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ bool retok = false;
+ Before();
+ for (int i=0; i<times; i++) {
+ QString name;
+ name.setNum(i);
+ ok = QMetaObject::invokeMethod(mActivityClient, "updateActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, variant), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok || !retok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::getActivityData()
+{
+ QList<QVariantHash> activities;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+
+ if (ok) {
+ QString name;
+ QVariant data;
+ Before();
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i).value(":ActivityName").toString();
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ }
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mItemMessage = (tr("items: %1")).arg(activities.count());
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::thumbnailReady(QPixmap pix, void * ptr)
+ {
+ if ( pix.isNull() )
+ {
+ mThumbnull++;
+ }
+ mThumbcurrent++;
+ mItemMessage = (tr("items: %1 from %2, but null %3")).arg(mThumbcurrent).arg(mThumbwait).arg(mThumbnull);
+ mItemLabel->setPlainText(mItemMessage);
+ mResultMessage = "";
+ mResultLabel->setPlainText(mResultMessage);
+ if (mThumbcurrent == mThumbwait)
+ {
+ After();
+ Result();
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ mResultLabel->setPlainText(mResultMessage);
+ }
+ }
+
+void MeasureTest::saveTimes()
+{
+ *mStream<<"save Times\n";
+ QList<int> trymeasure;
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert("screenshot", *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ bool retok = false;
+ QString name("0");
+ User::After(2000000); //2s
+ for (int i=0; i<times; i++) {
+ Before();
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, variant), Q_ARG(QVariantHash, metadata));
+ After();
+ Result();
+ if (!ok || !retok) {
+ break;
+ }
+ trymeasure.append(iResult);
+ ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name));
+ if (!ok || !retok) {
+ break;
+ }
+ User::After(2000000); //2s
+ }
+
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok || !retok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ *mStream<<"error\n";
+ } else {
+ int averageint = average(trymeasure);
+ mResultMessage = (tr("time: %1 ms")).arg(averageint);
+ writeResults(trymeasure, averageint);
+ }
+ mStream->flush();
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::save10actTimes()
+{
+ *mStream<<"save 10 act Times\n";
+ QList<int> trymeasure;
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert("screenshot", *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ bool retok = false;
+ QString name;
+ User::After(2000000); //2s
+ for(int i=0; i<times; i++) {
+ Before();
+ for (int i=0; i<10; i++) {
+
+ name.setNum(i);
+ ok = QMetaObject::invokeMethod(mActivityClient, "addActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name), Q_ARG(QVariant, variant), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ trymeasure.append(iResult);
+
+ QList<QVariantHash> activities;
+ ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+
+ if (ok) {
+ QString name;
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i).value(":ActivityName").toString();
+ ok = QMetaObject::invokeMethod(mActivityClient, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name));
+ if (!ok || !retok) {
+ break;
+ }
+ }
+ }
+ User::After(2000000); //2s
+
+ }
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok || !retok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ *mStream<<"error\n";
+ } else {
+ int averageint = average(trymeasure);
+ mResultMessage = (tr("time: %1 ms")).arg(averageint);
+ writeResults(trymeasure, averageint);
+ }
+ mStream->flush();
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+
+}
+
+void MeasureTest::getTimesActivityData()
+{
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ *mStream<<"get data Times\n";
+ QList<int> trymeasure;
+
+ QList<QVariantHash> activities;
+ bool ok = QMetaObject::invokeMethod(mActivityClient, "activities", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ User::After(2000000); //2s
+ if (ok) {
+ QString name;
+ QVariant data;
+ for(int i=0; i<times; i++) {
+ Before();
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i).value(":ActivityName").toString();
+ ok = QMetaObject::invokeMethod(mActivityClient, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ trymeasure.append(iResult);
+ User::After(2000000); //2s
+ }
+ }
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ *mStream<<"error\n";
+ } else {
+ int averageint = average(trymeasure);
+ mResultMessage = (tr("time: %1 ms")).arg(averageint);
+ writeResults(trymeasure, averageint);
+ }
+ mStream->flush();
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+
+}
+
+int MeasureTest::average(const QList<int>& list)
+{
+ int count = list.count();
+ int sum=0;
+ for(int i=0; i<count; i++) {
+ sum += list.at(i);
+ }
+ sum = (sum+0.5)/count;
+ return sum;
+}
+
+int MeasureTest::writeResults(const QList<int>& list, int average)
+{
+ for(int i=0; i<list.count(); i++){
+ *mStream<<"| ";
+ *mStream<<list.at(i);
+ *mStream<<" |\n";
+ }
+ *mStream<<"| ";
+ *mStream<<average;
+ *mStream<<" |\n";
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/hbmeasuretest/hbmeasuretest.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef MEASURETEST_H
+#define MEASURETEST_H
+
+#include <QWidget>
+#include <HbView>
+
+class HbLabel;
+class QString;
+class ActivityClient;
+class QPixmap;
+class QByteArray;
+class QVariant;
+class HbComboBox;
+class QGraphicsGridLayout;
+class HbPushButton;
+class QByteArray;
+class QFile;
+class QTextStream;
+
+class MeasureTest: public HbView
+{
+
+ Q_OBJECT
+
+public:
+ MeasureTest(QGraphicsItem *parent = 0);
+ ~MeasureTest();
+
+private slots:
+ void saveActivity();
+ void deleteActivity();
+ void getActivity();
+ void getActivityData();
+ void updateActivity();
+ void getActivityThumb();
+ void saveTimes();
+ void save10actTimes();
+ void getTimesActivityData();
+
+ void thumbnailReady(QPixmap pix, void * ptr);
+
+private:
+ void Before();
+ void After();
+ void Result();
+ int average(const QList<int>& list);
+ int writeResults(const QList<int>& list, int average);
+
+
+private:
+ HbLabel *mResultLabel;
+ HbLabel *mItemLabel;
+ HbLabel *mTimesLabel;
+ HbLabel *mPixmapLabel;
+ HbLabel *mBytesLabel;
+ HbLabel *mTypeLabel;
+ HbLabel *mSizeLabel;
+ QString mItemMessage;
+ QString mResultMessage;
+ QObject *mActivityClient;
+ QObject *mActivityManager;
+ QPixmap *mPixmap;
+ QPixmap *mEmptyPixmap;
+ HbComboBox *mTimesCombo;
+ HbComboBox *mLengthCombo;
+ HbComboBox *mPixmapCombo;
+ HbComboBox *mWidthCombo;
+ HbComboBox *mHeightCombo;
+ QGraphicsGridLayout *mLayout;
+ HbPushButton *mSaveButton;
+ HbPushButton *mDelButton;
+ HbPushButton *mGetButton;
+ HbPushButton *mGetDataButton;
+ HbPushButton *mUpdateButton;
+ HbPushButton *mThumbButton;
+ HbPushButton *mGetDataTimesButton;
+ HbPushButton *mSaveTimesButton;
+ HbPushButton *mSave10TimesButton;
+ QByteArray *mByteArray;
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+ int mThumbwait;
+ int mThumbnull;
+ int mThumbcurrent;
+
+ QFile* mFile;
+ QTextStream* mStream;
+
+
+
+};
+
+#endif //MEASURETEST_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/hbmeasuretest/hbmeasuretest.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = hbmeasuretest
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ hbmeasuretest.cpp \
+
+HEADERS += hbmeasuretest.h \
+
+RESOURCES += hbmeasuretest.qrc
+
+LIBS += -lafservice.dll \
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x2000000 // Min 2Mb, max 32Mb
+ TARGET.CAPABILITY = ALL -TCB
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/hbmeasuretest/hbmeasuretest.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/wolf.bmp</file>
+ <file alias="activityserviceplugin.xml">../../activityserviceplugin/data/afservice.xml</file>
+ </qresource>
+</RCC>
Binary file activityfw/testapplications/hbmeasuretest/images/wolf.bmp has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/hbmeasuretest/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+
+#include "hbmeasuretest.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MeasureTest *view = new MeasureTest;
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/actautobenchmark/actautobenchmark.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = actautobenchmark
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ hbmeasuretest.cpp \
+
+HEADERS += hbmeasuretest.h \
+
+
+
+LIBS += -lafservice
+LIBS += -lefsrv
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x2000000 // Min 2Mb, max 32Mb
+ TARGET.CAPABILITY = ALL -TCB
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/actautobenchmark/hbmeasuretest.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,642 @@
+/*
+* Copyright (c) 2009 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 "hbmeasuretest.h"
+
+#include <QGridLayout>
+#include <HbLabel>
+#include <HbPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+
+#include <QVariantHash>
+#include <HbComboBox>
+#include <QBrush>
+#include <QPalette>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <QFile>
+#include <QTextStream>
+#include <e32std.h>
+#include <HbInstance>
+#include <qservicemanager.h>
+#include <HbScrollArea>
+#include <afactivitystorage.h>
+#include <afactivation.h>
+#include "afstorageglobals.h"
+#include <HbCheckBox>
+#include <hblineedit.h>
+#include <f32file.h>
+
+QTM_USE_NAMESPACE
+
+const int KDefaultTimes = 10;
+const int KDefaultLoop = 10;
+const int KDefaultSaveBytes = 10*1024;
+const int KGet1Bytes = 10*1024;
+const int KGet2Bytes = 100*1024;
+const int KGet3Bytes = 1024*1024;
+const int KDefaultRepeat = 3;
+
+MeasureTest::MeasureTest(QGraphicsItem *parent) : HbView(parent), mByteArray(NULL),
+ mActionCounter(0)
+
+{
+ mFile = new QFile("c:\\data\\actautobenchmark.txt");
+ mFile->open(QIODevice::Append | QIODevice::Text);
+ mStream = new QTextStream(mFile);
+
+ QServiceManager serviceManager;
+ serviceManager.addService(":/activityserviceplugin.xml");
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service.");
+ }
+
+
+ mActivityStorage = new AfActivityStorage;
+ mActivation = new AfActivation;
+
+ mResultLabel = new HbLabel();
+ mItemLabel = new HbLabel();
+
+
+ mSaveOneButton = new HbPushButton("Save 1 in loop");
+ mSaveMoreButton = new HbPushButton("Save 10 in loop");
+ mGetButton = new HbPushButton("Get in loop");
+ mAllButton = new HbPushButton("All");
+
+
+ mLayout = new QGraphicsGridLayout();
+ mLayout->addItem(mResultLabel, 0, 0, 1, 6);
+ mLayout->addItem(mItemLabel, 1, 0, 1, 6);
+ mLayout->addItem(mSaveOneButton, 2, 0, 1, 6);
+ mLayout->addItem(mSaveMoreButton, 3, 0, 1, 6);
+ mLayout->addItem(mGetButton, 4, 0, 1, 6);
+ mLayout->addItem(mAllButton, 5, 0, 1, 6);
+ setLayout(mLayout);
+
+
+ connect(mSaveOneButton, SIGNAL(released()), this, SLOT(preClear()));
+ connect(mSaveMoreButton, SIGNAL(released()), this, SLOT(preClear()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(preClear()));
+ connect(mAllButton, SIGNAL(released()), this, SLOT(preClear()));
+
+ connect(mSaveOneButton, SIGNAL(released()), this, SLOT(saveOne()));
+ connect(mSaveMoreButton, SIGNAL(released()), this, SLOT(saveMore()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(getOne()));
+ connect(mAllButton, SIGNAL(released()), this, SLOT(all()));
+
+ connect(mSaveOneButton, SIGNAL(released()), this, SLOT(startTimer()));
+ connect(mSaveMoreButton, SIGNAL(released()), this, SLOT(startTimer()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(startTimer()));
+ connect(mAllButton, SIGNAL(released()), this, SLOT(startTimer()));
+
+ mTimer = new QTimer(this);
+ connect(mTimer, SIGNAL(timeout()), this, SLOT(timeout()));
+
+}
+
+MeasureTest::~MeasureTest()
+{
+ delete mFile;
+ delete mStream;
+ delete mActivityManager;
+ delete mActivityStorage;
+ delete mActivation;
+}
+
+
+void MeasureTest::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void MeasureTest::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void MeasureTest::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+
+int MeasureTest::average(const QList<int>& list)
+{
+ int count = list.count();
+ int sum=0;
+ for(int i=0; i<count; i++) {
+ sum += list.at(i);
+ }
+ sum = (sum+0.5)/count;
+ return sum;
+}
+
+int MeasureTest::writeResults(const QList<int>& list, int average)
+{
+ for(int i=0; i<list.count(); i++){
+ *mStream<<"| ";
+ *mStream<<list.at(i);
+ *mStream<<" |\n";
+ }
+ *mStream<<"| ";
+ *mStream<<average;
+ *mStream<<" |\n";
+}
+
+void MeasureTest::logError(const QString& mess)
+{
+ *mStream<<"*Fail: "<<mess<<" *\n";
+ mStream->flush();
+}
+
+bool MeasureTest::saveBytes(int bytes)
+{
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+
+
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+
+
+ bool ok = false;
+ QString name("0");
+
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ return ok;
+}
+
+bool MeasureTest::deleteActivities()
+{
+ QStringList activities = mActivityStorage->allActivities();
+ QString name;
+ bool ok = true;
+ for (int i=0; i<activities.count(); i++) {
+ ok = mActivityStorage->removeActivity(activities.at(i));
+ if (!ok) {
+ break;
+ }
+ }
+ return ok;
+}
+
+bool MeasureTest::saveOneInLoop(int action)
+{
+ int bytes = KDefaultSaveBytes;
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+
+
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+
+ int times = KDefaultTimes;
+ bool ok = false;
+ QString name("0");
+ ok = deleteActivities();
+ if(!ok) {
+ logError("Remove");
+ return false;
+ }
+ User::After(2000000); //2s
+
+ for (int i=0; i<times; i++) {
+ Before();
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ After();
+ Result();
+ if (!ok) {
+ break;
+ }
+ mResultsList[action].append(iResult);
+ ok = deleteActivities();
+ if(!ok) {
+ logError("Remove");
+ return false;
+ }
+ User::After(2000000); //2s
+ }
+
+ int averageint = average(mResultsList.at(action));
+ mResultsList[action].append(averageint);
+
+ if(!ok) {
+ logError("SaveOne");
+ }
+
+ return ok;
+
+}
+
+bool MeasureTest::saveMoreInLoop(int action)
+{
+ int bytes = KDefaultSaveBytes;
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+
+
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+
+ bool ok = deleteActivities();
+ if(!ok) {
+ logError("Remove");
+ return false;
+ }
+
+ int times = KDefaultTimes;
+
+
+ ok = false;
+ QString name;
+
+ User::After(2000000); //2s
+ for(int i=0; i<times; i++) {
+ Before();
+ for (int i=0; i<KDefaultLoop; i++) {
+
+ name.setNum(i);
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ if (!ok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ mResultsList[action].append(iResult);
+
+ QStringList activities = mActivityStorage->allActivities();
+
+ ok = deleteActivities();
+ if(!ok) {
+ logError("Remove");
+ return false;
+ }
+ User::After(2000000); //2s
+
+ }
+
+ int averageint = average(mResultsList.at(action));
+ averageint = (averageint+0.5)/KDefaultLoop;
+ mResultsList[action].append(averageint);
+
+ if(!ok) {
+ logError("SaveMore");
+ }
+
+ return ok;
+}
+
+bool MeasureTest::getOneInLoop(int bytes, int action)
+{
+ int times = KDefaultTimes;
+ bool ok = deleteActivities();
+ if(!ok) {
+ logError("Remove");
+ return false;
+ }
+ ok = saveBytes(bytes);
+ if(!ok) {
+ logError("SaveBytes");
+ return false;
+ }
+
+ QStringList activities = mActivityStorage->allActivities();
+
+
+ User::After(2000000); //2s
+ QString name;
+ QVariant data;
+
+ for(int i=0; i<times; i++) {
+ Before();
+ for (int i=0; i<activities.count(); i++) {
+ data = mActivityStorage->activityData(activities.at(i));
+ }
+ After();
+ Result();
+ mResultsList[action].append(iResult);
+ User::After(2000000); //2s
+ }
+
+ int averageint = average(mResultsList.at(action));
+ mResultsList[action].append(averageint);
+
+ if(!ok) {
+ logError("GetOne");
+ }
+
+ return ok;
+}
+
+void MeasureTest::saveOne()
+{
+ QList<int> l;
+ for(int i=0; i<KDefaultRepeat; i++) {
+ mActionsList.append("save1");
+ mResultsList.append(l);
+ }
+}
+
+void MeasureTest::saveMore()
+{
+ QList<int> l;
+ for(int i=0; i<KDefaultRepeat; i++) {
+ mActionsList.append("save10");
+ mResultsList.append(l);
+ }
+}
+
+void MeasureTest::getOne()
+{
+ QList<int> l;
+ for(int i=0; i<KDefaultRepeat; i++) {
+ mActionsList.append("get1");
+ mResultsList.append(l);
+ }
+ for(int i=0; i<KDefaultRepeat; i++) {
+ mActionsList.append("get2");
+ mResultsList.append(l);
+ }
+ for(int i=0; i<KDefaultRepeat; i++) {
+ mActionsList.append("get3");
+ mResultsList.append(l);
+ }
+}
+
+void MeasureTest::all()
+{
+ saveOne();
+ saveMore();
+ getOne();
+}
+
+void MeasureTest::timeout()
+{
+ if(mActionCounter == mActionsList.count()) {
+ mTimer->stop();
+ logResult();
+ enableControls(true);
+ return;
+ }
+ QString actionName = mActionsList.at(mActionCounter);
+ bool ok = false;
+
+ if(actionName == "save1") {
+ ok = saveOneInLoop(mActionCounter);
+ }
+ else if(actionName == "save10") {
+ ok = saveMoreInLoop(mActionCounter);
+ }
+ else if(actionName == "get1") {
+ ok = getOneInLoop(KGet1Bytes, mActionCounter);
+ }
+ else if(actionName == "get2") {
+ ok = getOneInLoop(KGet2Bytes, mActionCounter);
+ }
+ else if(actionName == "get3") {
+ ok = getOneInLoop(KGet3Bytes, mActionCounter);
+ }
+ else {
+ ok = false;
+ }
+
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ mItemMessage = (tr("action: %1")).arg(actionName);
+ mResultMessage = (tr("count: %1")).arg(mActionCounter).arg(ok);
+
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+
+ mActionCounter++;
+}
+
+void MeasureTest::preClear()
+{
+ mResultsList.clear();
+ mActionsList.clear();
+ mActionCounter = 0;
+ enableControls(false);
+}
+
+void MeasureTest::startTimer()
+{
+ mTimer->start(1);
+}
+
+void MeasureTest::logResult()
+{
+ QList<int> save1indexes;
+ QList<int> save10indexes;
+ QList<int> get1indexes;
+ QList<int> get2indexes;
+ QList<int> get3indexes;
+
+ for(int i=0; i<mActionsList.count(); i++) {
+ QString actionName = mActionsList.at(i);
+ if(actionName == "save1") {
+ save1indexes.append(i);
+ }
+ else if(actionName == "save10") {
+ save10indexes.append(i);
+ }
+ else if(actionName == "get1") {
+ get1indexes.append(i);
+ }
+ else if(actionName == "get2") {
+ get2indexes.append(i);
+ }
+ else if(actionName == "get3") {
+ get3indexes.append(i);
+ }
+ }
+ logSaveSummary(save1indexes, save10indexes);
+ logResult(save1indexes, 1, "Save one activity", "save");
+ logResult(save10indexes, 2, "Save 10 activities in loop", "save");
+
+ logGetSummary(get1indexes, get2indexes, get3indexes);
+ logResult(get1indexes, 1, "Get activities with 10 KB of data", "get");
+ logResult(get2indexes, 2, "Get activities with 100 KB of data", "get");
+ logResult(get3indexes, 3, "Get activities with 1 MB of data", "get");
+
+}
+
+void MeasureTest::logResult(const QList<int>& indexes, int caseno, const QString& mess, const QString& type)
+{
+ int indexno = indexes.count();
+ if(indexno == 0) {
+ return;
+ }
+
+ QString caseness = tr("---+++++ Case %1.\n\n").arg(caseno);
+ *mStream<<caseness;
+
+ *mStream<<mess<<"\n\n";
+
+ *mStream<<"| |";
+ for(int i=0; i<indexno; i++) {
+ QString mess = tr(" *Test %1 [ms]* |").arg(i);
+ *mStream<<mess;
+ }
+ *mStream<<"\n";
+ QString tempmess;
+ for(int i=0; i<KDefaultTimes+1; i++) {
+ if(i == KDefaultTimes) {
+ tempmess = tr("| *Average per one %1* |").arg(type);
+ }
+ else {
+ tempmess = tr("| *Sample %1* |").arg(i);
+ }
+ *mStream<<tempmess;
+
+ for(int j=0; j<indexno; j++) {
+ const QList<int>& reslist = mResultsList.at(indexes.at(j));
+ if(reslist.count()>i) {
+ int res = reslist.at(i);
+ *mStream<<" "<<res<<" |";
+ }
+ else {
+ *mStream<<" - |";
+ }
+ }
+ *mStream<<"\n";
+ }
+ *mStream<<"\n\n";
+ mStream->flush();
+}
+
+QString MeasureTest::middle(const QList<int>& list)
+{
+ if(list.count()==0) {
+ return "-";
+ }
+ QList<int> tlist = list;
+ qSort(tlist);
+ int count = tlist.count();
+ QString res;
+ res.setNum(tlist.at(count/2));
+ return res;
+}
+
+void MeasureTest::logSaveSummary(const QList<int>& indexes1, const QList<int>& indexes10)
+{
+ *mStream<<"---++++ Midle time of save activity - the faster and the slowest result has been rejected.\n\n";
+
+ QList<int> save1averages;
+ QList<int> save10averages;
+
+ for(int i=0; i<indexes1.count(); i++) {
+ const QList<int>& reslist = mResultsList.at(indexes1.at(i));
+ if(reslist.count()==KDefaultTimes+1) {
+ int d = reslist.at(KDefaultTimes);
+ save1averages.append(reslist.at(KDefaultTimes));
+ }
+ }
+
+ for(int i=0; i<indexes10.count(); i++) {
+ const QList<int>& reslist = mResultsList.at(indexes10.at(i));
+ if(reslist.count()==KDefaultTimes+1) {
+ save10averages.append(reslist.at(KDefaultTimes));
+ }
+ }
+ QString save1middle = middle(save1averages);
+ QString save10middle = middle(save10averages);
+
+ *mStream<<"| *Case no.* | *no. of saved activity in one measure* | *Midle time [ms]* |\n";
+ *mStream<<"| 1 | 1 | "<<save1middle<<" |\n";
+ *mStream<<"| 2 | 10 | "<<save10middle<<" |\n\n";
+ mStream->flush();
+}
+
+void MeasureTest::logGetSummary(const QList<int>& get1, const QList<int>& get2 , const QList<int>& get3)
+{
+ *mStream<<"---++++ Midle time of get activity - the faster and the slowest result has been rejected.\n\n";
+
+ QList<int> get1averages;
+ QList<int> get2averages;
+ QList<int> get3averages;
+
+ for(int i=0; i<get1.count(); i++) {
+ const QList<int>& reslist = mResultsList.at(get1.at(i));
+ if(reslist.count()==KDefaultTimes+1) {
+ get1averages.append(reslist.at(KDefaultTimes));
+ }
+ }
+
+ for(int i=0; i<get2.count(); i++) {
+ const QList<int>& reslist = mResultsList.at(get2.at(i));
+ if(reslist.count()==KDefaultTimes+1) {
+ get2averages.append(reslist.at(KDefaultTimes));
+ }
+ }
+
+ for(int i=0; i<get3.count(); i++) {
+ const QList<int>& reslist = mResultsList.at(get3.at(i));
+ if(reslist.count()==KDefaultTimes+1) {
+ get3averages.append(reslist.at(KDefaultTimes));
+ }
+ }
+ QString get1middle = middle(get1averages);
+ QString get2middle = middle(get2averages);
+ QString get3middle = middle(get3averages);
+
+ *mStream<<"| *Case no.* | *Data size [KB]* | *Midle time [ms]* |\n";
+ *mStream<<"| 1 | 10 | "<<get1middle<<" |\n";
+ *mStream<<"| 2 | 100 | "<<get2middle<<" |\n";
+ *mStream<<"| 3 | 1024 | "<<get3middle<<" |\n\n";
+ mStream->flush();
+}
+
+void MeasureTest::enableControls(bool enable)
+{
+ mSaveOneButton->setEnabled(enable);
+ mSaveMoreButton->setEnabled(enable);
+ mGetButton->setEnabled(enable);
+ mAllButton->setEnabled(enable);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/actautobenchmark/hbmeasuretest.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef MEASURETEST_H
+#define MEASURETEST_H
+
+#include <QWidget>
+#include <HbView>
+#include <afactivities_global.h>
+#include <QList>
+
+class HbLabel;
+class QString;
+class ActivityClient;
+class QPixmap;
+class QByteArray;
+class QVariant;
+class HbComboBox;
+class QGraphicsGridLayout;
+class HbPushButton;
+class QByteArray;
+class QFile;
+class QTextStream;
+class HbCheckBox;
+class AfActivityStorage;
+class AfActivation;
+class QTimer;
+
+class MeasureTest: public HbView
+{
+
+ Q_OBJECT
+
+public:
+ MeasureTest(QGraphicsItem *parent = 0);
+ ~MeasureTest();
+
+private slots:
+ void saveOne();
+ void saveMore();
+ void getOne();
+ void all();
+
+ void timeout();
+ void preClear();
+ void startTimer();
+
+private:
+ void Before();
+ void After();
+ void Result();
+ int average(const QList<int>& list);
+ int writeResults(const QList<int>& list, int average);
+ void logError(const QString& mess);
+
+ bool saveBytes(int bytes);
+ bool deleteActivities();
+ bool saveOneInLoop(int action);
+ bool saveMoreInLoop(int action);
+ bool getOneInLoop(int bytes, int action);
+
+ void logResult();
+ void logResult(const QList<int>& indexes, int caseno, const QString& mess, const QString& type);
+ QString middle(const QList<int>& list);
+ void logSaveSummary(const QList<int>& indexes1, const QList<int>& indexes10);
+ void logGetSummary(const QList<int>& get1, const QList<int>& get2 , const QList<int>& get3);
+
+ void enableControls(bool enable);
+
+
+private:
+ HbLabel *mResultLabel;
+ HbLabel *mItemLabel;
+ QString mItemMessage;
+ QString mResultMessage;
+
+ QGraphicsGridLayout *mLayout;
+ HbPushButton *mSaveOneButton;
+ HbPushButton *mSaveMoreButton;
+ HbPushButton *mGetButton;
+ HbPushButton *mAllButton;
+
+ QByteArray *mByteArray;
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+
+ QFile* mFile;
+ QTextStream* mStream;
+
+ AfActivityStorage* mActivityStorage;
+ AfActivation* mActivation;
+ QObject *mActivityManager;
+
+ QList<QString> mActionsList;
+ QList<QList<int> > mResultsList;
+
+ QTimer* mTimer;
+ int mActionCounter;
+
+};
+
+#endif //MEASURETEST_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/actautobenchmark/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+
+#include "hbmeasuretest.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MeasureTest *view = new MeasureTest;
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestanimal/activitytestanimal.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/africaelephant.jpg</file>
+ <file>images/africatiger.jpg</file>
+ <file>images/indiaelephant.jpg</file>
+ <file>images/syberiantiger.jpg</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestanimal/acttestanimal.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = acttestanimal
+
+CONFIG += console mobility
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ animalwidget.cpp \
+
+HEADERS += animalwidget.h \
+
+RESOURCES += activitytestanimal.qrc
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x800000 // Min 2Mb, max 8Mb
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestanimal/animalwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2009 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 "animalwidget.h"
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QApplication>
+#include <qservicemanager.h>
+#include "afstorageglobals.h"
+
+QTM_USE_NAMESPACE
+
+AnimalWidget::AnimalWidget(QWidget *parent) : QWidget(parent)
+{
+ QServiceManager serviceManager;
+ mActivityStorage = serviceManager.loadInterface("com.nokia.qt.activities.Storage");
+ if (!mActivityStorage) {
+ qFatal("load Storage plugin failed");
+ }
+
+ mActivaction = serviceManager.loadInterface("com.nokia.qt.activities.Activation");
+ if (!mActivaction) {
+ qFatal("load Activation plugin failed");
+ }
+
+ qRegisterMetaType<Af::ActivationReason>("Af::ActivationReason");
+ connect(mActivaction, SIGNAL(activated(Af::ActivationReason, QString, QVariantHash)), this, SLOT(loadActivity(Af::ActivationReason, QString, QVariantHash)));
+
+
+ mAnimalLabel = new QLabel();
+ mFileNameLabel = new QLabel("No image loaded");
+ QPushButton *africanElephantButton = new QPushButton("African elephant");
+ QPushButton *africanTigerButton = new QPushButton("African tiger");
+ QPushButton *indiaElephantButton = new QPushButton("India elephant");
+ QPushButton *siberianTigerButton = new QPushButton("Siberian tiger");
+ QPushButton *saveActivityButton = new QPushButton("Save activity");
+ QPushButton *quitButton = new QPushButton("Quit");
+
+ QGridLayout *layout = new QGridLayout();
+
+ layout->addWidget(mAnimalLabel, 0, 0, 1, 2);
+ layout->addWidget(mFileNameLabel, 1, 0, 1, 2);
+ layout->addWidget(africanElephantButton, 2, 0);
+ layout->addWidget(africanTigerButton, 2, 1);
+ layout->addWidget(indiaElephantButton, 3, 0);
+ layout->addWidget(siberianTigerButton, 3, 1);
+ layout->addWidget(saveActivityButton, 4, 0);
+ layout->addWidget(quitButton, 4, 1);
+
+ connect(saveActivityButton, SIGNAL(clicked()), this, SLOT(saveActivity()));
+ connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+ QSignalMapper *mapper = new QSignalMapper(this);
+ mapper->setMapping(africanElephantButton, ":/images/africaelephant.jpg");
+ mapper->setMapping(africanTigerButton, ":/images/africatiger.jpg");
+ mapper->setMapping(indiaElephantButton, ":/images/indiaelephant.jpg");
+ mapper->setMapping(siberianTigerButton, ":/images/syberiantiger.jpg");
+ connect(africanElephantButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ connect(africanTigerButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ connect(indiaElephantButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ connect(siberianTigerButton, SIGNAL(clicked()), mapper, SLOT(map()));
+
+ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(changeAnimalImage(QString)));
+
+ setLayout(layout);
+
+ //startup case
+ Af::ActivationReason reason;
+ bool ok = QMetaObject::invokeMethod(mActivaction, "reason", Q_RETURN_ARG(Af::ActivationReason, reason));
+ if (!ok) {
+ qFatal("Get reason failed");
+ }
+ QString actName;
+ QVariantHash parameters;
+ if (reason == Af::ActivationReasonActivity) {
+ ok = QMetaObject::invokeMethod(mActivaction, "name", Q_RETURN_ARG(QString, actName));
+ if (!ok) {
+ qFatal("Get name failed");
+ }
+ ok = QMetaObject::invokeMethod(mActivaction, "parameters", Q_RETURN_ARG(QVariantHash, parameters));
+ if (!ok) {
+ qFatal("Get parameter failed");
+ }
+
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actName));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ changeAnimalImage(data.toString());
+ }
+ //startup case end
+}
+
+AnimalWidget::~AnimalWidget()
+{
+ delete mActivityStorage;
+ delete mActivaction;
+}
+
+void AnimalWidget::changeAnimalImage(const QString &image)
+{
+ mAnimalLabel->setPixmap(QPixmap(image).scaled(QSize( 200, 300), Qt::KeepAspectRatio));
+ mFileNameLabel->setText(image);
+ mCurrentImage = image;
+}
+
+void AnimalWidget::saveActivity()
+{
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, *mAnimalLabel->pixmap());
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityStorage, "saveActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, "Activities - pure Qt"), Q_ARG(QVariant, QVariant(mCurrentImage)), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ qFatal("Save failed");
+ }
+}
+
+void AnimalWidget::loadActivity(Af::ActivationReason reason, const QString &name, QVariantHash parameter)
+{
+ QVariant data;
+ bool ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ changeAnimalImage(data.toString());
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestanimal/animalwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ANIMALWIDGET_H
+#define ANIMALWIDGET_H
+
+#include <QWidget>
+#include <QVariantHash>
+#include <afactivities_global.h>
+
+class QLabel;
+class QString;
+
+class AnimalWidget: public QWidget
+{
+
+ Q_OBJECT
+
+public:
+ AnimalWidget(QWidget *parent = 0);
+ ~AnimalWidget();
+
+private slots:
+ void changeAnimalImage(const QString &image);
+ void saveActivity();
+ void loadActivity(Af::ActivationReason reason, const QString &name, QVariantHash parameter);
+
+private:
+ QLabel *mAnimalLabel;
+ QLabel *mFileNameLabel;
+ QString mCurrentImage;
+ QObject *mActivityStorage;
+ QObject *mActivaction;
+};
+
+#endif //ANIMALWIDGET_H
Binary file activityfw/testapplications/newtestappset/acttestanimal/images/africaelephant.jpg has changed
Binary file activityfw/testapplications/newtestappset/acttestanimal/images/africatiger.jpg has changed
Binary file activityfw/testapplications/newtestappset/acttestanimal/images/indiaelephant.jpg has changed
Binary file activityfw/testapplications/newtestappset/acttestanimal/images/syberiantiger.jpg has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestanimal/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 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 <QApplication>
+
+#include "animalwidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ AnimalWidget widget;
+ widget.setMaximumSize(360,640);
+ widget.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ widget.showMaximized();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestbenchmark/acttestbenchmark.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = acttestbenchmark
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ hbmeasuretest.cpp \
+
+HEADERS += hbmeasuretest.h \
+
+RESOURCES += hbmeasuretest.qrc
+
+LIBS += -lafservice.dll \
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x2000000 // Min 2Mb, max 32Mb
+ TARGET.CAPABILITY = ALL -TCB
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestbenchmark/hbmeasuretest.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,603 @@
+/*
+* Copyright (c) 2009 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 "hbmeasuretest.h"
+
+#include <QGridLayout>
+#include <HbLabel>
+#include <HbPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QList>
+#include <QVariantHash>
+#include <HbComboBox>
+#include <QBrush>
+#include <QPalette>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <QFile>
+#include <QTextStream>
+#include <e32std.h>
+#include <HbInstance>
+#include <qservicemanager.h>
+#include <HbScrollArea>
+#include <afactivitystorage.h>
+#include <afactivation.h>
+#include "afstorageglobals.h"
+#include <HbCheckBox>
+
+
+QTM_USE_NAMESPACE
+
+MeasureTest::MeasureTest(QGraphicsItem *parent) : HbView(parent), mByteArray(NULL)
+
+{
+ mFile = new QFile("c:\\actbenchmark.txt");
+ mFile->open(QIODevice::Append | QIODevice::Text);
+ mStream = new QTextStream(mFile);
+
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ QServiceManager serviceManager;
+ serviceManager.addService(":/activityserviceplugin.xml");
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service.");
+ }
+
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ mActivityStorage = new AfActivityStorage;
+ mActivation = new AfActivation;
+
+ HbWidget* widget = new HbWidget;
+ HbScrollArea* scrollArea = new HbScrollArea;
+
+ mResultLabel = new HbLabel();
+ mItemLabel = new HbLabel();
+ mTimesLabel = new HbLabel("Times");
+ mBytesLabel = new HbLabel("Bytes");
+ mPixmapLabel = new HbLabel("Pixmap");
+ mSizeLabel = new HbLabel("Size(WxH)");
+
+ mPixmap = new QPixmap(":/images/wolf.bmp");
+ mEmptyPixmap = new QPixmap();
+
+
+ mTimesCombo = new HbComboBox();
+ mLengthCombo = new HbComboBox();
+ mPixmapCombo = new HbComboBox();
+ mWidthCombo = new HbComboBox();
+ mHeightCombo = new HbComboBox();
+
+ mTimesCombo->addItem("1");
+ mTimesCombo->addItem("2");
+ mTimesCombo->addItem("4");
+ mTimesCombo->addItem("5");
+ mTimesCombo->addItem("10");
+ mTimesCombo->addItem("20");
+ mTimesCombo->addItem("40");
+ mTimesCombo->addItem("60");
+
+ QVariant variant;
+ variant = 10;
+ mLengthCombo->addItem("10 B", variant);
+ variant = 100;
+ mLengthCombo->addItem("100 B", variant);
+ variant = 1024;
+ mLengthCombo->addItem("1 KB", variant);
+ variant = 10240;
+ mLengthCombo->addItem("10 KB", variant);
+ variant = 102400;
+ mLengthCombo->addItem("100 KB", variant);
+ variant = 1024*1024;
+ mLengthCombo->addItem("1 MB", variant);
+
+ mWidthCombo->addItem("360");
+ mWidthCombo->addItem("180");
+ mWidthCombo->addItem("128");
+ mWidthCombo->addItem("90");
+
+ mHeightCombo->addItem("640");
+ mHeightCombo->addItem("320");
+ mHeightCombo->addItem("160");
+ mHeightCombo->addItem("128");
+
+
+ mPixmapCombo->addItem("no");
+ mPixmapCombo->addItem("yes");
+ mPixmapCombo->addItem("grab");
+
+ mSaveButton = new HbPushButton("Save activities");
+ mGetButton = new HbPushButton("Get activities");
+ mDelButton = new HbPushButton("Delete activities");
+ mGetDataButton = new HbPushButton("Get activities data");
+ mUpdateButton = new HbPushButton("Reserved");
+ mThumbButton = new HbPushButton("Get act with thumb");
+ mGetDataTimesButton = new HbPushButton("Get data times");
+ mSaveTimesButton = new HbPushButton("Add act times");
+ mSave10TimesButton = new HbPushButton("Add 10 act times");;
+
+ mSaveDekCheckBox = new HbCheckBox("Delete before Save");
+ mSaveDekCheckBox->setCheckState(Qt::Checked);
+
+ mLayout = new QGraphicsGridLayout();
+ mLayout->addItem(mSizeLabel, 2, 0, 1, 2);
+ mLayout->addItem(mWidthCombo, 2, 2, 1, 2);
+ mLayout->addItem(mHeightCombo, 2, 4, 1, 2);
+ mLayout->addItem(mTimesLabel, 3, 0, 1, 2);
+ mLayout->addItem(mBytesLabel, 3, 2, 1, 2);
+ mLayout->addItem(mPixmapLabel, 3, 4, 1, 2);
+ mLayout->addItem(mTimesCombo, 4, 0, 1, 2);
+ mLayout->addItem(mLengthCombo, 4, 2, 1, 2);
+ mLayout->addItem(mPixmapCombo, 4, 4, 1, 2);
+ mLayout->addItem(mSaveButton, 5, 0, 1, 6);
+ mLayout->addItem(mGetButton, 6, 0, 1, 6);
+ mLayout->addItem(mDelButton, 7, 0, 1, 6);
+ mLayout->addItem(mGetDataButton, 8, 0, 1, 6);
+ mLayout->addItem(mUpdateButton, 9, 0, 1, 6);
+ mLayout->addItem(mThumbButton, 10, 0, 1, 6);
+ mLayout->addItem(mSaveTimesButton, 11, 0, 1, 6);
+ mLayout->addItem(mSave10TimesButton, 12, 0, 1, 6);
+ mLayout->addItem(mGetDataTimesButton, 13, 0, 1, 6);
+ mLayout->addItem(mSaveDekCheckBox, 14, 0, 1, 6);
+ widget->setLayout(mLayout);
+
+ scrollArea->setContentWidget(widget);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
+ connect(mSaveButton, SIGNAL(released()), this, SLOT(saveActivity()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(getActivity()));
+ connect(mDelButton, SIGNAL(released()), this, SLOT(deleteActivity()));
+ connect(mGetDataButton, SIGNAL(released()), this, SLOT(getActivityData()));
+ connect(mUpdateButton, SIGNAL(released()), this, SLOT(updateActivity()));
+ connect(mThumbButton, SIGNAL(released()), this, SLOT(getActivityThumb()));
+ connect(mGetDataTimesButton, SIGNAL(released()), this, SLOT(getTimesActivityData()));
+ connect(mSaveTimesButton, SIGNAL(released()), this, SLOT(saveTimes()));
+ connect(mSave10TimesButton, SIGNAL(released()), this, SLOT(save10actTimes()));
+
+ QGraphicsGridLayout* mainLayout = new QGraphicsGridLayout;
+ mainLayout->addItem(mResultLabel, 0, 0, 1, 6);
+ mainLayout->addItem(mItemLabel, 1, 0, 1, 6);
+ mainLayout->addItem(scrollArea, 2, 0, 1, 6);
+ setLayout(mainLayout);
+
+}
+
+MeasureTest::~MeasureTest()
+{
+ delete mFile;
+ delete mStream;
+ delete mEmptyPixmap;
+ delete mPixmap;
+ delete mActivityManager;
+ delete mActivityStorage;
+ delete mActivation;
+}
+
+
+void MeasureTest::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void MeasureTest::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void MeasureTest::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+void MeasureTest::deleteActivity()
+{
+ QStringList activities = mActivityStorage->allActivities();
+ QString name;
+ Before();
+ bool ok = false;
+ for (int i=0; i<activities.count(); i++) {
+ ok = mActivityStorage->removeActivity(activities.at(i));
+ if (!ok) {
+ break;
+ }
+ }
+ After();
+ Result();
+
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mItemMessage = (tr("items: %1")).arg(activities.count());
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::getActivity()
+{
+ QStringList activities;
+ Before();
+ activities = mActivityStorage->allActivities();
+ After();
+ Result();
+ int count = activities.count();
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ mItemMessage = (tr("items: %1")).arg(count);
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::getActivityThumb()
+{
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ bool ok = false;
+ QStringList activities;
+ Before();
+ activities = mActivityStorage->allActivities();
+ mThumbwait = activities.count();
+ int width = mWidthCombo->currentText().toInt();
+ int height = mHeightCombo->currentText().toInt();
+ QSize pixSize(width, height);
+ for ( int i=0; i<activities.count(); i++)
+ {
+ QString pixfile = mActivityStorage->activityMetaData(activities.at(i)).value(ActivityScreenshotKeyword).toString();
+ ok = QMetaObject::invokeMethod(mActivityManager, "getThumbnail", Q_ARG(QSize, pixSize), Q_ARG(QString, pixfile), Q_ARG(void*, NULL));
+ if ( !ok )
+ {
+ break;
+ }
+ }
+
+ int count = activities.count();
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+ } else {
+
+ }
+}
+
+void MeasureTest::saveActivity()
+{
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ Before();
+ for (int i=0; i<times; i++) {
+ QString name;
+ name.setNum(i);
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ if (!ok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ } else {
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ }
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::updateActivity()
+{
+
+}
+
+void MeasureTest::getActivityData()
+{
+ QStringList activities = mActivityStorage->allActivities();
+
+ QString name;
+ QVariant data;
+ Before();
+ for (int i=0; i<activities.count(); i++) {
+ data = mActivityStorage->activityData(activities.at(i));
+ }
+ After();
+ Result();
+
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+ mItemMessage = (tr("items: %1")).arg(activities.count());
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::thumbnailReady(QPixmap pix, void * ptr)
+ {
+ if ( pix.isNull() )
+ {
+ mThumbnull++;
+ }
+ mThumbcurrent++;
+ mItemMessage = (tr("items: %1 from %2, but null %3")).arg(mThumbcurrent).arg(mThumbwait).arg(mThumbnull);
+ mItemLabel->setPlainText(mItemMessage);
+ mResultMessage = "";
+ mResultLabel->setPlainText(mResultMessage);
+ if (mThumbcurrent == mThumbwait)
+ {
+ After();
+ Result();
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ mResultMessage = (tr("time: %1 ms")).arg(iResult);
+ mResultLabel->setPlainText(mResultMessage);
+ }
+ }
+void MeasureTest::saveTimes()
+{
+ *mStream<<"save Times\n";
+ QList<int> trymeasure;
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ QString name("0");
+ bool delBefore = mSaveDekCheckBox->checkState() == Qt::Checked ? true : false;
+ User::After(2000000); //2s
+ for (int i=0; i<times; i++) {
+ Before();
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ After();
+ Result();
+ if (!ok) {
+ break;
+ }
+ trymeasure.append(iResult);
+ if (delBefore) {
+ ok = mActivityStorage->removeActivity(name);
+ if (!ok) {
+ break;
+ }
+ }
+ User::After(2000000); //2s
+ }
+
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ *mStream<<"error\n";
+ } else {
+ int averageint = average(trymeasure);
+ mResultMessage = (tr("time: %1 ms")).arg(averageint);
+ writeResults(trymeasure, averageint);
+ }
+ mStream->flush();
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+}
+
+void MeasureTest::save10actTimes()
+{
+ *mStream<<"save 10 act Times\n";
+ QList<int> trymeasure;
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ bool delBefore = mSaveDekCheckBox->checkState() == Qt::Checked ? true : false;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ QString name;
+ User::After(2000000); //2s
+ for(int i=0; i<times; i++) {
+ Before();
+ for (int i=0; i<10; i++) {
+
+ name.setNum(i);
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ if (!ok) {
+ break;
+ }
+ }
+ After();
+ Result();
+ trymeasure.append(iResult);
+
+ QStringList activities = mActivityStorage->allActivities();
+
+ if (delBefore) {
+ for (int i=0; i<activities.count(); i++) {
+ ok = mActivityStorage->removeActivity(activities.at(i));
+ if (!ok) {
+ break;
+ }
+ }
+ }
+ User::After(2000000); //2s
+
+ }
+ mItemMessage.clear();
+ mResultMessage.clear();
+ if (!ok) {
+ mItemMessage = (tr("invoke error"));
+ mResultMessage = (tr("invoke error"));
+ *mStream<<"error\n";
+ } else {
+ int averageint = average(trymeasure);
+ mResultMessage = (tr("time: %1 ms")).arg(averageint);
+ writeResults(trymeasure, averageint);
+ }
+ mStream->flush();
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+
+}
+
+void MeasureTest::getTimesActivityData()
+{
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ *mStream<<"get data Times\n";
+ QList<int> trymeasure;
+
+ QStringList activities = mActivityStorage->allActivities();
+ User::After(2000000); //2s
+ QString name;
+ QVariant data;
+ for(int i=0; i<times; i++) {
+ Before();
+ for (int i=0; i<activities.count(); i++) {
+ data = mActivityStorage->activityData(activities.at(i));
+ }
+ After();
+ Result();
+ trymeasure.append(iResult);
+ User::After(2000000); //2s
+ }
+ mItemMessage.clear();
+ mResultMessage.clear();
+
+
+ int averageint = average(trymeasure);
+ mResultMessage = (tr("time: %1 ms")).arg(averageint);
+ writeResults(trymeasure, averageint);
+
+ mStream->flush();
+ mItemLabel->setPlainText(mItemMessage);
+ mResultLabel->setPlainText(mResultMessage);
+
+}
+
+int MeasureTest::average(const QList<int>& list)
+{
+ int count = list.count();
+ int sum=0;
+ for(int i=0; i<count; i++) {
+ sum += list.at(i);
+ }
+ sum = (sum+0.5)/count;
+ return sum;
+}
+
+int MeasureTest::writeResults(const QList<int>& list, int average)
+{
+ for(int i=0; i<list.count(); i++){
+ *mStream<<"| ";
+ *mStream<<list.at(i);
+ *mStream<<" |\n";
+ }
+ *mStream<<"| ";
+ *mStream<<average;
+ *mStream<<" |\n";
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestbenchmark/hbmeasuretest.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef MEASURETEST_H
+#define MEASURETEST_H
+
+#include <QWidget>
+#include <HbView>
+#include <afactivities_global.h>
+
+class HbLabel;
+class QString;
+class ActivityClient;
+class QPixmap;
+class QByteArray;
+class QVariant;
+class HbComboBox;
+class QGraphicsGridLayout;
+class HbPushButton;
+class QByteArray;
+class QFile;
+class QTextStream;
+class HbCheckBox;
+class AfActivityStorage;
+class AfActivation;
+
+class MeasureTest: public HbView
+{
+
+ Q_OBJECT
+
+public:
+ MeasureTest(QGraphicsItem *parent = 0);
+ ~MeasureTest();
+
+private slots:
+ void saveActivity();
+ void deleteActivity();
+ void getActivity();
+ void getActivityData();
+ void updateActivity();
+ void getActivityThumb();
+ void saveTimes();
+ void save10actTimes();
+ void getTimesActivityData();
+
+ void thumbnailReady(QPixmap pix, void * ptr);
+
+private:
+ void Before();
+ void After();
+ void Result();
+ int average(const QList<int>& list);
+ int writeResults(const QList<int>& list, int average);
+
+
+private:
+ HbLabel *mResultLabel;
+ HbLabel *mItemLabel;
+ HbLabel *mTimesLabel;
+ HbLabel *mPixmapLabel;
+ HbLabel *mBytesLabel;
+ HbLabel *mTypeLabel;
+ HbLabel *mSizeLabel;
+ QString mItemMessage;
+ QString mResultMessage;
+ QPixmap *mPixmap;
+ QPixmap *mEmptyPixmap;
+ HbComboBox *mTimesCombo;
+ HbComboBox *mLengthCombo;
+ HbComboBox *mPixmapCombo;
+ HbComboBox *mWidthCombo;
+ HbComboBox *mHeightCombo;
+ QGraphicsGridLayout *mLayout;
+ HbPushButton *mSaveButton;
+ HbPushButton *mDelButton;
+ HbPushButton *mGetButton;
+ HbPushButton *mGetDataButton;
+ HbPushButton *mUpdateButton;
+ HbPushButton *mThumbButton;
+ HbPushButton *mGetDataTimesButton;
+ HbPushButton *mSaveTimesButton;
+ HbPushButton *mSave10TimesButton;
+ HbCheckBox* mSaveDekCheckBox;
+ QByteArray *mByteArray;
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+ int mThumbwait;
+ int mThumbnull;
+ int mThumbcurrent;
+ QFile* mFile;
+ QTextStream* mStream;
+
+ AfActivityStorage* mActivityStorage;
+ AfActivation* mActivation;
+ QObject *mActivityManager;
+
+};
+
+#endif //MEASURETEST_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestbenchmark/hbmeasuretest.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/wolf.bmp</file>
+ <file alias="activityserviceplugin.xml">../../../activityserviceplugin/data/afservice.xml</file>
+ </qresource>
+</RCC>
Binary file activityfw/testapplications/newtestappset/acttestbenchmark/images/wolf.bmp has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestbenchmark/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+
+#include "hbmeasuretest.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ MeasureTest *view = new MeasureTest;
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/activitydebuger.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,528 @@
+/*
+* Copyright (c) 2009 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 "activitydebuger.h"
+
+#include <QGridLayout>
+#include <HbLabel>
+#include <HbPushButton>
+#include <QCoreApplication>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QList>
+#include <QVariantHash>
+#include <HbComboBox>
+#include <QBrush>
+#include <QPalette>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <e32std.h>
+#include <HbInstance>
+
+#include <qservicemanager.h>
+#include "activitydebugerconsole.h"
+
+#include <afactivitystorage.h>
+#include <afactivation.h>
+#include "afstorageglobals.h"
+
+
+QTM_USE_NAMESPACE
+
+ActivityDebuger::ActivityDebuger(QGraphicsItem *parent) : HbView(parent), mByteArray(NULL)
+{
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ QServiceManager serviceManager;
+ serviceManager.addService(":/activityserviceplugin.xml");
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("Cannot initialize critical com.nokia.qt.activities.ActivityManager service.");
+ }
+
+ mActivityStorage = new AfActivityStorage;
+ mActivation = new AfActivation;
+ qRegisterMetaType<Af::ActivationReason>("Af::ActivationReason");
+ connect(mActivation, SIGNAL(activated(Af::ActivationReason, QString, QVariantHash)), this, SLOT(loadActivityData(Af::ActivationReason, QString, QVariantHash)));
+
+
+ mTimesLabel = new HbLabel("Times");
+ mBytesLabel = new HbLabel("Bytes");
+ mPixmapLabel = new HbLabel("Pixmap");
+ mSizeLabel = new HbLabel("Size(WxH)");
+
+ mPixmap = new QPixmap(":/images/wolf.bmp");
+ mPixmap2 = new QPixmap(":/images/bird.bmp");
+ mEmptyPixmap = new QPixmap();
+
+
+ mTimesCombo = new HbComboBox();
+ mLengthCombo = new HbComboBox();
+ mPixmapCombo = new HbComboBox();
+ mWidthCombo = new HbComboBox();
+ mHeightCombo = new HbComboBox();
+
+ mTimesCombo->addItem("1");
+ mTimesCombo->addItem("2");
+ mTimesCombo->addItem("4");
+ mTimesCombo->addItem("5");
+ mTimesCombo->addItem("10");
+ mTimesCombo->addItem("20");
+ mTimesCombo->addItem("40");
+ mTimesCombo->addItem("60");
+
+ QVariant variant;
+ variant = 10;
+ mLengthCombo->addItem("10 B", variant);
+ variant = 100;
+ mLengthCombo->addItem("100 B", variant);
+ variant = 1024;
+ mLengthCombo->addItem("1 KB", variant);
+ variant = 10240;
+ mLengthCombo->addItem("10 KB", variant);
+ variant = 102400;
+ mLengthCombo->addItem("100 KB", variant);
+ variant = 1024*1024;
+ mLengthCombo->addItem("1 MB", variant);
+
+ mWidthCombo->addItem("360");
+ mWidthCombo->addItem("180");
+ mWidthCombo->addItem("128");
+ mWidthCombo->addItem("90");
+
+ mHeightCombo->addItem("640");
+ mHeightCombo->addItem("320");
+ mHeightCombo->addItem("160");
+ mHeightCombo->addItem("128");
+
+
+ mPixmapCombo->addItem("no");
+ mPixmapCombo->addItem("yes");
+ mPixmapCombo->addItem("grab");
+
+ mSaveButton = new HbPushButton("Save");
+ mGetButton = new HbPushButton("Activities");
+ mDelButton = new HbPushButton("Delete");
+ mGetDataButton = new HbPushButton("Get data");
+ mGetMyButton = new HbPushButton("Get my");
+ mThumbButton = new HbPushButton("Get pixmaps");
+ mClearButton = new HbPushButton("Clear");
+ mDelMyButton = new HbPushButton("Reserved");
+
+ mConsole = new ActivityDebugerConsole;
+
+ mLayout = new QGraphicsGridLayout();
+ mLayout->addItem(mConsole, 0, 0, 3, 6);
+ mLayout->addItem(mSizeLabel, 3, 0, 1, 2);
+ mLayout->addItem(mWidthCombo, 3, 2, 1, 2);
+ mLayout->addItem(mHeightCombo, 3, 4, 1, 2);
+ mLayout->addItem(mTimesLabel, 4, 0, 1, 2);
+ mLayout->addItem(mBytesLabel, 4, 2, 1, 2);
+ mLayout->addItem(mPixmapLabel, 4, 4, 1, 2);
+ mLayout->addItem(mTimesCombo, 5, 0, 1, 2);
+ mLayout->addItem(mLengthCombo, 5, 2, 1, 2);
+ mLayout->addItem(mPixmapCombo, 5, 4, 1, 2);
+ mLayout->addItem(mClearButton, 6, 0, 1, 3);
+ mLayout->addItem(mGetDataButton, 6, 3, 1, 3);
+ mLayout->addItem(mSaveButton, 7, 0, 1, 3);
+ mLayout->addItem(mGetMyButton, 7, 3, 1, 3);
+ mLayout->addItem(mGetButton, 8, 0, 1, 2);
+ mLayout->addItem(mThumbButton, 8, 2, 1, 4);
+ mLayout->addItem(mDelButton, 9, 0, 1, 3);
+ mLayout->addItem(mDelMyButton, 9, 3, 1, 3);
+
+
+
+ setLayout(mLayout);
+
+ connect(mSaveButton, SIGNAL(released()), this, SLOT(saveActivity()));
+ connect(mGetButton, SIGNAL(released()), this, SLOT(getActivity()));
+ connect(mDelButton, SIGNAL(released()), this, SLOT(deleteActivity()));
+ connect(mGetDataButton, SIGNAL(released()), this, SLOT(getActivityData()));
+ connect(mGetMyButton, SIGNAL(released()), this, SLOT(getMyActivity()));
+ connect(mThumbButton, SIGNAL(released()), this, SLOT(getActivityThumb()));
+ connect(mClearButton, SIGNAL(released()), mConsole, SLOT(clear()));
+
+
+
+}
+
+ActivityDebuger::~ActivityDebuger()
+{
+ delete mEmptyPixmap;
+ delete mPixmap;
+ delete mPixmap2;
+ delete mActivityManager;
+ delete mActivityStorage;
+ delete mActivation;
+}
+
+
+void ActivityDebuger::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void ActivityDebuger::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void ActivityDebuger::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+void ActivityDebuger::deleteActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Remove all:\n";
+ QStringList activities = mActivityStorage->allActivities();
+
+ int items = 0;
+ bool ok = false;
+ QString actname;
+ for (int i=0; i<activities.count(); i++) {
+ actname = activities.at(i);
+ ok = mActivityStorage->removeActivity(actname);
+
+ mItemMeaage += "*";
+ mItemMeaage += actname;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += res;
+
+ mItemMeaage += "*\n";
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+
+ UpdateConsole();
+
+}
+
+void ActivityDebuger::getActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activities list:\n";
+ bool ok = false;
+ QList<QVariantHash> activities;
+ ok = QMetaObject::invokeMethod(mActivityManager, "activitiesList", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ if ( ok )
+ {
+ int items = 0;
+ for ( int i=0; i<activities.count(); i++)
+ {
+ getMetadata(activities.at(i));
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ }
+ else
+ {
+ mItemMeaage += "*Failed*\n";
+ }
+ UpdateConsole();
+}
+
+void ActivityDebuger::getMetadata(QVariantHash varianthash)
+{
+ QString actname = varianthash.value(ActivityActivityKeyword).toString();
+ int appid = varianthash.value(ActivityApplicationKeyword).toInt();
+ mItemMeaage += "*";
+ QString aid;
+ aid.setNum(appid);
+ mItemMeaage += aid;
+ mItemMeaage += "; ";
+ mItemMeaage += actname;
+ mItemMeaage += "; ";
+ QString pixfile = varianthash.value(ActivityScreenshotKeyword).toString();
+ mItemMeaage += pixfile;
+ QVariantHash::const_iterator node(varianthash.find(ActivityVisibility));
+ QString visible;
+ if ( varianthash.end() != node )
+ {
+ bool vis = node.value().toBool();
+ visible.setNum(vis);
+ }
+ else
+ {
+ visible = "none";
+ }
+
+ QVariantHash::const_iterator node2(varianthash.find(ActivityPersistence));
+ QString persistence;
+ if ( varianthash.end() != node2 )
+ {
+ bool per = node2.value().toBool();
+ persistence.setNum(per);
+ }
+ else
+ {
+ persistence = "none";
+ }
+
+
+ QVariantHash::const_iterator node3(varianthash.find(ActivityApplicationName));
+ QString display;
+ if ( varianthash.end() != node3 )
+ {
+ display = node3.value().toString();
+ }
+ else
+ {
+ persistence = "none";
+ }
+
+ mItemMeaage += "; ";
+ mItemMeaage += visible;
+ mItemMeaage += "; ";
+ mItemMeaage += persistence;
+ mItemMeaage += "; ";
+ mItemMeaage += display;
+}
+
+void ActivityDebuger::getActivityThumb()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activities pixmaps:\n";
+ UpdateConsole();
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ mThumbwait = 0;
+ mThumbnull = 0;
+ mThumbcurrent = 0;
+ bool ok = false;
+ QList<QVariantHash> activities;
+
+ ok = QMetaObject::invokeMethod(mActivityManager, "activitiesList", Q_RETURN_ARG(QList<QVariantHash>, activities));
+ if ( ok )
+ {
+ mThumbwait = activities.count();
+ int width = mWidthCombo->currentText().toInt();
+ int height = mHeightCombo->currentText().toInt();
+ QSize pixSize(width, height);
+ for ( int i=0; i<activities.count(); i++)
+ {
+ QString actname = activities.at(i).value(ActivityActivityKeyword).toString();
+ int appid = activities.at(i).value(ActivityApplicationKeyword).toInt(&ok);
+ QString pixfile;
+ if ( ok )
+ {
+ pixfile = activities.at(i).value(ActivityScreenshotKeyword).toString();
+ void* userdata = reinterpret_cast<void*>(i);
+ ok = QMetaObject::invokeMethod(mActivityManager, "getThumbnail", Q_ARG(QSize, pixSize), Q_ARG(QString, pixfile), Q_ARG(void*, userdata));
+ }
+
+ mItemMeaage = "*";
+ QString aid;
+ aid.setNum(appid);
+ mItemMeaage += aid;
+ mItemMeaage += "; ";
+ mItemMeaage += actname;
+ mItemMeaage += "; ";
+ QString locid = tr("locid=%1").arg(i);
+ mItemMeaage += locid;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+ UpdateConsole();
+ }
+ }
+ else
+ {
+ mItemMeaage += "*Failed*\n";
+ UpdateConsole();
+ }
+
+}
+
+void ActivityDebuger::saveActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Save:\n";
+ int bytes = mLengthCombo->itemData(mLengthCombo->currentIndex()).toInt();
+ delete mByteArray;
+ mByteArray = NULL;
+ mByteArray = new QByteArray(bytes, 'a');
+ QVariant variant;
+ variant = *mByteArray;
+ QPixmap *pixmap = NULL;
+ QPixmap screenshot;
+ if (mPixmapCombo->currentText() == "yes") {
+ pixmap = mPixmap;
+ }
+ else if ( mPixmapCombo->currentText() == "grab" )
+ {
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ pixmap = &screenshot;
+ }
+ else
+ {
+ pixmap = mEmptyPixmap;
+ }
+
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, *pixmap);
+ int times = 0;
+ times = mTimesCombo->currentText().toInt();
+ bool ok = false;
+ int items = 0;
+ for (int i=0; i<times; i++) {
+ QString name;
+ name.setNum(i);
+ metadata.insert(ActivityApplicationName, name);
+ ok = mActivityStorage->saveActivity(name, variant, metadata);
+ mItemMeaage += "*";
+ mItemMeaage += name;
+ mItemMeaage += "; ";
+ QString res;
+ res.setNum(ok);
+ mItemMeaage += res;
+ mItemMeaage += "*\n";
+
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ UpdateConsole();
+}
+
+void ActivityDebuger::getMyActivity()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Get my activities:\n";
+ QStringList activities = mActivityStorage->allActivities();
+ QString name;
+ QVariantHash data;
+ int items = 0;
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i);
+ data = mActivityStorage->activityMetaData(activities.at(i));
+ getMetadata(data);
+ items++;
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+ UpdateConsole();
+}
+
+void ActivityDebuger::getActivityData()
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activities data:\n";
+ QStringList activities = mActivityStorage->allActivities();
+
+ QString name;
+ QVariant data;
+ int items = 0;
+ for (int i=0; i<activities.count(); i++) {
+ name = activities.at(i);
+ data = mActivityStorage->activityData(activities.at(i));
+ const char* type = data.typeName();
+ QString dtype(type);
+ items++;
+
+ mItemMeaage += "*";
+ mItemMeaage += name;
+ mItemMeaage += "; ";
+ mItemMeaage += dtype;
+ mItemMeaage += "; ";
+ mItemMeaage += "*\n";
+ }
+ mItemMeaage += tr("*Items %1*\n").arg(items);
+
+ UpdateConsole();
+}
+
+void ActivityDebuger::thumbnailReady(QPixmap pix, void * ptr)
+ {
+ mItemMeaage.clear();
+ QString pixsize;
+ if ( pix.isNull() )
+ {
+ mThumbnull++;
+ pixsize = "null";
+ }
+ else
+ {
+ QSize size = pix.size();
+ int w = size.width();
+ int h = size.height();
+ pixsize = tr("%1x%2").arg(w).arg(h);
+ }
+ int loc_id = reinterpret_cast<int>(ptr);
+ QString locid;
+ locid = tr("locid=%1").arg(loc_id);
+ mThumbcurrent++;
+
+ mItemMeaage += "*";
+ mItemMeaage += locid;
+ mItemMeaage += "; ";
+ mItemMeaage += pixsize;
+ mItemMeaage += "*\n";
+
+ if (mThumbcurrent == mThumbwait)
+ {
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ QString screennum = tr("*screennum: %1*\n").arg(mThumbwait);
+ mItemMeaage += screennum;
+ }
+ UpdateConsole();
+ }
+
+void ActivityDebuger::UpdateConsole()
+ {
+ mConsole->appendText(mItemMeaage);
+ mConsole->scrollToBotton();
+ }
+
+void ActivityDebuger::loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter)
+{
+ mItemMeaage.clear();
+ mItemMeaage += "***Activity requested:\n";
+ int reasonint = static_cast<int>(reason);
+ QString reasonstring;
+ reasonstring.setNum(reasonint);
+ int parametercount = parameter.count();
+ QString parametercountstring;;
+ parametercountstring.setNum(parametercount);
+
+
+ mItemMeaage += "*";
+ mItemMeaage += name;
+ mItemMeaage += "; ";
+ mItemMeaage += reasonstring;
+ mItemMeaage += "; ";
+ mItemMeaage += parametercountstring;
+ mItemMeaage += "*\n";
+
+ UpdateConsole();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/activitydebuger.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ACTIVITYDEBUGER_H
+#define ACTIVITYDEBUGER_H
+
+#include <QWidget>
+#include <QVariantHash>
+#include <HbView>
+#include <afactivities_global.h>
+
+class HbLabel;
+class QString;
+class ActivityClient;
+class QPixmap;
+class QByteArray;
+class QVariant;
+class HbComboBox;
+class QGraphicsGridLayout;
+class HbPushButton;
+class QByteArray;
+class ActivityDebugerConsole;
+class AfActivityStorage;
+class AfActivation;
+
+class ActivityDebuger: public HbView
+{
+
+ Q_OBJECT
+
+public:
+ ActivityDebuger(QGraphicsItem *parent = 0);
+ ~ActivityDebuger();
+
+private slots:
+ void saveActivity();
+ void deleteActivity();
+ void getActivity();
+ void getActivityData();
+ void getMyActivity();
+ void getActivityThumb();
+
+ void thumbnailReady(QPixmap pix, void * ptr);
+ void loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter);
+
+private:
+ void Before();
+ void After();
+ void Result();
+
+ void getMetadata(QVariantHash varianthash);
+ void UpdateConsole();
+
+
+private:
+
+ HbLabel *mTimesLabel;
+ HbLabel *mPixmapLabel;
+ HbLabel *mBytesLabel;
+ HbLabel *mSizeLabel;
+ QString mItemMeaage;
+ QPixmap *mPixmap;
+ QPixmap *mPixmap2;
+ QPixmap *mEmptyPixmap;
+ HbComboBox *mTimesCombo;
+ HbComboBox *mLengthCombo;
+ HbComboBox *mPixmapCombo;
+ HbComboBox *mWidthCombo;
+ HbComboBox *mHeightCombo;
+ QGraphicsGridLayout *mLayout;
+ HbPushButton *mSaveButton;
+ HbPushButton *mDelButton;
+ HbPushButton *mDelMyButton;
+ HbPushButton *mGetButton;
+ HbPushButton *mGetDataButton;
+ HbPushButton *mGetMyButton;
+ HbPushButton *mThumbButton;
+ HbPushButton *mClearButton;
+ QByteArray *mByteArray;
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+ int mThumbwait;
+ int mThumbnull;
+ int mThumbcurrent;
+
+ ActivityDebugerConsole* mConsole;
+
+ AfActivityStorage* mActivityStorage;
+ AfActivation* mActivation;
+ QObject *mActivityManager;
+
+};
+
+#endif //ACTIVITYDEBUGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/activitydebuger.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/wolf.bmp</file>
+ <file>images/bird.bmp</file>
+ <file alias="activityserviceplugin.xml">../../../activityserviceplugin/data/afservice.xml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/activitydebugerconsole.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 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 "activitydebugerconsole.h"
+#include <hbscrollarea.h>
+
+
+
+
+
+ActivityDebugerConsole::ActivityDebugerConsole(QGraphicsItem *parent):HbTextEdit(parent)
+{
+ setScrollable(true);
+ setReadOnly(true);
+ clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
+ clearContextMenuFlag(Hb::ShowTextContextMenuOnSelectionClicked);
+ connect( this, SIGNAL(contentsChanged()), this, SLOT(scrollToBotton()));
+}
+
+ActivityDebugerConsole::~ActivityDebugerConsole()
+{
+
+}
+
+
+void ActivityDebugerConsole::scrollToBotton()
+ {
+ HbScrollArea* scrollarea = scrollArea();
+ QSizeF size = scrollarea->contentWidget()->size();
+ QPointF point( 0, size.height() );
+ scrollarea->scrollContentsTo(point);
+ scrollarea->ensureVisible(point);
+ }
+
+void ActivityDebugerConsole::appendText(const QString& text)
+ {
+ setPlainText(toPlainText()+text);
+ }
+
+void ActivityDebugerConsole::clear()
+ {
+ setPlainText(QString());
+ }
+
+void ActivityDebugerConsole::mousePressEvent(QGraphicsSceneMouseEvent */*event*/)
+ {
+
+ }
+
+void ActivityDebugerConsole::focusInEvent(QFocusEvent */*event*/)
+ {
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/activitydebugerconsole.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ACTIVITYDEBUGERCONSOLE_H
+#define ACTIVITYDEBUGERCONSOLE_H
+
+
+#include <hbtextedit>
+
+
+
+class ActivityDebugerConsole: public HbTextEdit
+{
+
+ Q_OBJECT
+
+public:
+ ActivityDebugerConsole(QGraphicsItem *parent = 0);
+ ~ActivityDebugerConsole();
+ void appendText(const QString& text);
+
+
+public slots:
+ void clear();
+ void scrollToBotton();
+
+private:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void focusInEvent(QFocusEvent *event);
+
+};
+
+#endif //ACTIVITYDEBUGERCONSOLE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/acttestdebugger.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = acttestdebugger
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+ activitydebuger.cpp \
+ activitydebugerconsole.cpp
+
+HEADERS += activitydebuger.h \
+ activitydebugerconsole.h
+
+RESOURCES += activitydebuger.qrc
+
+LIBS += -lafservice.dll \
+
+symbian {
+ TARGET.EPOCHEAPSIZE=0x200000 0x2000000 // Min 2Mb, max 32Mb
+ TARGET.CAPABILITY = ALL -TCB
+}
Binary file activityfw/testapplications/newtestappset/acttestdebugger/images/bird.bmp has changed
Binary file activityfw/testapplications/newtestappset/acttestdebugger/images/wolf.bmp has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <HbApplication>
+#include <HbMainWindow>
+
+#include "activitydebuger.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ ActivityDebuger *view = new ActivityDebuger;
+
+ HbMainWindow window;
+ window.addView(view);
+ window.show();
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestdebugger/readme.txt Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+Clear - clear console
+
+Get data - activities data (only this app)
+Response format:
+act name; data type; ok
+
+Add - add activities
+Response format:
+act name; ok
+
+Activities - activities list
+Response format:
+app id; act name; pixmap file; visibility flag; persistence; display name
+
+Get my - get activities list of this app
+Response format:
+app id; act name; pixmap file; visibility flag; persistence; display name
+
+Get pixmaps - activities pizmaps
+Response format:
+app id; act name; loc id;; ok
+loc id; pixmap size
+
+Delete -deletes all activities
+Response format:
+app id; act name; ok
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/acttestfigure.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = acttestfigure
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+squrewidget.cpp\
+trianglewidget.cpp\
+viewmanager.cpp\
+circlewidget.cpp\
+figurewidget.cpp
+
+HEADERS += squrewidget.h\
+trianglewidget.h\
+viewmanager.h\
+circlewidget.h\
+figurewidget.h
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
+LIBS += -lafservice
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/circlewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 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 "circlewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+
+
+circlewidget::circlewidget(QGraphicsItem *parent)
+ : figurewidget(parent)
+{
+ mGridLayout->addItem(mTriangle, 1, 0, 1, 1);
+ mGridLayout->addItem(mSqure, 1, 1, 1, 1);
+
+ mColor = "blue";
+ mNameCombo->addItem("Circle");
+
+ delete mCircle;
+ mCircle = NULL;
+}
+
+circlewidget::~circlewidget()
+{
+}
+
+void circlewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QRect rect(10, 10, 300, 300);
+ QPainterPath painterpath;
+ painterpath.addEllipse(rect);
+ painterpath.setFillRule(Qt::WindingFill);
+
+ painter->setPen(Qt::black);
+ if (mColor == "red") {
+ painter->setBrush(Qt::red);
+ } else if (mColor == "green") {
+ painter->setBrush(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setBrush(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+ painter->drawPath(painterpath);
+
+ figurewidget::paint(painter, option, widget);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/circlewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef CIRCLEWIDGET_H_
+#define CIRCLEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include "figurewidget.h"
+
+class circlewidget: public figurewidget
+{
+ Q_OBJECT
+public:
+ circlewidget(QGraphicsItem *parent = 0);
+ ~circlewidget();
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+};
+
+#endif /* CIRCLEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/figurewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,180 @@
+/*
+* Copyright (c) 2009 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 "figurewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+#include <HbCheckBox>
+#include <HbScrollArea>
+
+figurewidget::figurewidget(QGraphicsItem *parent)
+ : HbWidget(parent), mFailed(false)
+{
+ HbWidget* widget = new HbWidget;
+ HbScrollArea* scrollArea = new HbScrollArea;
+ mTriangle = new HbPushButton("Triangle");
+ mSqure = new HbPushButton("Squre");
+ mCircle = new HbPushButton("Circle");
+ mRed = new HbPushButton("Red");
+ mGreen = new HbPushButton("Green");
+ mBlue = new HbPushButton("Blue");
+ mSave = new HbPushButton("Save");
+ mDelete = new HbPushButton("Delete");
+ mVisibilityLabel = new HbLabel("Visibility");
+ mVisibilityCombo = new HbComboBox();
+ mVisibilityCombo->addItem("none");
+ mVisibilityCombo->addItem("true");
+ mVisibilityCombo->addItem("false");
+
+ mPersistentLabel = new HbLabel("Persistence");
+ mPersistentCombo = new HbComboBox();
+ mPersistentCombo->addItem("none");
+ mPersistentCombo->addItem("true");
+ mPersistentCombo->addItem("false");
+
+ mNameLabel = new HbLabel("Name");
+ mNameCombo = new HbComboBox();
+ mNameCombo->addItem("none");
+
+ mSaveDekCheckBox = new HbCheckBox("Delete before Save");
+ mSaveDekCheckBox->setCheckState(Qt::Unchecked);
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mRed, 0, 0, 1, 1);
+ mGridLayout->addItem(mGreen, 0, 1, 1, 1);
+ mGridLayout->addItem(mBlue, 0, 2, 1, 1);
+ mGridLayout->addItem(mSave, 2, 0, 1, 1);
+ mGridLayout->addItem(mDelete, 2, 2, 1, 1);
+ mGridLayout->addItem(mVisibilityLabel, 3, 0, 1, 1);
+ mGridLayout->addItem(mVisibilityCombo, 3, 1, 1, 2);
+ mGridLayout->addItem(mPersistentLabel, 4, 0, 1, 1);
+ mGridLayout->addItem(mPersistentCombo, 4, 1, 1, 2);
+ mGridLayout->addItem(mNameLabel, 5, 0, 1, 1);
+ mGridLayout->addItem(mNameCombo, 5, 1, 1, 2);
+ mGridLayout->addItem(mSaveDekCheckBox, 6, 0, 1, 3);
+
+ widget->setLayout(mGridLayout);
+
+ scrollArea->setContentWidget(widget);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
+
+ connect(mRed, SIGNAL(released()), this, SLOT(red()));
+ connect(mGreen, SIGNAL(released()), this, SLOT(green()));
+ connect(mBlue, SIGNAL(released()), this, SLOT(blue()));
+
+ connect(mTriangle, SIGNAL(released()), this, SIGNAL(totriangle()));
+ connect(mSqure, SIGNAL(released()), this, SIGNAL(tosqure()));
+ connect(mCircle, SIGNAL(released()), this, SIGNAL(tocircle()));
+
+ connect(mSave, SIGNAL(released()), this, SIGNAL(save()));
+ connect(mDelete, SIGNAL(released()), this, SIGNAL(del()));
+
+ connect(mRed, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mGreen, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mBlue, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mSqure, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+ connect(mTriangle, SIGNAL(released()), this, SLOT(clearFailedFlag()));
+
+ QGraphicsGridLayout* mainLayout = new QGraphicsGridLayout;
+ mainLayout->addItem(scrollArea, 1, 0, 1, 6);
+ mainLayout->setRowFixedHeight(0, 250);
+ setLayout(mainLayout);
+}
+
+figurewidget::~figurewidget()
+{
+}
+
+void figurewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ HbWidget::paint(painter, option, widget);
+
+ if ( mFailed ) {
+ painter->setPen(Qt::gray);
+ QFont font;
+ font.setPointSize(38);
+ font.setBold(true);
+ painter->setFont(font);
+ painter->drawText(10, 120, "*FAIL*");
+ }
+}
+
+
+void figurewidget::red()
+{
+ mColor = "red";
+ update();
+}
+
+void figurewidget::green()
+{
+ mColor = "green";
+ update();
+}
+
+void figurewidget::blue()
+{
+ mColor = "blue";
+ update();
+}
+
+void figurewidget::setcolor(const QString &color)
+{
+ mColor = color;
+}
+
+QString figurewidget::color()
+{
+ return mColor;
+}
+
+void figurewidget::clearFailedFlag()
+ {
+ mFailed = false;
+ update();
+ }
+
+void figurewidget::setFailedFlag()
+ {
+ mFailed = true;
+ update();
+ }
+
+QString figurewidget::visibility()
+{
+ return mVisibilityCombo->currentText();
+}
+
+QString figurewidget::persistent()
+{
+ return mPersistentCombo->currentText();
+}
+
+QString figurewidget::name()
+{
+ return mNameCombo->currentText();
+}
+
+
+bool figurewidget::delBeforeSave()
+{
+ if (mSaveDekCheckBox->checkState() == Qt::Checked) {
+ return true;
+ }
+ return false;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/figurewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef FIGUREWIDGET_H_
+#define FIGUREWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+
+class HbComboBox;
+class HbCheckBox;
+
+class figurewidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ figurewidget(QGraphicsItem *parent = 0);
+ ~figurewidget();
+ void setcolor(const QString &color);
+ QString color();
+ QString visibility();
+ QString persistent();
+ QString name();
+
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mTriangle;
+ HbPushButton *mSqure;
+ HbPushButton *mCircle;
+ HbPushButton *mRed;
+ HbPushButton *mGreen;
+ HbPushButton *mBlue;
+ HbPushButton *mSave;
+ HbPushButton *mDelete;
+ HbLabel* mVisibilityLabel;
+ HbLabel* mPersistentLabel;
+ HbLabel* mNameLabel;
+ HbComboBox *mVisibilityCombo;
+ HbComboBox *mPersistentCombo;
+ HbComboBox *mNameCombo;
+ HbCheckBox* mSaveDekCheckBox;
+ QString mColor;
+ bool mFailed;
+
+signals:
+ void tosqure();
+ void totriangle();
+ void tocircle();
+ void save();
+ void updateAct();
+ void del();
+
+protected slots:
+ void red();
+ void green();
+ void blue();
+
+public slots:
+ void clearFailedFlag();
+ void setFailedFlag();
+ bool delBeforeSave();
+};
+
+#endif /* FIGUREWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "squrewidget.h"
+#include "trianglewidget.h"
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow(&app);
+ mainWindow.show();
+
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/squrewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 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 "squrewidget.h"
+#include <QRect>
+#include <QPainter>
+
+
+squrewidget::squrewidget(QGraphicsItem *parent)
+ : figurewidget(parent)
+{
+ mGridLayout->addItem(mTriangle, 1, 0, 1, 1);
+ mGridLayout->addItem(mCircle, 1, 1, 1, 1);
+
+ mColor = "red";
+ mNameCombo->addItem("Squre");
+
+ delete mSqure;
+ mSqure = NULL;
+}
+
+squrewidget::~squrewidget()
+{
+}
+
+void squrewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QRect rect(10, 10, 300, 300);
+ painter->setPen(Qt::black);
+ if (mColor == "red") {
+ painter->setBrush(Qt::red);
+ } else if (mColor == "green") {
+ painter->setBrush(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setBrush(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+ painter->drawRect(rect);
+
+ figurewidget::paint(painter, option, widget);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/squrewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef SQUREWIDGET_H_
+#define SQUREWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include "figurewidget.h"
+
+class squrewidget: public figurewidget
+{
+ Q_OBJECT
+public:
+ squrewidget(QGraphicsItem *parent = 0);
+ ~squrewidget();
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+};
+
+#endif /* SQUREWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/trianglewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 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 "trianglewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPolygon>
+
+
+trianglewidget::trianglewidget(QGraphicsItem *parent)
+ : figurewidget(parent)
+{
+ mGridLayout->addItem(mSqure, 1, 0, 1, 1);
+ mGridLayout->addItem(mCircle, 1, 1, 1, 1);
+
+ mColor = "green";
+ mNameCombo->addItem("Triangle");
+
+ delete mTriangle;
+ mTriangle = NULL;
+}
+
+trianglewidget::~trianglewidget()
+{
+
+}
+
+void trianglewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QPolygon polygon;
+ polygon.putPoints(0, 3, 10,300, 150,10, 300,300);
+ painter->setPen(Qt::black);
+ if (mColor == "red") {
+ painter->setBrush(Qt::red);
+ } else if (mColor == "green") {
+ painter->setBrush(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setBrush(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+
+ painter->drawPolygon(polygon, Qt::WindingFill);
+
+ figurewidget::paint(painter, option, widget);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/trianglewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TRAINGLEWIDGET_H_
+#define TRAINGLEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include "figurewidget.h"
+
+class trianglewidget: public figurewidget
+{
+ Q_OBJECT
+public:
+ trianglewidget(QGraphicsItem *parent = 0);
+ ~trianglewidget();
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+};
+
+#endif /* TRAINGLEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2009 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 "viewmanager.h"
+#include <qservicemanager.h>
+#include <HbInstance>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbinstance.h>
+#include <hbapplication.h>
+#include <hbactivitymanager.h>
+#include <hbmainwindow.h>
+#include "squrewidget.h"
+#include "trianglewidget.h"
+#include "circlewidget.h"
+#include "figurewidget.h"
+#include <QEventLoop>
+
+#include <afactivitystorage.h>
+#include <afactivation.h>
+#include "afstorageglobals.h"
+
+QTM_USE_NAMESPACE
+
+
+viewmanager::viewmanager(HbApplication *hbapp):
+ HbMainWindow(), mHbApp(hbapp)
+{
+
+ mActivityStorage = new AfActivityStorage;
+ mActivation = new AfActivation;
+
+ qRegisterMetaType<Af::ActivationReason>("Af::ActivationReason");
+ connect(mActivation, SIGNAL(activated(Af::ActivationReason, QString, QVariantHash)), this, SLOT(loadActivityData(Af::ActivationReason, QString, QVariantHash)));
+
+
+
+ mSw = new squrewidget();
+ mTw = new trianglewidget();
+ mCw = new circlewidget();
+ mSView = addView(mSw);
+ mSView->setTitle("Squre");
+ mTView = addView(mTw);
+ mTView->setTitle("Triangle");
+ mCView = addView(mCw);
+ mCView->setTitle("Circle");
+ totriangle();
+ connect(mSw, SIGNAL(totriangle()), this, SLOT(totriangle()));
+ connect(mSw, SIGNAL(tocircle()), this, SLOT(tocircle()));
+
+ connect(mTw, SIGNAL(tocircle()), this, SLOT(tocircle()));
+ connect(mTw, SIGNAL(tosqure()), this, SLOT(tosqure()));
+
+ connect(mCw, SIGNAL(tosqure()), this, SLOT(tosqure()));
+ connect(mCw, SIGNAL(totriangle()), this, SLOT(totriangle()));
+
+ connect(mSw, SIGNAL(save()), this, SLOT(save()));
+ connect(mTw, SIGNAL(save()), this, SLOT(save()));
+ connect(mCw, SIGNAL(save()), this, SLOT(save()));
+ connect(mSw, SIGNAL(del()), this, SLOT(del()));
+ connect(mTw, SIGNAL(del()), this, SLOT(del()));
+ connect(mCw, SIGNAL(del()), this, SLOT(del()));
+
+ //startup case
+ Af::ActivationReason reason = mActivation->reason();
+ QString actName;
+ QVariantHash parameters;
+ if (reason == Af::ActivationReasonActivity) {
+ actName = mActivation->name();
+ parameters = mActivation->parameters();
+ QVariant data = mActivityStorage->activityData(actName);
+ loadActivityData(data, true);
+ }
+ //startup case end
+
+}
+
+viewmanager::~viewmanager()
+{
+
+ delete mActivityStorage;
+ delete mActivation;
+}
+
+void viewmanager::totriangle()
+{
+ setCurrentView(mTView);
+ mStatename = "triangle";
+}
+
+void viewmanager::tosqure()
+{
+ setCurrentView(mSView);
+ mStatename = "squre";
+}
+
+void viewmanager::tocircle()
+{
+ setCurrentView(mCView);
+ mStatename = "circle";
+}
+
+
+void viewmanager::save()
+{
+ QString color;
+ figurewidget* widget = currentWidget();
+ color = widget->color();
+
+ QStringList list;
+ list.append(mStatename);
+ list.append(color);
+ mSaveVariant.clear();
+ mSaveVariant = list;
+ QString visible = widget->visibility();
+ QString persistent = widget->persistent();
+ QString name = widget->name();
+ bool delBefore = widget->delBeforeSave();
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert("screenshot", screenshot);
+ if ( visible == "true" )
+ {
+ metadata.insert(ActivityVisibility, true);
+ }
+ else if ( visible == "false" )
+ {
+ metadata.insert(ActivityVisibility, false);
+ }
+
+ if ( persistent == "true" )
+ {
+ metadata.insert(ActivityPersistence, true);
+ }
+ else if ( persistent == "false" )
+ {
+ metadata.insert(ActivityPersistence, false);
+ }
+
+ if ( name != "none" )
+ {
+ metadata.insert(ActivityApplicationName, name);
+ }
+
+ if (delBefore) {
+ bool ok = mActivityStorage->removeActivity(mStatename);
+ }
+ bool ok = mActivityStorage->saveActivity(mStatename, mSaveVariant, metadata);
+ if (!ok) {
+ widget->setFailedFlag();
+ }
+ else {
+ widget->clearFailedFlag();
+ }
+}
+
+
+void viewmanager::del()
+{
+ bool ok = mActivityStorage->removeActivity(mStatename);
+ figurewidget* widget = currentWidget();
+ if (!ok) {
+ widget->setFailedFlag();
+ }
+ else {
+ widget->clearFailedFlag();
+ }
+}
+
+void viewmanager::loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter)
+{
+ QVariant data = mActivityStorage->activityData( name );
+ loadActivityData( data, false );
+}
+
+void viewmanager::loadActivityData(const QVariant &data, bool startup)
+{
+ HbView *oldView = currentView();
+ QStringList list = data.toStringList();
+ QString statename = list.at(0);
+ QString color = list.at(1);
+ if (statename == "squre") {
+ mSw->setcolor(color);
+ tosqure();
+ mSw->update();
+ } else if (statename == "triangle") {
+ mTw->setcolor(color);
+ totriangle();
+ mTw->update();
+ } else if (statename == "circle") {
+ mCw->setcolor(color);
+ tocircle();
+ mCw->update();
+ } else {
+ Q_ASSERT(false);
+ }
+
+ if (currentView() != oldView && !startup) {
+ QEventLoop loop;
+ loop.connect(this, SIGNAL(viewReady()), SLOT(quit()));
+ loop.exec();
+ }
+}
+
+figurewidget* viewmanager::currentWidget()
+ {
+ HbView* view = currentView();
+ QGraphicsWidget* gwidget = view->widget();
+ figurewidget* lwidget = qobject_cast<figurewidget*>(gwidget);
+ }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestfigure/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+class HbApplication;
+class figurewidget;
+class AfActivityStorage;
+class AfActivation;
+
+#include <QFile>
+#include <QTextStream>
+#include <afactivities_global.h>
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager(HbApplication *hbapp);
+ virtual ~viewmanager();
+ figurewidget* currentWidget();
+
+private:
+ figurewidget *mSw;
+ figurewidget *mTw;
+ figurewidget *mCw;
+ HbView *mSView;
+ HbView *mTView;
+ HbView *mCView;
+
+private slots:
+ void totriangle();
+ void tosqure();
+ void tocircle();
+
+ void save();
+ void del();
+
+public slots:
+ void loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter);
+
+public:
+ void loadActivityData(const QVariant &data, bool startup);
+
+private:
+ QString mStatename;
+ QVariant mSaveVariant;
+ HbApplication *mHbApp;
+ AfActivityStorage* mActivityStorage;
+ AfActivation* mActivation;
+
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/acttestletter.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = acttestletter
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+boldwidget.cpp\
+italicwidget.cpp\
+viewmanager.cpp\
+underlinewidget.cpp\
+letterwidget.cpp
+
+HEADERS += boldwidget.h\
+italicwidget.h\
+viewmanager.h\
+underlinewidget.h\
+letterwidget.h\
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0xEba3ddd2
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/boldwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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 "boldwidget.h"
+#include <QRect>
+#include <QPainter>
+
+
+boldwidget::boldwidget(QGraphicsItem *parent)
+ : letterwidget(parent)
+{
+ mGridLayout->addItem(mItalic, 1, 0, 1, 1);
+ mGridLayout->addItem(mUnderline, 1, 1, 1, 1);
+
+ mColor = "red";
+ mNameCombo->addItem("Bold");
+
+ delete mBold;
+ mBold = NULL;
+}
+
+boldwidget::~boldwidget()
+{
+
+}
+
+void boldwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ letterwidget::paint(painter, option, widget);
+ QFont font;
+ font.setPointSize(45);
+ font.setBold(true);
+ painter->setFont(font);
+ painter->drawText(10, 140, "Bold");
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/boldwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef BOLDWIDGET_H_
+#define BOLDWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include "letterwidget.h"
+
+class boldwidget: public letterwidget
+{
+ Q_OBJECT
+public:
+ boldwidget(QGraphicsItem *parent = 0);
+ ~boldwidget();
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+};
+
+#endif /* BOLDWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/italicwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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 "italicwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPolygon>
+
+const QString KButtonString("to bold");
+
+italicwidget::italicwidget(QGraphicsItem *parent)
+ : letterwidget(parent)
+{
+ mGridLayout->addItem(mBold, 1, 0, 1, 1);
+ mGridLayout->addItem(mUnderline, 1, 1, 1, 1);
+
+ mColor = "green";
+ mNameCombo->addItem("Italic");
+
+ delete mItalic;
+ mItalic = NULL;
+}
+
+italicwidget::~italicwidget()
+{
+
+}
+
+void italicwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ letterwidget::paint(painter, option, widget);
+ QFont font;
+ font.setPointSize(45);
+ font.setItalic(true);
+ painter->setFont(font);
+ painter->drawText(10, 140, "Italic");
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/italicwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef ITALICWIDGET_H_
+#define ITALICWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include "letterwidget.h"
+
+class italicwidget: public letterwidget
+{
+ Q_OBJECT
+public:
+ italicwidget(QGraphicsItem *parent = 0);
+ ~italicwidget();
+
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+};
+
+#endif /* ITALICWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/letterwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2009 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 "letterwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+#include <hbgridview.h>
+#include <QStandardItemModel>
+#include <HbScrollArea>
+#include <QPalette>
+
+letterwidget::letterwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ HbWidget* widget = new HbWidget;
+ HbScrollArea* scrollArea = new HbScrollArea;
+
+ mItalic = new HbPushButton("Italic");
+ mBold = new HbPushButton("Bold");
+ mUnderline = new HbPushButton("Underline");
+ mRed = new HbPushButton("Red");
+ mGreen = new HbPushButton("Green");
+ mBlue = new HbPushButton("Blue");
+ mSave = new HbPushButton("Save");
+ mDelete = new HbPushButton("Delete");
+
+ mVisibilityLabel = new HbLabel("Visibility");
+ mVisibilityCombo = new HbComboBox();
+ mVisibilityCombo->addItem("none");
+ mVisibilityCombo->addItem("true");
+ mVisibilityCombo->addItem("false");
+
+ mPersistentLabel = new HbLabel("Persistence");
+ mPersistentCombo = new HbComboBox();
+ mPersistentCombo->addItem("none");
+ mPersistentCombo->addItem("true");
+ mPersistentCombo->addItem("false");
+
+ mNameLabel = new HbLabel("Name");
+ mNameCombo = new HbComboBox();
+ mNameCombo->addItem("none");
+
+ mStatusLabel = new HbLabel("Status");
+ mResultLabel = new HbLabel;
+
+ mSaveDekCheckBox = new HbCheckBox("Delete before Save");
+ mSaveDekCheckBox->setCheckState(Qt::Checked);
+
+ mBackgroundLabel = new HbLabel("Background");
+ mBackgroundStatusLabel = new HbLabel();
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mStatusLabel, 0, 0, 1, 1);
+ mGridLayout->addItem(mResultLabel, 0, 1, 1, 2);
+ mGridLayout->addItem(mRed, 2, 0, 1, 1);
+ mGridLayout->addItem(mGreen, 2, 1, 1, 1);
+ mGridLayout->addItem(mBlue, 2, 2, 1, 1);
+ mGridLayout->addItem(mSave, 3, 0, 1, 1);
+ mGridLayout->addItem(mDelete, 3, 1, 1, 1);
+ mGridLayout->addItem(mVisibilityLabel, 4, 0, 1, 1);
+ mGridLayout->addItem(mVisibilityCombo, 4, 1, 1, 2);
+ mGridLayout->addItem(mPersistentLabel, 5, 0, 1, 1);
+ mGridLayout->addItem(mPersistentCombo, 5, 1, 1, 2);
+ mGridLayout->addItem(mNameLabel, 6, 0, 1, 1);
+ mGridLayout->addItem(mNameCombo, 6, 1, 1, 2);
+ mGridLayout->addItem(mSaveDekCheckBox, 7, 0, 1, 3);
+ mGridLayout->addItem(mBackgroundLabel, 8, 0, 1, 2);
+ mGridLayout->addItem(mBackgroundStatusLabel, 8, 2, 1, 1);
+
+ widget->setLayout(mGridLayout);
+
+ scrollArea->setContentWidget(widget);
+ scrollArea->setScrollDirections(Qt::Vertical);
+ scrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
+
+ connect(mRed, SIGNAL(released()), this, SLOT(red()));
+ connect(mGreen, SIGNAL(released()), this, SLOT(green()));
+ connect(mBlue, SIGNAL(released()), this, SLOT(blue()));
+
+ connect(mItalic, SIGNAL(released()), this, SIGNAL(toitalic()));
+ connect(mBold, SIGNAL(released()), this, SIGNAL(tobold()));
+ connect(mUnderline, SIGNAL(released()), this, SIGNAL(tounderline()));
+
+ connect(mSave, SIGNAL(released()), this, SIGNAL(save()));
+ connect(mDelete, SIGNAL(released()), this, SIGNAL(del()));
+
+ QGraphicsGridLayout* mainLayout = new QGraphicsGridLayout;
+ mainLayout->addItem(scrollArea, 1, 0, 1, 6);
+ mainLayout->setRowFixedHeight(0, 200);
+ setLayout(mainLayout);
+
+ setStatus(true);
+
+}
+
+void letterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ HbWidget::paint(painter, option, widget);
+
+ if (mColor == "red") {
+ painter->setPen(Qt::red);
+ } else if (mColor == "green") {
+ painter->setPen(Qt::green);
+ } else if (mColor == "blue") {
+ painter->setPen(Qt::blue);
+ } else {
+ Q_ASSERT(false);
+ }
+}
+
+letterwidget::~letterwidget()
+{
+}
+
+
+void letterwidget::red()
+{
+ mColor = "red";
+ update();
+}
+
+void letterwidget::green()
+{
+ mColor = "green";
+ update();
+}
+
+void letterwidget::blue()
+{
+ mColor = "blue";
+ update();
+}
+
+void letterwidget::setcolor(const QString &color)
+{
+ mColor = color;
+}
+
+QString letterwidget::color()
+{
+ return mColor;
+}
+
+QString letterwidget::visibility()
+{
+ return mVisibilityCombo->currentText();
+}
+
+QString letterwidget::persistent()
+{
+ return mPersistentCombo->currentText();
+}
+
+QString letterwidget::name()
+{
+ return mNameCombo->currentText();
+}
+
+void letterwidget::setStatus(bool status)
+{
+ if(status) {
+ mResultLabel->setTextColor(Qt::green);
+ mResultLabel->setPlainText("Ok");
+ } else {
+ mResultLabel->setTextColor(Qt::red);
+ mResultLabel->setPlainText("Fail");
+ }
+
+}
+
+bool letterwidget::delBeforeSave()
+{
+ if (mSaveDekCheckBox->checkState() == Qt::Checked) {
+ return true;
+ }
+ return false;
+}
+
+void letterwidget::setBackgroundFlag(bool background)
+{
+ QString mess = "";
+ if (background) {
+ mess = "true";
+ }
+ mBackgroundStatusLabel->setPlainText(mess);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/letterwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LETTERWIDGET_H_
+#define LETTERWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include <hbcheckbox.h>
+
+class letterwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ letterwidget(QGraphicsItem *parent = 0);
+ ~letterwidget();
+ void setcolor(const QString &color);
+ QString color();
+ QString visibility();
+ QString persistent();
+ QString name();
+ void setBackgroundFlag(bool background);
+
+
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+protected:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mItalic;
+ HbPushButton *mBold;
+ HbPushButton *mUnderline;
+ HbPushButton *mRed;
+ HbPushButton *mGreen;
+ HbPushButton *mBlue;
+ HbPushButton *mSave;
+ HbPushButton *mDelete;
+ HbLabel* mVisibilityLabel;
+ HbLabel* mPersistentLabel;
+ HbLabel* mNameLabel;
+ HbComboBox *mVisibilityCombo;
+ HbComboBox *mPersistentCombo;
+ HbComboBox *mNameCombo;
+ HbLabel* mStatusLabel;
+ HbLabel* mResultLabel;
+ HbCheckBox* mSaveDekCheckBox;
+ QString mColor;
+ HbLabel* mBackgroundLabel;
+ HbLabel* mBackgroundStatusLabel;
+
+signals:
+ void tobold();
+ void toitalic();
+ void tounderline();
+ void save();
+ void del();
+
+protected slots:
+ void red();
+ void green();
+ void blue();
+
+public:
+ void setStatus(bool status);
+ bool delBeforeSave();
+
+};
+
+#endif /* LETTERWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "boldwidget.h"
+#include "italicwidget.h"
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow(&app);
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/underlinewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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 "underlinewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+
+
+underlinewidget::underlinewidget(QGraphicsItem *parent)
+ : letterwidget(parent)
+{
+ mGridLayout->addItem(mItalic, 1, 0, 1, 1);
+ mGridLayout->addItem(mBold, 1, 1, 1, 1);
+
+ mColor = "blue";
+ mNameCombo->addItem("Underline");
+
+ delete mUnderline;
+ mUnderline = NULL;
+}
+
+underlinewidget::~underlinewidget()
+{
+
+}
+
+void underlinewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ letterwidget::paint(painter, option, widget);
+ QFont font;
+ font.setPointSize(40);
+ font.setUnderline(true);
+ painter->setFont(font);
+ painter->drawText(10, 120, "Under");
+ painter->drawText(10, 240, "line");
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/underlinewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef UNDERLINEWIDGET_H_
+#define UNDERLINEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include "letterwidget.h"
+
+class underlinewidget: public letterwidget
+{
+ Q_OBJECT
+public:
+ underlinewidget(QGraphicsItem *parent = 0);
+ ~underlinewidget();
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+};
+
+#endif /* UNDERLINEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,268 @@
+/*
+* Copyright (c) 2009 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 <qservicemanager.h>
+#include <HbInstance>
+#include <QEventLoop>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "boldwidget.h"
+#include "italicwidget.h"
+#include "underlinewidget.h"
+#include "letterwidget.h"
+#include "afstorageglobals.h"
+
+QTM_USE_NAMESPACE
+
+viewmanager::viewmanager(HbApplication *hbapp):
+ HbMainWindow(), mHbApp(hbapp)
+{
+ QServiceManager serviceManager;
+ mActivityStorage = serviceManager.loadInterface("com.nokia.qt.activities.Storage");
+ if (!mActivityStorage) {
+ qFatal("load Storage plugin failed");
+ }
+
+ mActivaction = serviceManager.loadInterface("com.nokia.qt.activities.Activation");
+ if (!mActivaction) {
+ qFatal("load Activation plugin failed");
+ }
+
+ qRegisterMetaType<Af::ActivationReason>("Af::ActivationReason");
+ connect(mActivaction, SIGNAL(activated(Af::ActivationReason, QString, QVariantHash)), this, SLOT(loadActivityData(Af::ActivationReason, QString, QVariantHash)));
+
+
+ mBoldWidget = new boldwidget();
+ mItalicWidget = new italicwidget();
+ mUnderlineWidget = new underlinewidget();
+ mBoldView = addView(mBoldWidget);
+ mBoldView->setTitle("Bold");
+ mItalicView = addView(mItalicWidget);
+ mItalicView->setTitle("Italic");
+ mUnderlineView = addView(mUnderlineWidget);
+ mUnderlineView->setTitle("Underline");
+ toitalic();
+ connect(mBoldWidget, SIGNAL(toitalic()), this, SLOT(toitalic()));
+ connect(mBoldWidget, SIGNAL(tounderline()), this, SLOT(tounderline()));
+
+ connect(mItalicWidget, SIGNAL(tounderline()), this, SLOT(tounderline()));
+ connect(mItalicWidget, SIGNAL(tobold()), this, SLOT(tobold()));
+
+ connect(mUnderlineWidget, SIGNAL(tobold()), this, SLOT(tobold()));
+ connect(mUnderlineWidget, SIGNAL(toitalic()), this, SLOT(toitalic()));
+
+ connect(mBoldWidget, SIGNAL(save()), this, SLOT(save()));
+ connect(mItalicWidget, SIGNAL(save()), this, SLOT(save()));
+ connect(mUnderlineWidget, SIGNAL(save()), this, SLOT(save()));
+ connect(mBoldWidget, SIGNAL(del()), this, SLOT(del()));
+ connect(mItalicWidget, SIGNAL(del()), this, SLOT(del()));
+ connect(mUnderlineWidget, SIGNAL(del()), this, SLOT(del()));
+
+ connect(this, SIGNAL(statusChanged(bool)), this, SLOT(newStatus(bool)));
+
+ //startup case
+ Af::ActivationReason reason;
+ bool ok = QMetaObject::invokeMethod(mActivaction, "reason", Q_RETURN_ARG(Af::ActivationReason, reason));
+ if (!ok) {
+ emit statusChanged(false);
+ }
+ QString actName;
+ QVariantHash parameters;
+ if (reason == Af::ActivationReasonActivity) {
+ ok = QMetaObject::invokeMethod(mActivaction, "name", Q_RETURN_ARG(QString, actName));
+ if (!ok) {
+ emit statusChanged(false);
+ }
+ ok = QMetaObject::invokeMethod(mActivaction, "parameters", Q_RETURN_ARG(QVariantHash, parameters));
+ if (!ok) {
+ emit statusChanged(false);
+ }
+
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actName));
+ if (!ok) {
+ emit statusChanged(false);
+ }
+
+ bool background = false;
+ if (parameters.contains(Af::KActivityUriBackgroundKey)) {
+ background = true;
+ }
+ loadActivityData(data, background, true);
+ }
+ //startup case end
+}
+
+viewmanager::~viewmanager()
+{
+}
+
+void viewmanager::toitalic()
+{
+ setCurrentView(mItalicView);
+ mStatename = "italic";
+}
+
+void viewmanager::tobold()
+{
+ setCurrentView(mBoldView);
+ mStatename = "bold";
+}
+
+void viewmanager::tounderline()
+{
+ setCurrentView(mUnderlineView);
+ mStatename = "underline";
+}
+
+
+void viewmanager::save()
+{
+ QString color;
+ QString visible;
+ QString persistent;
+ QString name;
+ bool delBefore;
+ letterwidget* widget = currentWidget();
+ color = widget->color();
+ visible = widget->visibility();
+ persistent = widget->persistent();
+ name = widget->name();
+ delBefore = widget->delBeforeSave();
+
+ QStringList list;
+ list.append(mStatename);
+ list.append(color);
+ mSaveVariant.clear();
+ mSaveVariant = list;
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+ if ( visible == "true" )
+ {
+ metadata.insert(ActivityVisibility, true);
+ }
+ else if ( visible == "false" )
+ {
+ metadata.insert(ActivityVisibility, false);
+ }
+
+ if ( persistent == "true" )
+ {
+ metadata.insert(ActivityPersistence, true);
+ }
+ else if ( persistent == "false" )
+ {
+ metadata.insert(ActivityPersistence, false);
+ }
+
+ if ( name != "none" )
+ {
+ metadata.insert(ActivityApplicationName, name);
+ }
+
+ bool retok, ok;
+ if (delBefore) {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mStatename));
+ if (!ok) {
+ emit statusChanged(false);
+ return;
+ }
+ }
+
+ ok = QMetaObject::invokeMethod(mActivityStorage, "saveActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mStatename), Q_ARG(QVariant, mSaveVariant), Q_ARG(QVariantHash, metadata));
+ if (!ok || !retok) {
+ emit statusChanged(false);
+ return;
+ }
+ emit statusChanged(true);
+}
+void viewmanager::del()
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityStorage, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mStatename));
+ if (!ok || !retok) {
+ emit statusChanged(false);
+ }
+ emit statusChanged(true);
+}
+
+void viewmanager::loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter)
+{
+ QVariant data;
+ bool ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ emit statusChanged(false);
+ return;
+ }
+ bool background = false;
+ if (parameter.contains(Af::KActivityUriBackgroundKey)) {
+ background = true;
+ }
+ loadActivityData(data, background, false);
+}
+
+void viewmanager::loadActivityData(const QVariant &data, bool background, bool startup)
+{
+ HbView *oldView = currentView();
+
+ QStringList list = data.toStringList();
+ QString statename = list.at(0);
+ QString color = list.at(1);
+ if (statename == "bold") {
+ mBoldWidget->setcolor(color);
+ mBoldWidget->setBackgroundFlag(background);
+ tobold();
+ mBoldWidget->update();
+ } else if (statename == "italic") {
+ mItalicWidget->setcolor(color);
+ mItalicWidget->setBackgroundFlag(background);
+ toitalic();
+ mItalicWidget->update();
+ } else if (statename == "underline") {
+ mUnderlineWidget->setcolor(color);
+ mUnderlineWidget->setBackgroundFlag(background);
+ tounderline();
+ mUnderlineWidget->update();
+ } else {
+ statusChanged(false);
+ }
+
+ if (currentView() != oldView && !startup) {
+ QEventLoop loop;
+ loop.connect(this, SIGNAL(viewReady()), SLOT(quit()));
+ loop.exec();
+ }
+}
+
+letterwidget* viewmanager::currentWidget()
+{
+ HbView* view = currentView();
+ QGraphicsWidget* gwidget = view->widget();
+ letterwidget* lwidget = qobject_cast<letterwidget*>(gwidget);
+}
+
+void viewmanager::newStatus(bool status)
+{
+ letterwidget* cw = currentWidget();
+ if(cw) {
+ cw->setStatus(status);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttestletter/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+#include <afactivities_global.h>
+
+class HbApplication;
+class letterwidget;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager(HbApplication *hbapp);
+ virtual ~viewmanager();
+ void initialize();
+
+private:
+ letterwidget *mBoldWidget;
+ letterwidget *mItalicWidget;
+ letterwidget *mUnderlineWidget;
+ HbView *mBoldView;
+ HbView *mItalicView;
+ HbView *mUnderlineView;
+
+private slots:
+ void toitalic();
+ void tobold();
+ void tounderline();
+
+ void save();
+ void del();
+ void newStatus(bool status);
+
+public slots:
+ void loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter);
+
+signals:
+ void statusChanged(bool status);
+
+public:
+ void loadActivityData(const QVariant &data, bool background, bool startup);
+ letterwidget* currentWidget();
+
+private:
+ QObject *mActivityStorage;
+ QObject *mActivaction;
+ QString mStatename;
+ QVariant mSaveVariant;
+ HbApplication *mHbApp;
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttesttakeawhile/acttesttakeawhile.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = acttesttakeawhile
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp \
+viewmanager.cpp \
+letterwidget.cpp
+
+HEADERS += viewmanager.h \
+letterwidget.h
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttesttakeawhile/letterwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2009 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 "letterwidget.h"
+#include <QRect>
+#include <QPainter>
+
+
+letterwidget::letterwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ mA = new HbPushButton("A");
+ mB = new HbPushButton("B");
+ mC = new HbPushButton("C");
+
+ mSave = new HbPushButton("Save");
+ mDel = new HbPushButton("Delete");
+ mWait = new HbPushButton("Wait 10 s");
+ mPanic = new HbPushButton("Panic client process");
+
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mA, 3, 0, 1, 1);
+ mGridLayout->addItem(mB, 3, 1, 1, 1);
+ mGridLayout->addItem(mC, 3, 2, 1, 1);
+ mGridLayout->addItem(mSave, 4, 0, 1, 1);
+ mGridLayout->addItem(mDel, 4, 1, 1, 1);
+ mGridLayout->addItem(mWait, 4, 2, 1, 1);
+ mGridLayout->addItem(mPanic, 5, 0, 1, 3);
+ mGridLayout->setRowStretchFactor(0, 1);
+ mGridLayout->setRowStretchFactor(1, 1);
+ mGridLayout->setRowStretchFactor(2, 1);
+ setLayout(mGridLayout);
+
+ connect(mA, SIGNAL(released()), this, SLOT(toA()));
+ connect(mB, SIGNAL(released()), this, SLOT(toB()));
+ connect(mC, SIGNAL(released()), this, SLOT(toC()));
+ connect(mWait, SIGNAL(released()), this, SLOT(wait()));
+ connect(mPanic, SIGNAL(released()), this, SLOT(panic()));
+
+ connect(mSave, SIGNAL(released()), this, SIGNAL(save()));
+ connect(mDel, SIGNAL(released()), this, SIGNAL(del()));
+
+ toA();
+
+}
+
+letterwidget::~letterwidget()
+{
+ // TODO Auto-generated destructor stub
+}
+
+void letterwidget::toA()
+{
+ mStatename = "A";
+ update();
+}
+
+void letterwidget::toB()
+{
+ mStatename = "B";
+ update();
+}
+
+void letterwidget::toC()
+{
+ mStatename = "C";
+ update();
+}
+
+void letterwidget::wait()
+ {
+ User::After(10000000); //10 s
+ }
+
+void letterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ HbWidget::paint(painter, option, widget);
+
+ if ( mStatename.isNull() ) {
+ return;
+ }
+ else if ( mStatename == "A" ) {
+ painter->setPen(Qt::red);
+ }
+ else if ( mStatename == "B" ) {
+ painter->setPen(Qt::green);
+ }
+ else {
+ painter->setPen(Qt::blue);
+ }
+
+ QFont font;
+ font.setPointSize(60);
+ painter->setFont(font);
+ painter->drawText(10, 140, mStatename);
+}
+
+QString letterwidget::state()
+{
+ return mStatename;
+}
+
+void letterwidget::setState( QString state )
+{
+ mStatename = state;
+ update();
+}
+
+void letterwidget::panic()
+{
+ User::Panic(_L("forced panic"), 122);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttesttakeawhile/letterwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LETTERWIDGET_H_
+#define LETTERWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+
+class letterwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ letterwidget(QGraphicsItem *parent = 0);
+ ~letterwidget();
+ QString state();
+ void setState( QString state );
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+ QGraphicsGridLayout *mGridLayout;
+
+ HbPushButton *mA;
+ HbPushButton *mB;
+ HbPushButton *mC;
+
+ HbPushButton *mSave;
+ HbPushButton *mDel;
+ HbPushButton *mWait;
+ HbPushButton *mPanic;
+
+signals:
+ void save();
+ void del();
+
+private slots:
+ void toA();
+ void toB();
+ void toC();
+ void wait();
+ void panic();
+
+private:
+ QString mStatename;
+
+};
+
+#endif /* LETTERWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttesttakeawhile/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttesttakeawhile/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2009 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 <qservicemanager.h>
+#include <HbInstance>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "letterwidget.h"
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include "afstorageglobals.h"
+
+QTM_USE_NAMESPACE
+
+viewmanager::viewmanager():
+ HbMainWindow()
+{
+ mLw = new letterwidget;
+ addView(mLw);
+
+ QServiceManager serviceManager;
+ mActivityStorage = serviceManager.loadInterface("com.nokia.qt.activities.Storage");
+ if (!mActivityStorage) {
+ qFatal("load Storage plugin failed");
+ }
+
+ mActivaction = serviceManager.loadInterface("com.nokia.qt.activities.Activation");
+ if (!mActivaction) {
+ qFatal("load Activation plugin failed");
+ }
+
+ qRegisterMetaType<Af::ActivationReason>("Af::ActivationReason");
+ connect(mActivaction, SIGNAL(activated(Af::ActivationReason, QString, QVariantHash)), this, SLOT(loadActivityData(Af::ActivationReason, QString, QVariantHash)));
+
+
+ //startup case
+ Af::ActivationReason reason;
+ bool ok = QMetaObject::invokeMethod(mActivaction, "reason", Q_RETURN_ARG(Af::ActivationReason, reason));
+ if (!ok) {
+ qFatal("Get reason failed");
+ }
+ QString actName;
+ QVariantHash parameters;
+ if (reason == Af::ActivationReasonActivity) {
+ ok = QMetaObject::invokeMethod(mActivaction, "name", Q_RETURN_ARG(QString, actName));
+ if (!ok) {
+ qFatal("Get name failed");
+ }
+ ok = QMetaObject::invokeMethod(mActivaction, "parameters", Q_RETURN_ARG(QVariantHash, parameters));
+ if (!ok) {
+ qFatal("Get parameter failed");
+ }
+
+ QVariant data;
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, actName));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ loadActivityData(data);
+ }
+ //startup case end
+
+ connect(mLw, SIGNAL(save()), this, SLOT(save()));
+ connect(mLw, SIGNAL(del()), this, SLOT(del()));
+}
+
+viewmanager::~viewmanager()
+{
+ delete mActivityStorage;
+ delete mActivaction;
+}
+
+void viewmanager::save()
+{
+ mSaveVariant = mLw->state();
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+ QVariantHash metadata;
+ metadata.insert(ActivityScreenshotKeyword, screenshot);
+
+ bool ok, retok;
+ ok = QMetaObject::invokeMethod(mActivityStorage, "saveActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mLw->state()), Q_ARG(QVariant, mSaveVariant), Q_ARG(QVariantHash, metadata));
+
+ if (!ok || !retok) {
+ qFatal("Save failed");
+ }
+}
+void viewmanager::del()
+{
+ bool retok;
+ bool ok = QMetaObject::invokeMethod(mActivityStorage, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, mLw->state()));
+ if (!ok) {
+ qFatal("Remove failed");
+ }
+}
+
+void viewmanager::loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter)
+{
+ QVariant data;
+ bool ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ if (!ok) {
+ qFatal("Get data failed");
+ }
+ loadActivityData(data);
+}
+
+void viewmanager::loadActivityData(const QVariant &data)
+{
+ QString statename = data.toString();
+ mLw->setState(statename);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/acttesttakeawhile/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+#include <afactivities_global.h>
+
+class HbApplication;
+class QGraphicsGridLayout;
+class HbPushButton;
+class letterwidget;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager();
+ virtual ~viewmanager();
+ void initialize();
+
+
+
+private slots:
+
+ void save();
+ void del();
+
+public slots:
+ void loadActivityData(Af::ActivationReason reason, const QString &name, QVariantHash parameter);
+
+public:
+ void loadActivityData(const QVariant &data);
+
+private:
+
+
+ QObject *mActivityStorage;
+ QObject *mActivaction;
+
+ QVariant mSaveVariant;
+ letterwidget *mLw;
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/newtestappset.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += acttestletter
+SUBDIRS += acttestfigure
+SUBDIRS += acttestbenchmark
+SUBDIRS += acttestanimal
+SUBDIRS += acttestdebugger
+SUBDIRS += acttesttakeawhile
+SUBDIRS += actautobenchmark
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/newtestappset/sis/activitytests.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+; acttestletter_template.pkg generated by qmake at 2010-07-06T11:50:44
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+
+; SIS header: name, uid, version
+#{"activitytests"},(0xEba3ddd2),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+
+; Manual PKG pre-rules from PRO files
+; Default dependency to Qt libraries
+
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Default dependency to QtMobility libraries
+(0x2002AC89), 1, 0, 1, {"QtMobility"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/acttestletter.exe" - "!:\sys\bin\acttestletter.exe"
+"/epoc32/data/z/resource/apps/acttestletter.rsc" - "!:\resource\apps\acttestletter.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/acttestletter_reg.rsc" - "!:\private\10003a3f\import\apps\acttestletter_reg.rsc"
+
+"/epoc32/release/armv5/urel/acttestfigure.exe" - "!:\sys\bin\acttestfigure.exe"
+"/epoc32/data/z/resource/apps/acttestfigure.rsc" - "!:\resource\apps\acttestfigure.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/acttestfigure_reg.rsc" - "!:\private\10003a3f\import\apps\acttestfigure_reg.rsc"
+
+"/epoc32/release/armv5/urel/acttestbenchmark.exe" - "!:\sys\bin\acttestbenchmark.exe"
+"/epoc32/data/z/resource/apps/acttestbenchmark.rsc" - "!:\resource\apps\acttestbenchmark.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/acttestbenchmark_reg.rsc" - "!:\private\10003a3f\import\apps\acttestbenchmark_reg.rsc"
+
+"/epoc32/release/armv5/urel/acttestanimal.exe" - "!:\sys\bin\acttestanimal.exe"
+"/epoc32/data/z/resource/apps/acttestanimal.rsc" - "!:\resource\apps\acttestanimal.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/acttestanimal_reg.rsc" - "!:\private\10003a3f\import\apps\acttestanimal_reg.rsc"
+
+"/epoc32/release/armv5/urel/acttestdebugger.exe" - "!:\sys\bin\acttestdebugger.exe"
+"/epoc32/data/z/resource/apps/acttestdebugger.rsc" - "!:\resource\apps\acttestdebugger.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/acttestdebugger_reg.rsc" - "!:\private\10003a3f\import\apps\acttestdebugger_reg.rsc"
+
+"/epoc32/release/armv5/urel/acttesttakeawhile.exe" - "!:\sys\bin\acttesttakeawhile.exe"
+"/epoc32/data/z/resource/apps/acttesttakeawhile.rsc" - "!:\resource\apps\acttesttakeawhile.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/acttesttakeawhile_reg.rsc" - "!:\private\10003a3f\import\apps\acttesttakeawhile_reg.rsc"
+
+"/epoc32/release/armv5/urel/actautobenchmark.exe" - "!:\sys\bin\actautobenchmark.exe"
+"/epoc32/data/z/resource/apps/actautobenchmark.rsc" - "!:\resource\apps\actautobenchmark.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/actautobenchmark_reg.rsc" - "!:\private\10003a3f\import\apps\actautobenchmark_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lowmemoryapp/basewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,435 @@
+/*
+* Copyright (c) 2009 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 "basewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+#include <hbgridview.h>
+#include <QStandardItemModel>
+#include <HbScrollArea>
+#include <QPalette>
+#include <QImage>
+#include <QColor>
+#include <HbInstance>
+#include <f32file.h>
+#include <qglobal.h>
+
+const int KDataDataSize = 2*1024*1024; // 2 MB
+const int KThumbDataSize = 10; // 10 B
+const int KMaxHeapMem = 16*1024*1024; // 16 MB
+
+
+basewidget::basewidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent)
+ : HbWidget(parent), mActivityStorage(activityStorage), mActivityManager(activityManager), mStream(stream),
+ mPixmap(NULL),mByteArray(NULL),
+ mSaveVariant(NULL), mSaveMetadata(NULL),
+ mAlloc(0)
+{
+
+
+ mSaveButton = new HbPushButton("Save");
+ mThumbButton = new HbPushButton("Thumb");
+ mDataButton = new HbPushButton("Data");
+
+
+ mKBytesEdid = new HbLineEdit("1024");
+ mKBytesEdid->setObjectName("KBytesEditLine");
+ mQKBytesValidator = new QIntValidator(this);
+ mQKBytesValidator->setRange(40, KMaxHeapMem);
+ mKBytesValidator = new HbValidator(this);
+ mKBytesValidator->addField(mQKBytesValidator, "3000");
+ mKBytesEdid->setValidator(mKBytesValidator);
+
+
+ mStatusValueLabel = new HbLabel("None status, none message");
+ mBytesEditLabel = new HbLabel("Free KBytes[KB]");
+ mCatchLabel = new HbLabel("Catches");
+
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mStatusValueLabel, 0, 0, 1, 6);
+ mGridLayout->addItem(mCatchLabel, 1, 0, 1, 6);
+ mGridLayout->addItem(mBytesEditLabel, 2, 0, 1, 2);
+ mGridLayout->addItem(mKBytesEdid, 2, 2, 1, 4);
+ mGridLayout->addItem(mSaveButton, 3, 0, 1, 2);
+ mGridLayout->addItem(mDataButton, 3, 2, 1, 2);
+ mGridLayout->addItem(mThumbButton, 3, 4, 1, 2);
+ setLayout(mGridLayout);
+
+
+ connect(mSaveButton, SIGNAL(released()), this, SLOT(save()));
+ connect(mThumbButton, SIGNAL(released()), this, SLOT(thumb()));
+ connect(mDataButton, SIGNAL(released()), this, SLOT(data()));
+}
+
+basewidget::~basewidget()
+{
+ delete mQKBytesValidator;
+ delete mKBytesValidator;
+}
+
+
+
+
+int basewidget::Bytes() const
+{
+ int kb = Edit2Int(mKBytesEdid);
+ return kb*1024;
+}
+
+int basewidget::Edit2Int(const HbLineEdit* lineedit) const
+{
+ int retvalue = 0;
+ bool ok = false;
+ QString edittext = lineedit->text();
+ retvalue = edittext.toInt(&ok);
+ if(ok) {
+ return retvalue;
+ }
+ return 0;
+}
+
+void basewidget::prepareDataSave()
+{
+ clearSaveData();
+ int bytes = KDataDataSize;
+ mByteArray = new QByteArray(bytes, 'a');
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ mPixmap = new QPixmap(QPixmap::grabWidget(mainWindow, mainWindow->rect()));
+
+ mSaveVariant = new QVariant;
+ *mSaveVariant = *mByteArray;
+ delete mByteArray;
+ mByteArray = NULL;
+
+
+ mSaveMetadata = new QVariantHash;
+ mSaveMetadata->insert(ActivityScreenshotKeyword, *mPixmap);
+ delete mPixmap;
+ mPixmap = NULL;
+}
+
+void basewidget::prepareThumbSave()
+{
+ clearSaveData();
+ int bytes = KThumbDataSize;
+ mByteArray = new QByteArray(bytes, 'a');
+
+ QImage img = QImage(1000, 1000, QImage::Format_ARGB32);
+ img.fill(1);
+ for( int i=0; i<img.width(); i++) {
+ for(int j=0; j<img.height(); j++) {
+ int index = i*j;
+ img.setPixel(i, j, qRgba((10*index+104*i)%255, (200*index+6*j)%255, (150*index+34*i)%255, (80*index+40*j)%255));
+ }
+ }
+ mPixmap = new QPixmap(QPixmap::fromImage(img));
+ bool ok = mPixmap->save("c:\\ala.bmp");
+
+ mSaveVariant = new QVariant;
+ *mSaveVariant = *mByteArray;
+ delete mByteArray;
+ mByteArray = NULL;
+
+
+ mSaveMetadata = new QVariantHash;
+ mSaveMetadata->insert(ActivityScreenshotKeyword, *mPixmap);
+ delete mPixmap;
+ mPixmap = NULL;
+}
+
+void basewidget::clearSaveData()
+{
+ delete mByteArray;
+ mByteArray = NULL;
+ delete mPixmap;
+ mPixmap = NULL;
+ delete mSaveVariant;
+ mSaveVariant = NULL;
+ delete mSaveMetadata;
+ mSaveMetadata = NULL;
+}
+
+bool basewidget::saveActivity(int name)
+{
+ QString display;
+ display.setNum(name);
+ mSaveMetadata->insert(ActivityApplicationName, display);
+ bool retok, ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "saveActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, display), Q_ARG(QVariant, *mSaveVariant), Q_ARG(QVariantHash, *mSaveMetadata));
+ }
+ catch(...) {
+ logCatchError("save");
+ return false;
+ }
+
+ return ok && retok;
+}
+
+bool basewidget::removeActivity(const QString& name)
+{
+ bool retok, ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name));
+ }
+ catch(...) {
+ logCatchError("remove");
+ return false;
+ }
+ return ok && retok;
+}
+
+bool basewidget::activities()
+{
+ bool ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "allActivities", Q_RETURN_ARG(QStringList, mActivities));
+ }
+ catch(...) {
+ logCatchError("activities");
+ return false;
+ }
+ return ok;
+}
+
+bool basewidget::privateData(const QString& name)
+{
+ QVariant data;
+ bool ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ }
+ catch(...) {
+ logCatchError("data");
+ return false;
+ }
+ const char* type = data.typeName();
+ QString dtype(type);
+ logDataType(dtype);
+ return ok;
+}
+
+bool basewidget::getThumbnail(const QString& name)
+{
+ QVariantHash metadata;
+ bool ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityMetaData", Q_RETURN_ARG(QVariantHash, metadata), Q_ARG(QString, name));
+ }
+ catch(...) {
+ logCatchError("thumbnail");
+ return false;
+ }
+ if(!ok) {
+ return false;
+ }
+ QString pixfile = metadata.value(ActivityScreenshotKeyword).toString();
+ ok = QMetaObject::invokeMethod(mActivityManager, "getThumbnail", Q_ARG(QSize, QSize(1000, 1000)), Q_ARG(QString, pixfile), Q_ARG(void*, NULL));
+ return ok;
+}
+
+
+
+int basewidget::ClientHeapSize()
+{
+ RHeap& heap = User::Heap();
+ TInt all=0;
+ heap.AllocSize(all);
+ return all;
+}
+
+
+
+
+void basewidget::logErrorMessage(const QString& mess)
+{
+ QString messlog("*Fail: ");
+ messlog += mess;
+ messlog += "*\n";
+ *mStream<<messlog;
+ mStream->flush();
+ mStatusValueLabel->setPlainText("Fail");
+}
+
+
+
+void basewidget::releaseMem()
+{
+ mActivities.clear();
+ clearSaveData();
+ releaseAlloced();
+}
+
+
+void basewidget::save()
+{
+ releaseMem();
+ bool ok = removeActivity("0");
+ logAction("save");
+ prepareDataSave();
+ alloc();
+ ok = saveActivity(0);
+ releaseMem();
+ logSaveResult(ok);
+}
+
+void basewidget::thumb()
+{
+ releaseMem();
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ bool ok = removeActivity("0");
+ logAction("thumb");
+ prepareThumbSave();
+ ok = saveActivity(0);
+ if(!ok) {
+ logErrorMessage("save");
+ return;
+ }
+ clearSaveData();
+ ok = activities();
+ if(!ok || mActivities.count()==0) {
+ logErrorMessage("activities");
+ return;
+ }
+ QString name = mActivities.at(0);
+ alloc();
+ ok = getThumbnail(name);
+ if(!ok) {
+ logErrorMessage("getthumb");
+ return;
+ }
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+
+}
+
+void basewidget::data()
+{
+ releaseMem();
+ bool ok = removeActivity("0");
+ logAction("data");
+ prepareDataSave();
+ ok = saveActivity(0);
+ if(!ok) {
+ logErrorMessage("save");
+ return;
+ }
+ ok = activities();
+ if(!ok || mActivities.count()==0) {
+ logErrorMessage("activities");
+ return;
+ }
+ QString name = mActivities.at(0);
+ alloc();
+ ok = privateData(name);
+ if(!ok) {
+ logErrorMessage("data");
+ return;
+ }
+ releaseMem();
+}
+
+void basewidget::thumbnailReady(QPixmap pixmap, void* ptr)
+{
+ releaseMem();
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ logPixmapSize(pixmap);
+}
+
+void basewidget::logCatchError(const QString& mess)
+{
+ QString msg = tr("Catch err: %1").arg(mess);
+ mCatchLabel->setPlainText(msg);
+ *mStream<<msg<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logDataType(const QString& type)
+{
+ QString msg = tr("Data type: %1").arg(type);
+ mStatusValueLabel->setPlainText(msg);
+ *mStream<<msg<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logPixmapSize(const QPixmap& pix)
+{
+ QSize s = pix.size();
+ QString msg = tr("Pix size: %1x%2").arg(s.width()).arg(s.height());
+ mStatusValueLabel->setPlainText(msg);
+ *mStream<<msg<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logAction(const QString& mess)
+{
+ mStatusValueLabel->clear();
+ mCatchLabel->clear();
+ QString msg = tr("Action: %1").arg(mess);
+ *mStream<<msg<<"\n";
+ QString bytemsg = tr("Free Bytes: %1").arg(Bytes());
+ *mStream<<bytemsg<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logSaveResult(bool res)
+{
+ QString msg = tr("Save: %1").arg(res);
+ mStatusValueLabel->setPlainText(msg);
+ *mStream<<msg<<"\n";
+ mStream->flush();
+}
+
+bool basewidget::alloc()
+{
+ releaseAlloced();
+ int tobefreebytes = Bytes();
+ int all = ClientHeapSize();
+
+ int nowfree = KMaxHeapMem - all;
+ int toalloc = nowfree - tobefreebytes;
+
+ bool ok = false;
+ if( toalloc>=0 ) {
+ ok = true;
+ try {
+ mAlloc = new char[toalloc];
+ }
+ catch(...) {
+ ok = false;
+ }
+ }
+ if(!mAlloc) {
+ ok = false;
+ }
+
+ if(!ok) {
+ QString msg = tr("Alloc Failed");
+ mCatchLabel->setPlainText(msg);
+ *mStream<<msg<<"\n";
+ mStream->flush();
+ }
+ return ok;
+}
+
+void basewidget::releaseAlloced()
+{
+ delete mAlloc;
+ mAlloc = NULL;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lowmemoryapp/basewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef BASEWIDGET_H_
+#define BASEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include <hbcheckbox.h>
+#include <hblineedit.h>
+#include <HbValidator>
+#include <QPixmap>
+#include <QByteArray>
+#include <QTimer>
+#include <QTextStream>
+#include <afactivitystorage.h>
+#include <afstorageglobals.h>
+
+class basewidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ basewidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent = 0);
+ ~basewidget();
+
+
+protected:
+
+
+protected:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mSaveButton;
+ HbPushButton *mThumbButton;
+ HbPushButton *mDataButton;
+ HbLabel* mStatusValueLabel;
+ HbLineEdit* mKBytesEdid;
+ HbLabel* mCatchLabel;
+
+ HbLabel* mBytesEditLabel;
+
+
+
+ QIntValidator* mQKBytesValidator;
+ HbValidator* mKBytesValidator;
+
+ QObject* mActivityStorage;
+ QObject* mActivityManager;
+ QPixmap* mPixmap;
+ QByteArray* mByteArray;
+
+
+ QTextStream* mStream;
+
+ QVariant* mSaveVariant;
+ QVariantHash* mSaveMetadata;
+ QStringList mActivities;
+ char* mAlloc;
+ QString mAction;
+
+
+
+protected slots:
+ void save();
+ void data();
+ void thumb();
+ void thumbnailReady(QPixmap pixmap, void* ptr);
+
+public:
+
+protected:
+ int Bytes() const;
+
+ int Edit2Int(const HbLineEdit* lineedit) const;
+ void prepareDataSave();
+ void prepareThumbSave();
+ void clearSaveData();
+ bool saveActivity(int name);
+ bool removeActivity(const QString& name);
+ bool privateData(const QString& name);
+ bool getThumbnail(const QString& name);
+ bool activities();
+
+ int ClientHeapSize();
+
+ void logErrorMessage(const QString& mess);
+
+ void releaseMem();
+
+ void logCatchError(const QString& mess);
+ void logDataType(const QString& type);
+ void logPixmapSize(const QPixmap& pix);
+ void logAction(const QString& mess);
+ void logSaveResult(bool res);
+ bool alloc();
+ void releaseAlloced();
+
+
+
+};
+
+#endif /* BASEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lowmemoryapp/lowmemoryapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = lowmemoryapp
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+basewidget.cpp\
+viewmanager.cpp
+
+HEADERS += viewmanager.h\
+basewidget.h
+
+LIBS += -lefsrv
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lowmemoryapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lowmemoryapp/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 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 <qservicemanager.h>
+#include <HbInstance>
+#include <QEventLoop>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "basewidget.h"
+
+#include "afstorageglobals.h"
+#include <QFile>
+#include <QTextStream>
+
+QTM_USE_NAMESPACE
+
+viewmanager::viewmanager():
+ HbMainWindow()
+{
+ QServiceManager serviceManager;
+ mActivityStorage = serviceManager.loadInterface("com.nokia.qt.activities.Storage");
+ if (!mActivityStorage) {
+ qFatal("load Storage plugin failed");
+ }
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("load Manger plugin failed");
+ }
+
+ mFile = new QFile("c:\\data\\nftlowmemory.txt");
+ mFile->open(QIODevice::Append | QIODevice::Text);
+ mStream = new QTextStream(mFile);
+ mBaseWidget = new basewidget(mActivityStorage, mActivityManager, mStream);
+ mBaseView = addView(mBaseWidget);
+ mBaseView->setTitle("Low memory");
+ setCurrentView(mBaseView);
+
+}
+
+viewmanager::~viewmanager()
+{
+ delete mActivityStorage;
+ delete mActivityManager;
+ delete mFile;
+ delete mStream;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lowmemoryapp/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+#include <afactivities_global.h>
+
+class basewidget;
+class QFile;
+class QTextStream;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager();
+ virtual ~viewmanager();
+
+private:
+ basewidget* mBaseWidget;
+ HbView* mBaseView;
+
+ QFile* mFile;
+ QTextStream* mStream;
+
+private slots:
+
+public slots:
+
+
+signals:
+
+
+public:
+
+
+private:
+ QObject* mActivityStorage;
+ QObject* mActivityManager;
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/basewidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,503 @@
+/*
+* Copyright (c) 2009 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 "basewidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QPainterPath>
+#include <QPolygon>
+#include <hbgridview.h>
+#include <QStandardItemModel>
+#include <HbScrollArea>
+#include <QPalette>
+#include <HbInstance>
+#include <f32file.h>
+
+
+
+
+basewidget::basewidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent)
+ : HbWidget(parent), mActivityStorage(activityStorage), mActivityManager(activityManager), mStream(stream),
+ mPixmap(NULL),mByteArray(NULL),
+ mItemsCounter(0), mTimesCounter(0),
+ mSaveVariant(NULL), mSaveMetadata(NULL),
+ mAction("none")
+{
+
+
+ mStartTestButton = new HbPushButton("Start");
+ mChangeTestButton = new HbPushButton("Change Test");
+ mBreakButton = new HbPushButton("Break");
+
+ mTestCheckBox = new HbCheckBox("Delete after Save");
+ mTestCheckBox->setCheckState(Qt::Checked);
+
+ mItemsEdid = new HbLineEdit("100");
+ mItemsEdid->setObjectName("ItemsEditLine");
+ mQItemsValidator = new QIntValidator(this);
+ mQItemsValidator->setRange(0, 1000000);
+ mItemsValidator = new HbValidator(this);
+ mItemsValidator->addField(mQItemsValidator, "100");
+ mItemsEdid->setValidator(mItemsValidator);
+
+ mTimesEdid = new HbLineEdit("100");
+ mTimesEdid->setObjectName("TimesEditLine");
+ mQTimesValidator = new QIntValidator(this);
+ mQTimesValidator->setRange(0, 1000000);
+ mTimesValidator = new HbValidator(this);
+ mTimesValidator->addField(mQTimesValidator, "100");
+ mTimesEdid->setValidator(mTimesValidator);
+
+ mKBytesEdid = new HbLineEdit("10");
+ mKBytesEdid->setObjectName("KBytesEditLine");
+ mQKBytesValidator = new QIntValidator(this);
+ mQKBytesValidator->setRange(0, 1000000);
+ mKBytesValidator = new HbValidator(this);
+ mKBytesValidator->addField(mQKBytesValidator, "10");
+ mKBytesEdid->setValidator(mKBytesValidator);
+
+ mClientMemBeforeLabel = new HbLabel("ClMemBef");
+ mClientMemAfterLabel = new HbLabel("ClMemAft");
+ mClientMemDiffLabel = new HbLabel("ClMemDiff");
+ mDbMemBeforeLabel = new HbLabel("DbMemBef");
+ mDbMemAfterLabel = new HbLabel("DbMemAft");
+ mDbMemDiffLabel = new HbLabel("DbMemDiff");
+ mActionLabel = new HbLabel("action");
+ mIterLabel = new HbLabel("iter");
+ mTimesLabel = new HbLabel("times");
+ mStatusLabel = new HbLabel("Status");
+ mStatusValueLabel = new HbLabel("None");
+ mTimesEditLabel = new HbLabel("Times");
+ mBytesEditLabel = new HbLabel("KBytes[KB]");
+ mItemsEditLabel = new HbLabel("Items");
+
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mClientMemBeforeLabel, 0, 0, 1, 2);
+ mGridLayout->addItem(mClientMemAfterLabel, 0, 2, 1, 2);
+ mGridLayout->addItem(mClientMemDiffLabel, 0, 4, 1, 2);
+ mGridLayout->addItem(mDbMemBeforeLabel, 1, 0, 1, 2);
+ mGridLayout->addItem(mDbMemAfterLabel, 1, 2, 1, 2);
+ mGridLayout->addItem(mDbMemDiffLabel, 1, 4, 1, 2);
+ mGridLayout->addItem(mActionLabel, 2, 0, 1, 2);
+ mGridLayout->addItem(mIterLabel, 2, 2, 1, 2);
+ mGridLayout->addItem(mTimesLabel, 2, 4, 1, 2);
+ mGridLayout->addItem(mStatusLabel, 3, 0, 1, 2);
+ mGridLayout->addItem(mStatusValueLabel, 3, 2, 1, 4);
+ mGridLayout->addItem(mTimesEditLabel, 4, 0, 1, 2);
+ mGridLayout->addItem(mTimesEdid, 4, 2, 1, 4);
+ mGridLayout->addItem(mItemsEditLabel, 5, 0, 1, 2);
+ mGridLayout->addItem(mItemsEdid, 5, 2, 1, 4);
+ mGridLayout->addItem(mBytesEditLabel, 6, 0, 1, 2);
+ mGridLayout->addItem(mKBytesEdid, 6, 2, 1, 4);
+ mGridLayout->addItem(mBytesEditLabel, 7, 0, 1, 2);
+ mGridLayout->addItem(mKBytesEdid, 7, 2, 1, 4);
+ mGridLayout->addItem(mChangeTestButton, 8, 0, 1, 2);
+ mGridLayout->addItem(mStartTestButton, 8, 2, 1, 4);
+ mGridLayout->addItem(mBreakButton, 9, 0, 1, 2);
+ mGridLayout->addItem(mTestCheckBox, 9, 2, 1, 4);
+
+ setLayout(mGridLayout);
+
+ mTimer = new QTimer(this);
+
+ connect(mChangeTestButton, SIGNAL(released()), this, SIGNAL(viewChangedRequest()));
+ connect(mStartTestButton, SIGNAL(released()), this, SLOT(test()));
+ connect(mTimer, SIGNAL(timeout()), this, SLOT(timeout()));
+ connect(mBreakButton, SIGNAL(released()), this, SLOT(breakTest()));
+}
+
+basewidget::~basewidget()
+{
+ delete mQItemsValidator;
+ delete mItemsValidator;
+ delete mQTimesValidator;
+ delete mTimesValidator;
+ delete mQKBytesValidator;
+ delete mKBytesValidator;
+}
+
+
+bool basewidget::TestCheckBoxChecked() const
+{
+ if( mTestCheckBox->checkState() == Qt::Checked ) {
+ return true;
+ }
+ return false;
+}
+
+int basewidget::Bytes() const
+{
+ int kb = Edit2Int(mKBytesEdid);
+ return kb*1024;
+}
+
+int basewidget::Times() const
+{
+ return Edit2Int(mTimesEdid);
+}
+
+int basewidget::Items() const
+{
+ return Edit2Int(mItemsEdid);
+}
+
+int basewidget::Edit2Int(const HbLineEdit* lineedit) const
+{
+ int retvalue = 0;
+ bool ok = false;
+ QString edittext = lineedit->text();
+ retvalue = edittext.toInt(&ok);
+ if(ok) {
+ return retvalue;
+ }
+ return 0;
+}
+
+void basewidget::prepareSave()
+{
+ clearSaveData();
+ int bytes = Bytes();
+ mByteArray = new QByteArray(bytes, 'a');
+
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ mPixmap = new QPixmap(QPixmap::grabWidget(mainWindow, mainWindow->rect()));
+
+ mSaveVariant = new QVariant;
+ *mSaveVariant = *mByteArray;
+ delete mByteArray;
+ mByteArray = NULL;
+
+
+ mSaveMetadata = new QVariantHash;
+ mSaveMetadata->insert(ActivityScreenshotKeyword, *mPixmap);
+ delete mPixmap;
+ mPixmap = NULL;
+
+}
+
+void basewidget::clearSaveData()
+{
+ delete mByteArray;
+ mByteArray = NULL;
+ delete mPixmap;
+ mPixmap = NULL;
+ delete mSaveVariant;
+ mSaveVariant = NULL;
+ delete mSaveMetadata;
+ mSaveMetadata = NULL;
+}
+
+bool basewidget::saveActivity(int name)
+{
+ QString display;
+ display.setNum(name);
+ mSaveMetadata->insert(ActivityApplicationName, display);
+ bool retok, ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "saveActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, display), Q_ARG(QVariant, *mSaveVariant), Q_ARG(QVariantHash, *mSaveMetadata));
+ }
+ catch(...) {
+ return false;
+ }
+
+ return ok && retok;
+}
+
+bool basewidget::removeActivity(const QString& name)
+{
+ bool retok, ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "removeActivity", Q_RETURN_ARG(bool, retok), Q_ARG(QString, name));
+ }
+ catch(...) {
+ return false;
+ }
+ return ok && retok;
+}
+
+bool basewidget::activities()
+{
+ bool ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "allActivities", Q_RETURN_ARG(QStringList, mActivities));
+ }
+ catch(...) {
+ return false;
+ }
+ return ok;
+}
+
+bool basewidget::privateData(const QString& name)
+{
+ QVariant data;
+ bool ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityData", Q_RETURN_ARG(QVariant, data), Q_ARG(QString, name));
+ }
+ catch(...) {
+ return false;
+ }
+ return ok;
+}
+
+bool basewidget::getThumbnail(const QString& name)
+{
+ QVariantHash metadata;
+ bool ok;
+ try {
+ ok = QMetaObject::invokeMethod(mActivityStorage, "activityMetaData", Q_RETURN_ARG(QVariantHash, metadata), Q_ARG(QString, name));
+ }
+ catch(...) {
+ return false;
+ }
+ if(!ok) {
+ return false;
+ }
+ QString pixfile = metadata.value(ActivityScreenshotKeyword).toString();
+ ok = QMetaObject::invokeMethod(mActivityManager, "getThumbnail", Q_ARG(QSize, QSize(128, 128)), Q_ARG(QString, pixfile), Q_ARG(void*, NULL));
+ return ok;
+}
+
+int basewidget::dbSize()
+{
+ _LIT(KFilePath, "c:\\private\\200267b4\\activity.db");
+ TInt fileSize = 0;
+ RFs fs;
+ TInt err = fs.Connect();
+ if (err == KErrNone) {
+ TEntry entry;
+ err = fs.Entry(KFilePath, entry);
+ if (err == KErrNone) {
+ fileSize = entry.iSize;
+ }
+ }
+ fs.Close();
+ return fileSize;
+}
+
+int basewidget::ClientHeapSize()
+{
+ RHeap& heap = User::Heap();
+ TInt all=0;
+ heap.AllocSize(all);
+ return all;
+}
+
+void basewidget::enableControls(bool enable)
+{
+ mStartTestButton->setEnabled(enable);
+ mChangeTestButton->setEnabled(enable);
+ mItemsEdid->setEnabled(enable);
+ mTimesEdid->setEnabled(enable);
+ mKBytesEdid->setEnabled(enable);
+ mTestCheckBox->setEnabled(enable);
+}
+
+void basewidget::timeout()
+{
+
+}
+
+void basewidget::logFirst()
+{
+ int memclient = ClientHeapSize();
+ int memdb = dbSize();
+ mClientMemBefore = memclient;
+ mDbMemBefore = memdb;
+
+ QString clinetKB;
+ clinetKB.setNum(memclient/1024.0, 'f', 2);
+ mClientMemBeforeLabel->setPlainText(clinetKB);
+
+ QString dbKB;
+ dbKB.setNum(memdb/1024.0, 'f', 2);
+ mDbMemBeforeLabel->setPlainText(dbKB);
+
+ *mStream<<"Client heap first: ";
+ *mStream<<memclient<<"\n";
+ *mStream<<"Db size first: ";
+ *mStream<<memdb<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logLast()
+{
+ int memclient = ClientHeapSize();
+ int memdb = dbSize();
+ int clientdiff = memclient - mClientMemBefore;
+ int dbdiff = memdb - mDbMemBefore;
+
+ QString clinetKB;
+ clinetKB.setNum(memclient/1024.0, 'f', 2);
+ mClientMemAfterLabel->setPlainText(clinetKB);
+
+ QString dbKB;
+ dbKB.setNum(memdb/1024.0, 'f', 2);
+ mDbMemAfterLabel->setPlainText(dbKB);
+
+ QString clientDiffKb;
+ clientDiffKb.setNum(clientdiff/1024.0, 'f', 2);
+ mClientMemDiffLabel->setPlainText(clientDiffKb);
+
+
+ QString dbDiffKb;
+ dbDiffKb.setNum(dbdiff/1024.0, 'f', 2);
+ mDbMemDiffLabel->setPlainText(dbDiffKb);
+
+ *mStream<<"Client heap last: ";
+ *mStream<<memclient<<"\n";
+ *mStream<<"Db size last: ";
+ *mStream<<memdb<<"\n";
+
+ *mStream<<"Client heap difference: ";
+ *mStream<<clientdiff<<"\n";
+ *mStream<<"Db size defference: ";
+ *mStream<<dbdiff<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logBaseMessage()
+{
+ *mStream <<"action: ";
+ *mStream<<mAction<<"\n";
+ *mStream <<"itemCounter: ";
+ *mStream<<mItemsCounter<<"\n";
+ *mStream <<"TimeCounter: ";
+ *mStream<<mTimesCounter<<"\n";
+ mStream->flush();
+}
+
+void basewidget::logErrorMessage(const QString& mess)
+{
+ QString messlog("*Fail: ");
+ messlog += mess;
+ messlog += "*\n";
+ *mStream<<messlog;
+ logBaseMessage();
+}
+
+void basewidget::updateItemLabel(int item)
+{
+ QString num;
+ num.setNum(item);
+ mIterLabel->setPlainText(num);
+}
+
+void basewidget::updateTimeLabel(int time)
+{
+ QString num;
+ num.setNum(time);
+ mTimesLabel->setPlainText(num);
+
+}
+
+void basewidget::updateActionLabel()
+{
+ mActionLabel->setPlainText(mAction);
+}
+
+bool basewidget::checkActNum()
+{
+ int getact = mActivities.count();
+ int expectedact = Items();
+ if (getact != expectedact) {
+ *mStream<<"*Fail: Unexpected activities number got*\n";
+ *mStream<<"Got: "<<getact<<", but expected: "<<expectedact<<"\n";
+ return false;
+ }
+ return true;
+}
+
+void basewidget::endTest(int reason)
+{
+ mTimer->stop();
+ if(reason == 0) {
+ mStatusValueLabel->setPlainText("End");
+ }
+ else if(reason == 1) {
+ mStatusValueLabel->setPlainText("Error");
+ }
+ else if(reason == 2) {
+ mStatusValueLabel->setPlainText("Break");
+ }
+ emit testEnded(reason);
+}
+
+void basewidget::releaseMem()
+{
+ mActivities.clear();
+ clearSaveData();
+}
+
+void basewidget::setError(const QString& mess)
+{
+ releaseMem();
+ logErrorMessage(mess);
+ if( mAction != "predel" && mAction != "presave" ) {
+ logLast();
+ }
+ endTest(1);
+ enableControls(true);
+}
+
+void basewidget::endNormally()
+{
+ releaseMem();
+ logLast();
+ endTest(0);
+ enableControls(true);
+}
+
+void basewidget::breakTest()
+{
+ releaseMem();
+ endTest(2);
+ *mStream<<"Breaked\n";
+ mStream->flush();
+ enableControls(true);
+}
+
+void basewidget::logSettings()
+{
+ *mStream <<"items: ";
+ *mStream<<Items()<<"\n";
+ *mStream <<"Times: ";
+ *mStream<<Times()<<"\n";
+ *mStream <<"Checkbox: ";
+ *mStream<<TestCheckBoxChecked()<<"\n";
+ mStream->flush();
+}
+
+void basewidget::clearLabels()
+{
+ mClientMemBeforeLabel->clear();
+ mClientMemAfterLabel->clear();
+ mClientMemDiffLabel->clear();
+ mDbMemBeforeLabel->clear();
+ mDbMemAfterLabel->clear();
+ mDbMemDiffLabel->clear();
+ mIterLabel->clear();
+ mTimesLabel->clear();
+ mStatusValueLabel->clear();
+}
+
+void basewidget::test()
+{
+ updateActionLabel();
+ clearLabels();
+ mTimer->start(1);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/basewidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef BASEWIDGET_H_
+#define BASEWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <HbComboBox>
+#include <hbcheckbox.h>
+#include <hblineedit.h>
+#include <HbValidator>
+#include <QPixmap>
+#include <QByteArray>
+#include <QTimer>
+#include <QTextStream>
+#include <afactivitystorage.h>
+#include <afstorageglobals.h>
+
+class basewidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ basewidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent = 0);
+ ~basewidget();
+
+
+protected:
+
+
+protected:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mStartTestButton;
+ HbPushButton *mChangeTestButton;
+ HbPushButton *mBreakButton;
+ HbCheckBox* mTestCheckBox;
+ HbLineEdit* mItemsEdid;
+ HbLineEdit* mTimesEdid;
+ HbLineEdit* mKBytesEdid;
+ HbLabel* mClientMemBeforeLabel;
+ HbLabel* mClientMemAfterLabel;
+ HbLabel* mClientMemDiffLabel;
+ HbLabel* mDbMemBeforeLabel;
+ HbLabel* mDbMemAfterLabel;
+ HbLabel* mDbMemDiffLabel;
+ HbLabel* mActionLabel;
+ HbLabel* mIterLabel;
+ HbLabel* mTimesLabel;
+ HbLabel* mStatusLabel;
+ HbLabel* mStatusValueLabel;
+ HbLabel* mTimesEditLabel;
+ HbLabel* mBytesEditLabel;
+ HbLabel* mItemsEditLabel;
+
+ QIntValidator* mQItemsValidator;
+ HbValidator* mItemsValidator;
+ QIntValidator* mQTimesValidator;
+ HbValidator* mTimesValidator;
+ QIntValidator* mQKBytesValidator;
+ HbValidator* mKBytesValidator;
+
+ QObject* mActivityStorage;
+ QObject* mActivityManager;
+ QPixmap* mPixmap;
+ QByteArray* mByteArray;
+
+ int mItemsCounter;
+ int mTimesCounter;
+ int mItems;
+ int mTimes;
+ int mClientMemBefore;
+ int mDbMemBefore;
+
+ QTimer* mTimer;
+ QTextStream* mStream;
+
+ QVariant* mSaveVariant;
+ QVariantHash* mSaveMetadata;
+ QStringList mActivities;
+ QString mAction;
+
+
+signals:
+ void viewChangedRequest();
+ void testEnded(int reason);
+
+protected slots:
+ virtual void timeout();
+ virtual void test();
+ void breakTest();
+
+public:
+
+protected:
+ bool TestCheckBoxChecked() const;
+ int Bytes() const;
+ int Times() const;
+ int Items() const;
+ int Edit2Int(const HbLineEdit* lineedit) const;
+ void prepareSave();
+ void clearSaveData();
+ bool saveActivity(int name);
+ bool removeActivity(const QString& name);
+ bool privateData(const QString& name);
+ bool getThumbnail(const QString& name);
+ bool activities();
+ int dbSize();
+ int ClientHeapSize();
+ void enableControls(bool enable);
+ void logFirst();
+ void logLast();
+ void logBaseMessage();
+ void logErrorMessage(const QString& mess);
+ void updateItemLabel(int item);
+ void updateTimeLabel(int time);
+ void updateActionLabel();
+ bool checkActNum();
+ void releaseMem();
+ virtual void endTest(int reason);
+ void setError(const QString& mess);
+ void endNormally();
+ void logSettings();
+ void clearLabels();
+
+
+
+};
+
+#endif /* BASEWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/datawidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2009 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 "datawidget.h"
+
+
+
+datawidget::datawidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent)
+ : basewidget(activityStorage, activityManager, stream, parent)
+{
+ mTestCheckBox->setText("Prepare data");
+ mStartTestButton->setText("Data");
+}
+
+datawidget::~datawidget()
+{
+}
+
+
+void datawidget::timeout()
+{
+ if(mAction == "predel") {
+ if(mItemsCounter<mItems) {
+ QString name = mActivities.at(mItemsCounter);
+ bool ok = removeActivity(name);
+ mItemsCounter++;
+ if(!ok) {
+ setError("remove activity");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mItems=Items();
+ mItemsCounter = 0;
+ mAction = "presave";
+ updateActionLabel();
+ //updateItemLabel(mItemsCounter);
+ prepareSave();
+ }
+ }
+ else if(mAction == "presave") {
+ if(mItemsCounter<mItems) {
+ bool ok = saveActivity(mItemsCounter);
+ mItemsCounter++;
+ if(!ok) {
+ setError("save activity");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mItems=Items();
+ mTimes=Times();
+ mItemsCounter = 0;
+ mAction = "data";
+ updateActionLabel();
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ clearSaveData();
+ logFirst();
+ bool ok = activities();
+ if(!ok) {
+ setError("get activities list");
+ return;
+ }
+ }
+ }
+ else if(mAction == "data") {
+ if(mTimesCounter==mTimes) {
+ endNormally();
+ return;
+ }
+ if(mItemsCounter<mItems) {
+ QString name = mActivities.at(mItemsCounter);
+ bool ok = privateData(name);
+ mItemsCounter++;
+ if(!ok) {
+ setError("get data");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mTimesCounter++;
+ mItemsCounter = 0;
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ }
+ }
+ else {
+ setError("unexpected state");
+ }
+}
+
+void datawidget::test()
+{
+ mTimesCounter = 0;
+ mStatusValueLabel->setPlainText("Pending");
+ enableControls(false);
+ *mStream<<tr("*Get private data*\n");
+ mStream->flush();
+ logSettings();
+ bool ok = activities();
+ if(!ok) {
+ setError("get activities list");
+ return;
+ }
+ if (TestCheckBoxChecked()) {
+ mAction = "predel";
+ mItems = mActivities.count();
+ }
+ else {
+ mAction = "data";
+ ok = checkActNum();
+ if(!ok) {
+ setError("unexpected act number");
+ return;
+ }
+ mItems=Items();
+ mTimes=Times();
+ mItemsCounter = 0;
+ updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ logFirst();
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ }
+ basewidget::test();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/datawidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef DATAWIDGET_H_
+#define DATAWIDGET_H_
+
+#include "basewidget.h"
+
+class datawidget: public basewidget
+{
+ Q_OBJECT
+public:
+ datawidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent = 0);
+ ~datawidget();
+
+private slots:
+ void timeout();
+ void test();
+
+};
+
+#endif /* DATAWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/lptapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = lptapp
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+basewidget.cpp\
+savedelwidget.cpp\
+datawidget.cpp\
+thumbwidget.cpp\
+viewmanager.cpp\
+
+HEADERS += viewmanager.h\
+savedelwidget.h\
+datawidget.h\
+thumbwidget.h\
+basewidget.h\
+
+LIBS += -lefsrv
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "viewmanager.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+
+ viewmanager mainWindow;
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/savedelwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2009 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 "savedelwidget.h"
+
+
+
+savedelwidget::savedelwidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent)
+ : basewidget(activityStorage, activityManager, stream, parent)
+{
+ mStartTestButton->setText("Save");
+}
+
+savedelwidget::~savedelwidget()
+{
+}
+
+
+void savedelwidget::timeout()
+{
+ if(mAction == "predel") {
+ if(mItemsCounter<mItems) {
+ QString name = mActivities.at(mItemsCounter);
+ bool ok = removeActivity(name);
+ mItemsCounter++;
+ if(!ok) {
+ setError("remove activity");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mItems=Items();
+ mTimes=Times();
+ mItemsCounter = 0;
+ mAction = "save";
+ updateActionLabel();
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ logFirst();
+ prepareSave();
+ }
+ }
+ else if(mAction=="save") {
+ if(mTimesCounter==mTimes) {
+ endNormally();
+ return;
+ }
+ if(mItemsCounter<mItems) {
+
+ bool ok = saveActivity(mItemsCounter);
+ if(!ok) {
+ setError("save activity");
+ return;
+ }
+ mItemsCounter++;
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ if(TestCheckBoxChecked()) {
+ bool ok = activities();
+ if(!ok) {
+ setError("get activities list");
+ return;
+ }
+ ok = checkActNum();
+ if(!ok) {
+ setError("unexpected act number");
+ return;
+ }
+ mItemsCounter = 0;
+ mAction = "remove";
+ updateActionLabel();
+ //updateItemLabel(mItemsCounter);
+
+ }
+ else {
+ mTimesCounter++;
+ mItemsCounter = 0;
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ }
+ }
+ }
+ else if(mAction=="remove") {
+ if(mItemsCounter<mItems) {
+
+ QString name = mActivities.at(mItemsCounter);
+ bool ok = removeActivity(name);
+ mItemsCounter++;
+ if(!ok) {
+ setError("remove activity");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mTimesCounter++;
+ mItemsCounter = 0;
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ mAction = "save";
+ updateActionLabel();
+ }
+ }
+ else {
+ setError("unexpected state");
+ }
+}
+
+void savedelwidget::test()
+{
+ mTimesCounter = 0;
+ mStatusValueLabel->setPlainText("Pending");
+ enableControls(false);
+ *mStream<<tr("*Save del start*\n");
+ logSettings();
+ mStream->flush();
+ mAction = "predel";
+ bool ok = activities();
+ if(!ok) {
+ setError("get activities list");
+ return;
+ }
+ mItems = mActivities.count();
+ basewidget::test();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/savedelwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef SAVEDELWIDGET_H_
+#define SAVEDELWIDGET_H_
+
+#include "basewidget.h"
+
+class savedelwidget: public basewidget
+{
+ Q_OBJECT
+public:
+ savedelwidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent = 0);
+ ~savedelwidget();
+
+private slots:
+ void timeout();
+ void test();
+
+};
+
+#endif /* SAVEDELWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/thumbwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2009 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 "thumbwidget.h"
+
+
+
+thumbwidget::thumbwidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent)
+ : basewidget(activityStorage, activityManager, stream, parent)
+{
+ mTestCheckBox->setText("Prepare data");
+ mKBytesEdid->setText("1");
+ mStartTestButton->setText("Thumb");
+}
+
+thumbwidget::~thumbwidget()
+{
+}
+
+
+void thumbwidget::timeout()
+{
+ if(mAction == "predel") {
+ if(mItemsCounter<mItems) {
+ QString name = mActivities.at(mItemsCounter);
+ bool ok = removeActivity(name);
+ mItemsCounter++;
+ if(!ok) {
+ setError("remove activity");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mItems=Items();
+ mItemsCounter = 0;
+ mAction = "presave";
+ updateActionLabel();
+ //updateItemLabel(mItemsCounter);
+ prepareSave();
+ }
+ }
+ else if(mAction == "presave") {
+ if(mItemsCounter<mItems) {
+ bool ok = saveActivity(mItemsCounter);
+ mItemsCounter++;
+ if(!ok) {
+ setError("save activity");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ }
+ else {
+ mItems=Items();
+ mTimes=Times();
+ mItemsCounter = 0;
+ mAction = "thumb";
+ updateActionLabel();
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ clearSaveData();
+ logFirst();
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ bool ok = activities();
+ if(!ok) {
+ setError("get activities list");
+ return;
+ }
+ }
+ }
+ else if(mAction == "thumb") {
+ if(mTimesCounter==mTimes) {
+ endNormally();
+ return;
+ }
+ if(mItemsCounter<mItems) {
+ QString name = mActivities.at(mItemsCounter);
+ bool ok = getThumbnail(name);
+ mItemsCounter++;
+ if(!ok) {
+ setError("get thumbnail");
+ return;
+ }
+ updateItemLabel(mItemsCounter);
+ mTimer->stop();
+ }
+ else {
+ mTimesCounter++;
+ mItemsCounter = 0;
+ //updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ }
+ }
+ else {
+ setError("unexpected state");
+ }
+}
+
+void thumbwidget::test()
+{
+ mTimesCounter = 0;
+ mStatusValueLabel->setPlainText("Pending");
+ enableControls(false);
+ *mStream<<tr("*Get thumbnail*\n");
+ mStream->flush();
+ logSettings();
+ bool ok = activities();
+ if(!ok) {
+ setError("get activities list");
+ return;
+ }
+ if (TestCheckBoxChecked()) {
+ mAction = "predel";
+ mItems = mActivities.count();
+ }
+ else {
+ mAction = "thumb";
+ ok = checkActNum();
+ if(!ok) {
+ setError("unexpected act number");
+ return;
+ }
+ mItems=Items();
+ mTimes=Times();
+ mItemsCounter = 0;
+ updateItemLabel(mItemsCounter);
+ updateTimeLabel(mTimesCounter);
+ logFirst();
+ connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ }
+ basewidget::test();
+}
+
+void thumbwidget::thumbnailReady(QPixmap pixmap, void* ptr)
+{
+ if(pixmap.isNull()) {
+ setError("Null pixmap");
+ return;
+ }
+ mTimer->start(1);
+}
+
+void thumbwidget::endTest(int reason)
+{
+ disconnect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
+ basewidget::endTest(reason);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/thumbwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef THUMBWIDGET_H_
+#define THUMBWIDGET_H_
+
+#include "basewidget.h"
+
+class thumbwidget: public basewidget
+{
+ Q_OBJECT
+public:
+ thumbwidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent = 0);
+ ~thumbwidget();
+
+private slots:
+ void timeout();
+ void test();
+ void thumbnailReady(QPixmap pixmap, void* ptr);
+private:
+ void endTest(int reason);
+};
+
+#endif /* THUMBWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 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 <qservicemanager.h>
+#include <HbInstance>
+#include <QEventLoop>
+#include <QStringList>
+#include <QCoreApplication>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "savedelwidget.h"
+#include "datawidget.h"
+#include "thumbwidget.h"
+#include "afstorageglobals.h"
+#include <QFile>
+#include <QTextStream>
+
+QTM_USE_NAMESPACE
+
+viewmanager::viewmanager():
+ HbMainWindow()
+{
+ QServiceManager serviceManager;
+ mActivityStorage = serviceManager.loadInterface("com.nokia.qt.activities.Storage");
+ if (!mActivityStorage) {
+ qFatal("load Storage plugin failed");
+ }
+
+ mActivityManager = serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager");
+ if (!mActivityManager) {
+ qFatal("load Manger plugin failed");
+ }
+
+ mFile = new QFile("c:\\data\\lpt.txt");
+ mFile->open(QIODevice::Append | QIODevice::Text);
+ mStream = new QTextStream(mFile);
+ mSaveDelWidget = new savedelwidget(mActivityStorage, mActivityManager, mStream);
+ mSaveDelView = addView(mSaveDelWidget);
+ mSaveDelView->setTitle("SaveDel");
+ mDataWidget = new datawidget(mActivityStorage, mActivityManager, mStream);
+ mDataView = addView(mDataWidget);
+ mDataView->setTitle("Data");
+ mThumbWidget = new thumbwidget(mActivityStorage, mActivityManager, mStream);
+ mThumbView = addView(mThumbWidget);
+ mThumbView->setTitle("Thumb");
+ setCurrentView(mSaveDelView);
+
+ connect(mSaveDelWidget, SIGNAL(viewChangedRequest()), this, SLOT(toData()));
+ connect(mDataWidget, SIGNAL(viewChangedRequest()), this, SLOT(toThumb()));
+ connect(mThumbWidget, SIGNAL(viewChangedRequest()), this, SLOT(toSaveDel()));
+}
+
+viewmanager::~viewmanager()
+{
+ delete mActivityStorage;
+ delete mActivityManager;
+ delete mFile;
+ delete mStream;
+}
+
+void viewmanager::toSaveDel()
+{
+ setCurrentView(mSaveDelView);
+}
+
+void viewmanager::toData()
+{
+ setCurrentView(mDataView);
+}
+
+void viewmanager::toThumb()
+{
+ setCurrentView(mThumbView);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/lptapp/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QVariant>
+#include <afactivities_global.h>
+
+class basewidget;
+class QFile;
+class QTextStream;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager();
+ virtual ~viewmanager();
+
+private:
+ basewidget* mSaveDelWidget;
+ HbView* mSaveDelView;
+ basewidget* mDataWidget;
+ HbView* mDataView;
+ basewidget* mThumbWidget;
+ HbView* mThumbView;
+ QFile* mFile;
+ QTextStream* mStream;
+
+private slots:
+ void toSaveDel();
+ void toData();
+ void toThumb();
+
+public slots:
+
+
+signals:
+
+
+public:
+
+
+private:
+ QObject* mActivityStorage;
+ QObject* mActivityManager;
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/nftapps.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += lptapp
+SUBDIRS += lowmemoryapp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/nftapps/sis/lptapp.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+; X:/hs/homescreensrv/activityfw/testapplications/nftapps/lptapp//lptapp_template.pkg generated by qmake at 2010-07-28T14:29:51
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+
+; SIS header: name, uid, version
+#{"lptapp"},(0xE5d1c651),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+
+; Manual PKG pre-rules from PRO files
+; Default dependency to Qt libraries
+
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+[0x20022e6d],0,0,0,{"S60ProductID"}
+
+; Default dependency to QtMobility libraries
+(0x2002AC89), 1, 0, 2, {"QtMobility"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/lptapp.exe" - "!:\sys\bin\lptapp.exe"
+"/epoc32/data/z/resource/apps/lptapp.rsc" - "!:\resource\apps\lptapp.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/lptapp_reg.rsc" - "!:\private\10003a3f\import\apps\lptapp_reg.rsc"
+
+"/epoc32/release/armv5/urel/lowmemoryapp.exe" - "!:\sys\bin\lowmemoryapp.exe"
+"/epoc32/data/z/resource/apps/lowmemoryapp.rsc" - "!:\resource\apps\lowmemoryapp.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/lowmemoryapp_reg.rsc" - "!:\private\10003a3f\import\apps\lowmemoryapp_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/simplehbapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+
+int main(int argc, char **argv)
+{
+ HbApplication a( argc, argv );
+
+ HbMainWindow mainWindow;
+ mainWindow.show();
+
+ return a.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/simplehbapp/simplehbapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = simplehbapp
+
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+SOURCES = main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/sis/testapplications.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,73 @@
+; activitytestletter_template.pkg generated by qmake at 2010-04-13T10:42:42
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"testapplications"},(0xEd92f9a1),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Default dependency to QtMobility libraries
+(0x2002AC89), 1, 0, 0, {"QtMobility"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/activitytestletter.exe" - "!:\sys\bin\activitytestletter.exe"
+"/epoc32/data/z/resource/apps/activitytestletter.rsc" - "!:\resource\apps\activitytestletter.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitytestletter_reg.rsc" - "!:\private\10003a3f\import\apps\activitytestletter_reg.rsc"
+
+"/epoc32/release/armv5/urel/hbmeasuretest.exe" - "!:\sys\bin\hbmeasuretest.exe"
+"/epoc32/data/z/resource/apps/hbmeasuretest.rsc" - "!:\resource\apps\hbmeasuretest.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/hbmeasuretest_reg.rsc" - "!:\private\10003a3f\import\apps\hbmeasuretest_reg.rsc"
+
+"/epoc32/release/armv5/urel/activitydebugger.exe" - "!:\sys\bin\activitydebugger.exe"
+"/epoc32/data/z/resource/apps/activitydebugger.rsc" - "!:\resource\apps\activitydebugger.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitydebugger_reg.rsc" - "!:\private\10003a3f\import\apps\activitydebugger_reg.rsc"
+
+"/epoc32/release/armv5/urel/activitytestmodel.exe" - "!:\sys\bin\activitytestmodel.exe"
+"/epoc32/data/z/resource/apps/activitytestmodel.rsc" - "!:\resource\apps\activitytestmodel.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitytestmodel_reg.rsc" - "!:\private\10003a3f\import\apps\activitytestmodel_reg.rsc"
+
+"/epoc32/release/armv5/urel/activitytestanimal.exe" - "!:\sys\bin\activitytestanimal.exe"
+"/epoc32/data/z/resource/apps/activitytestanimal.rsc" - "!:\resource\apps\activitytestanimal.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitytestanimal_reg.rsc" - "!:\private\10003a3f\import\apps\activitytestanimal_reg.rsc"
+
+"/epoc32/release/armv5/urel/activitytestfigure.exe" - "!:\sys\bin\activitytestfigure.exe"
+"/epoc32/data/z/resource/apps/activitytestfigure.rsc" - "!:\resource\apps\activitytestfigure.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitytestfigure_reg.rsc" - "!:\private\10003a3f\import\apps\activitytestfigure_reg.rsc"
+
+"/epoc32/release/armv5/urel/activitytestmodelhbintegration.exe" - "!:\sys\bin\activitytestmodelhbintegration.exe"
+"/epoc32/data/z/resource/apps/activitytestmodelhbintegration.rsc" - "!:\resource\apps\activitytestmodelhbintegration.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitytestmodelhbintegration_reg.rsc" - "!:\private\10003a3f\import\apps\activitytestmodelhbintegration_reg.rsc"
+
+"/epoc32/release/armv5/urel/simplehbapp.exe" - "!:\sys\bin\simplehbapp.exe"
+"/epoc32/data/z/resource/apps/simplehbapp.rsc" - "!:\resource\apps\simplehbapp.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/simplehbapp_reg.rsc" - "!:\private\10003a3f\import\apps\simplehbapp_reg.rsc"
+
+"/epoc32/release/armv5/urel/appactluncher.exe" - "!:\sys\bin\appactluncher.exe"
+"/epoc32/data/z/resource/apps/appactluncher.rsc" - "!:\resource\apps\appactluncher.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/appactluncher_reg.rsc" - "!:\private\10003a3f\import\apps\appactluncher_reg.rsc"
+
+"/epoc32/release/armv5/urel/apptostart.exe" - "!:\sys\bin\apptostart.exe"
+"/epoc32/data/z/resource/apps/apptostart.rsc" - "!:\resource\apps\apptostart.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/apptostart_reg.rsc" - "!:\private\10003a3f\import\apps\apptostart_reg.rsc"
+
+"/epoc32/release/armv5/urel/activitytakeawhile.exe" - "!:\sys\bin\activitytakeawhile.exe"
+"/epoc32/data/z/resource/apps/activitytakeawhile.rsc" - "!:\resource\apps\activitytakeawhile.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/activitytakeawhile_reg.rsc" - "!:\private\10003a3f\import\apps\activitytakeawhile_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/testapplications/testapplications.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += activitytestanimal
+SUBDIRS += activitytestmodelhbintegration
+SUBDIRS += activitytestmodel
+SUBDIRS += activitytestletter
+SUBDIRS += activitytestfigure
+SUBDIRS += activitydebugger
+SUBDIRS += simplehbapp
+SUBDIRS += hbmeasuretest
+SUBDIRS += appactluncher
+SUBDIRS += apptostart
+SUBDIRS += activitytakeawhile
\ No newline at end of file
Binary file activityfw/tsutils/tsrc/t_tsgraphicfilescalinghandler/data/image_file.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/tsutils/tsrc/t_tsgraphicfilescalinghandler/inc/t_tsgraphicfilescalinghandler.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,77 @@
+//Copyright (c) 2010 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:
+
+/////////////////////////////////////////////////////////////////////
+
+#ifndef T_TSGRAPHICFILESCALINGHANDLER_H
+#define T_TSGRAPHICFILESCALINGHANDLER_H
+
+// INCLUDED FILES
+#include <QObject>
+ #include <QPixmap>
+#include "tsgraphicfilescalinghandler.h"
+
+class T_CTsGraphicFileScalingHandler :
+ public QObject,
+ public MImageReadyCallBack
+{
+ Q_OBJECT
+
+private:
+ static TInt CallStop(TAny *aWait);
+ static void WaitActive(TInt aTime);
+
+//From MImageReadyCallBack
+private:
+ virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap);
+
+public:
+ explicit T_CTsGraphicFileScalingHandler(QObject *parent = 0);
+ virtual ~T_CTsGraphicFileScalingHandler();
+
+private slots:
+
+// tests for file path and kind of graphic file as imput
+ void testGraphicFileScalingIgnoreAspectRatio_LessWidth();
+ void testGraphicFileScalingIgnoreAspectRatio_LessHeight();
+ void testGraphicFileScalingIgnoreAspectRatio_TheSameRatio();
+ void testGraphicFileScalingKeepAspectRatio_LessWidth();
+ void testGraphicFileScalingKeepAspectRatio_LessHeight();
+ void testGraphicFileScalingKeepAspectRatio_TheSameRatio();
+ void testGraphicFileScalingKeepAspectRatioByExpanding_LessWidth();
+ void testGraphicFileScalingKeepAspectRatioByExpanding_LessHeight();
+ void testGraphicFileScalingKeepAspectRatioByExpanding_TheSameRatio();
+
+// tests incorrect situation
+ void testGraphicFileScalingInvalidImagePath();
+ void testGraphicFileScalingEmptyImagePath();
+ void testGraphicFileScalingEmptyMimeType();
+ void testGraphicFileScalingScalingToIncorrectWidthSize();
+ void testGraphicFileScalingScalingToIncorrectHeightSize();
+ void testGraphicFileScalingScalingToZeroSize();
+ void testDoCancel();
+
+// tests for CFbsBitmap as imput
+ void testCFbsBitmapScalingToCorrectSize();
+ void testCFbsBitmapScalinToIncorrectWidthSize();
+ void testCFbsBitmapScalinToIncorrectHeightSize();
+
+private:
+ RFs mFs;
+ QPixmap mPixMapCallBack;
+ TInt mErrorCallBack;
+};
+
+#endif // T_TSGRAPHICFILESCALINGHANDLER_H
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/tsutils/tsrc/t_tsgraphicfilescalinghandler/src/t_tsgraphicfilescalinghandler.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,550 @@
+//Copyright (c) 2010 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:
+
+/////////////////////////////////////////////////////////////////////
+
+// INCLUDED FILES
+#include <QtTest/QtTest>
+#include "t_tsgraphicfilescalinghandler.h"
+
+_LIT(KFileName, "c:\\data\\Images\\Pictures\\image_file.png");
+_LIT8(KMimeType, "image/png");
+QString KFileName2("c:\\data\\Images\\Pictures\\image_file.png");
+
+const TSize KOriginalSize(480, 236);
+const TSize KWanted_TheSameRatio(KOriginalSize.iWidth/2, KOriginalSize.iHeight/2);
+const TSize KWanted_LessWidth(KOriginalSize.iWidth/2, KOriginalSize.iHeight);
+const TSize KWanted_LessHeight(KOriginalSize.iWidth, KOriginalSize.iHeight/2);
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+QTEST_MAIN(T_CTsGraphicFileScalingHandler)
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+T_CTsGraphicFileScalingHandler::T_CTsGraphicFileScalingHandler(QObject *parent) :
+ QObject(parent),
+ mErrorCallBack(KErrNone)
+{
+ User::LeaveIfError(mFs.Connect());
+ User::LeaveIfError(RFbsSession::Connect(mFs));
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+T_CTsGraphicFileScalingHandler::~T_CTsGraphicFileScalingHandler()
+{
+ mFs.Close();
+ RFbsSession::Disconnect();
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::WaitActive(TInt aTime)
+{
+ CActiveSchedulerWait *wait = new (ELeave)CActiveSchedulerWait();
+ CPeriodic *periodic = CPeriodic::NewL(CActive::EPriorityIdle);
+ periodic->Start(aTime, aTime, TCallBack(CallStop, wait));
+ wait->Start();
+ delete periodic;
+ delete wait;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+TInt T_CTsGraphicFileScalingHandler::CallStop(TAny *aWait)
+{
+ (static_cast<CActiveSchedulerWait*>(aWait))->AsyncStop();
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingIgnoreAspectRatio_LessWidth()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessWidth
+ /*CTsGraphicFileScalingHandler::EIgnoreAspectRatio*/));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_LessWidth.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_LessWidth.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingIgnoreAspectRatio_LessHeight()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessHeight
+ /*CTsGraphicFileScalingHandler::EIgnoreAspectRatio*/));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_LessHeight.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_LessHeight.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingIgnoreAspectRatio_TheSameRatio()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_TheSameRatio
+ /*CTsGraphicFileScalingHandler::EIgnoreAspectRatio*/));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_TheSameRatio.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_TheSameRatio.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingKeepAspectRatio_LessWidth()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessWidth,
+ CTsGraphicFileScalingHandler::EKeepAspectRatio));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QVERIFY(mPixMapCallBack.width() <= KWanted_LessWidth.iWidth);
+ QVERIFY(mPixMapCallBack.height() <= KWanted_LessWidth.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingKeepAspectRatio_LessHeight()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessHeight,
+ CTsGraphicFileScalingHandler::EKeepAspectRatio));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QVERIFY(mPixMapCallBack.width() <= KWanted_LessHeight.iWidth);
+ QVERIFY(mPixMapCallBack.height() <= KWanted_LessHeight.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingKeepAspectRatio_TheSameRatio()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_TheSameRatio,
+ CTsGraphicFileScalingHandler::EKeepAspectRatio));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QVERIFY(mPixMapCallBack.width() <= KWanted_TheSameRatio.iWidth);
+ QVERIFY(mPixMapCallBack.height() <= KWanted_TheSameRatio.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingKeepAspectRatioByExpanding_LessWidth()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessWidth,
+ CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_LessWidth.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_LessWidth.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingKeepAspectRatioByExpanding_LessHeight()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessHeight,
+ CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_LessHeight.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_LessHeight.iHeight);
+ delete screenShotHadnler;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingKeepAspectRatioByExpanding_TheSameRatio()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_TheSameRatio,
+ CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding));
+
+ QCOMPARE(errNo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_TheSameRatio.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_TheSameRatio.iHeight);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingInvalidImagePath()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(240, 118);
+ _LIT(wrongImagePath, "c:\\data\\Images\\Pictures\\<image_file.png");
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ wrongImagePath,
+ KMimeType,
+ newSize);
+ );
+
+ QCOMPARE(errNo, KErrPathNotFound);
+ WaitActive(5000000);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingEmptyImagePath()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(240, 118);
+ _LIT(wrongImagePath, "");
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ wrongImagePath,
+ KMimeType,
+ newSize);
+ );
+
+ QCOMPARE(errNo, KErrPathNotFound);
+ WaitActive(5000000);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingEmptyMimeType()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(240, 118);
+ _LIT8(wrongMimeType, "");
+
+ TRAPD(errNo,
+ screenShotHadnler = CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ wrongMimeType,
+ newSize);
+ );
+
+ QCOMPARE(errNo, KErrBadName);
+ WaitActive(5000000);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingScalingToIncorrectWidthSize()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(-20, 118);
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ newSize);
+ );
+
+ QCOMPARE(errNo, KErrCorrupt);
+ WaitActive(5000000);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingScalingToIncorrectHeightSize()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(240, -20);
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ newSize);
+ );
+
+ QCOMPARE(errNo, KErrCorrupt);
+ WaitActive(5000000);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testGraphicFileScalingScalingToZeroSize()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(0, 0);
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ newSize);
+ );
+
+ QCOMPARE(errNo, KErrCorrupt);
+ WaitActive(5000000);
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testDoCancel()
+{
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ mFs,
+ KFileName,
+ KMimeType,
+ KWanted_LessWidth));
+
+ QCOMPARE(errNo, KErrNone);
+
+ screenShotHadnler->Cancel();
+
+ WaitActive(5000000);
+ QCOMPARE(mErrorCallBack, KErrCancel);
+ QVERIFY(mPixMapCallBack.isNull());
+ delete screenShotHadnler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testCFbsBitmapScalingToCorrectSize()
+{
+ QPixmap imputPixMap(KFileName2);
+
+ CFbsBitmap *cFbsBitmap = new(ELeave)CFbsBitmap();
+ QVERIFY(cFbsBitmap = imputPixMap.toSymbianCFbsBitmap());
+
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+
+ TRAPD(errNoo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ *cFbsBitmap,
+ KWanted_LessHeight));
+
+ QCOMPARE(errNoo, KErrNone);
+ WaitActive(5000000);
+
+ QVERIFY(!mErrorCallBack);
+ QVERIFY(!mPixMapCallBack.isNull());
+ QCOMPARE(mPixMapCallBack.width(), KWanted_LessHeight.iWidth);
+ QCOMPARE(mPixMapCallBack.height(), KWanted_LessHeight.iHeight);
+
+ delete screenShotHadnler;
+ delete cFbsBitmap;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testCFbsBitmapScalinToIncorrectWidthSize()
+{
+ QPixmap imputPixMap(KFileName2);
+
+ CFbsBitmap *cFbsBitmap = new(ELeave)CFbsBitmap();
+ QVERIFY(cFbsBitmap = imputPixMap.toSymbianCFbsBitmap());
+
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(-20, 118);
+
+ TRAPD(errNoo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ *cFbsBitmap,
+ newSize));
+
+ QCOMPARE(errNoo, KErrCorrupt);
+ WaitActive(5000000);
+
+ delete screenShotHadnler;
+ delete cFbsBitmap;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::testCFbsBitmapScalinToIncorrectHeightSize()
+{
+ QPixmap imputPixMap(KFileName2);
+
+ CFbsBitmap *cFbsBitmap = new(ELeave)CFbsBitmap();
+ QVERIFY(cFbsBitmap = imputPixMap.toSymbianCFbsBitmap());
+
+ CTsGraphicFileScalingHandler *screenShotHadnler = 0;
+ TSize newSize(240, -20);
+
+ TRAPD(errNoo, screenShotHadnler =
+ CTsGraphicFileScalingHandler::NewL(*this,
+ *cFbsBitmap,
+ newSize));
+
+ QCOMPARE(errNoo, KErrCorrupt);
+ WaitActive(5000000);
+
+ delete screenShotHadnler;
+ delete cFbsBitmap;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_CTsGraphicFileScalingHandler::ImageReadyCallBack(TInt error,
+ const CFbsBitmap *bitmap)
+{
+ CFbsBitmap *retBitmap = const_cast<CFbsBitmap *>(bitmap);
+
+ mErrorCallBack = error;
+ mPixMapCallBack = QPixmap();
+
+ if (retBitmap && !error) {
+ mPixMapCallBack = QPixmap::fromSymbianCFbsBitmap(retBitmap);
+ }
+}
+
+// End of KFileName
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/tsutils/tsrc/t_tsgraphicfilescalinghandler/t_tsgraphicfilescalinghandler.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2009 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:
+#
+CONFIG += qtestlib console
+
+HEADERS += ./inc/t_tsgraphicfilescalinghandler.h
+HEADERS += ../../inc/tsgraphicfilescalinghandler.h
+
+SOURCES += ./src/t_tsgraphicfilescalinghandler.cpp
+SOURCES += ../../src/tsgraphicfilescalinghandler.cpp
+
+LIBS += -lbitmaptransforms \
+ -limageconversion \
+ -lfbscli \
+ -lapparc \
+ -lapgrfx \
+ -lcone \
+ -lefsrv \
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ export.sources = ./data/image_file.png
+ export.path = c:/data/Images/Pictures/
+ DEPLOYMENT += export
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/tsutils/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += symbian_tests
+
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+}
+
+
+SUBDIRS += t_tsgraphicfilescalinghandler \
Binary file contentstorage/caclient/tsrc/t_caclient/data/armv5/sapiapp_S60_3_X_v_1_0_0.SISX has changed
Binary file contentstorage/caclient/tsrc/t_caclient/data/castorage.db has changed
Binary file contentstorage/caclient/tsrc/t_caclient/data/emailTest.qm has changed
Binary file contentstorage/caclient/tsrc/t_caclient/data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../../..");
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system('ctcwrap -i fd -2comp -C "EXCLUDE=*" -C "EXCLUDE+./srvsrc/casrvengutils.cpp" -C "NO_EXCLUDE+srvsrc/menusrvmain.cpp" -C "NO_EXCLUDE+srvsrc/casrv.cpp" -C "NO_EXCLUDE+srvsrc/cadatamanager.cpp" -C "NO_EXCLUDE+srvsrc/casrveng.cpp" -C "NO_EXCLUDE+srvsrc/casrvnotifier.cpp" -C "NO_EXCLUDE+srvsrc/casrvsession.cpp" -C "NO_EXCLUDE+srvsrc/castorageproxy.cpp" -C "NO_EXCLUDE+cautils/src/cai*" -C "NO_EXCLUDE+cautils/src/cae*" -C "NO_EXCLUDE+cautils/src/cal*" -C "NO_EXCLUDE+extsrc/cai*" -C "NO_EXCLUDE+casrv/casrvmgr/src/casrvmanager.cpp" -C "NO_EXCLUDE+caclient/s60/src/*" -C "NO_EXCLUDE+caclient/src/*" sbs -j 4 -c winscw_udeb');
+
+ chdir("caclient/tsrc/t_caclient");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_caclient -o c:\\t_caclient.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../../..");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o caclient/tsrc/t_caclient/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o caclient/tsrc/t_caclient/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/inc/t_caclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,383 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+#ifndef T_CACLIENT_H
+#define T_CACLIENT_H
+
+#include <QtTest/QtTest>
+#include "cadefs.h"
+
+#ifdef Q_OS_SYMBIAN
+#include <e32std.h>
+#endif
+
+class CaService;
+class CaEntry;
+class CaItemModel;
+
+/**
+ * @test Test class for hsmcsserviceprovider library.
+ */
+class TestCaClient : public QObject
+{
+ Q_OBJECT
+
+private slots:
+
+#ifdef Q_OS_SYMBIAN
+ //executeCommand
+ void TestExecuteCommandRemove();
+
+ void TestExecuteCommandOpen();
+#endif //Q_OS_SYMBIAN
+
+ /**
+ * initialize
+ */
+ void initTestCase();
+
+ //localization
+
+ void TestLocalizationEntryGetters();
+
+ void TestLocalizationTApp();
+
+ void TestCreateLocalizedItem();
+
+// query&entry getters
+ void TestEntryGetters();
+
+ void TestEntryAssignmentOperator();
+
+ void TestQueryGetters();
+
+ void TestQueryClear();
+
+ void TestQueryRemove();
+
+ void TestQueryAssignmentOperator();
+
+ void TestMakeDefaultCollectionIcon();
+
+ void TestMakeDefaultApplicationIcon();
+
+ void TestMakeNotNativeApplicationIcon();
+
+ void TestMakeExistingIcon();
+
+ void TestMakeNotExistingIcon();
+
+ void TestGetEntryIcon();
+ void TestGetApplicationIcon();
+ void TestGetIconFromEntry();
+ void TestGetIconFromApparc();
+ void TestGetDefaultIcon();
+
+
+//create&update
+ void TestUpdateItem();
+
+ void TestCreateItem();
+
+ void TestCreateGroup();
+
+ void TestCreateItemNotAllParams();
+
+ void TestCreateGroupNotAllParams();
+
+ void TestUpdateGroup();
+
+//remove
+ void TestRemoveItem();
+
+ void TestRemoveGroup();
+
+ void TestRemoveItems();
+
+ void TestRemoveItemsFail();
+
+ void TestRemoveGroups();
+
+ void TestRemoveGroupsFail();
+
+// backup
+
+ void TestCreateBackupNotifier();
+
+ void TestBackupNotifierRunL();
+
+
+//organize
+
+ void TestAppendEntryIntoGroup1();
+
+ void TestAppendEntryIntoGroup2();
+
+ void TestAppendEntriesIntoGroup1();
+
+ void TestAppendEntriesIntoGroup2();
+
+ void TestPrependEntryIntoGroup1();
+
+ void TestPrependEntryIntoGroup2();
+
+ void TestPrependEntriesIntoGroup1();
+
+ void TestPrependEntriesIntoGroup2();
+
+ void TestInsertEntryIntoGroup1();
+
+ void TestInsertEntryIntoGroup2();
+
+ void TestInsertEntriesIntoGroup1();
+
+ void TestInsertEntriesIntoGroup2();
+
+ void TestRemoveEntryFromGroup1();
+
+ void TestRemoveEntryFromGroup2();
+
+ void TestRemoveEntriesFromGroup1();
+
+ void TestRemoveEntriesFromGroup2();
+
+ void TestCustomSort();
+
+ void TestCustomSortArrange();
+
+ void TestCustomSortGroups();
+
+ void TestCustomSortFake();
+
+
+//get entries
+ void TestGetEntry();
+
+ void TestGetEntriesByIds();
+
+ void TestGetEntriesByRole();
+
+ void TestGetEntriesByParent();
+
+ void TestGetEntriesByType1();
+
+ void TestGetEntriesByType2();
+
+ void TestGetEntriesByFlagsOn();
+
+ void TestGetEntriesByFlagsOff();
+
+ void TestGetEntriesByFlagsOnOff();
+
+ void TestGetEntriesByRoleParent();
+
+ void TestGetEntriesByRoleType();
+
+ void TestGetEntriesByRoleFlags();
+
+ void TestGetEntriesByParentType();
+
+ void TestGetEntriesByParentFlags();
+
+ void TestGetEntriesByTypeFlags();
+
+ void TestGetEntriesByRoleParentType();
+
+ void TestGetEntriesByRoleParentFlags();
+
+ void TestGetEntriesByParentTypeFlags();
+
+ void TestGetEntriesByRoleParentTypeFlags();
+
+ void TestGetEntriesCount();
+
+ void TestGetEntriesSortCreated();
+
+ void TestGetEntriesSortDefault();
+
+ void TestGetEntriesSortName();
+
+ void TestGetEntriesSortLast();
+
+ void TestGetEntriesSortMost();
+
+ void TestGetEntriesIdsByRole();
+
+ void TestGetEntriesIdsByParent();
+
+ void TestGetEntriesIdsByType1();
+
+ void TestGetEntriesIdsByType2();
+
+ void TestGetEntriesIdsByFlagsOn();
+
+ void TestGetEntriesIdsByFlagsOff();
+
+ void TestGetEntriesIdsByFlagsOnOff();
+
+ void TestGetEntriesIdsByRoleParent();
+
+ void TestGetEntriesIdsByRoleType();
+
+ void TestGetEntriesIdsByRoleFlags();
+
+ void TestGetEntriesIdsByParentType();
+
+ void TestGetEntriesIdsByParentFlags();
+
+ void TestGetEntriesIdsByTypeFlags();
+
+ void TestGetEntriesIdsByRoleParentType();
+
+ void TestGetEntriesIdsByRoleParentFlags();
+
+ void TestGetEntriesIdsByParentTypeFlags();
+
+ void TestGetEntriesIdsByRoleParentTypeFlags();
+
+ void TestGetEntriesIdsCount();
+
+ void TestGetEntriesIdsSortDefault();
+
+ void TestGetEntriesIdsSortCreated();
+
+ void TestGetEntriesIdsSortName();
+
+ void TestGetEntriesIdsSortLast();
+
+ void TestGetEntriesIdsSortMost();
+
+ void TestGetEntriesByAttributes();
+
+ //caitemmodel
+ void TestCaItemModelConstruct();
+ void TestCaItemModelAutoUpdate();
+ void TestCaItemModelIndex();
+ void TestCaItemModelData();
+ void TestCaItemModelIconSize();
+ void TestCaItemModelChangeParent();
+ void TestCaItemModelSortOrder();
+ void TestCaItemModelUpdateItem();
+ void TestCaItemModelAddItems();
+ void TestCaItemModelEmptySignal();
+
+// notifier
+
+ void TestAssignmentOperatorNotifier();
+
+ void TestAddItemChangeTypeNotifier();
+ void TestAddGroupChangeTypeNotifier();
+
+ void TestRemoveEntryChangeTypeNotifier();
+ void TestRemoveEntryIdChangeTypeNotifier();
+ void TestRemoveEntryChangeTypeNotifierFake();
+ void TestRemoveEntryIdChangeTypeNotifierFake();
+ void TestRemoveEntriesChangeTypeNotifier();
+ void TestRemoveEntriesIdsChangeTypeNotifier();
+ void TestRemoveEntriesChangeTypeNotifierFake();
+ void TestRemoveEntriesIdsChangeTypeNotifierFake();
+ void TestRemoveGroupChangeTypeNotifier();
+ void TestRemoveGroupsChangeTypeNotifier();
+
+ void TestUpdateChangeTypeNotifier();
+ void TestUpdateChangeTypeNotifierFake();
+ void TestAddUpdateRemove();
+
+ void TestRegisterNotifier();
+ void TestUnregisterNotifier();
+
+ void TestTouchEntryNotifier();
+ void TestTouchEntryIdNotifier();
+ void TestTouchEntryUidNotifier();
+ void TestTouchEntryNotifierFake();
+ void TestTouchEntryIdNotifierFake();
+ void TestTouchGroupNotifier();
+
+ void TestAppendEntryGroupNotifier();
+ void TestAppendEntryGroupIdNotifier();
+ void TestAppendEntriesGroupNotifier();
+ void TestAppendEntriesGroupIdNotifier();
+
+ void TestPrependEntryGroupNotifier();
+ void TestPrependEntryGroupIdNotifier();
+ void TestPrependEntriesGroupNotifier();
+ void TestPrependEntriesGroupIdNotifier();
+
+ void TestRemoveEntryGroupNotifier();
+ void TestRemoveEntryGroupIdNotifier();
+ void TestRemoveEntriesGroupNotifier();
+ void TestRemoveEntriesGroupIdNotifier();
+
+ void TestInsertEntryGroupNotifier();
+ void TestInsertEntryGroupIdNotifier();
+ void TestInsertEntriesGroupNotifier();
+ void TestInsertEntriesGroupIdNotifier();
+
+ void TestChangeEntryWithParentIdNotifier();
+
+
+
+ void TestRemoveEntriesChangeTypeNotifier3Clients();
+
+ void TestAddItemChangeTypeNotifierNClients();
+ void TestAddItemChangeTypeNotifierNClientsFast();
+ void TestAddItemChangeTypeNotifierNClientsThreads();
+
+ void TestRemoveEntryChangeTypeNotifierNClients();
+ void TestRemoveEntryChangeTypeNotifierNClientsThreads();
+ void TestRemoveEntryIdChangeTypeNotifierNClientsThreads();
+
+ void TestAddItemChangeTypeNotifierManyClientsThreads();
+ //void TestRemoveEntriesChangeTypeNotifier3Clients();
+
+ // void TestAppendRemoveEntryGroupNotifier();
+
+ void TestCreateItemWhenServerWasTerminated();
+
+ void TestAddItemChangeTypeNotifier3Clients();
+ void TestRemoveEntryChangeTypeNotifier3Clients();
+
+ /**
+ * cleanup
+ */
+ void cleanupTestCase();
+
+private:
+ void startThread();
+ void stopThread();
+ // utility methods
+ QSharedPointer<CaEntry> createGroup(const QString &groupName, const QString &typeName);
+ QSharedPointer<CaEntry> createItem(const QString &itemName, const QString &description,
+ const QString &typeName, EntryFlags flags);
+ QSharedPointer<CaEntry> createItem(const QString &itemName, const QString &typeName);
+ void addItemToGroup(int groupId, int itemId);
+ void removeItemFromGroup(int groupId, int itemId);
+ void removeEntry(int entryId);
+ bool removeEntry(const QString &entryName);
+ QString itemName(const CaItemModel &model, int row);
+ void terminatServer();
+
+#ifdef Q_OS_SYMBIAN
+ RThread iThread;
+#endif //Q_OS_SYMBIAN
+
+private:
+ QSharedPointer<CaService> mService;
+};
+
+
+#endif//T_CACLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/inc/t_caclientnotifier.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+#ifndef T_CACLIENTNOTIFIER_H
+#define T_CACLIENTNOTIFIER_H
+
+#include <QObject>
+#include <QList>
+#include "cadefs.h"
+
+class CaEntry;
+class CaNotifierFilter;
+class CaNotifier;
+class CaService;
+
+/**
+ * @test Test class for hsmcsserviceprovider library.
+ */
+class TestCaClientNotifier : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ TestCaClientNotifier();
+ TestCaClientNotifier(const CaService &service, CaNotifierFilter *filter = 0);
+ ~TestCaClientNotifier();
+
+ CaNotifier *getNotifier() const;
+ CaNotifierFilter *getFilter() const;
+ void clean();
+
+public slots:
+
+ void entryChanged(int entryId, ChangeType changeType);
+ void entryChanged(const CaEntry &entry, ChangeType changeType);
+ void entryTouched(int id);
+ void groupContentChanged(int groupId);
+
+public:
+
+ int mEntryId;
+ int mGroupId;
+ ChangeType mChangeType;
+ CaEntry *mEntry;
+
+ int mCount;
+ QList<int> *mEntryIds;
+ QList<int> *mGroupIds;
+ QList<ChangeType> *mChangeTypes;
+ QList<const CaEntry *> *mEntries;
+
+ CaNotifierFilter *mFilter;
+ CaNotifier *mNotifier;
+
+private:
+
+ Q_DISABLE_COPY(TestCaClientNotifier)
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_caclient_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\sis\rd.cer -key ..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_backupnotifier.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+#include <sacls.h>
+#include <connect/sbdefs.h>
+
+#ifdef Q_OS_SYMBIAN
+//s60
+#include <e32base.h>
+//#include <>
+#include <W32STD.H>
+#include <APGTASK.H>
+
+#include "t_caclient.h"
+#include "cabackupnotifier.h"
+#include "castorageproxy.h"
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCreateBackupNotifier()
+{
+ QScopedPointer<CCaStorageProxy> proxy( CCaStorageProxy::NewL() ) ;
+ QScopedPointer<CCaBackupNotifier> notifier( CCaBackupNotifier::NewL( proxy.data() ) );
+
+ QVERIFY( notifier );
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestBackupNotifierRunL()
+{
+ QScopedPointer<CCaStorageProxy> proxy( CCaStorageProxy::NewL() );
+ QScopedPointer<CCaBackupNotifier> notifier( CCaBackupNotifier::NewL( proxy.data() ) );
+
+ TUid KUidMyCat={0x101aaaa6};
+ RProperty::Define(KUidMyCat, 0, RProperty::EInt, 0);
+
+ notifier->Cancel();
+ notifier->iProperty.Attach(KUidMyCat,0);
+ notifier->iStatus = KRequestPending;
+ notifier->iProperty.Subscribe(notifier->iStatus);
+ notifier->SetActive();
+
+ RProperty::Set(KUidMyCat, 0, conn::EBURRestorePartial);
+ QTest::qWait(5000);
+
+ QVERIFY( notifier->iLastState == CCaBackupNotifier::ECaRestore );
+
+}
+
+
+#endif //Q_OS_SYMBIAN
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_createupdate.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,402 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCreateItem()
+{
+ {
+ const CaEntry constItem;
+ QCOMPARE(constItem.role(), ItemEntryRole);
+
+ //create item
+ //check if proper entry returned
+ CaEntry item;
+ item.setText("testName");
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+ item.setDescription("description");
+ CaIconDescription iconDescription;
+ iconDescription.setFilename("iconFileName");
+ iconDescription.setSkinId("iconSkinId");
+ iconDescription.setApplicationId("268458321");
+
+ item.setIconDescription(iconDescription);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem = service->createEntry(item);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(!resultItem.isNull());
+ QCOMPARE(resultItem->role(), ItemEntryRole);
+ QCOMPARE(item.text(),resultItem->text());
+ QCOMPARE(item.description(),resultItem->description());
+ QCOMPARE(item.entryTypeName(),resultItem->entryTypeName());
+ QCOMPARE(QString("attrVal1"),resultItem->attribute("attrName1"));
+ QCOMPARE(item.flags(),resultItem->flags());
+ int itId =item.id();
+ int resItId =resultItem->id();
+ QVERIFY(itId != resItId);
+ QCOMPARE(iconDescription.filename(),resultItem->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),resultItem->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),resultItem->iconDescription().applicationId());
+
+ // entry from storage
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem->id());
+ QVERIFY(storageItem1);
+ QCOMPARE(QString("testName"),storageItem1->text());
+ QCOMPARE(QString("description"),storageItem1->description());
+ QCOMPARE(QString("test"),storageItem1->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageItem1->attribute("attrName1"));
+ EntryFlags flags = item.flags();
+ EntryFlags storageFlags = storageItem1->flags();
+ QCOMPARE(iconDescription.filename(),storageItem1->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),storageItem1->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),storageItem1->iconDescription().applicationId());
+ QVERIFY(storageItem1->iconDescription().id() > 0);
+
+ QCOMPARE(flags ,storageFlags);
+
+ //Cleanup
+ service->removeEntry(*resultItem);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCreateItemNotAllParams()
+{
+ {
+ //create item
+ //check if proper entry returned
+ CaEntry item;
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item);
+ QVERIFY(resultItem1.isNull());
+ QVERIFY(service->lastError() != NoErrorCode);
+ item.setText("text");
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item);
+ QVERIFY(resultItem2.isNull());
+ QVERIFY(service->lastError() != NoErrorCode);
+ item.setEntryTypeName("type");
+ item.setText("");
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item);
+ QVERIFY(resultItem3.isNull());
+ QVERIFY(service->lastError() != NoErrorCode);
+ item.setText("text");
+ QSharedPointer<CaEntry> resultItem4 = service->createEntry(item);
+ QVERIFY(!resultItem4.isNull());
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+ //Cleanup
+ service->removeEntry(*resultItem4);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCreateGroup()
+{
+ {
+ const CaEntry constGroup(GroupEntryRole);
+ QCOMPARE(constGroup.role(), GroupEntryRole);
+
+ //create group
+ //check if proper entry returned
+ CaEntry group(GroupEntryRole);
+ group.setText("testName");
+ group.setAttribute("attrName1", "attrVal1");
+ group.setEntryTypeName("test");
+ group.setFlags(RemovableEntryFlag);
+ CaIconDescription iconDescription;
+ iconDescription.setFilename("iconFileName");
+ iconDescription.setSkinId("iconSkinId");
+ iconDescription.setApplicationId("268458321");
+ group.setIconDescription(iconDescription);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultGroup = service->createEntry(group);
+ QCOMPARE(service->lastError(), NoErrorCode);
+
+ QVERIFY(!resultGroup.isNull());
+ QCOMPARE(resultGroup->role(), GroupEntryRole);
+
+ QCOMPARE(group.text(),resultGroup->text());
+ QCOMPARE(group.entryTypeName(),resultGroup->entryTypeName());
+ QCOMPARE(QString("attrVal1"),resultGroup->attribute("attrName1"));
+ QCOMPARE(group.flags(),resultGroup->flags());
+ QVERIFY(group.id() != resultGroup->id());
+ QCOMPARE(iconDescription.filename(),resultGroup->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),resultGroup->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),resultGroup->iconDescription().applicationId());
+
+ // entry from storage
+ QSharedPointer<CaEntry> storageGroup1 = service->getEntry(resultGroup->id());
+ QVERIFY(!storageGroup1.isNull());
+ QCOMPARE(QString("testName"),storageGroup1->text());
+ QCOMPARE(QString("test"),storageGroup1->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageGroup1->attribute("attrName1"));
+ QCOMPARE(group.flags(),storageGroup1->flags());
+ QCOMPARE(iconDescription.filename(),storageGroup1->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),storageGroup1->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),storageGroup1->iconDescription().applicationId());
+ //Cleanup
+ service->removeEntry(*resultGroup);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCreateGroupNotAllParams()
+{
+ {
+ //create group
+ //check if proper entry returned
+ CaEntry group(GroupEntryRole);
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> result1 = service->createEntry(group);
+ QVERIFY(result1.isNull());
+ QVERIFY(service->lastError() != NoErrorCode);
+ group.setText("text");
+ QSharedPointer<CaEntry> result2 = service->createEntry(group);
+ QVERIFY(result2.isNull());
+ QVERIFY(service->lastError() != NoErrorCode);
+ group.setEntryTypeName("type");
+ group.setText("");
+ QSharedPointer<CaEntry> result3 = service->createEntry(group);
+ QVERIFY(result3.isNull());
+ QVERIFY(service->lastError() != NoErrorCode);
+ group.setText("text");
+ QSharedPointer<CaEntry> result4 = service->createEntry(group);
+ QVERIFY(!result4.isNull() );
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+ //Cleanup
+ service->removeEntry(*result4);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestUpdateItem()
+{
+ {
+ CaEntry item1;
+ item1.setText("testName");
+ item1.setAttribute("attrName1", "attrVal1");
+ item1.setEntryTypeName("test");
+ item1.setFlags(RemovableEntryFlag);
+ CaIconDescription iconDescription1;
+ iconDescription1.setFilename("iconFileName");
+ iconDescription1.setSkinId("iconSkinId");
+ iconDescription1.setApplicationId("268458321"); //Bluetouth app UID
+ item1.setIconDescription(iconDescription1);
+
+ CaIconDescription iconDescription2;
+ iconDescription2.setFilename("iconFileName2");
+ iconDescription2.setSkinId("iconSkinId2");
+ iconDescription2.setApplicationId("537001519"); //SW update app UID
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QCOMPARE(service->lastError(), NoErrorCode);
+
+ QVERIFY(!resultItem1.isNull());
+
+ int id1 = resultItem1->id();
+ resultItem1->setText("testName2");
+ resultItem1->setAttribute("attrName2", "attrVal2");
+ resultItem1->setAttribute("attrName1", "attrVal2");
+ resultItem1->setEntryTypeName("test2");
+ resultItem1->setFlags(UninstallEntryFlag);
+ resultItem1->setIconDescription(iconDescription2);
+
+ bool updateResult1 = service->updateEntry(item1);
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(!updateResult1); // no id -> return false
+
+ bool updateResult2 = service->updateEntry(*resultItem1);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(updateResult2); // id present -> true
+
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(*resultItem1);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(!resultItem2.isNull());
+
+ int id2 = resultItem2->id();
+ QVERIFY(id1 != id2); //entry clone created
+
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(id1);
+ QVERIFY(!storageItem1.isNull());
+
+ QSharedPointer<CaEntry> storageItem2 = service->getEntry(id2);
+ QVERIFY(!storageItem2.isNull());
+
+ // check if attributes were updated
+ QCOMPARE(QString("testName2"),storageItem1->text());
+ QCOMPARE(QString("test2"),storageItem1->entryTypeName());
+
+ QCOMPARE(QString("attrVal2"),storageItem1->attribute("attrName1"));
+ QCOMPARE(QString("attrVal2"),storageItem1->attribute("attrName2"));
+ QCOMPARE(resultItem1->flags(),storageItem1->flags());
+ QCOMPARE(iconDescription2.filename(),storageItem1->iconDescription().filename());
+ QCOMPARE(iconDescription2.skinId(),storageItem1->iconDescription().skinId());
+ QCOMPARE(iconDescription2.applicationId(),storageItem1->iconDescription().applicationId());
+ // cloned item should have the same attributes
+ QCOMPARE(QString("testName2"),storageItem2->text());
+ QCOMPARE(QString("test2"),storageItem2->entryTypeName());
+ QCOMPARE(QString("attrVal2"),storageItem2->attribute("attrName1"));
+ QCOMPARE(QString("attrVal2"),storageItem2->attribute("attrName2"));
+ QCOMPARE(resultItem1->flags(),storageItem2->flags());
+
+ //Cleanup
+ service->removeEntry(id1);
+ service->removeEntry(id2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestUpdateGroup()
+{
+ {
+ CaEntry group1(GroupEntryRole);
+ group1.setText("testName");
+ group1.setAttribute("attrName1", "attrVal1");
+ group1.setEntryTypeName("test");
+ group1.setFlags(RemovableEntryFlag);
+ CaIconDescription iconDescription1;
+ iconDescription1.setFilename("iconFileName");
+ iconDescription1.setSkinId("iconSkinId");
+ iconDescription1.setApplicationId("268458321");
+ group1.setIconDescription(iconDescription1);
+ CaIconDescription iconDescription2;
+ iconDescription2.setFilename("iconFileName2");
+ iconDescription2.setSkinId("iconSkinId2");
+ iconDescription2.setApplicationId("537001519");
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(!resultGroup1.isNull());
+
+ int id1 = resultGroup1->id();
+ resultGroup1->setText("testName2");
+ resultGroup1->setAttribute("attrName2", "attrVal2");
+ resultGroup1->setEntryTypeName("test2");
+ resultGroup1->setFlags(UninstallEntryFlag);
+ resultGroup1->setIconDescription(iconDescription2);
+
+ bool updateResult1 = service->updateEntry(group1);
+ QVERIFY(!updateResult1); // no id -> return false
+ QVERIFY(service->lastError() != NoErrorCode);
+
+
+ bool updateResult2 = service->updateEntry(*resultGroup1);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(updateResult2); // id present -> true
+
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(*resultGroup1);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int id2 = resultGroup2->id();
+ QVERIFY(id1 != id2); //entry clone created
+
+ QSharedPointer<CaEntry> storageGroup1 = service->getEntry(id1);
+ QVERIFY(!storageGroup1.isNull());
+
+ QSharedPointer<CaEntry> storageGroup2 = service->getEntry(id2);
+ QVERIFY(!storageGroup2.isNull());
+
+ // check if attributes were updated
+ QCOMPARE(QString("testName2"),storageGroup1->text());
+ QCOMPARE(QString("test2"),storageGroup1->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageGroup1->attribute("attrName1"));
+ QCOMPARE(QString("attrVal2"),storageGroup1->attribute("attrName2"));
+ QCOMPARE(resultGroup1->flags(),storageGroup1->flags());
+ QCOMPARE(iconDescription2.filename(),storageGroup1->iconDescription().filename());
+ QCOMPARE(iconDescription2.skinId(),storageGroup1->iconDescription().skinId());
+ QCOMPARE(iconDescription2.applicationId(),storageGroup1->iconDescription().applicationId());
+ // cloned item should have the same attributes
+ QCOMPARE(QString("testName2"),storageGroup2->text());
+ QCOMPARE(QString("test2"),storageGroup2->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageGroup2->attribute("attrName1"));
+ QCOMPARE(QString("attrVal2"),storageGroup2->attribute("attrName2"));
+ QCOMPARE(resultGroup1->flags(),storageGroup2->flags());
+
+ //Cleanup
+ service->removeEntry(id1);
+ service->removeEntry(id2);
+
+ }
+}
+//TODO: change name
+void TestCaClient::TestCreateItemWhenServerWasTerminated()
+{
+ terminatServer();
+ TestCreateItem();
+ terminatServer();
+ TestUpdateItem();
+ terminatServer();
+ TestGetEntry();
+ terminatServer();
+ TestGetEntriesByIds();
+ terminatServer();
+ TestGetEntriesByRole();
+ terminatServer();
+ TestGetEntriesIdsByRole();
+ terminatServer();
+ TestRemoveItem();
+ terminatServer();
+ TestInsertEntriesIntoGroup1();
+ terminatServer();
+ TestRemoveEntriesFromGroup1();
+ terminatServer();
+ TestCustomSort();
+ terminatServer();
+ TestAppendEntriesIntoGroup1();
+ terminatServer();
+ TestPrependEntryIntoGroup1();
+}
+
+void TestCaClient::terminatServer()
+{
+ TFindProcess processFinder;
+ processFinder.Find(_L("camenuserver*"));
+ TFullName caName;
+ while ( KErrNone == processFinder.Next( caName ) ) {
+ RProcess caProcess;
+ TInt err = caProcess.Open(caName);
+ if( KErrNone == err ) {
+ caProcess.Terminate(0);
+ }
+ caProcess.Close();
+ }
+}
+
+QTEST_MAIN(TestCaClient)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_entryquery.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,508 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+#include <HbIcon>
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+#include "calocalizationentry.h"
+
+#include "camenuiconutility.h"
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestEntryGetters()
+{
+ {
+ CaIconDescription iconDesc;
+ iconDesc.setFilename(QString("fileName"));
+ iconDesc.setSkinId(QString("skinId"));
+ iconDesc.setApplicationId(QString("268458321"));
+
+ CaEntry entry;
+ entry.setText(QString("test"));
+ entry.setFlags(UninstallEntryFlag);
+ entry.setEntryTypeName(QString("typeNameTest"));
+ entry.setAttribute(QString("aname"),QString("aval"));
+ entry.setIconDescription(iconDesc);
+
+ QCOMPARE(entry.text(), QString("test"));
+ QCOMPARE(entry.flags(), UninstallEntryFlag);
+ QCOMPARE(entry.entryTypeName(), QString("typeNameTest"));
+ QCOMPARE(entry.attribute(QString("aname")), QString("aval"));
+ QCOMPARE(entry.iconDescription().filename(), QString("fileName"));
+ QCOMPARE(entry.iconDescription().skinId(), QString("skinId"));
+ QCOMPARE(entry.iconDescription().applicationId(), QString("268458321"));
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestEntryAssignmentOperator()
+{
+ {
+ CaIconDescription iconDesc;
+ iconDesc.setFilename(QString("fileName"));
+ iconDesc.setSkinId(QString("skinId"));
+ iconDesc.setApplicationId(QString("268458321"));
+
+ CaEntry entry;
+ entry.setText(QString("test"));
+ entry.setFlags(UninstallEntryFlag);
+ entry.setEntryTypeName(QString("typeNameTest"));
+ entry.setAttribute(QString("aname"),QString("aval"));
+ entry.setIconDescription(iconDesc);
+
+ CaEntry copied(entry);
+ CaEntry assigned;
+ assigned = entry;
+
+ QCOMPARE(copied.text(), QString("test"));
+ QCOMPARE(copied.flags(), UninstallEntryFlag);
+ QCOMPARE(copied.entryTypeName(), QString("typeNameTest"));
+ QCOMPARE(copied.attribute(QString("aname")), QString("aval"));
+ QCOMPARE(copied.iconDescription().filename(), QString("fileName"));
+ QCOMPARE(copied.iconDescription().skinId(), QString("skinId"));
+ QCOMPARE(copied.iconDescription().applicationId(), QString("268458321"));
+
+
+ QCOMPARE(assigned.text(), QString("test"));
+ QCOMPARE(assigned.flags(), UninstallEntryFlag);
+ QCOMPARE(assigned.entryTypeName(), QString("typeNameTest"));
+ QCOMPARE(assigned.attribute(QString("aname")), QString("aval"));
+ QCOMPARE(assigned.iconDescription().filename(), QString("fileName"));
+ QCOMPARE(assigned.iconDescription().skinId(), QString("skinId"));
+ QCOMPARE(assigned.iconDescription().applicationId(), QString("268458321"));
+
+ CaEntry group(GroupEntryRole);
+ group.setText(QString("test"));
+ group.setFlags(UninstallEntryFlag);
+ group.setEntryTypeName(QString("typeNameTest"));
+ group.setAttribute(QString("aname"),QString("aval"));
+ group.setIconDescription(iconDesc);
+
+ CaEntry copiedG(group);
+ CaEntry assignedG(GroupEntryRole);
+ assignedG = group;
+
+ QCOMPARE(copiedG.text(), QString("test"));
+ QCOMPARE(copiedG.flags(), UninstallEntryFlag);
+ QCOMPARE(copiedG.entryTypeName(), QString("typeNameTest"));
+ QCOMPARE(copiedG.attribute(QString("aname")), QString("aval"));
+ QCOMPARE(copiedG.iconDescription().filename(), QString("fileName"));
+ QCOMPARE(copiedG.iconDescription().skinId(), QString("skinId"));
+ QCOMPARE(copiedG.iconDescription().applicationId(), QString("268458321"));
+
+ QCOMPARE(assignedG.text(), QString("test"));
+ QCOMPARE(assignedG.flags(), UninstallEntryFlag);
+ QCOMPARE(assignedG.entryTypeName(), QString("typeNameTest"));
+ QCOMPARE(assignedG.attribute(QString("aname")), QString("aval"));
+ QCOMPARE(assignedG.iconDescription().filename(), QString("fileName"));
+ QCOMPARE(assignedG.iconDescription().skinId(), QString("skinId"));
+ QCOMPARE(assignedG.iconDescription().applicationId(), QString("268458321"));
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestQueryGetters()
+{
+ {
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ QStringList typenames;
+ typenames << QString("typename1");
+ query.setEntryTypeNames(typenames);
+ query.addEntryTypeName(QString("typename2"));
+ query.setFlagsOn(UninstallEntryFlag);
+ query.setFlagsOff(RemovableEntryFlag);
+ query.setParentId(7777);
+ query.setChildId(1111);
+ query.setSort(MostUsedSortAttribute, Qt::AscendingOrder);
+ query.setCount(67);
+
+ QCOMPARE(query.entryRoles(), ItemEntryRole);
+ QCOMPARE(query.parentId(), 7777);
+ QCOMPARE(query.childId(), 1111);
+ QCOMPARE(query.count(), uint(67));
+ QCOMPARE(query.entryTypeNames().count(), 2);
+ QCOMPARE(query.entryTypeNames().at(0), QString("typename1"));
+ QCOMPARE(query.entryTypeNames().at(1), QString("typename2"));
+ QCOMPARE(query.flagsOn(), UninstallEntryFlag);
+ QCOMPARE(query.flagsOff(), RemovableEntryFlag);
+ SortAttribute srtAttr;
+ Qt::SortOrder srtOrd;
+ query.getSort(srtAttr,srtOrd);
+ QCOMPARE(srtAttr, MostUsedSortAttribute);
+ QCOMPARE(srtOrd, Qt::AscendingOrder);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestQueryClear()
+{
+ {
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ QStringList typenames;
+ typenames << QString("typename1");
+ query.setEntryTypeNames(typenames);
+ query.addEntryTypeName(QString("typename2"));
+ query.setFlagsOn(UninstallEntryFlag);
+ query.setFlagsOff(RemovableEntryFlag);
+ query.setParentId(7777);
+ query.setChildId(1111);
+ query.setSort(MostUsedSortAttribute, Qt::DescendingOrder);
+ query.setCount(67);
+
+ query.clear();
+
+ QCOMPARE(query.entryRoles(), ItemEntryRole|GroupEntryRole);
+ QCOMPARE(query.parentId(), 0);
+ QCOMPARE(query.childId(), 0);
+ QCOMPARE(query.count(), uint(0));
+ QCOMPARE(query.entryTypeNames().count(), 0);
+ QCOMPARE(query.flagsOn(), EntryFlags());
+ QCOMPARE(query.flagsOff(), EntryFlags());
+ SortAttribute srtAttr;
+ Qt::SortOrder srtOrd;
+ query.getSort(srtAttr,srtOrd);
+ QCOMPARE(srtAttr, DefaultSortAttribute);
+ QCOMPARE(srtOrd, Qt::AscendingOrder);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestQueryRemove()
+{
+ CaQuery query;
+ QString native("native");
+ QString zero("0");
+ query.setAttribute(native, zero);
+ QCOMPARE(query.attribute(native), zero);
+ query.removeAttribute(native);
+ QCOMPARE(query.attribute(native), QString());
+}
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestQueryAssignmentOperator()
+{
+ {
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ QStringList typenames;
+ typenames << QString("typename1");
+ query.setEntryTypeNames(typenames);
+ query.addEntryTypeName(QString("typename2"));
+ query.setFlagsOn(UninstallEntryFlag);
+ query.setFlagsOff(RemovableEntryFlag);
+ query.setParentId(7777);
+ query.setChildId(1111);
+ query.setSort(MostUsedSortAttribute, Qt::DescendingOrder);
+ query.setCount(67);
+
+ CaQuery copied(query);
+ CaQuery assigned;
+ assigned = query;
+
+ QCOMPARE(copied.entryRoles(), ItemEntryRole);
+ QCOMPARE(copied.parentId(), 7777);
+ QCOMPARE(copied.childId(), 1111);
+ QCOMPARE(copied.count(), uint(67));
+ QCOMPARE(copied.entryTypeNames().count(), 2);
+ QCOMPARE(copied.entryTypeNames().at(0), QString("typename1"));
+ QCOMPARE(copied.entryTypeNames().at(1), QString("typename2"));
+ QCOMPARE(copied.flagsOn(), UninstallEntryFlag);
+ QCOMPARE(copied.flagsOff(), RemovableEntryFlag);
+ SortAttribute srtAttr;
+ Qt::SortOrder srtOrd;
+ copied.getSort(srtAttr,srtOrd);
+ QCOMPARE(srtAttr, MostUsedSortAttribute);
+ QCOMPARE(srtOrd, Qt::DescendingOrder);
+
+ QCOMPARE(assigned.entryRoles(), ItemEntryRole);
+ QCOMPARE(assigned.parentId(), 7777);
+ QCOMPARE(assigned.childId(), 1111);
+ QCOMPARE(assigned.count(), uint(67));
+ QCOMPARE(assigned.entryTypeNames().count(), 2);
+ QCOMPARE(assigned.entryTypeNames().at(0), QString("typename1"));
+ QCOMPARE(assigned.entryTypeNames().at(1), QString("typename2"));
+ QCOMPARE(assigned.flagsOn(), UninstallEntryFlag);
+ QCOMPARE(assigned.flagsOff(), RemovableEntryFlag);
+ assigned.getSort(srtAttr,srtOrd);
+ QCOMPARE(srtAttr, MostUsedSortAttribute);
+ QCOMPARE(srtOrd, Qt::DescendingOrder);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestMakeDefaultCollectionIcon()
+{
+ {
+ CaEntry entry;
+ entry.setText(QString("text"));
+ entry.setEntryTypeName(QString("collection"));
+ CaIconDescription iconDesc;// fake icon -> default should be fetched
+ iconDesc.setFilename(QString("fake"));
+ iconDesc.setSkinId(QString("fake"));
+ iconDesc.setApplicationId(QString("1234056789"));
+ entry.setIconDescription(iconDesc);
+ HbIcon icon = entry.makeIcon();
+ QVERIFY(icon.height() > 0);
+ QVERIFY(icon.width() > 0);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestMakeDefaultApplicationIcon()
+{
+ {
+ CaEntry entry;
+ entry.setText(QString("text"));
+ entry.setEntryTypeName(QString("application"));
+ CaIconDescription iconDesc;// fake icon -> default should be fetched
+ iconDesc.setFilename(QString("fake"));
+ iconDesc.setSkinId(QString("fake"));
+ iconDesc.setApplicationId(QString("1234056789"));
+ entry.setIconDescription(iconDesc);
+ HbIcon icon = entry.makeIcon();
+ QVERIFY(icon.height() > 0);
+ QVERIFY(icon.width() > 0);
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestMakeNotNativeApplicationIcon()
+{
+ {
+ CaEntry entry;
+ entry.setText(QString("text"));
+ entry.setEntryTypeName(QString("application"));
+ entry.setAttribute(QString("native"), QString("0"));
+ HbIcon icon = entry.makeIcon();
+ QVERIFY(icon.height() > 0);
+ QVERIFY(icon.width() > 0);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestMakeExistingIcon()
+{
+ {
+ CaEntry entry;
+ entry.setText(QString("text"));
+ entry.setEntryTypeName(QString("type"));
+ CaIconDescription iconDesc;// fake icon -> default should be fetched
+ iconDesc.setSkinId(QString("qtg_large_applications_user"));
+ entry.setIconDescription(iconDesc);
+ HbIcon icon = entry.makeIcon();
+ QVERIFY(icon.height() > 0);
+ QVERIFY(icon.width() > 0);
+
+ //tapplication
+ CaEntry entry2;
+ entry2.setText(QString("text2"));
+ entry2.setEntryTypeName(QString("templatedApplication"));
+ CaIconDescription iconDesc2;// fake icon -> default should be fetched
+ iconDesc2.setApplicationId(QString("537001519")); // bluetouth
+ entry2.setIconDescription(iconDesc2);
+ HbIcon icon2 = entry2.makeIcon();
+ QVERIFY(icon2.height() > 0);
+ QVERIFY(icon2.width() > 0);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestMakeNotExistingIcon()
+{
+ {
+ CaEntry entry;
+ entry.setText(QString("text"));
+ entry.setEntryTypeName(QString("type"));
+ CaIconDescription iconDesc;// fake icon
+ iconDesc.setFilename(QString("z:/resource/apps/fake.mif"));
+ entry.setIconDescription(iconDesc);
+ HbIcon icon = entry.makeIcon();
+ QVERIFY(icon.height() < 0);
+ QVERIFY(icon.width() < 0);
+
+ CaEntry entry2;
+ entry2.setText(QString("text2"));
+ entry2.setEntryTypeName(QString("type"));
+ CaIconDescription iconDesc2;// fake icon
+ iconDesc2.setFilename(QString("aaaa"));
+ entry2.setIconDescription(iconDesc2);
+ HbIcon icon2 = entry2.makeIcon();
+ QVERIFY(icon2.height() < 0);
+ QVERIFY(icon2.width() < 0);
+
+ CaEntry entry3;
+ entry3.setId(9999); //to avoid cache
+ entry3.setText(QString("text3"));
+ entry3.setEntryTypeName(QString("type"));
+ CaIconDescription iconDesc3;// fake icon
+ iconDesc3.setSkinId(QString("z:/resource/apps/fake_notcached.mif"));
+ entry3.setIconDescription(iconDesc3);
+ HbIcon icon3 = entry3.makeIcon();
+ QVERIFY(icon3.height() < 0);
+ QVERIFY(icon3.width() < 0);
+
+ CaEntry entry4;
+ entry4.setId(1000); //to avoid cache
+ entry4.setText(QString("text4"));
+ entry4.setEntryTypeName(QString("type"));
+ CaIconDescription iconDesc4;// fake icon
+ iconDesc4.setSkinId(QString("aaaa"));
+ entry4.setIconDescription(iconDesc4);
+ HbIcon icon4 = entry4.makeIcon();
+ QVERIFY(icon4.height() < 0);
+ QVERIFY(icon4.width() < 0);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntryIcon()
+{
+ {
+ CaEntry entry;
+ entry.setEntryTypeName(QString("application"));
+ QSizeF size(50,50);
+
+ HbIcon icon = CaMenuIconUtility::getEntryIcon(entry, size);
+ QVERIFY(icon.size().isValid());
+ QVERIFY(icon.height() > 0);
+ QVERIFY(icon.width() > 0);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetApplicationIcon()
+{
+ {
+ int uid = 270495019; // contest mbm icon
+ QSizeF size(50,50);
+
+ HbIcon icon = CaMenuIconUtility::getApplicationIcon(uid,size);
+
+ QVERIFY(icon.size().isValid());
+ QVERIFY(icon.height() > 0);
+ QVERIFY(icon.width() > 0);
+
+ int uid2 = 537006483; // AknConf mif icon
+ HbIcon icon2 = CaMenuIconUtility::getApplicationIcon(uid2,size);
+ QVERIFY(icon2.size().isValid());
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetIconFromEntry()
+{
+ {
+ CaEntry entry;
+ entry.setEntryTypeName(QString("application"));
+ entry.iconDescription().setFilename(QString("qtg_large_applications_download"));
+ QSizeF size(50,50);
+ HbIcon icon = CaMenuIconUtility::getEntryIcon(entry,size);
+ QVERIFY(icon.size().isValid());
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetIconFromApparc()
+{
+ {
+ CaEntry entry;
+ entry.setEntryTypeName(QString("application"));
+ int uid = 270495019; // contest mbm icon
+ QSizeF size(50,50);
+ HbIcon icon = CaMenuIconUtility::getApplicationIcon(uid,size);
+
+ QVERIFY(icon.size().isValid());
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetDefaultIcon()
+{
+ {
+ CaEntry entry;
+ entry.setText(QString("text"));
+ entry.setEntryTypeName(QString("application"));
+ CaIconDescription iconDesc;// fake icon -> default should be fetched
+ iconDesc.setFilename(QString("fake"));
+ iconDesc.setSkinId(QString("fake"));
+
+ entry.setIconDescription(iconDesc);
+ HbIcon icon = CaMenuIconUtility::getEntryIcon(entry);
+ QVERIFY(icon.size().isValid());
+
+ entry.setEntryTypeName(QString("collection"));
+ HbIcon icon2 = CaMenuIconUtility::getEntryIcon(entry);
+ QVERIFY(icon2.size().isValid());
+
+ entry.setEntryTypeName(QString("url"));
+ HbIcon icon3 = CaMenuIconUtility::getEntryIcon(entry);
+ QVERIFY(icon3.size().isValid());
+
+ entry.setEntryTypeName(QString("widget"));
+ HbIcon icon4 = CaMenuIconUtility::getEntryIcon(entry);
+ QVERIFY(icon4.size().isValid());
+
+ entry.setEntryTypeName(QString("templatedApplication"));
+ HbIcon icon5 = CaMenuIconUtility::getEntryIcon(entry);
+ QVERIFY(icon5.size().isValid());
+
+ entry.setEntryTypeName(QString("package"));
+ HbIcon icon6 = CaMenuIconUtility::getEntryIcon(entry);
+ QVERIFY(icon6.size().isValid());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_executecommand.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+
+#ifdef Q_OS_SYMBIAN
+//s60
+#include <e32base.h>
+//#include <>
+#include <W32STD.H>
+#include <APGTASK.H>
+
+#include "t_cainstaller.h"
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestExecuteCommandOpen()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> entry;
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ QList< QSharedPointer<CaEntry> > items = service->getEntries(query);
+ int itemsCount = items.count();
+ QVERIFY(itemsCount >0);
+ for (int i=0; i< itemsCount; i++) {
+ QString tmp = items[i]->text();
+ if (items[i]->text() == "Contacts") {
+ entry=items[i];
+ break;
+ }
+ }
+ QVERIFY(entry);
+ bool result = service->executeCommand(entry->id(), "open") == 0;
+ QTest::qWait(2500);
+ QVERIFY2(result, "Command *open* failed");
+ RWsSession session;
+ TInt error = session.Connect();
+ TApaTaskList taskList(session);
+ TApaTask task = taskList.FindApp(_L("Contacts"));
+ QTest::qWait(250);
+ bool taskExists(false);
+ if (task.Exists()) {
+ taskExists = true;
+ task.EndTask();
+ }
+ QTest::qWait(250);
+ session.Close();
+ QTest::qWait(250);
+ QVERIFY(taskExists);
+ }
+}
+
+void TestCaClient::TestExecuteCommandRemove()
+{
+ {
+
+ _LIT(KAppTestFile, "c:\\testing\\data\\t_caclient\\installs\\sapiapp_S60_3_X_v_1_0_0.sisx");
+ CaQuery query;
+ QSharedPointer<CaService> service = CaService::instance();
+ CaEntry *entry;
+ CaEntry *entryPhonebook;
+ QTest::qWait(250);
+ QStringList list("application");
+ query.setEntryTypeNames(list);
+ query.setFlagsOn(VisibleEntryFlag);
+ RFs TheFs;
+ User::LeaveIfError(TheFs.Connect());
+
+ QScopedPointer<T_CaInstaller> installer;
+ QT_TRAP_THROWING(installer.reset(T_CaInstaller::NewL()));
+
+ installer->InstallL( KAppTestFile );
+
+ QTest::qWait(30000);
+
+ QList< QSharedPointer<CaEntry> > items = service->getEntries(query);
+
+ int itemsCountAndOne = items.count();
+
+ for (int i=0; i< items.count(); i++) {
+ QString tmp = items[i]->text();
+ if (items[i]->text() == "Contacts") {
+ entryPhonebook=items[i].data();
+ break;
+ }
+ }
+
+ for (int i=0; i< itemsCountAndOne; i++) {
+ if (items[i]->text() == "sapiapp") {
+ entry=items[i].data();
+ break;
+ }
+ }
+ //entry attribute will be removed by appscanner
+ //after "sapiapp" entry is removed
+ entryPhonebook->setAttribute("mmc_id","0x12345678");
+ service->updateEntry(*entryPhonebook);
+ bool result = false;
+ if (entry->id() > 0) {
+ result = service->executeCommand(entry->id(), "remove") == 0;
+ }
+ QVERIFY2(result, "Remove command returns false");
+ QTest::qWait(40000);
+
+ QList< QSharedPointer<CaEntry> > itemsNew = service->getEntries(query);
+ int itemsCount = itemsNew.count();
+
+ QVERIFY2(itemsCountAndOne == itemsCount +1 , "Remove unsuccessful");
+
+ }
+}
+
+
+#endif //Q_OS_SYMBIAN
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_getentries.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,3129 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntry()
+{
+ {
+ CaEntry item;
+ item.setText("testName");
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+
+ CaIconDescription iconDescription;
+ iconDescription.setFilename("iconFileName");
+ iconDescription.setSkinId("iconSkinId");
+ iconDescription.setApplicationId("268458321");
+ item.setIconDescription(iconDescription);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem = service->createEntry(item);
+
+ QVERIFY(!resultItem.isNull());
+ // entry from storage
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem->id());
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(storageItem1);
+ QCOMPARE(storageItem1->role(), ItemEntryRole);
+ QCOMPARE(QString("testName"),storageItem1->text());
+ QCOMPARE(QString("test"),storageItem1->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageItem1->attribute("attrName1"));
+ QCOMPARE(item.flags(),storageItem1->flags());
+ QCOMPARE(iconDescription.filename(),storageItem1->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),storageItem1->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),storageItem1->iconDescription().applicationId());
+ QSharedPointer<CaEntry> storageItem2 = service->getEntry(9999);
+ QVERIFY(service->lastError() != NoErrorCode);
+ QVERIFY(!storageItem2);
+
+ //Cleanup
+ service->removeEntry(*resultItem);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByIds()
+{
+ {
+ CaEntry item;
+ item.setText("testName1");
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item);
+ item.setText("testName2");
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item);
+ item.setText("testName3");
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item);
+ QVERIFY(!resultItem1.isNull());
+ QVERIFY(!resultItem2.isNull());
+ QVERIFY(!resultItem3.isNull());
+
+ QList<int> ids;
+ ids.append(resultItem1->id());
+ ids.append(resultItem3->id());
+ ids.append(resultItem2->id());
+
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(ids) ;
+ QCOMPARE(entries.count(), 3);
+ QCOMPARE(service->lastError(), NoErrorCode);
+
+ QVERIFY(entries.at(0));
+ QCOMPARE(entries.at(0)->role(), ItemEntryRole);
+ QCOMPARE(QString("testName1"),entries.at(0)->text());
+ QCOMPARE(QString("test"),entries.at(0)->entryTypeName());
+ QCOMPARE(QString("attrVal1"),entries.at(0)->attribute("attrName1"));
+ QCOMPARE(item.flags(),entries.at(0)->flags());
+ QVERIFY(entries.at(1));
+ QCOMPARE(entries.at(1)->role(), ItemEntryRole);
+ QCOMPARE(QString("testName3"),entries.at(1)->text());
+ QCOMPARE(QString("test"),entries.at(1)->entryTypeName());
+ QCOMPARE(QString("attrVal1"),entries.at(1)->attribute("attrName1"));
+ QCOMPARE(item.flags(),entries.at(1)->flags());
+ QVERIFY(entries.at(2));
+ QCOMPARE(entries.at(2)->role(), ItemEntryRole);
+ QCOMPARE(QString("testName2"),entries.at(2)->text());
+ QCOMPARE(QString("test"),entries.at(2)->entryTypeName());
+ QCOMPARE(QString("attrVal1"),entries.at(2)->attribute("attrName1"));
+ QCOMPARE(item.flags(),entries.at(2)->flags());
+
+ QCOMPARE(entries.at(0)->id(),resultItem1->id());
+ QCOMPARE(entries.at(1)->id(),resultItem3->id());
+ QCOMPARE(entries.at(2)->id(),resultItem2->id());
+
+ QList<int> ids2;
+ ids2.append(resultItem1->id());
+ ids2.append(9999);
+
+ QList< QSharedPointer<CaEntry> > entries2 = service->getEntries(ids2) ;
+ QCOMPARE(entries2.count(), 1);
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ //Cleanup
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRole()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ QList< QSharedPointer<CaEntry> > items = service->getEntries(query);
+ int itemsCountBefore = items.count();
+ query.setEntryRoles(GroupEntryRole);
+ QList<QSharedPointer<CaEntry> > groups = service->getEntries(query);
+ int groupsCountBefore = groups.count();
+ query.setEntryRoles(ItemEntryRole | GroupEntryRole);
+ QList<QSharedPointer<CaEntry> > itemsOrGroups = service->getEntries(query);
+ int itemsOrGroupsCountBefore = itemsOrGroups.count();
+
+
+ //ADD TO STORAGE
+ CaEntry item;
+ item.setText("testName_item");
+ item.setAttribute("attrName1_item", "attrVal1_item");
+ item.setEntryTypeName("test_item");
+ item.setFlags(RemovableEntryFlag);
+ CaEntry group(GroupEntryRole);
+ group.setText("testName_group");
+ group.setAttribute("attrName1_group", "attrVal1_group");
+ group.setEntryTypeName("test_group");
+ group.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(group);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET RESULTS AFTER ADD
+ query.setEntryRoles(ItemEntryRole);
+ items = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+
+ int itemsCountAfter = items.count();
+ query.setEntryRoles(GroupEntryRole);
+ groups = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+
+ int groupsCountAfter = groups.count();
+ query.setEntryRoles(ItemEntryRole | GroupEntryRole);
+ itemsOrGroups = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int itemsOrGroupsCountAfter = itemsOrGroups.count();
+
+ //CHECK RESULTS
+ QCOMPARE(itemsCountAfter, itemsCountBefore+1);
+ QCOMPARE(groupsCountAfter, groupsCountBefore+1);
+ QCOMPARE(itemsOrGroupsCountAfter, itemsOrGroupsCountBefore+2);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByParent()
+{
+ {
+ //ADD TEST DATA TO THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaEntry group(GroupEntryRole);
+ group.setText("testName_group");
+ group.setAttribute("attrName1_group", "attrVal1_group");
+ group.setEntryTypeName("test_group");
+ group.setFlags(RemovableEntryFlag);
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(group);
+
+ QVERIFY(!parentEntry.isNull());
+ CaEntry item;
+ item.setText("testName_item");
+ item.setAttribute("attrName1_item", "attrVal1_item");
+ item.setEntryTypeName("test_item");
+ item.setFlags(RemovableEntryFlag);
+ QSharedPointer<CaEntry> childEntry = service->createEntry(item);
+
+ QVERIFY(!childEntry.isNull());
+
+ //PREPARE QUERY
+ CaQuery query;
+ query.setParentId(parentEntry->id());
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query);
+
+ int countBefore = entries.count();
+
+ //APPEND ENTRY TO THE GROUP
+ service->appendEntryToGroup(parentEntry->id(),childEntry->id());
+ entries = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+
+ int countAfter = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(countBefore, 0);
+ QCOMPARE(countAfter, 1);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*childEntry);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByType1()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ QStringList strList;
+ strList << QString("WRONGTYPENAME");
+ query.setEntryTypeNames(strList);
+ QList< QSharedPointer<CaEntry> > entriesWrongType = service->getEntries(query);
+ int countWrongBefore = entriesWrongType.count();
+ strList.clear();
+ strList << QString("WRONGTYPENAME");
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ QList< QSharedPointer<CaEntry> > entriesWrong12 = service->getEntries(query);
+ int countWrong12Before = entriesWrong12.count();
+ strList.clear();
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ QList< QSharedPointer<CaEntry> > entries1 = service->getEntries(query);
+ int count1Before = entries1.count();
+ strList.clear();
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ QList< QSharedPointer<CaEntry> > entries2 = service->getEntries(query);
+ int count2Before = entries2.count();
+ strList.clear();
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ QList< QSharedPointer<CaEntry> > entries12 = service->getEntries(query);
+ int count12Before = entries12.count();
+
+ //ADD TEST DATA TO THE STORAGE
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ strList.clear();
+ strList << QString("WRONGTYPENAME");
+ query.setEntryTypeNames(strList);
+ query.setEntryTypeNames(strList);
+ entriesWrongType = service->getEntries(query);
+ int countWrongAfter = entriesWrongType.count();
+ strList.clear();
+ strList << QString("WRONGTYPENAME");
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ entriesWrong12 = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int countWrong12After = entriesWrong12.count();
+ strList.clear();
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ entries1 = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int count1After = entries1.count();
+ strList.clear();
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ entries2 = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int count2After = entries2.count();
+ strList.clear();
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ entries12 = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int count12After = entries12.count();
+
+ //CHECK RESULTS
+ QCOMPARE(countWrongBefore,countWrongAfter);
+ QCOMPARE(countWrong12Before+2,countWrong12After);
+ QCOMPARE(count1Before+1,count1After);
+ QCOMPARE(count2Before+1,count2After);
+ QCOMPARE(count12Before+2,count12After);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByType2()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ QStringList strList;
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ query.addEntryTypeName(QString("test_item2"));
+ QList< QSharedPointer<CaEntry> > entries12 = service->getEntries(query);
+ int count12Before = entries12.count();
+
+ //ADD TEST DATA TO THE STORAGE
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ strList.clear();
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ query.addEntryTypeName(QString("test_item2"));
+ entries12 = service->getEntries(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int count12After = entries12.count();
+
+ //CHECK RESULTS
+ QCOMPARE(count12Before+2,count12After);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByFlagsOn()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setFlagsOn(UninstallEntryFlag);
+ CaQuery query2;
+ query2.setFlagsOn(RemovableEntryFlag);
+ CaQuery query3;
+ query3.setFlagsOn(UninstallEntryFlag|RemovableEntryFlag);
+ QList< QSharedPointer<CaEntry> > entriesSystem = service->getEntries(query1);
+ int systemCountBefore = entriesSystem.count();
+ QList< QSharedPointer<CaEntry> > entriesRemovable = service->getEntries(query2);
+ int removableCountBefore = entriesRemovable.count();
+ QList< QSharedPointer<CaEntry> > entriesSysRem = service->getEntries(query3);
+ int sysremoveCountBefore = entriesSysRem.count();
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ item1.setFlags(UninstallEntryFlag);
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+ item2.setFlags(UninstallEntryFlag | RemovableEntryFlag);
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+ //CHECK STATE IN THE STORAGE AFTER ADD
+ entriesSystem = service->getEntries(query1);
+ int systemCountAfter = entriesSystem.count();
+ QCOMPARE(service->lastError(), NoErrorCode);
+ entriesRemovable = service->getEntries(query2);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int removableCountAfter = entriesRemovable.count();
+ entriesSysRem = service->getEntries(query3);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int sysremoveCountAfter = entriesSysRem.count();
+ //CHECK RESULTS
+ QCOMPARE(systemCountBefore+2,systemCountAfter);
+ QCOMPARE(removableCountBefore+1,removableCountAfter);
+ QCOMPARE(sysremoveCountBefore+1,sysremoveCountAfter);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByFlagsOff()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setFlagsOff(UninstallEntryFlag);
+ CaQuery query2;
+ query2.setFlagsOff(RemovableEntryFlag);
+ CaQuery query3;
+ query3.setFlagsOff(UninstallEntryFlag|RemovableEntryFlag);
+ QList< QSharedPointer<CaEntry> > entriesSystem = service->getEntries(query1);
+ int systemCountBefore = entriesSystem.count();
+ QList< QSharedPointer<CaEntry> > entriesRemovable = service->getEntries(query2);
+ int removableCountBefore = entriesRemovable.count();
+ QList< QSharedPointer<CaEntry> > entriesSysRem = service->getEntries(query3);
+ int sysremoveCountBefore = entriesSysRem.count();
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ item1.setFlags(UninstallEntryFlag);
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+ item2.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entriesSystem = service->getEntries(query1);
+ int systemCountAfter = entriesSystem.count();
+ entriesRemovable = service->getEntries(query2);
+ int removableCountAfter = entriesRemovable.count();
+ entriesSysRem = service->getEntries(query3);
+ int sysremoveCountAfter = entriesSysRem.count();
+ //CHECK RESULTS
+ QCOMPARE(systemCountBefore+1,systemCountAfter);
+ QCOMPARE(removableCountBefore+1,removableCountAfter);
+ QCOMPARE(sysremoveCountBefore,sysremoveCountAfter);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByFlagsOnOff()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setFlagsOn(UninstallEntryFlag);
+ query1.setFlagsOff(RemovableEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QVERIFY(!resultEntry1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB
+ CaEntry item2;
+ item2.setText("testName_item1");
+ item2.setAttribute("attrName1_item", "attrVal1_item");
+ item2.setEntryTypeName("test_item1");
+ item2.setFlags(RemovableEntryFlag);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB
+ CaEntry item3;
+ item3.setText("testName_item1");
+ item3.setAttribute("attrName1_item", "attrVal1_item");
+ item3.setEntryTypeName("test_item1");
+ item3.setFlags(UninstallEntryFlag|RemovableEntryFlag);
+ QSharedPointer<CaEntry> resultEntry3 = service->createEntry(item3);
+ QVERIFY(!resultEntry3.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3,entriesCount4);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ service->removeEntry(*resultEntry3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRoleParent()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT ENTRY TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (item, parent2)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry2->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (group, parent2)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry2->id(),resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB (item, parent1)
+ service->appendEntryToGroup(parentEntry->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (group, parent1)
+ service->appendEntryToGroup(parentEntry->id(),resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3+1, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRoleType()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.addEntryTypeName(QString("TestTypeName"));
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB (item, typeOk)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TestTypeName"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (item, typeWrong)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TestTypeWRONG"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB (group, typeOk)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TestTypeName"));
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (group, typeWrong)
+ CaEntry group2(GroupEntryRole);
+ group2.setText(QString("text"));
+ group2.setEntryTypeName(QString("TestTypeWRONG"));
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(group2);
+ QVERIFY(!resultGroup2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRoleFlags()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB (item, systemOn)
+ CaEntry item1;
+ item1.setFlags(UninstallEntryFlag);
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Name"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (item, systemOff)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("Name"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(group, systemOn)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("type"));
+ group1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(group, systemoff)
+ CaEntry group2(GroupEntryRole);
+ group2.setText(QString("text"));
+ group2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(group2);
+ QVERIFY(!resultGroup2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByParentType()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("typeOK"));
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB (parent1, typeok)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("typeOK"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (parent1, typeWrong)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("typeWrong"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB (parent2, typeOk)
+ service->appendEntryToGroup(parentEntry2->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (parent2,typeWrong)
+ service->appendEntryToGroup(parentEntry2->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByParentFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setParentId(parentEntry->id());
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (parent1, system)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (parent1, not system)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB( parent2, system )
+ service->appendEntryToGroup(parentEntry2->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (parent2, not system)
+ service->appendEntryToGroup(parentEntry2->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByTypeFlags()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.addEntryTypeName(QString("TypeOK"));
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (typeOk, system)
+ CaEntry item1;
+ item1.setFlags(UninstallEntryFlag);
+ item1.setEntryTypeName(QString("TypeOK"));
+ item1.setText(QString("Name"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB(typeOk, not system)
+ CaEntry item2;
+ item2.setEntryTypeName(QString("TypeOK"));
+ item2.setText(QString("Name"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(typeWrong, system)
+ CaEntry item3;
+ item3.setFlags(UninstallEntryFlag);
+ item3.setText(QString("Name"));
+ item3.setEntryTypeName(QString("TypeWrong"));
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+ QVERIFY(!resultItem3.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(typeWrong, not system)
+ CaEntry item4;
+ item4.setEntryTypeName(QString("TypeWrong"));
+ item4.setText(QString("Name"));
+
+ QSharedPointer<CaEntry> resultItem4 = service->createEntry(item4);
+ QVERIFY(!resultItem4.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*resultItem4);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRoleParentType()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("TypeOK"));
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB ( item, parent1, typeOk)
+ CaEntry item1;
+ item1.setEntryTypeName(QString("TypeOK"));
+ item1.setText(QString("Name"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2= entries.count();
+ //ADD TO DB ( item, parent1, typeWrong)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeWRONG"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB ( item, parent2, typeOk)
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB ( group, parent1, typeOk)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRoleParentFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (item, parent1, system )
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB(item, parent1, not system )
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(item, parent2 , system )
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(group, parent1, system )
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("type"));
+ group1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultGroup1->id());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup1);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByParentTypeFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("TypeOK"));
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (parent1, typeOk, system)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TypeOK"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB(parent1, typeOk, not system)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(parent1, typeWRONG, system)
+ CaEntry item3;
+ item3.setText(QString("Name"));
+ item3.setEntryTypeName(QString("TypeWRONG"));
+ item3.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+ QVERIFY(!resultItem3.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem3->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(parent2, typeOk, system)
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByRoleParentTypeFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("TypeOK"));
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB ( item, parent1, typeOK, system )
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TypeOK"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB ( item, parent1, typeOK, not system )
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB( item, parent1, typeWRONG, system )
+ CaEntry item3;
+ item3.setText(QString("Name"));
+ item3.setEntryTypeName(QString("TypeWRONG"));
+ item3.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+ QVERIFY(!resultItem3.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem3->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB( item, parent2, typeOK, system )
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount5 = entries.count();
+ //ADD TO DB( group, parent1, typeOK, system )
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TypeOK"));
+ group1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntries(query1);
+ int entriesCount6 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ QCOMPARE(entriesCount5, entriesCount6);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesCount()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("CountTest"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("CountTest"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("CountTest"));
+ query1.setCount(1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("CountTest"));
+ query2.setCount(2);
+ CaQuery query3;
+ query3.addEntryTypeName(QString("CountTest"));
+ query3.setCount(3);
+ QList< QSharedPointer<CaEntry> > entries1 = service->getEntries(query1);
+ QList< QSharedPointer<CaEntry> > entries2 = service->getEntries(query2);
+ QList< QSharedPointer<CaEntry> > entries3 = service->getEntries(query3);
+
+ //CHECK RESULTS
+ QCOMPARE(entries1.count(),1);
+ QCOMPARE(entries2.count(),2);
+ QCOMPARE(entries3.count(),3);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesSortCreated()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort1Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+
+ //ADD TO DB
+ CaEntry item1;
+ item1.setEntryTypeName(QString("Sort1Test"));
+ item1.setText(QString("Name"));
+
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort1Test"));
+ query1.setSort(CreatedTimestampSortAttribute, Qt::AscendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesAsc = service->getEntries(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort1Test"));
+ query2.setSort(CreatedTimestampSortAttribute, Qt::DescendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesDesc = service->getEntries(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0)->id(),resultItem1->id());
+ QCOMPARE(entriesAsc.at(1)->id(),resultItem2->id());
+ QCOMPARE(entriesAsc.at(2)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1)->id(),resultItem2->id());
+ QCOMPARE(entriesDesc.at(2)->id(),resultItem1->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesSortDefault()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort0Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+
+ //ADD TO DB
+ CaEntry item1;
+ item1.setEntryTypeName(QString("Sort0Test"));
+ item1.setText(QString("Name"));
+
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort0Test"));
+ query1.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesAsc = service->getEntries(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort0Test"));
+ query2.setSort(DefaultSortAttribute, Qt::DescendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesDesc = service->getEntries(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0)->id(),resultItem1->id());
+ QCOMPARE(entriesAsc.at(1)->id(),resultItem2->id());
+ QCOMPARE(entriesAsc.at(2)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1)->id(),resultItem2->id());
+ QCOMPARE(entriesDesc.at(2)->id(),resultItem1->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesSortName()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort2Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("nameB"));
+ item1.setEntryTypeName(QString("Sort2Test"));
+ CaEntry item2;
+ item2.setText(QString("NameA"));
+ item2.setEntryTypeName(QString("Sort2Test"));
+ CaEntry item3;
+ item3.setText(QString("NameC"));
+ item3.setEntryTypeName(QString("Sort2Test"));
+
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort2Test"));
+ query1.setSort(NameSortAttribute, Qt::AscendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesAsc = service->getEntries(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort2Test"));
+ query2.setSort(NameSortAttribute, Qt::DescendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesDesc = service->getEntries(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0)->id(),resultItem2->id());
+ QCOMPARE(entriesAsc.at(1)->id(),resultItem1->id());
+ QCOMPARE(entriesAsc.at(2)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1)->id(),resultItem1->id());
+ QCOMPARE(entriesDesc.at(2)->id(),resultItem2->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesSortLast()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort3Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setEntryTypeName(QString("Sort3Test"));
+ item1.setText(QString("Name"));
+
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ service->touch(*resultItem2);
+ service->touch(*resultItem1);
+ service->touch(*resultItem3);
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort3Test"));
+ query1.setSort(LastUsedSortAttribute, Qt::AscendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesAsc = service->getEntries(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort3Test"));
+ query2.setSort(LastUsedSortAttribute, Qt::DescendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesDesc = service->getEntries(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0)->id(),resultItem2->id());
+ QCOMPARE(entriesAsc.at(1)->id(),resultItem1->id());
+ QCOMPARE(entriesAsc.at(2)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0)->id(),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1)->id(),resultItem1->id());
+ QCOMPARE(entriesDesc.at(2)->id(),resultItem2->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesSortMost()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort4Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Sort4Test"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ service->touch(*resultItem2);
+ service->touch(*resultItem2);
+ service->touch(*resultItem2);
+ service->touch(*resultItem1);
+ service->touch(*resultItem1);
+ service->touch(*resultItem3);
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort4Test"));
+ query1.setSort(MostUsedSortAttribute, Qt::AscendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesAsc = service->getEntries(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort4Test"));
+ query2.setSort(MostUsedSortAttribute, Qt::DescendingOrder);
+ QList< QSharedPointer<CaEntry> > entriesDesc = service->getEntries(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0)->id(),resultItem3->id());
+ QCOMPARE(entriesAsc.at(1)->id(),resultItem1->id());
+ QCOMPARE(entriesAsc.at(2)->id(),resultItem2->id());
+ QCOMPARE(entriesDesc.at(0)->id(),resultItem2->id());
+ QCOMPARE(entriesDesc.at(1)->id(),resultItem1->id());
+ QCOMPARE(entriesDesc.at(2)->id(),resultItem3->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRole()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ QList<int> items = service->getEntryIds(query);
+ int itemsCountBefore = items.count();
+ query.setEntryRoles(GroupEntryRole);
+ QList<int> groups = service->getEntryIds(query);
+ int groupsCountBefore = groups.count();
+ query.setEntryRoles(ItemEntryRole | GroupEntryRole);
+ QList<int> itemsOrGroups = service->getEntryIds(query);
+ int itemsOrGroupsCountBefore = itemsOrGroups.count();
+
+
+ //ADD TO STORAGE
+ CaEntry item;
+ item.setText("testName_item");
+ item.setAttribute("attrName1_item", "attrVal1_item");
+ item.setEntryTypeName("test_item");
+ item.setFlags(RemovableEntryFlag);
+ CaEntry group(GroupEntryRole);
+ group.setText("testName_group");
+ group.setAttribute("attrName1_group", "attrVal1_group");
+ group.setEntryTypeName("test_group");
+ group.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(group);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET RESULTS AFTER ADD
+ query.setEntryRoles(ItemEntryRole);
+ items = service->getEntryIds(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int itemsCountAfter = items.count();
+ query.setEntryRoles(GroupEntryRole);
+ groups = service->getEntryIds(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int groupsCountAfter = groups.count();
+ query.setEntryRoles(ItemEntryRole | GroupEntryRole);
+ itemsOrGroups = service->getEntryIds(query);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ int itemsOrGroupsCountAfter = itemsOrGroups.count();
+
+ //CHECK RESULTS
+ QCOMPARE(itemsCountAfter, itemsCountBefore+1);
+ QCOMPARE(groupsCountAfter, groupsCountBefore+1);
+ QCOMPARE(itemsOrGroupsCountAfter, itemsOrGroupsCountBefore+2);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByParent()
+{
+ {
+ //ADD TEST DATA TO THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaEntry group(GroupEntryRole);
+ group.setText("testName_group");
+ group.setAttribute("attrName1_group", "attrVal1_group");
+ group.setEntryTypeName("test_group");
+ group.setFlags(RemovableEntryFlag);
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(group);
+ QVERIFY(!parentEntry.isNull());
+ CaEntry item;
+ item.setText("testName_item");
+ item.setAttribute("attrName1_item", "attrVal1_item");
+ item.setEntryTypeName("test_item");
+ item.setFlags(RemovableEntryFlag);
+ QSharedPointer<CaEntry> childEntry = service->createEntry(item);
+ QVERIFY(!childEntry.isNull());
+
+ //PREPARE QUERY
+ CaQuery query;
+ query.setParentId(parentEntry->id());
+ QList<int> entries = service->getEntryIds(query);
+ int countBefore = entries.count();
+
+ //APPEND ENTRY TO THE GROUP
+ service->appendEntryToGroup(parentEntry->id(),childEntry->id());
+ entries = service->getEntryIds(query);
+ int countAfter = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(countBefore, 0);
+ QCOMPARE(countAfter, 1);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*childEntry);
+ service->removeEntry(*parentEntry);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByType1()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ QStringList strList;
+ strList << QString("WRONGTYPENAME");
+ query.setEntryTypeNames(strList);
+ QList<int> entriesWrongType = service->getEntryIds(query);
+ int countWrongBefore = entriesWrongType.count();
+ strList.clear();
+ strList << QString("WRONGTYPENAME");
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ QList<int> entriesWrong12 = service->getEntryIds(query);
+ int countWrong12Before = entriesWrong12.count();
+ strList.clear();
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ QList<int> entries1 = service->getEntryIds(query);
+ int count1Before = entries1.count();
+ strList.clear();
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ QList<int> entries2 = service->getEntryIds(query);
+ int count2Before = entries2.count();
+ strList.clear();
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ QList<int> entries12 = service->getEntryIds(query);
+ int count12Before = entries12.count();
+
+ //ADD TEST DATA TO THE STORAGE
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ strList.clear();
+ strList << QString("WRONGTYPENAME");
+ query.setEntryTypeNames(strList);
+ query.setEntryTypeNames(strList);
+ entriesWrongType = service->getEntryIds(query);
+ int countWrongAfter = entriesWrongType.count();
+ strList.clear();
+ strList << QString("WRONGTYPENAME");
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ entriesWrong12 = service->getEntryIds(query);
+ int countWrong12After = entriesWrong12.count();
+ strList.clear();
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ entries1 = service->getEntryIds(query);
+ int count1After = entries1.count();
+ strList.clear();
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ entries2 = service->getEntryIds(query);
+ int count2After = entries2.count();
+ strList.clear();
+ strList << QString("test_item1");
+ strList << QString("test_item2");
+ query.setEntryTypeNames(strList);
+ entries12 = service->getEntryIds(query);
+ int count12After = entries12.count();
+
+ //CHECK RESULTS
+ QCOMPARE(countWrongBefore,countWrongAfter);
+ QCOMPARE(countWrong12Before+2,countWrong12After);
+ QCOMPARE(count1Before+1,count1After);
+ QCOMPARE(count2Before+1,count2After);
+ QCOMPARE(count12Before+2,count12After);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByType2()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ QStringList strList;
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ query.addEntryTypeName(QString("test_item2"));
+ QList<int> entries12 = service->getEntryIds(query);
+ int count12Before = entries12.count();
+
+ //ADD TEST DATA TO THE STORAGE
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ strList.clear();
+ strList << QString("test_item1");
+ query.setEntryTypeNames(strList);
+ query.addEntryTypeName(QString("test_item2"));
+ entries12 = service->getEntryIds(query);
+ int count12After = entries12.count();
+
+ //CHECK RESULTS
+ QCOMPARE(count12Before+2,count12After);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByFlagsOn()
+{
+ {
+ //CHECK INITIAL STATE IN DB
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setFlagsOn(UninstallEntryFlag);
+ CaQuery query2;
+ query2.setFlagsOn(RemovableEntryFlag);
+ CaQuery query3;
+ query3.setFlagsOn(UninstallEntryFlag|RemovableEntryFlag);
+ QList<int> entriesSystem = service->getEntryIds(query1);
+ int systemCountBefore = entriesSystem.count();
+ QList<int> entriesRemovable = service->getEntryIds(query2);
+ int removableCountBefore = entriesRemovable.count();
+ QList<int> entriesSysRem = service->getEntryIds(query3);
+ int sysremoveCountBefore = entriesSysRem.count();
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ item1.setFlags(UninstallEntryFlag);
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+ item2.setFlags(UninstallEntryFlag | RemovableEntryFlag);
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+ //CHECK STATE IN THE STORAGE AFTER ADD
+ entriesSystem = service->getEntryIds(query1);
+ int systemCountAfter = entriesSystem.count();
+ entriesRemovable = service->getEntryIds(query2);
+ int removableCountAfter = entriesRemovable.count();
+ entriesSysRem = service->getEntryIds(query3);
+ int sysremoveCountAfter = entriesSysRem.count();
+ //CHECK RESULTS
+ QCOMPARE(systemCountBefore+2,systemCountAfter);
+ QCOMPARE(removableCountBefore+1,removableCountAfter);
+ QCOMPARE(sysremoveCountBefore+1,sysremoveCountAfter);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByFlagsOff()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setFlagsOff(UninstallEntryFlag);
+ CaQuery query2;
+ query2.setFlagsOff(RemovableEntryFlag);
+ CaQuery query3;
+ query3.setFlagsOff(UninstallEntryFlag|RemovableEntryFlag);
+ QList<int> entriesSystem = service->getEntryIds(query1);
+ int systemCountBefore = entriesSystem.count();
+ QList<int> entriesRemovable = service->getEntryIds(query2);
+ int removableCountBefore = entriesRemovable.count();
+ QList<int> entriesSysRem = service->getEntryIds(query3);
+ int sysremoveCountBefore = entriesSysRem.count();
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ item1.setFlags(UninstallEntryFlag);
+ CaEntry item2;
+ item2.setText("testName_item2");
+ item2.setAttribute("attrName2_item", "attrVal2_item");
+ item2.setEntryTypeName("test_item2");
+ item2.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry1.isNull());
+ QVERIFY(!resultEntry2.isNull());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entriesSystem = service->getEntryIds(query1);
+ int systemCountAfter = entriesSystem.count();
+ entriesRemovable = service->getEntryIds(query2);
+ int removableCountAfter = entriesRemovable.count();
+ entriesSysRem = service->getEntryIds(query3);
+ int sysremoveCountAfter = entriesSysRem.count();
+ //CHECK RESULTS
+ QCOMPARE(systemCountBefore+1,systemCountAfter);
+ QCOMPARE(removableCountBefore+1,removableCountAfter);
+ QCOMPARE(sysremoveCountBefore,sysremoveCountAfter);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByFlagsOnOff()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setFlagsOn(UninstallEntryFlag);
+ query1.setFlagsOff(RemovableEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText("testName_item1");
+ item1.setAttribute("attrName1_item", "attrVal1_item");
+ item1.setEntryTypeName("test_item1");
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultEntry1 = service->createEntry(item1);
+ QVERIFY(!resultEntry1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB
+ CaEntry item2;
+ item2.setText("testName_item1");
+ item2.setAttribute("attrName1_item", "attrVal1_item");
+ item2.setEntryTypeName("test_item1");
+ item2.setFlags(RemovableEntryFlag);
+ QSharedPointer<CaEntry> resultEntry2 = service->createEntry(item2);
+ QVERIFY(!resultEntry2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB
+ CaEntry item3;
+ item3.setText("testName_item1");
+ item3.setAttribute("attrName1_item", "attrVal1_item");
+ item3.setEntryTypeName("test_item1");
+ item3.setFlags(UninstallEntryFlag|RemovableEntryFlag);
+ QSharedPointer<CaEntry> resultEntry3 = service->createEntry(item3);
+ QVERIFY(!resultEntry3.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3,entriesCount4);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultEntry1);
+ service->removeEntry(*resultEntry2);
+ service->removeEntry(*resultEntry3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRoleParent()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT ENTRY TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("TypeOK"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("TypeOK"));
+
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (item, parent2)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry2->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (group, parent2)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry2->id(),resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB (item, parent1)
+ service->appendEntryToGroup(parentEntry->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (group, parent1)
+ service->appendEntryToGroup(parentEntry->id(),resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3+1, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRoleType()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.addEntryTypeName(QString("TestTypeName"));
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB (item, typeOk)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TestTypeName"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (item, typeWrong)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TestTypeWRONG"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB (group, typeOk)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TestTypeName"));
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (group, typeWrong)
+ CaEntry group2(GroupEntryRole);
+ group2.setText(QString("text"));
+ group2.setEntryTypeName(QString("TestTypeWRONG"));
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(group2);
+ QVERIFY(!resultGroup2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRoleFlags()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB (item, systemOn)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (item, systemOff)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(group, systemOn)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("type"));
+ group1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(group, systemoff)
+ CaEntry group2(GroupEntryRole);
+ group2.setText(QString("text"));
+ group2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(group2);
+ QVERIFY(!resultGroup2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByParentType()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("typeOK"));
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+ //ADD TO DB (parent1, typeok)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("typeOK"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (parent1, typeWrong)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("typeWrong"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB (parent2, typeOk)
+ service->appendEntryToGroup(parentEntry2->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (parent2,typeWrong)
+ service->appendEntryToGroup(parentEntry2->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByParentFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setParentId(parentEntry->id());
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (parent1, system)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB (parent1, not system)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB( parent2, system )
+ service->appendEntryToGroup(parentEntry2->id(),resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB (parent2, not system)
+ service->appendEntryToGroup(parentEntry2->id(),resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByTypeFlags()
+{
+ {
+ //GET INITIAL STATE FROM THE STORAGE
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query1;
+ query1.addEntryTypeName(QString("TypeOK"));
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (typeOk, system)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setFlags(UninstallEntryFlag);
+ item1.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB(typeOk, not system)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(typeWrong, system)
+ CaEntry item3;
+ item3.setText(QString("Name"));
+ item3.setFlags(UninstallEntryFlag);
+ item3.setEntryTypeName(QString("TypeWrong"));
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+ QVERIFY(!resultItem3.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(typeWrong, not system)
+ CaEntry item4;
+ item4.setText(QString("Name"));
+ item4.setEntryTypeName(QString("TypeWrong"));
+ QSharedPointer<CaEntry> resultItem4 = service->createEntry(item4);
+ QVERIFY(!resultItem4.isNull());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*resultItem4);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRoleParentType()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("TypeOK"));
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB ( item, parent1, typeOk)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2= entries.count();
+ //ADD TO DB ( item, parent1, typeWrong)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeWRONG"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB ( item, parent2, typeOk)
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB ( group, parent1, typeOk)
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRoleParentFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("Type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (item, parent1, system )
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Type"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB(item, parent1, not system )
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(item, parent2 , system )
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(group, parent1, system )
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("Type"));
+ group1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultGroup1->id());
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByParentTypeFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("Type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("TypeOK"));
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB (parent1, typeOk, system)
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TypeOK"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB(parent1, typeOk, not system)
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB(parent1, typeWRONG, system)
+ CaEntry item3;
+ item3.setText(QString("Name"));
+ item3.setEntryTypeName(QString("TypeWRONG"));
+ item3.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+ QVERIFY(!resultItem3.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem3->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB(parent2, typeOk, system)
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsByRoleParentTypeFlags()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //ADD PARENT TO THE STORAGE
+ CaEntry parent(GroupEntryRole);
+ CaEntry parent2(GroupEntryRole);
+ parent.setText(QString("text"));
+ parent.setEntryTypeName(QString("Type"));
+ parent2.setText(QString("text"));
+ parent2.setEntryTypeName(QString("Type"));
+ QSharedPointer<CaEntry> parentEntry = service->createEntry(parent);
+ QVERIFY(!parentEntry.isNull());
+ QSharedPointer<CaEntry> parentEntry2 = service->createEntry(parent2);
+ QVERIFY(!parentEntry2.isNull());
+
+ //GET INITIAL STATE FROM THE STORAGE
+ CaQuery query1;
+ query1.setEntryRoles(ItemEntryRole);
+ query1.setParentId(parentEntry->id());
+ query1.addEntryTypeName(QString("TypeOK"));
+ query1.setFlagsOn(UninstallEntryFlag);
+ QList<int> entries = service->getEntryIds(query1);
+ int entriesCount1 = entries.count();
+
+ //ADD TO DB ( item, parent1, typeOK, system )
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("TypeOK"));
+ item1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QVERIFY(!resultItem1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount2 = entries.count();
+ //ADD TO DB ( item, parent1, typeOK, not system )
+ CaEntry item2;
+ item2.setText(QString("Name"));
+ item2.setEntryTypeName(QString("TypeOK"));
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QVERIFY(!resultItem2.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem2->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount3 = entries.count();
+ //ADD TO DB( item, parent1, typeWRONG, system )
+ CaEntry item3;
+ item3.setText(QString("Name"));
+ item3.setEntryTypeName(QString("TypeWRONG"));
+ item3.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+ QVERIFY(!resultItem3.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultItem3->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount4 = entries.count();
+ //ADD TO DB( item, parent2, typeOK, system )
+ service->appendEntryToGroup(parentEntry2->id(), resultItem1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount5 = entries.count();
+ //ADD TO DB( group, parent1, typeOK, system )
+ CaEntry group1(GroupEntryRole);
+ group1.setText(QString("text"));
+ group1.setEntryTypeName(QString("TypeOK"));
+ group1.setFlags(UninstallEntryFlag);
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group1);
+ QVERIFY(!resultGroup1.isNull());
+ service->appendEntryToGroup(parentEntry->id(), resultGroup1->id());
+ //GET STATE FROM THE STORAGE AFTER ADD
+ entries = service->getEntryIds(query1);
+ int entriesCount6 = entries.count();
+
+ //CHECK RESULTS
+ QCOMPARE(entriesCount1+1,entriesCount2);
+ QCOMPARE(entriesCount2,entriesCount3);
+ QCOMPARE(entriesCount3, entriesCount4);
+ QCOMPARE(entriesCount4, entriesCount5);
+ QCOMPARE(entriesCount5, entriesCount6);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*parentEntry);
+ service->removeEntry(*parentEntry2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsCount()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("CountTest2"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("CountTest2"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("CountTest2"));
+ query1.setCount(1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("CountTest2"));
+ query2.setCount(2);
+ CaQuery query3;
+ query3.addEntryTypeName(QString("CountTest2"));
+ query3.setCount(3);
+ QList<int> entries1 = service->getEntryIds(query1);
+ QList<int> entries2 = service->getEntryIds(query2);
+ QList<int> entries3 = service->getEntryIds(query3);
+
+ //CHECK RESULTS
+ QCOMPARE(entries1.count(),1);
+ QCOMPARE(entries2.count(),2);
+ QCOMPARE(entries3.count(),3);
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsSortDefault()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort9Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+
+ //ADD TO DB
+ CaEntry item1;
+ item1.setEntryTypeName(QString("Sort9Test"));
+ item1.setText(QString("Name"));
+
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort9Test"));
+ query1.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesAsc = service->getEntryIds(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort9Test"));
+ query2.setSort(DefaultSortAttribute, Qt::DescendingOrder);
+ QList<int> entriesDesc = service->getEntryIds(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0),resultItem1->id());
+ QCOMPARE(entriesAsc.at(1),resultItem2->id());
+ QCOMPARE(entriesAsc.at(2),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1),resultItem2->id());
+ QCOMPARE(entriesDesc.at(2),resultItem1->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsSortCreated()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort5Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Sort5Test"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort5Test"));
+ query1.setSort(CreatedTimestampSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesAsc = service->getEntryIds(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort5Test"));
+ query2.setSort(CreatedTimestampSortAttribute, Qt::DescendingOrder);
+ QList<int> entriesDesc = service->getEntryIds(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0),resultItem1->id());
+ QCOMPARE(entriesAsc.at(1),resultItem2->id());
+ QCOMPARE(entriesAsc.at(2),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1),resultItem2->id());
+ QCOMPARE(entriesDesc.at(2),resultItem1->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsSortName()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort6Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("NameB"));
+ item1.setEntryTypeName(QString("Sort6Test"));
+ CaEntry item2;
+ item2.setText(QString("NameA"));
+ item2.setEntryTypeName(QString("Sort6Test"));
+ CaEntry item3;
+ item3.setText(QString("NameC"));
+ item3.setEntryTypeName(QString("Sort6Test"));
+
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item2);
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item3);
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort6Test"));
+ query1.setSort(NameSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesAsc = service->getEntryIds(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort6Test"));
+ query2.setSort(NameSortAttribute, Qt::DescendingOrder);
+ QList<int> entriesDesc = service->getEntryIds(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0),resultItem2->id());
+ QCOMPARE(entriesAsc.at(1),resultItem1->id());
+ QCOMPARE(entriesAsc.at(2),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1),resultItem1->id());
+ QCOMPARE(entriesDesc.at(2),resultItem2->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsSortLast()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort7Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Sort7Test"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ service->touch(*resultItem2);
+ service->touch(*resultItem1);
+ service->touch(*resultItem3);
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort7Test"));
+ query1.setSort(LastUsedSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesAsc = service->getEntryIds(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort7Test"));
+ query2.setSort(LastUsedSortAttribute, Qt::DescendingOrder);
+ QList<int> entriesDesc = service->getEntryIds(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0),resultItem2->id());
+ QCOMPARE(entriesAsc.at(1),resultItem1->id());
+ QCOMPARE(entriesAsc.at(2),resultItem3->id());
+ QCOMPARE(entriesDesc.at(0),resultItem3->id());
+ QCOMPARE(entriesDesc.at(1),resultItem1->id());
+ QCOMPARE(entriesDesc.at(2),resultItem2->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesIdsSortMost()
+{
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ //REMOVE "OLD" ENTRIES FROM STORAGE
+ CaQuery query;
+ query.addEntryTypeName(QString("Sort8Test"));
+ QList<int> oldIds = service->getEntryIds(query);
+ if (oldIds.count()) {
+ service->removeEntries(oldIds);
+ }
+ //ADD TO DB
+ CaEntry item1;
+ item1.setText(QString("Name"));
+ item1.setEntryTypeName(QString("Sort8Test"));
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item1);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item1); //item clone
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item1); //item clone
+
+ service->touch(*resultItem2);
+ service->touch(*resultItem2);
+ service->touch(*resultItem2);
+ service->touch(*resultItem1);
+ service->touch(*resultItem1);
+ service->touch(*resultItem3);
+
+ //GET STATE FROM THE STORAGE AFTER ADD
+ CaQuery query1;
+ query1.addEntryTypeName(QString("Sort8Test"));
+ query1.setSort(MostUsedSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesAsc = service->getEntryIds(query1);
+ CaQuery query2;
+ query2.addEntryTypeName(QString("Sort8Test"));
+ query2.setSort(MostUsedSortAttribute, Qt::DescendingOrder);
+ QList<int> entriesDesc = service->getEntryIds(query2);
+
+ //CHECK RESULTS
+ QCOMPARE(entriesAsc.count(),3);
+ QCOMPARE(entriesDesc.count(),3);
+ QCOMPARE(entriesAsc.at(0),resultItem3->id());
+ QCOMPARE(entriesAsc.at(1),resultItem1->id());
+ QCOMPARE(entriesAsc.at(2),resultItem2->id());
+ QCOMPARE(entriesDesc.at(0),resultItem2->id());
+ QCOMPARE(entriesDesc.at(1),resultItem1->id());
+ QCOMPARE(entriesDesc.at(2),resultItem3->id());
+
+ //CLEANUP THE STORAGE AFTER THE TEST
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestGetEntriesByAttributes()
+{
+ {
+ CaEntry item;
+ item.setText("testName");
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+
+ CaIconDescription iconDescription;
+ iconDescription.setFilename("iconFileName");
+ iconDescription.setSkinId("iconSkinId");
+ iconDescription.setApplicationId("268458321");
+ item.setIconDescription(iconDescription);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem = service->createEntry(item);
+
+ QVERIFY(!resultItem.isNull());
+ // entry from storage
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem->id());
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(storageItem1);
+ QCOMPARE(storageItem1->role(), ItemEntryRole);
+ QCOMPARE(QString("testName"),storageItem1->text());
+ QCOMPARE(QString("test"),storageItem1->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageItem1->attribute("attrName1"));
+ QCOMPARE(item.flags(),storageItem1->flags());
+ QCOMPARE(iconDescription.filename(),storageItem1->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),storageItem1->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),storageItem1->iconDescription().applicationId());
+
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ query.setAttribute(QString("attrName1"),QString("attrVal1"));
+ QVERIFY(query.attributes().contains(QString("attrName1")));
+ QCOMPARE(query.attribute(QString("attrName1")),QString("attrVal1"));
+ QList<int> entries = service->getEntryIds(query);
+ int entriesCount1 = entries.count();
+ QSharedPointer<CaEntry> afterGetItem = service->getEntry(entries.first());
+
+ QCOMPARE(afterGetItem->id(),storageItem1->id());
+ //Cleanup
+ service->removeEntry(*resultItem);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_localization.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,183 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+#include "t_caclient.h"
+#include "caservice.h"
+#include "castorageproxy.h"
+#include "caquery.h"
+#include "calocalizationentry.h"
+#include "cainnerentry.h"
+
+#ifdef Q_OS_SYMBIAN
+//s60
+#include <e32base.h>
+//#include <>
+#include <W32STD.H>
+#include <APGTASK.H>
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestLocalizationEntryGetters()
+{
+ CCaLocalizationEntry *entry(0);
+ _LIT(AttributeName,"AttributeName");
+ _LIT(StringId,"StringId");
+ _LIT(TableName,"TableName");
+ _LIT(LocalizedString,"LocalizedString");
+
+ QT_TRAP_THROWING(entry = CCaLocalizationEntry::NewL());
+
+ entry->SetRowId(1);
+ entry->SetTextId(2);
+
+ TRAPD(err,
+ entry->SetAttributeNameL(AttributeName);
+ entry->SetStringIdL(StringId);
+ entry->SetTableNameL(TableName);
+ entry->SetLocalizedStringL(LocalizedString);
+ );
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(entry->GetRowId(), 1);
+ QCOMPARE(entry->GetTextId(), 2);
+ QCOMPARE(entry->GetAttributeName().Compare(AttributeName), 0);
+ QCOMPARE(entry->GetTableName().Compare(TableName), 0);
+ QCOMPARE(entry->GetStringId().Compare(StringId), 0);
+ QCOMPARE(entry->GetLocalizedString().Compare(LocalizedString), 0);
+
+ delete entry;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestLocalizationTApp()
+{
+ _LIT( KTestDbSource, "C:\\testing\\data\\t_caclient\\castorage.db" ); // normal db
+ _LIT( KTestDbDest, "C:\\castorage.db" );
+
+ RFs fs;
+ User::LeaveIfError( fs.Connect() );
+ CFileMan* fileManager = CFileMan::NewL( fs );
+
+ fileManager->Copy( KTestDbSource, KTestDbDest );
+
+
+ CCaStorageProxy* proxy = CCaStorageProxy::NewL();
+
+
+ _LIT(BadLocTxt,"loc://emailTest_/haha");
+ _LIT(BadQmTxt,"loc://haha/haha");
+
+ _LIT(GoodLocTxt,"loc://emailTest_/txt_applib_dblist_games");
+ _LIT(GoodLocKey,"txt_applib_dblist_games");
+ _LIT(GoodLocResult,"Games");
+
+
+
+ CCaInnerEntry* entry = CCaInnerEntry::NewL();
+
+ entry->SetTextL( GoodLocTxt );
+ CCaLocalizationEntry* locEntry = proxy->LocalizeTextL( entry );
+ QVERIFY( !locEntry->GetStringId().Compare( GoodLocKey ) );
+ QVERIFY( !entry->GetText().Compare( GoodLocResult ) );
+ delete locEntry;
+
+ entry->SetDescriptionL( BadLocTxt );
+ CCaLocalizationEntry* locEntry2 = proxy->LocalizeDescriptionL( entry );
+ QVERIFY( locEntry2 == NULL );
+ QVERIFY( !entry->GetDescription().Compare( BadLocTxt ) );
+ delete locEntry2;
+
+ entry->SetDescriptionL( GoodLocTxt );
+ CCaLocalizationEntry* locEntry3 = proxy->LocalizeDescriptionL( entry );
+ QVERIFY( !locEntry3->GetStringId().Compare( GoodLocKey ) );
+ QVERIFY( !entry->GetDescription().Compare( GoodLocResult ) );
+ delete locEntry3;
+
+ delete fileManager;
+ fs.Close();
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCreateLocalizedItem()
+{
+ {
+ const CaEntry constItem;
+ QCOMPARE(constItem.role(), ItemEntryRole);
+
+ //create item
+ //check if proper entry returned
+ CaEntry item;
+ item.setText("testName",true);
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+ item.setDescription("description",true);
+ CaIconDescription iconDescription;
+ iconDescription.setFilename("iconFileName");
+ iconDescription.setSkinId("iconSkinId");
+ iconDescription.setApplicationId("268458321");
+
+ item.setIconDescription(iconDescription);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem = service->createEntry(item);
+ QCOMPARE(service->lastError(), NoErrorCode);
+ QVERIFY(!resultItem.isNull());
+ QCOMPARE(resultItem->role(), ItemEntryRole);
+ QCOMPARE(item.text(),resultItem->text());
+ QCOMPARE(item.description(),resultItem->description());
+ QCOMPARE(item.entryTypeName(),resultItem->entryTypeName());
+ QCOMPARE(QString("attrVal1"),resultItem->attribute("attrName1"));
+ QCOMPARE(item.flags(),resultItem->flags());
+ int itId =item.id();
+ int resItId =resultItem->id();
+ QVERIFY(itId != resItId);
+ QCOMPARE(iconDescription.filename(),resultItem->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),resultItem->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),resultItem->iconDescription().applicationId());
+
+ // entry from storage
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem->id());
+ QVERIFY(storageItem1);
+ QCOMPARE(QString("testName"),storageItem1->text());
+ QCOMPARE(QString("description"),storageItem1->description());
+ QCOMPARE(QString("test"),storageItem1->entryTypeName());
+ QCOMPARE(QString("attrVal1"),storageItem1->attribute("attrName1"));
+ EntryFlags flags = item.flags();
+ EntryFlags storageFlags = storageItem1->flags();
+ QCOMPARE(iconDescription.filename(),storageItem1->iconDescription().filename());
+ QCOMPARE(iconDescription.skinId(),storageItem1->iconDescription().skinId());
+ QCOMPARE(iconDescription.applicationId(),storageItem1->iconDescription().applicationId());
+ QVERIFY(storageItem1->iconDescription().id() > 0);
+
+ QCOMPARE(flags ,storageFlags);
+
+ //Cleanup
+ service->removeEntry(*resultItem);
+ }
+}
+
+
+
+
+
+#endif //Q_OS_SYMBIAN
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_notifier.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,2966 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+#include <QScopedPointer>
+#include <qservicemanager.h>
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "canotifier.h"
+#include "canotifierfilter.h"
+#include "caquery.h"
+#include "t_caclientNotifier.h"
+
+const int entryIdFake(-1);
+const int waitTime500ms(500);
+const int waitTime1sec(1000);
+
+QTM_USE_NAMESPACE
+
+QStringList pluginPaths;
+QString xmlName("caapphandlerplugin.xml");
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::initTestCase()
+{
+#ifdef Q_OS_SYMBIAN
+ startThread();
+#endif //Q_OS_SYMBIAN
+ mService = CaService::instance();
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::cleanupTestCase()
+{
+#ifdef Q_OS_SYMBIAN
+ stopThread();
+#endif //Q_OS_SYMBIAN
+ QSharedPointer<CaService> serviceNull(NULL);
+ mService = serviceNull;
+ QTest::qWait(5000);
+}
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+int threadFunction(void *params)
+{
+#ifdef Q_OS_SYMBIAN
+ while (ETrue) {
+ User::ResetInactivityTime();//it should help for Viewserver11 panic
+ User::After(5000000);
+ }
+#endif //Q_OS_SYMBIAN
+ return 0;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::startThread()
+{
+#ifdef Q_OS_SYMBIAN
+ User::LeaveIfError(iThread.Create(
+ _L("thread_kill_viewsrv11"),
+ threadFunction,
+ 16384,
+ 4000,
+ 4000,
+ NULL));
+ iThread.Resume();
+#endif //Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::stopThread()
+{
+#ifdef Q_OS_SYMBIAN
+ iThread.Close();
+#endif //Q_OS_SYMBIAN
+}
+
+
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAssignmentOperatorNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ CaNotifierFilter filter;
+ filter.setEntryRole(ItemEntryRole);
+ filter.setTypeNames(QStringList() << "typeName1" << "typeName2");
+ filter.setParentId(22);
+ filter.setIds(QList<int>() << 11 << 22);
+
+ CaNotifierFilter filterAssign;
+ filterAssign = filter;
+ QCOMPARE(filterAssign.getEntryRole(), filter.getEntryRole());
+ QCOMPARE(filterAssign.getParentId(), filter.getParentId());
+ for (int i(0); i < filter.getIds().count(); i++) {
+ QCOMPARE(filterAssign.getIds().at(i),
+ filter.getIds().at(i));
+ }
+ for (int i(0); i < filter.getTypeNames().count(); i++) {
+ QCOMPARE(filterAssign.getTypeNames().at(i),
+ filter.getTypeNames().at(i));
+ }
+
+ filter.setEntryRole(GroupEntryRole);
+ filter.getTypeNames().clear();
+ filter.setTypeNames(QStringList() << "typeName3" << "typeName4");
+ filter.setParentId(55);
+ filter.getIds().clear();
+ filter.setIds(QList<int>() << 33 << 44);
+
+ QVERIFY(filterAssign.getEntryRole() != filter.getEntryRole());
+ QVERIFY(filterAssign.getParentId() != filter.getParentId());
+ for (int i(0); i < filter.getIds().count(); i++) {
+ QVERIFY(filterAssign.getIds().at(i)
+ != filter.getIds().at(i));
+ }
+ for (int i(0); i < filter.getTypeNames().count(); i++) {
+ QVERIFY(filterAssign.getTypeNames().at(i)
+ != filter.getTypeNames().at(i));
+ }
+
+ CaNotifierFilter filterCopyConstructor(filter);
+ QCOMPARE(filterCopyConstructor.getEntryRole(), filter.getEntryRole());
+ QCOMPARE(filterCopyConstructor.getParentId(), filter.getParentId());
+ for (int i(0); i < filter.getIds().count(); i++) {
+ QCOMPARE(filterCopyConstructor.getIds().at(i),
+ filter.getIds().at(i));
+ }
+ for (int i(0); i < filter.getTypeNames().count(); i++) {
+ QCOMPARE(filterCopyConstructor.getTypeNames().at(i),
+ filter.getTypeNames().at(i));
+ }
+
+ CaQuery query;
+ query.setEntryRoles(GroupEntryRole);
+ query.setEntryTypeNames(QStringList() << "Query1" << "Query2");
+ query.setParentId(77);
+
+ CaNotifierFilter filterQuery(query);
+ QCOMPARE(filterQuery.getEntryRole(), query.entryRoles());
+ QCOMPARE(filterQuery.getParentId(), query.parentId());
+ QCOMPARE(filterQuery.getIds().count(), 0);
+ for (int i(0); i < query.entryTypeNames().count(); i++) {
+ QCOMPARE(filterQuery.getTypeNames().at(i),
+ query.entryTypeNames().at(i));
+ }
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddItemChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ QStringList strList;
+ strList.append("TypeName");
+ filter->setTypeNames(strList);
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ delete filter;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime500ms);
+ QTest::qWait(waitTime500ms);
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddGroupChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(GroupEntryRole);
+ filter->setTypeNames(QStringList() << "TypeName");
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+
+ QSharedPointer<CaEntry> entry = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ filter->setTypeNames(QStringList() << "TypeName");
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ int entryId = clientNotifier->mEntryId;
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntry(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryId);
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryIdChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ filter->setTypeNames(QStringList() << "TypeName");
+ filter->setIds(QList<int>() << entry->id());
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ int entryId = entry->id();
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntry(entryId);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryId);
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ delete filter;
+ mService->removeEntry(entry->id());
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryChangeTypeNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ clientNotifier->mEntryId = 0;
+ CaEntry *entryFake = new CaEntry();
+ entryFake->setText("Text");
+ entryFake->setEntryTypeName("TypeName");
+
+ bool removed = mService->removeEntry(*entryFake);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(removed, FALSE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ delete entryFake;
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryIdChangeTypeNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ clientNotifier->mEntryId = 0;
+ bool removed = mService->removeEntry(entryIdFake);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(removed, FALSE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+ CaEntry item3;
+ item3.setText("Text");
+ item3.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text");
+ item4.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry4 = mService->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList< QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+ entriesList.append(entry3);
+ entriesList.append(entry4);
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ filter->setTypeNames(QStringList() << "TypeName");
+ filter->setIds(QList<int>() << entry2->id() << entry3->id());
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry3->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ delete filter;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime500ms);
+ entriesList.clear();
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesIdsChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+ CaEntry item3;
+ item3.setText("Text");
+ item3.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text");
+ item4.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry4 = mService->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList<int> entriesIdsList;
+ entriesIdsList.append(entry1->id());
+ entriesIdsList.append(entry2->id());
+ entriesIdsList.append(entry3->id());
+ entriesIdsList.append(entry4->id());
+
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntries(entriesIdsList);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry4->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesIdsList);
+ QTest::qWait(waitTime500ms);
+ entriesIdsList.clear();
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesChangeTypeNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+ CaEntry item3;
+ item3.setText("Text");
+ item3.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text");
+ item4.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry4 = mService->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList<QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+ entriesList.append(entry3);
+ entriesList.append(entry4);
+
+ clientNotifier->mEntryId = 0;
+
+ CaEntry itemFake1;
+ itemFake1.setText("Text");
+ itemFake1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryFake1 = mService->createEntry(itemFake1);
+ int entryFake1Id = entryFake1->id();
+ entryFake1->setId(entryIdFake);
+ QTest::qWait(waitTime1sec);
+ CaEntry itemFake2;
+ itemFake2.setText("Text");
+ itemFake2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryFake2 = mService->createEntry(itemFake2);
+ int entryFake2Id = entryFake2->id();
+ entryFake2->setId(entryIdFake);
+ QTest::qWait(waitTime1sec);
+ QList<QSharedPointer<CaEntry> > entriesListFake;
+ entriesListFake.append(entryFake1);
+ entriesListFake.append(entryFake2);
+
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mChangeType = AddChangeType;
+
+ bool removed = mService->removeEntries(entriesListFake);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(removed, FALSE);
+
+ entryFake1->setId(entryFake1Id);
+ entryFake2->setId(entryFake2Id);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ mService->removeEntries(entriesListFake);
+ QTest::qWait(waitTime500ms);
+ entriesList.clear();
+ entriesListFake.clear();
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesIdsChangeTypeNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+ CaEntry item3;
+ item3.setText("Text");
+ item3.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text");
+ item4.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry4 = mService->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList<int> entriesIdsList;
+ entriesIdsList.append(entry1->id());
+ entriesIdsList.append(entry2->id());
+ entriesIdsList.append(entry3->id());
+ entriesIdsList.append(entry4->id());
+
+ CaEntry itemFake1;
+ itemFake1.setText("Text");
+ itemFake1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryFake1 = mService->createEntry(itemFake1);
+ int entryFake1Id = entryFake1->id();
+ entryFake1->setId(entryIdFake);
+ QTest::qWait(waitTime1sec);
+ CaEntry itemFake2;
+ itemFake2.setText("Text");
+ itemFake2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryFake2 = mService->createEntry(itemFake2);
+ int entryFake2Id = entryFake2->id();
+ entryFake2->setId(entryIdFake);
+ QTest::qWait(waitTime1sec);
+ QList<int> entriesIdsListFake;
+ entriesIdsListFake.append(entryFake1->id());
+ entriesIdsListFake.append(entryFake2->id());
+
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mChangeType = AddChangeType;
+
+ bool removed = mService->removeEntries(entriesIdsListFake);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(removed, FALSE);
+
+ entryFake1->setId(entryFake1Id);
+ entryFake2->setId(entryFake2Id);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesIdsList);
+ mService->removeEntry(*entryFake1);
+ mService->removeEntry(*entryFake2);
+ QTest::qWait(waitTime1sec);
+ entriesIdsList.clear();
+ entriesIdsListFake.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveGroupChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ int entryId = clientNotifier->mEntryId;
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntry(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryId);
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveGroupsChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+
+ CaEntry group1(GroupEntryRole);
+ group1.setText("Text");
+ group1.setEntryTypeName("TypeName1");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(group1);
+ QTest::qWait(waitTime1sec);
+ CaEntry group2(GroupEntryRole);
+ group2.setText("Text");
+ group2.setEntryTypeName("TypeName2");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(group2);
+ QTest::qWait(waitTime1sec);
+ CaEntry group3(GroupEntryRole);
+ group3.setText("Text");
+ group3.setEntryTypeName("TypeName3");
+ QSharedPointer<CaEntry> entry3 = mService->createEntry(group3);
+ QTest::qWait(waitTime1sec);
+ CaEntry group4(GroupEntryRole);
+ group4.setText("Text");
+ group4.setEntryTypeName("TypeName4");
+ QSharedPointer<CaEntry> entry4 = mService->createEntry(group4);
+ QTest::qWait(waitTime1sec);
+
+ QList< QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+ entriesList.append(entry3);
+ entriesList.append(entry4);
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(GroupEntryRole);
+ filter->setTypeNames(QStringList() << "TypeName3" << "TypeName4");
+ filter->setIds(QList<int>() << entry3->id());
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry3->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ delete filter;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestUpdateChangeTypeNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ item.setDescription("description");
+
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ int entryId = clientNotifier->mEntryId;
+ delete clientNotifier;
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ filter->setIds(QList<int>() << entry->id());
+ TestCaClientNotifier *clientNotifierUpdate = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifierUpdate = clientNotifierUpdate->getNotifier();
+
+ connect(notifierUpdate, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifierUpdate, SLOT(entryChanged(int,ChangeType)));
+ connect(notifierUpdate, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifierUpdate, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ bool updated = mService->updateEntry(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifierUpdate->mChangeType, UpdateChangeType);
+ QVERIFY(clientNotifierUpdate->mEntryId > 0);
+ QCOMPARE(clientNotifierUpdate->mEntryId, entryId);
+ QCOMPARE(clientNotifierUpdate->mEntryId, entry->id());
+ QCOMPARE(clientNotifierUpdate->mEntry->description(), QString("description"));
+ QCOMPARE(updated, TRUE);
+
+ // cleanup
+ disconnect(notifierUpdate, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifierUpdate, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifierUpdate, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifierUpdate, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ delete clientNotifierUpdate;
+ delete filter;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestUpdateChangeTypeNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+
+ int entryId = clientNotifier->mEntryId;
+ clientNotifier->mEntryId = 0;
+ CaEntry itemFake;
+ itemFake.setText("Text");
+ itemFake.setEntryTypeName("TypeName");
+
+ bool updated = mService->updateEntry(itemFake);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(updated, FALSE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddUpdateRemove()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+
+
+ int entryId = clientNotifier->mEntryId;
+ clientNotifier->mEntryId = 0;
+
+ bool updated = mService->updateEntry(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, UpdateChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+ QCOMPARE(updated, TRUE);
+
+ entryId = clientNotifier->mEntryId;
+ clientNotifier->mEntryId = 0;
+
+ bool removed = mService->removeEntry(entryId);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRegisterNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(int,ChangeType))), 1);
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(CaEntry,ChangeType))), 1);
+ QCOMPARE(notifier->receivers(SIGNAL(entryTouched(int))), 1);
+ QCOMPARE(notifier->receivers(SIGNAL(groupContentChanged(int))), 1);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(int,ChangeType))), 0);
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(CaEntry,ChangeType))), 0);
+ QCOMPARE(notifier->receivers(SIGNAL(entryTouched(int))), 0);
+ QCOMPARE(notifier->receivers(SIGNAL(groupContentChanged(int))), 0);
+
+ delete clientNotifier;
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestUnregisterNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(int,ChangeType))), 1);
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(CaEntry,ChangeType))), 1);
+ QCOMPARE(notifier->receivers(SIGNAL(entryTouched(int))), 1);
+ QCOMPARE(notifier->receivers(SIGNAL(groupContentChanged(int))), 1);
+
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(int,ChangeType))), 0);
+ QCOMPARE(notifier->receivers(SIGNAL(entryChanged(CaEntry,ChangeType))), 0);
+ QCOMPARE(notifier->receivers(SIGNAL(entryTouched(int))), 0);
+ QCOMPARE(notifier->receivers(SIGNAL(groupContentChanged(int))), 0);
+
+ delete clientNotifier;
+ QTest::qWait(waitTime500ms);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestTouchEntryNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ filter->setIds(QList<int>() << entry->id());
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+
+ bool touched = mService->touch(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+ QCOMPARE(touched, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ delete filter;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestTouchEntryIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+
+ bool touched = mService->touch(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+ QCOMPARE(touched, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestTouchEntryNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mEntryId, 0);
+
+ CaEntry *entryFake = new CaEntry();
+ entryFake->setText("Text");
+ entryFake->setEntryTypeName("TypeName");
+
+ bool touched = mService->touch(*entryFake);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(touched, FALSE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+ delete entryFake;
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+
+void TestCaClient::TestTouchEntryUidNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ QScopedPointer<TestCaClientNotifier> clientNotifier(
+ new TestCaClientNotifier(*mService));
+
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier.data(), SLOT(entryTouched(int)));
+
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("application");
+ item.setAttribute(
+ "application:uid",
+ "-3");
+
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(!entry.isNull());
+
+ const int expectedEntryId = entry->id();
+
+ entry->setId(0);
+
+ QCOMPARE(clientNotifier->mEntryId, 0);
+
+ bool touched = mService->touch(*entry);
+
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mEntryId, expectedEntryId);
+ QCOMPARE(touched, true);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier.data(), SLOT(entryTouched(int)));
+
+ QTest::qWait(waitTime500ms);
+
+ mService->removeEntry(expectedEntryId);
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestTouchEntryIdNotifierFake()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mEntryId, 0);
+
+ QScopedPointer<CaEntry> entryFake(new CaEntry());
+ entryFake->setText("Text");
+ entryFake->setEntryTypeName("TypeName");
+ entryFake->setId(entryIdFake);
+
+ bool touched = mService->touch(*entryFake);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(touched, FALSE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestTouchGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mEntryId, 0);
+
+ bool touched = mService->touch(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entry->id());
+ QCOMPARE(touched, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryTouched(int)),
+ clientNotifier, SLOT(entryTouched(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entry->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntryGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryI = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->appendEntryToGroup((CaEntry &)(*entryG), *entryI);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI->id());
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntryGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryI = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->appendEntryToGroup(((CaEntry &)*entryG).id(), (*entryI).id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI->id());
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntriesGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList< QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->appendEntriesToGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntriesGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryItem1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryItem2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList<int> entriesIdsList;
+ entriesIdsList.append(entryItem1->id());
+ entriesIdsList.append(entryItem2->id());
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->appendEntriesToGroup(((CaEntry &)*entryGroup).id(), entriesIdsList);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesIdsList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesIdsList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntryGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryI = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->prependEntryToGroup((CaEntry &)(*entryG), *entryI);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI->id());
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntryGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryI = mService->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->prependEntryToGroup(((CaEntry &)*entryG).id(), (*entryI).id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI->id());
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntriesGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList< QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->prependEntriesToGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntriesGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryItem1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryItem2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList<int> entriesIdsList;
+ entriesIdsList.append(entryItem1->id());
+ entriesIdsList.append(entryItem2->id());
+
+ clientNotifier->mChangeType = RemoveChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool appended = mService->prependEntriesToGroup(((CaEntry &)*entryGroup).id(), entriesIdsList);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(appended, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesIdsList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesIdsList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList< QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+
+ bool appended = mService->appendEntriesToGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(appended, TRUE);
+
+ clientNotifier->mChangeType = AddChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+ bool removed = mService->removeEntryFromGroup((CaEntry &)*entryGroup, *entry1);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(removed, TRUE);
+
+ clientNotifier->mChangeType = AddChangeType;
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+ removed = mService->removeEntryFromGroup((CaEntry &)*entryGroup, *entry2);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList< QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+
+ bool appended = mService->appendEntriesToGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(appended, TRUE);
+
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+ bool removed = mService->removeEntryFromGroup(entryGroup->id(), entry1->id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(removed, TRUE);
+
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+ removed = mService->removeEntryFromGroup(entryGroup->id(), entry2->id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList<QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+
+ bool appended = mService->appendEntriesToGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(appended, TRUE);
+
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+ bool removed = mService->removeEntriesFromGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryGroup = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryGroup->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryGroup->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text");
+ item1.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text");
+ item2.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ QList<QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+
+ bool appended = mService->appendEntriesToGroup((CaEntry &)*entryGroup, entriesList);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(appended, TRUE);
+
+ QList<int> entriesIdList;
+ entriesIdList.append(entry1->id());
+ entriesIdList.append(entry2->id());
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+ bool removed = mService->removeEntriesFromGroup(entryGroup->id(), entriesIdList);
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryGroup->id());
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+ mService->removeEntry(entryGroup->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+ entriesIdList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntryGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text1");
+ item1.setEntryTypeName("TypeName1");
+ QSharedPointer<CaEntry> entryI1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text2");
+ item2.setEntryTypeName("TypeName2");
+ QSharedPointer<CaEntry> entryI2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ bool appended = mService->appendEntryToGroup((CaEntry &)(*entryG), *entryI1);
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+ appended = mService->prependEntryToGroup((CaEntry &)(*entryG), *entryI2);
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+
+ CaEntry item3;
+ item3.setText("Text3");
+ item3.setEntryTypeName("TypeName3");
+ QSharedPointer<CaEntry> entryI3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool inserted = mService->insertEntryIntoGroup((CaEntry &)*entryG, *entryI3, entryI2->id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(inserted, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI1->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI2->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI3->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntryGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text1");
+ item1.setEntryTypeName("TypeName1");
+ QSharedPointer<CaEntry> entryI1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text2");
+ item2.setEntryTypeName("TypeName2");
+ QSharedPointer<CaEntry> entryI2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ bool appended = mService->appendEntryToGroup(entryG->id(), entryI1->id());
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+ appended = mService->prependEntryToGroup(entryG->id(), entryI2->id());
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+
+ CaEntry item3;
+ item3.setText("Text3");
+ item3.setEntryTypeName("TypeName3");
+ QSharedPointer<CaEntry> entryI3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool inserted = mService->insertEntryIntoGroup(entryG->id(), entryI3->id(), entryI2->id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(inserted, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI1->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI2->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI3->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntriesGroupNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text1");
+ item1.setEntryTypeName("TypeName1");
+ QSharedPointer<CaEntry> entryI1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text2");
+ item2.setEntryTypeName("TypeName2");
+ QSharedPointer<CaEntry> entryI2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ bool appended = mService->appendEntryToGroup((CaEntry &)(*entryG), *entryI1);
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+ appended = mService->prependEntryToGroup((CaEntry &)(*entryG), *entryI2);
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+
+ CaEntry item3;
+ item3.setText("Text3");
+ item3.setEntryTypeName("TypeName3");
+ QSharedPointer<CaEntry> entryI3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text4");
+ item4.setEntryTypeName("TypeName4");
+ QSharedPointer<CaEntry> entryI4 = mService->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList<QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entryI3);
+ entriesList.append(entryI4);
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool inserted = mService->insertEntriesIntoGroup((CaEntry &)*entryG, entriesList, entryI2->id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(inserted, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI1->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI2->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI3->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI4->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+ entriesList.clear();
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntriesGroupIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ QTest::qWait(waitTime500ms);
+ CaEntry group(GroupEntryRole);
+ group.setText("Text");
+ group.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entryG = mService->createEntry(group);
+ QTest::qWait(waitTime1sec);
+ int groupId = entryG->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mEntryId > 0);
+ QCOMPARE(clientNotifier->mEntryId, entryG->id());
+
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ CaEntry item1;
+ item1.setText("Text1");
+ item1.setEntryTypeName("TypeName1");
+ QSharedPointer<CaEntry> entryI1 = mService->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text2");
+ item2.setEntryTypeName("TypeName2");
+ QSharedPointer<CaEntry> entryI2 = mService->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+
+ bool appended = mService->appendEntryToGroup((CaEntry &)(*entryG), *entryI1);
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+ appended = mService->prependEntryToGroup((CaEntry &)(*entryG), *entryI2);
+ QTest::qWait(waitTime500ms);
+ QCOMPARE(appended, TRUE);
+
+ CaEntry item3;
+ item3.setText("Text3");
+ item3.setEntryTypeName("TypeName3");
+ QSharedPointer<CaEntry> entryI3 = mService->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text4");
+ item4.setEntryTypeName("TypeName4");
+ QSharedPointer<CaEntry> entryI4 = mService->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList<int> entriesIdsList;
+ entriesIdsList.append(entryI3->id());
+ entriesIdsList.append(entryI4->id());
+ clientNotifier->mEntryId = 0;
+ clientNotifier->mGroupId = 0;
+
+ bool inserted = mService->insertEntriesIntoGroup(entryG->id(), entriesIdsList, entryI2->id());
+ QTest::qWait(waitTime1sec);
+
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mGroupId, groupId);
+ QCOMPARE(clientNotifier->mGroupId, entryG->id());
+ QCOMPARE(inserted, TRUE);
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ mService->removeEntry(entryI1->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI2->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI3->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryI4->id());
+ QTest::qWait(waitTime500ms);
+ mService->removeEntry(entryG->id());
+ QTest::qWait(waitTime1sec);
+ entriesIdsList.clear();
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestChangeEntryWithParentIdNotifier()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setParentId(1); // AllCollections
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*mService, filter);
+
+ CaNotifier *notifier = clientNotifier->getNotifier();
+
+ connect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ connect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+ QTest::qWait(waitTime500ms);
+
+ CaEntry entryToAdd(ItemEntryRole);
+ entryToAdd.setText("Text");
+ entryToAdd.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = mService->createEntry(entryToAdd);
+ QTest::qWait(waitTime1sec);
+ int entryId = entry->id();
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, 0);
+ QCOMPARE(clientNotifier->mCount, 0);
+
+ bool appended = mService->appendEntryToGroup(3, entryId); // office
+ QTest::qWait(waitTime1sec);
+
+
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mCount, 1);
+
+ mService->removeEntry(entryId);
+
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier->mGroupId > 0);
+ QCOMPARE(clientNotifier->mCount, 2);
+
+ disconnect(notifier, SIGNAL(entryChanged(int, ChangeType)),
+ clientNotifier, SLOT(entryChanged(int, ChangeType)));
+ disconnect(notifier, SIGNAL(groupContentChanged(int)),
+ clientNotifier, SLOT(groupContentChanged(int)));
+
+ QTest::qWait(waitTime500ms);
+
+ delete clientNotifier;
+ delete filter;
+
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+//QTEST_MAIN(homescreen::test::TestCaClient)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_notifier_adv.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,267 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "canotifier.h"
+#include "canotifierfilter.h"
+#include "t_caclientNotifier.h"
+
+const int entryIdFake(-1);
+const int waitTime500ms(500);
+const int waitTime1sec(1000);
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddItemChangeTypeNotifier3Clients()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier_1 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_1 = clientNotifier_1->getNotifier();
+
+ TestCaClientNotifier *clientNotifier_2 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_2 = clientNotifier_2->getNotifier();
+
+ TestCaClientNotifier *clientNotifier_3 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_3 = clientNotifier_3->getNotifier();
+
+ connect(notifier_1, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_1, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier_2, SIGNAL(entryChanged(CaEntry,ChangeType)),
+ clientNotifier_2, SLOT(entryChanged(CaEntry,ChangeType)));
+ connect(notifier_3, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_3, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+
+ clientNotifier_1->mChangeType = RemoveChangeType;
+ clientNotifier_2->mChangeType = RemoveChangeType;
+ clientNotifier_3->mChangeType = RemoveChangeType;
+ terminatServer();
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entry = service->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier_1->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier_1->mEntryId > 0);
+ QCOMPARE(clientNotifier_1->mEntryId, entry->id());
+ QCOMPARE(clientNotifier_1->mEntryId, clientNotifier_2->mEntryId);
+ QCOMPARE(clientNotifier_3->mEntryId, clientNotifier_2->mEntryId);
+ QCOMPARE(clientNotifier_2->mChangeType, AddChangeType);
+ QCOMPARE(entry->text(), clientNotifier_2->mEntry->text());
+ QCOMPARE(clientNotifier_3->mChangeType, AddChangeType);
+
+
+ // cleanup
+ disconnect(notifier_1, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_1, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier_2, SIGNAL(entryChanged(CaEntry,ChangeType)),
+ clientNotifier_2, SLOT(entryChanged(CaEntry,ChangeType)));
+ disconnect(notifier_3, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_3, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+ delete clientNotifier_1;
+ delete clientNotifier_2;
+ delete clientNotifier_3;
+ service->removeEntry(entry->id());
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryChangeTypeNotifier3Clients()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier_1 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_1 = clientNotifier_1->getNotifier();
+
+ TestCaClientNotifier *clientNotifier_2 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_2 = clientNotifier_2->getNotifier();
+
+ TestCaClientNotifier *clientNotifier_3 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_3 = clientNotifier_3->getNotifier();
+
+ connect(notifier_1, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_1, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier_2, SIGNAL(entryChanged(CaEntry,ChangeType)),
+ clientNotifier_2, SLOT(entryChanged(CaEntry,ChangeType)));
+ connect(notifier_3, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_3, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+ terminatServer();
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+
+ QSharedPointer<CaEntry> entry = service->createEntry(item);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier_1->mChangeType, AddChangeType);
+ QVERIFY(clientNotifier_2->mEntryId > 0);
+ QCOMPARE(clientNotifier_3->mEntryId, entry->id());
+
+ int entryId_1 = clientNotifier_1->mEntryId;
+ clientNotifier_1->mEntryId = 0;
+ int entryId_2 = clientNotifier_2->mEntryId;
+ clientNotifier_2->mEntryId = 0;
+ int entryId_3 = clientNotifier_3->mEntryId;
+ clientNotifier_3->mEntryId = 0;
+
+ bool removed = service->removeEntry(*entry);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier_1->mChangeType, RemoveChangeType);
+ QCOMPARE(clientNotifier_2->mChangeType, RemoveChangeType);
+ QCOMPARE(clientNotifier_3->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier_1->mEntryId > 0);
+ QCOMPARE(clientNotifier_1->mEntryId, entryId_1);
+ QCOMPARE(clientNotifier_2->mEntryId, entryId_2);
+ QCOMPARE(clientNotifier_3->mEntryId, entryId_3);
+ QCOMPARE(entryId_1, entryId_3);
+ QCOMPARE(entryId_2, entryId_3);
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier_1, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_1, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier_2, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier_2, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ disconnect(notifier_3, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_3, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier_1;
+ delete clientNotifier_2;
+ delete clientNotifier_3;
+ service->removeEntry(entry->id());
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesChangeTypeNotifier3Clients()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier_1 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_1 = clientNotifier_1->getNotifier();
+
+ TestCaClientNotifier *clientNotifier_2 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_2 = clientNotifier_2->getNotifier();
+
+ TestCaClientNotifier *clientNotifier_3 = new TestCaClientNotifier(*service);
+ CaNotifier *notifier_3 = clientNotifier_3->getNotifier();
+
+ connect(notifier_1, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_1, SLOT(entryChanged(int,ChangeType)));
+ connect(notifier_2, SIGNAL(entryChanged(CaEntry,ChangeType)),
+ clientNotifier_2, SLOT(entryChanged(CaEntry,ChangeType)));
+ connect(notifier_3, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_3, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+
+ CaEntry item1;
+ item1.setText("Text1");
+ item1.setEntryTypeName("TypeName1");
+ QSharedPointer<CaEntry> entry1 = service->createEntry(item1);
+ QTest::qWait(waitTime1sec);
+ CaEntry item2;
+ item2.setText("Text2");
+ item2.setEntryTypeName("TypeName2");
+ QSharedPointer<CaEntry> entry2 = service->createEntry(item2);
+ QTest::qWait(waitTime1sec);
+ CaEntry item3;
+ item3.setText("Text3");
+ item3.setEntryTypeName("TypeName3");
+ QSharedPointer<CaEntry> entry3 = service->createEntry(item3);
+ QTest::qWait(waitTime1sec);
+ CaEntry item4;
+ item4.setText("Text4");
+ item4.setEntryTypeName("TypeName4");
+ QSharedPointer<CaEntry> entry4 = service->createEntry(item4);
+ QTest::qWait(waitTime1sec);
+
+ QList<QSharedPointer<CaEntry> > entriesList;
+ entriesList.append(entry1);
+ entriesList.append(entry2);
+ entriesList.append(entry3);
+ entriesList.append(entry4);
+
+ clientNotifier_1->mEntryId = clientNotifier_2->mEntryId =
+ clientNotifier_3->mEntryId = 0;
+
+ bool removed = service->removeEntries(entriesList);
+ QTest::qWait(waitTime1sec);
+
+ QCOMPARE(clientNotifier_1->mChangeType, RemoveChangeType);
+ QCOMPARE(clientNotifier_2->mChangeType, RemoveChangeType);
+ QCOMPARE(clientNotifier_3->mChangeType, RemoveChangeType);
+ QVERIFY(clientNotifier_1->mEntryId > 0);
+ QCOMPARE(clientNotifier_1->mEntryId, clientNotifier_2->mEntryId);
+ QCOMPARE(clientNotifier_1->mEntryId, clientNotifier_3->mEntryId);
+ QCOMPARE(removed, TRUE);
+
+ // cleanup
+ disconnect(notifier_1, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_1, SLOT(entryChanged(int,ChangeType)));
+ disconnect(notifier_2, SIGNAL(entryChanged(CaEntry,ChangeType)),
+ clientNotifier_2, SLOT(entryChanged(CaEntry,ChangeType)));
+ disconnect(notifier_3, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier_3, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+
+ delete clientNotifier_1;
+ delete clientNotifier_2;
+ delete clientNotifier_3;
+ service->removeEntries(entriesList);
+ QTest::qWait(waitTime500ms);
+ entriesList.clear();
+ }
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+// __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_notifier_ext.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,532 @@
+/*
+* Copyright (c) 2009 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: Extra tests notifications.
+*
+*/
+
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "canotifier.h"
+#include "canotifierfilter.h"
+#include "t_caclientnotifier.h"
+
+const int entryIdFake(-1);
+const int waitTimeMin(100);
+const int waitTime500ms(500);
+const int waitTime1sec(1000);
+
+const int noOfClients(3);
+const int noOfManyClients(20);
+
+class Thread: public QThread
+{
+public:
+ enum OpType {None, AddItem, RemoveEntry, RemoveEntryId, TooMuchClients};
+ void run();
+ Thread(): mOpType(None), mRemoved(false), mEntry(), mId(0), mClientNotifier(NULL), mNotifier(NULL) { }
+ ~Thread();
+
+ OpType mOpType;
+ bool mRemoved;
+ QSharedPointer<CaEntry> mEntry;
+ int mId;
+ TestCaClientNotifier *mClientNotifier;
+ CaNotifier *mNotifier;
+};
+
+Thread::~Thread()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ service->removeEntry(mId);
+ disconnect(mNotifier, SIGNAL(entryChanged(int,ChangeType)),
+ mClientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete mClientNotifier;
+}
+
+void Thread::run()
+{
+ QTest::qWait(waitTimeMin);
+ QSharedPointer<CaService> service = CaService::instance();
+ CaNotifierFilter *filter = new CaNotifierFilter();
+ filter->setEntryRole(ItemEntryRole);
+ filter->setTypeNames(QStringList() << "TypeName");
+ mClientNotifier = new TestCaClientNotifier(*service, filter);
+ mNotifier = mClientNotifier->getNotifier();
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ switch (mOpType) {
+ case AddItem: {
+ connect(mNotifier, SIGNAL(entryChanged(int,ChangeType)),
+ mClientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+ QSharedPointer<CaEntry> entry = service->createEntry(item);
+ mId = entry->id();
+ }
+ break;
+ case RemoveEntry: {
+ connect(mNotifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ mClientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+ QTest::qWait(waitTime1sec);
+ mRemoved = service->removeEntry(*mEntry);
+ }
+ break;
+ case RemoveEntryId: {
+ connect(mNotifier, SIGNAL(entryChanged(int,ChangeType)),
+ mClientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime1sec);
+ mRemoved = service->removeEntry(mId);
+ }
+ break;
+ case TooMuchClients: {
+ connect(mNotifier, SIGNAL(entryChanged(int,ChangeType)),
+ mClientNotifier, SLOT(entryChanged(int,ChangeType)));
+ }
+ break;
+ default:
+ qWarning("Thread::run: unknown operation (mOpType)");
+ break;
+ }
+
+ exec();
+}
+
+/*
+class ThreadRemoveEntry: public QThread
+{
+public:
+ void run();
+ ~ThreadRemoveEntry();
+
+ bool mRemoved;
+ CaEntry *mEntry;
+ int mId;
+ TestCaClientNotifier *mClientNotifier;
+ CaNotifier *mNotifier;
+};
+
+ThreadRemoveEntry::~ThreadRemoveEntry()
+{
+ disconnect(mNotifier, SIGNAL(entryChanged(int,ChangeType)),
+ mClientNotifier, SLOT(entryChanged(int,ChangeType)) );
+ QTest::qWait(waitTime500ms);
+ delete mClientNotifier;
+}
+
+void ThreadRemoveEntry::run()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*service);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+ connect( notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType )),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType )) );
+
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+
+ mRemoved = service->removeEntry(*mEntry);
+
+ exec();
+}
+*/
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddItemChangeTypeNotifierNClients()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*service);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+
+ QTest::qWait(waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entries[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ entries[i] = service->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, entries[i]->id());
+ QCOMPARE(clientNotifier->mCount, i+1);
+ }
+
+ for (int i=0; i<noOfClients; i++) {
+ for (int j=i+1; j<noOfClients; j++) {
+ QVERIFY(entries[i]->id() != entries[j]->id());
+ }
+ }
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ for (int i=0; i<noOfClients; i++) {
+ service->removeEntry(entries[i]->id());
+ }
+ }
+
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddItemChangeTypeNotifierNClientsFast()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*service);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+
+ QTest::qWait(waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entries[noOfClients];
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ for (int i=0; i<noOfClients; i++) {
+ entries[i] = service->createEntry(item);
+ }
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(clientNotifier->mCount, 3);
+ for (int i=0; i<noOfClients; i++) {
+ QVERIFY(clientNotifier->mEntryIds->contains(entries[i]->id()));
+ for (int j=i+1; j<noOfClients; j++) {
+ QVERIFY(entries[i]->id() != entries[j]->id());
+ }
+ }
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ for (int i=0; i<noOfClients; i++) {
+ service->removeEntry(entries[i]->id());
+ }
+ }
+
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddItemChangeTypeNotifierNClientsThreads()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ Thread threads[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ threads[i].mOpType = Thread::AddItem;
+ threads[i].start();
+ }
+ QTest::qWait(6*noOfClients*waitTime1sec);
+
+ for (int i=0; i<noOfClients; i++) {
+ QCOMPARE(threads[i].mClientNotifier->mCount, noOfClients);
+ for (int j=0; j<noOfClients; j++) {
+ for (int k=j+1; k<noOfClients; k++) {
+ QVERIFY(threads[i].mClientNotifier->mEntryIds->at(j)
+ != threads[i].mClientNotifier->mEntryIds->at(k));
+ }
+ }
+ }
+ for (int i=0; i<noOfClients; i++) {
+ for (int j=0; j<noOfClients; j++) {
+ QVERIFY(threads[j].mClientNotifier->mEntryIds->contains(threads[i].mId));
+ }
+ }
+
+ for (int i=0; i<noOfClients; i++) {
+ threads[i].exit(0);
+ }
+ QTest::qWait(waitTime500ms);
+
+ }
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryChangeTypeNotifierNClients()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ TestCaClientNotifier *clientNotifier = new TestCaClientNotifier(*service);
+ CaNotifier *notifier = clientNotifier->getNotifier();
+ connect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ connect(notifier, SIGNAL(entryChanged(const CaEntry &,ChangeType)),
+ clientNotifier, SLOT(entryChanged(const CaEntry &,ChangeType)));
+
+ QTest::qWait(waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entries[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ entries[i] = service->createEntry(item);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(clientNotifier->mChangeType, AddChangeType);
+ QCOMPARE(clientNotifier->mEntryId, entries[i]->id());
+ QCOMPARE(clientNotifier->mCount, 2*(i+1));
+ }
+ for (int i=0; i<noOfClients; i++) {
+ bool removed = service->removeEntry(*entries[i]);
+ QVERIFY(removed);
+ QTest::qWait(waitTime1sec);
+ QCOMPARE(clientNotifier->mChangeType, RemoveChangeType);
+ QCOMPARE(clientNotifier->mEntryId, entries[i]->id());
+ }
+
+ // cleanup
+ disconnect(notifier, SIGNAL(entryChanged(int,ChangeType)),
+ clientNotifier, SLOT(entryChanged(int,ChangeType)));
+ QTest::qWait(waitTime500ms);
+ delete clientNotifier;
+ }
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryChangeTypeNotifierNClientsThreads()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ QTest::qWait(waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ QSharedPointer<CaEntry> entries[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ entries[i] = service->createEntry(item);
+ }
+
+ QTest::qWait(waitTime1sec);
+ Thread threads[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ threads[i].mOpType = Thread::RemoveEntry;
+ threads[i].mEntry = entries[i];
+ threads[i].start();
+ }
+ QTest::qWait(6*noOfClients*waitTime1sec);
+ for (int i=0; i<noOfClients; i++) {
+ QVERIFY(threads[i].mRemoved);
+ QCOMPARE(threads[i].mClientNotifier->mChangeType, RemoveChangeType);
+ QCOMPARE(threads[i].mClientNotifier->mCount, noOfClients);
+ QVERIFY(threads[i].mClientNotifier->mEntryIds->contains(entries[i]->id()));
+ }
+
+ for (int i=0; i<noOfClients; i++) {
+ threads[i].exit(0);
+ }
+ QTest::qWait(waitTime500ms);
+
+ // cleanup
+ for (int i=0; i<noOfClients; i++) {
+ bool removed = service->removeEntry(*entries[i]);
+ QTest::qWait(waitTime1sec);
+ }
+
+ }
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryIdChangeTypeNotifierNClientsThreads()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+ QTest::qWait(waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ int ids[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ ids[i] = service->createEntry(item)->id();
+ }
+
+ QTest::qWait(waitTime1sec);
+ Thread threads[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ threads[i].mOpType = Thread::RemoveEntryId;
+ threads[i].mId = ids[i];
+ threads[i].start();
+ }
+ QTest::qWait(6*noOfClients*waitTime1sec);
+ for (int i=0; i<noOfClients; i++) {
+ QVERIFY(threads[i].mRemoved);
+ QCOMPARE(threads[i].mClientNotifier->mChangeType, RemoveChangeType);
+ QCOMPARE(threads[i].mClientNotifier->mCount, noOfClients);
+ QVERIFY(threads[i].mClientNotifier->mEntryIds->contains(ids[i]));
+ }
+
+ for (int i=0; i<noOfClients; i++) {
+ threads[i].exit(0);
+ }
+ QTest::qWait(waitTime500ms);
+
+ // cleanup
+ for (int i=0; i<noOfClients; i++) {
+ bool removed = service->removeEntry(ids[i]);
+ QTest::qWait(waitTime1sec);
+ }
+
+ }
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAddItemChangeTypeNotifierManyClientsThreads()
+{
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARK;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+ {
+ QSharedPointer<CaService> service = CaService::instance();
+
+ Thread threads[noOfManyClients];
+ for (int i=0; i<noOfManyClients; i++) {
+ threads[i].mOpType = Thread::TooMuchClients;
+ threads[i].start();
+ }
+ QTest::qWait(10*waitTime1sec);
+ CaEntry item;
+ item.setText("Text");
+ item.setEntryTypeName("TypeName");
+ int ids[noOfClients];
+ for (int i=0; i<noOfClients; i++) {
+ ids[i] = service->createEntry(item)->id();
+ }
+ QTest::qWait(6*noOfManyClients*waitTime1sec);
+
+ for (int i=0; i<noOfManyClients; i++) {
+ QCOMPARE(threads[i].mClientNotifier->mCount, noOfClients);
+ for (int j=0; j<noOfClients; j++) {
+ for (int k=j+1; k<noOfClients; k++) {
+ QVERIFY(threads[i].mClientNotifier->mEntryIds->at(j)
+ != threads[i].mClientNotifier->mEntryIds->at(k));
+ }
+ }
+ }
+ for (int i=0; i<noOfClients; i++) {
+ for (int j=0; j<noOfManyClients; j++) {
+ QVERIFY(threads[j].mClientNotifier->mEntryIds->contains(ids[i]));
+ }
+ }
+
+ for (int i=0; i<noOfManyClients; i++) {
+ threads[i].exit(0);
+ }
+ QTest::qWait(waitTime500ms);
+
+ // cleanup
+ for (int i=0; i<noOfClients; i++) {
+ bool removed = service->removeEntry(ids[i]);
+ QVERIFY(removed);
+ QTest::qWait(waitTime1sec);
+ }
+
+ }
+
+#ifdef Q_OS_SYMBIAN
+#ifdef UT_MEMORY_CHECK
+ __UHEAP_MARKEND;
+#endif//UT_MEMORY_CHECK
+#endif//Q_OS_SYMBIAN
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_organize.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,1028 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntryIntoGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->appendEntryToGroup(9999, entry1->id()));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(!service->appendEntryToGroup(group->id(), 9999));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(service->appendEntryToGroup(group->id(), entry1->id()));
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),1);
+ QVERIFY(service->appendEntryToGroup(group->id(), entry2->id()));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QCOMPARE(entries.at(0),entry1->id());
+ QCOMPARE(entries.at(1),entry2->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntryIntoGroup2()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->appendEntryToGroup(groupEntry, *entry1));
+ QVERIFY(!service->appendEntryToGroup(*group , itemEntry));
+ QVERIFY(service->appendEntryToGroup(*group , *entry1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),1);
+ QVERIFY(service->appendEntryToGroup(*group, *entry2));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QCOMPARE(entries.at(0),entry1->id());
+ QCOMPARE(entries.at(1),entry2->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntriesIntoGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry3 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry4 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList<int> entries1;
+ entries1.append(entry1->id());
+ entries1.append(entry2->id());
+ QList<int> entries2;
+ entries2.append(entry3->id());
+ entries2.append(entry4->id());
+ QList<int> wrongEntries1;
+ wrongEntries1.append(entry1->id());
+ wrongEntries1.append(9999);
+
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->appendEntriesToGroup(9999, entries1));
+ QVERIFY(!service->appendEntriesToGroup(group->id(), wrongEntries1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+
+ QVERIFY(service->appendEntriesToGroup(group->id(), entries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QVERIFY(service->appendEntriesToGroup(group->id(), entries2));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),4);
+
+ QCOMPARE(entries.at(0),entry1->id());
+ QCOMPARE(entries.at(1),entry2->id());
+ QCOMPARE(entries.at(2),entry3->id());
+ QCOMPARE(entries.at(3),entry4->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*entry3);
+ service->removeEntry(*entry4);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestAppendEntriesIntoGroup2()
+{
+ {
+ QSharedPointer<CaEntry> itemEntry (new CaEntry());
+ itemEntry->setText("item");
+ itemEntry->setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry3 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry4 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList< QSharedPointer<CaEntry> > entries1;
+ entries1.append(entry1);
+ entries1.append(entry2);
+ QList< QSharedPointer<CaEntry> > entries2;
+ entries2.append(entry3);
+ entries2.append(entry4);
+ QList<QSharedPointer<CaEntry> > wrongEntries1;
+ wrongEntries1.append(entry1);
+ wrongEntries1.append(itemEntry); //this item has unspecified id
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->appendEntriesToGroup(groupEntry, entries1));
+ QVERIFY(!service->appendEntriesToGroup(*group, wrongEntries1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+ QVERIFY(service->appendEntriesToGroup(*group, entries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QVERIFY(service->appendEntriesToGroup(*group, entries2));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),4);
+
+ QCOMPARE(entries.at(0),entry1->id());
+ QCOMPARE(entries.at(1),entry2->id());
+ QCOMPARE(entries.at(2),entry3->id());
+ QCOMPARE(entries.at(3),entry4->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*entry3);
+ service->removeEntry(*entry4);
+ service->removeEntry(*group);
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntryIntoGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->prependEntryToGroup(9999, entry1->id()));
+ QVERIFY(service->lastError() != NoErrorCode);
+ QVERIFY(!service->prependEntryToGroup(group->id(), 9999));
+ QVERIFY(service->lastError() != NoErrorCode);
+ QVERIFY(service->prependEntryToGroup(group->id(), entry1->id()));
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),1);
+ QVERIFY(service->prependEntryToGroup(group->id(), entry2->id()));
+ entries = service->getEntryIds(query);
+
+ QCOMPARE(entries.count(),2);
+ QCOMPARE(entries.at(0),entry2->id());
+ QCOMPARE(entries.at(1),entry1->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntryIntoGroup2()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->prependEntryToGroup(groupEntry, *entry1));
+ QVERIFY(!service->prependEntryToGroup(*group , itemEntry));
+ QVERIFY(service->prependEntryToGroup(*group , *entry1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),1);
+ QVERIFY(service->prependEntryToGroup(*group, *entry2));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QCOMPARE(entries.at(0),entry2->id());
+ QCOMPARE(entries.at(1),entry1->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntriesIntoGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry3 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry4 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList<int> entries1;
+ entries1.append(entry1->id());
+ entries1.append(entry2->id());
+ QList<int> entries2;
+ entries2.append(entry3->id());
+ entries2.append(entry4->id());
+ QList<int> wrongEntries1;
+ wrongEntries1.append(entry1->id());
+ wrongEntries1.append(9999);
+
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->prependEntriesToGroup(9999, entries1));
+ QVERIFY(!service->prependEntriesToGroup(group->id(), wrongEntries1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+
+ QVERIFY(service->prependEntriesToGroup(group->id(), entries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QVERIFY(service->prependEntriesToGroup(group->id(), entries2));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),4);
+
+ QCOMPARE(entries.at(0),entry3->id());
+ QCOMPARE(entries.at(1),entry4->id());
+ QCOMPARE(entries.at(2),entry1->id());
+ QCOMPARE(entries.at(3),entry2->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*entry3);
+ service->removeEntry(*entry4);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestPrependEntriesIntoGroup2()
+{
+ {
+ QSharedPointer<CaEntry> itemEntry (new CaEntry());
+ itemEntry->setText("item");
+ itemEntry->setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry3 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry4 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList< QSharedPointer<CaEntry> > entries1;
+ entries1.append(entry1);
+ entries1.append(entry2);
+ QList< QSharedPointer<CaEntry> > entries2;
+ entries2.append(entry3);
+ entries2.append(entry4);
+ QList< QSharedPointer<CaEntry> > wrongEntries1;
+ wrongEntries1.append(entry1);
+ wrongEntries1.append(itemEntry); //this item has unspecified id
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->prependEntriesToGroup(groupEntry, entries1));
+ QVERIFY(!service->prependEntriesToGroup(*group, wrongEntries1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+ QVERIFY(service->prependEntriesToGroup(*group, entries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QVERIFY(service->prependEntriesToGroup(*group, entries2));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),4);
+
+ QCOMPARE(entries.at(0),entry3->id());
+ QCOMPARE(entries.at(1),entry4->id());
+ QCOMPARE(entries.at(2),entry1->id());
+ QCOMPARE(entries.at(3),entry2->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*entry3);
+ service->removeEntry(*entry4);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntryIntoGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(service->prependEntryToGroup(group->id(), entry1->id()));
+
+ QVERIFY(!service->insertEntryIntoGroup(9999, entry2->id(), entry1->id()));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(!service->insertEntryIntoGroup(group->id(), 9999, entry1->id()));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(!service->insertEntryIntoGroup(group->id(), entry2->id(), 9999));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(service->insertEntryIntoGroup(group->id(), entry2->id(), entry1->id()));
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QCOMPARE(entries.at(0),entry2->id());
+ QCOMPARE(entries.at(1),entry1->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntryIntoGroup2()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(service->prependEntryToGroup(*group, *entry1));
+
+ QVERIFY(!service->insertEntryIntoGroup(groupEntry, *entry2, entry1->id()));
+ QVERIFY(!service->insertEntryIntoGroup(*group, itemEntry, entry1->id()));
+ QVERIFY(!service->insertEntryIntoGroup(*group, *entry2, 9999));
+
+ QVERIFY(service->insertEntryIntoGroup(*group, *entry2, entry1->id()));
+
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QCOMPARE(entries.at(0),entry2->id());
+ QCOMPARE(entries.at(1),entry1->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntriesIntoGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry3 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry4 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList<int> entries2;
+ entries2.append(entry3->id());
+ entries2.append(entry4->id());
+ QList<int> wrongEntries1;
+ wrongEntries1.append(entry1->id());
+ wrongEntries1.append(9999);
+
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(service->prependEntryToGroup(group->id(), entry1->id()));
+
+ QVERIFY(!service->insertEntriesIntoGroup(9999, entries2, entry1->id()));
+ QVERIFY(!service->insertEntriesIntoGroup(group->id(), wrongEntries1, entry1->id()));
+ QVERIFY(!service->insertEntriesIntoGroup(group->id(), entries2, 9999));
+
+ QVERIFY(service->insertEntriesIntoGroup(group->id(), entries2, entry1->id()));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),3);
+
+ QCOMPARE(entries.at(0),entry3->id());
+ QCOMPARE(entries.at(1),entry4->id());
+ QCOMPARE(entries.at(2),entry1->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry3);
+ service->removeEntry(*entry4);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestInsertEntriesIntoGroup2()
+{
+ {
+ QSharedPointer<CaEntry> itemEntry (new CaEntry());
+ itemEntry->setText("item");
+ itemEntry->setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry3 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry4 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList< QSharedPointer<CaEntry> > entries2;
+ entries2.append(entry3);
+ entries2.append(entry4);
+ QList< QSharedPointer<CaEntry> > wrongEntries1;
+ wrongEntries1.append(entry1);
+ wrongEntries1.append(itemEntry); //this item has unspecified id
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(service->prependEntryToGroup(group->id(), entry1->id()));
+
+ QVERIFY(!service->insertEntriesIntoGroup(groupEntry, entries2, entry1->id()));
+ QVERIFY(!service->insertEntriesIntoGroup(*group, wrongEntries1, entry1->id()));
+ QVERIFY(!service->insertEntriesIntoGroup(*group, entries2, 9999));
+
+ QVERIFY(service->insertEntriesIntoGroup(*group, entries2, entry1->id()));
+
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),3);
+
+ QCOMPARE(entries.at(0),entry3->id());
+ QCOMPARE(entries.at(1),entry4->id());
+ QCOMPARE(entries.at(2),entry1->id());
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry3);
+ service->removeEntry(*entry4);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryFromGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->removeEntryFromGroup(9999, entry1->id()));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(!service->removeEntryFromGroup(group->id(), 9999));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QVERIFY(service->prependEntryToGroup(group->id(), entry1->id()));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),1);
+ QVERIFY(service->removeEntryFromGroup(group->id(), entry1->id()));
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntryFromGroup2()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(!service->removeEntryFromGroup(groupEntry, *entry1));
+ QVERIFY(!service->removeEntryFromGroup(*group, itemEntry));
+
+ QVERIFY(service->prependEntryToGroup(group->id(), entry1->id()));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),1);
+ QVERIFY(service->removeEntryFromGroup(*group, *entry1));
+
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesFromGroup1()
+{
+ {
+ CaEntry itemEntry;
+ itemEntry.setText("item");
+ itemEntry.setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList<int> entries1;
+ entries1.append(entry1->id());
+ entries1.append(entry2->id());
+ QList<int> wrongEntries1;
+ wrongEntries1.append(entry1->id());
+ wrongEntries1.append(9999);
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(service->prependEntriesToGroup(group->id(), entries1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+ QVERIFY(!service->removeEntriesFromGroup(9999, entries1));
+ QVERIFY(!service->removeEntriesFromGroup(group->id(), wrongEntries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+
+ QVERIFY(service->removeEntriesFromGroup(group->id(), entries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveEntriesFromGroup2()
+{
+ {
+ QSharedPointer<CaEntry> itemEntry (new CaEntry);
+ itemEntry->setText("item");
+ itemEntry->setEntryTypeName("typeok");
+ CaEntry groupEntry(GroupEntryRole);
+ groupEntry.setText("group");
+ groupEntry.setEntryTypeName("typeok");
+ QSharedPointer<CaService> service = CaService::instance();
+
+ QSharedPointer<CaEntry> entry1 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> entry2 = service->createEntry(*itemEntry);
+ QSharedPointer<CaEntry> group = service->createEntry(groupEntry);
+
+ QList<QSharedPointer<CaEntry> > entries1;
+ entries1.append(entry1);
+ entries1.append(entry2);
+ QList<QSharedPointer<CaEntry> > wrongEntries1;
+ wrongEntries1.append(entry1);
+ wrongEntries1.append(itemEntry); //this item has unspecified id
+
+ CaQuery query;
+ query.setParentId(group->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QVERIFY(service->prependEntriesToGroup(*group, entries1));
+ QList<int> entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+
+ QVERIFY(!service->removeEntriesFromGroup(groupEntry, entries1));
+ QVERIFY(!service->removeEntriesFromGroup(*group, wrongEntries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),2);
+
+ QVERIFY(service->removeEntriesFromGroup(*group, entries1));
+ entries = service->getEntryIds(query);
+ QCOMPARE(entries.count(),0);
+
+ //Cleanup
+ service->removeEntry(*entry1);
+ service->removeEntry(*entry2);
+ service->removeEntry(*group);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCustomSortArrange()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ CaEntry itemEntry_1;
+ itemEntry_1.setText("item_1");
+ itemEntry_1.setEntryTypeName("collection");
+ CaEntry groupEntry_1(GroupEntryRole);
+ groupEntry_1.setText("group_1");
+ groupEntry_1.setEntryTypeName("collection");
+
+ QSharedPointer<CaEntry> entry_1 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_2 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_3 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_4 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> group_1 = service->createEntry(groupEntry_1);
+
+ QList<int> entriesIds;
+ entriesIds << entry_1->id() << entry_2->id()
+ << entry_3->id() << entry_4->id();
+ service->appendEntriesToGroup(group_1->id(), entriesIds);
+
+ CaQuery query;
+ query.setParentId(group_1->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesIdsBefore = service->getEntryIds(query);
+ QVERIFY(entriesIds == entriesIdsBefore);
+
+ entriesIds.clear();
+ for (int i(entriesIdsBefore.count()-1); i >= 0; i--) {
+ entriesIds.append(entriesIdsBefore.at(i));
+ }
+
+ QVERIFY(service->customSort(group_1->id(), entriesIds));
+ QTest::qWait(500);
+ QList<int> entriesIdsAfter = service->getEntryIds(query);
+
+ QVERIFY(entriesIds != entriesIdsBefore);
+ QVERIFY(entriesIds == entriesIdsAfter);
+
+ // cleanup
+ service->removeEntries(entriesIdsAfter << group_1->id());
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCustomSortGroups()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ CaEntry itemEntry_1;
+ itemEntry_1.setText("item_1");
+ itemEntry_1.setEntryTypeName("collection");
+ CaEntry groupEntry_1(GroupEntryRole);
+ groupEntry_1.setText("group_1");
+ groupEntry_1.setEntryTypeName("collection");
+
+ QSharedPointer<CaEntry> entry_1 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_2 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_3 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_4 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> group_1 = service->createEntry(groupEntry_1);
+
+ CaEntry itemEntry_2;
+ itemEntry_2.setText("item_2");
+ itemEntry_2.setEntryTypeName("collection");
+ CaEntry groupEntry_2(GroupEntryRole);
+ groupEntry_2.setText("group_2");
+ groupEntry_2.setEntryTypeName("collection");
+
+ QSharedPointer<CaEntry> entry_5 = service->createEntry(itemEntry_2);
+ QSharedPointer<CaEntry> entry_6 = service->createEntry(itemEntry_2);
+ QSharedPointer<CaEntry> entry_7 = service->createEntry(itemEntry_2);
+ QSharedPointer<CaEntry> entry_8 = service->createEntry(itemEntry_2);
+ QSharedPointer<CaEntry> group_2 = service->createEntry(groupEntry_2);
+
+ QList<int> entriesIds;
+ entriesIds << entry_1->id() << entry_2->id()
+ << entry_3->id() << entry_4->id();
+ service->appendEntriesToGroup(group_1->id(), entriesIds);
+
+ entriesIds.clear();
+ entriesIds << entry_5->id() << entry_6->id()
+ << entry_7->id() << entry_8->id();
+ service->appendEntriesToGroup(group_2->id(), entriesIds);
+
+ CaQuery query;
+ query.setParentId(group_1->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesIdsBefore_1 = service->getEntryIds(query);
+
+ query.setParentId(group_2->id());
+ QList<int> entriesIdsBefore_2 = service->getEntryIds(query);
+ QVERIFY(entriesIdsBefore_1 != entriesIdsBefore_2);
+
+ entriesIds.clear();
+ for (int i(entriesIdsBefore_1.count()-1); i >= 0; i--) {
+ entriesIds.append(entriesIdsBefore_1.at(i));
+ }
+
+ QVERIFY(service->customSort(group_1->id(), entriesIds));
+ QTest::qWait(500);
+ query.setParentId(group_1->id());
+ QList<int> entriesIdsAfter_1 = service->getEntryIds(query);
+ query.setParentId(group_2->id());
+ QList<int> entriesIdsAfter_2 = service->getEntryIds(query);
+
+ QVERIFY(entriesIds != entriesIdsBefore_1);
+ QVERIFY(entriesIds == entriesIdsAfter_1);
+ QVERIFY(entriesIds != entriesIdsBefore_2);
+ QVERIFY(entriesIdsBefore_2 == entriesIdsAfter_2);
+
+ entriesIds.clear();
+ for (int i(entriesIdsBefore_2.count()-1); i >= 0; i--) {
+ entriesIds.append(entriesIdsBefore_2.at(i));
+ }
+
+ QVERIFY(service->customSort(group_2->id(), entriesIds));
+ QTest::qWait(500);
+ query.setParentId(group_1->id());
+ entriesIdsBefore_1 = service->getEntryIds(query);
+ query.setParentId(group_2->id());
+ entriesIdsAfter_2 = service->getEntryIds(query);
+
+ QVERIFY(entriesIds != entriesIdsBefore_2);
+ QVERIFY(entriesIds == entriesIdsAfter_2);
+ QVERIFY(entriesIds != entriesIdsBefore_1);
+ QVERIFY(entriesIdsBefore_1 == entriesIdsAfter_1);
+ QVERIFY(entriesIdsBefore_2 != entriesIdsAfter_2);
+
+ // cleanup
+ service->removeEntries(entriesIdsAfter_1 << group_1->id());
+ service->removeEntries(entriesIdsAfter_2 << group_2->id());
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCustomSortFake()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ CaEntry itemEntry_1;
+ itemEntry_1.setText("item_1");
+ itemEntry_1.setEntryTypeName("collection");
+ CaEntry groupEntry_1(GroupEntryRole);
+ groupEntry_1.setText("group_1");
+ groupEntry_1.setEntryTypeName("collection");
+
+ QSharedPointer<CaEntry> entry_1 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_2 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_3 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> entry_4 = service->createEntry(itemEntry_1);
+ QSharedPointer<CaEntry> group_1 = service->createEntry(groupEntry_1);
+
+ QList<int> entriesIds;
+ entriesIds << entry_1->id() << entry_2->id()
+ << entry_3->id() << entry_4->id();
+ service->appendEntriesToGroup(group_1->id(), entriesIds);
+
+ CaQuery query;
+ query.setParentId(group_1->id());
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QList<int> entriesIdsBefore = service->getEntryIds(query);
+ QVERIFY(entriesIds == entriesIdsBefore);
+
+ entriesIds.clear();
+ // fake list, not fulfilled correctly
+ for (int i(entriesIdsBefore.count()-1); i >= 0; i--) {
+ if (i%2) {
+ entriesIds.append(entriesIdsBefore.at(i));
+ }
+ }
+
+ QVERIFY(service->customSort(group_1->id(), entriesIds));
+ QTest::qWait(500);
+ QList<int> entriesIdsAfter = service->getEntryIds(query);
+
+ QVERIFY(entriesIdsBefore != entriesIdsAfter);
+ QVERIFY(entriesIds != entriesIdsAfter);
+
+ // cleanup
+ service->removeEntries(entriesIdsAfter << group_1->id());
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCustomSort()
+{
+ CaQuery collectionQuery;
+ collectionQuery.addEntryTypeName("collection");
+ QSharedPointer<CaService> service = CaService::instance();
+ QList<int> collectionIds = service->getEntryIds(collectionQuery);
+ QVERIFY(collectionIds.count());
+
+ const int groupId = collectionIds.at(0);
+
+ CaQuery query;
+ query.setParentId(groupId);
+ query.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+
+ QList<int> idsBefore = service->getEntryIds(query);
+ QVERIFY(idsBefore.count());
+
+ int first = idsBefore.takeFirst();
+ idsBefore.append(first);
+
+ // sort entries is group in custom order
+ QVERIFY(service->customSort(groupId, idsBefore));
+
+ // check results
+ QList<int> idsAfter = service->getEntryIds(query);
+ QVERIFY(idsAfter.count());
+
+ QCOMPARE(idsAfter.count(),idsBefore.count());
+ QCOMPARE(idsAfter, idsBefore);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclient_remove.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,275 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveItem()
+{
+ {
+ CaEntry item;
+ item.setText("testName");
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item);
+ QVERIFY(!resultItem1.isNull());
+ QVERIFY(!service->removeEntry(9999));
+ QVERIFY(service->removeEntry(resultItem1->id()));
+ QCOMPARE(service->lastError() , NoErrorCode);
+
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem1->id());
+ QVERIFY(storageItem1.isNull()); // entry not present in the storage
+ QVERIFY(!service->removeEntry(resultItem1->id()));
+ QVERIFY(service->lastError() != NoErrorCode);
+
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item);
+ QVERIFY(!resultItem2.isNull());
+
+ QVERIFY(service->removeEntry(*resultItem2));
+ QSharedPointer<CaEntry> storageItem2 = service->getEntry(resultItem2->id());
+ QVERIFY(storageItem2.isNull()); // entry not present in the storage
+ QVERIFY(!service->removeEntry(*resultItem2));
+
+ //cleanup
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveGroup()
+{
+ {
+ CaEntry group(GroupEntryRole);
+ group.setText("testName");
+ group.setAttribute("attrName1", "attrVal1");
+ group.setEntryTypeName("test");
+ group.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultgroup1 = service->createEntry(group);
+ QVERIFY(!resultgroup1.isNull());
+
+ QVERIFY(service->removeEntry(resultgroup1->id()));
+ QSharedPointer<CaEntry> storagegroup1 = service->getEntry(resultgroup1->id());
+ QVERIFY(!storagegroup1); // entry not present in the storage
+ QVERIFY(!service->removeEntry(resultgroup1->id()));
+
+ QSharedPointer<CaEntry> resultgroup2 = service->createEntry(group);
+ QVERIFY(!resultgroup2.isNull());
+
+ QVERIFY(service->removeEntry(*resultgroup2));
+ QSharedPointer<CaEntry> storagegroup2 = service->getEntry(resultgroup2->id());
+ QVERIFY(!storagegroup2); // entry not present in the storage
+ QVERIFY(!service->removeEntry(*resultgroup2));
+
+ //cleanup
+ service->removeEntry(*resultgroup1);
+ service->removeEntry(*resultgroup2);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveItems()
+{
+ {
+ CaEntry item;
+ item.setText("testName");
+ item.setAttribute("attrName1", "attrVal1");
+ item.setEntryTypeName("test");
+ item.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(item);
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(item);
+ QVERIFY(!resultItem1.isNull());
+ QVERIFY(!resultItem2.isNull());
+
+ QList<int> ids;
+ ids.append(resultItem1->id());
+ ids.append(resultItem2->id());
+ QVERIFY(service->removeEntries(ids));
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem1->id());
+ QSharedPointer<CaEntry> storageItem2 = service->getEntry(resultItem2->id());
+ QVERIFY(storageItem1.isNull()); // entry not present in the storage
+ QVERIFY(storageItem2.isNull()); // entry not present in the storage
+
+ QSharedPointer<CaEntry> resultItem3 = service->createEntry(item);
+ QSharedPointer<CaEntry> resultItem4 = service->createEntry(item);
+ QVERIFY(!resultItem3.isNull());
+ QVERIFY(!resultItem4.isNull());
+
+ QList<QSharedPointer<CaEntry> > entries;
+ entries.append(resultItem3);
+ entries.append(resultItem4);
+
+ QVERIFY(service->removeEntries(entries));
+ QSharedPointer<CaEntry> storageItem3 = service->getEntry(resultItem3->id());
+ QSharedPointer<CaEntry> storageItem4 = service->getEntry(resultItem4->id());
+ QVERIFY(storageItem3.isNull()); // entry not present in the storage
+ QVERIFY(storageItem4.isNull()); // entry not present in the storage
+
+ //cleanup
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+ service->removeEntry(*resultItem3);
+ service->removeEntry(*resultItem4);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveItemsFail()
+{
+ {
+ QSharedPointer<CaEntry> item (new CaEntry());
+ item->setText("testName");
+ item->setAttribute("attrName1", "attrVal1");
+ item->setEntryTypeName("test");
+ item->setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultItem1 = service->createEntry(*item);
+ QVERIFY(!resultItem1.isNull());
+
+ QList<int> ids;
+ ids.append(resultItem1->id());
+ ids.append(9999);// not present in the storage
+ QVERIFY(!service->removeEntries(ids));
+ QSharedPointer<CaEntry> storageItem1 = service->getEntry(resultItem1->id());
+ QVERIFY(!storageItem1.isNull()); // entry present in the storage
+
+ QSharedPointer<CaEntry> resultItem2 = service->createEntry(*item);
+ QVERIFY(!resultItem2.isNull());
+
+ QList<QSharedPointer<CaEntry> > entries;
+ entries.append(resultItem2);
+ entries.append(item);//id not specified
+
+ QVERIFY(!service->removeEntries(entries));
+ QSharedPointer<CaEntry> storageItem2 = service->getEntry(resultItem2->id());
+ QVERIFY(storageItem2); // entry present in the storage
+
+ //cleanup
+ service->removeEntry(*resultItem1);
+ service->removeEntry(*resultItem2);
+
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveGroups()
+{
+ {
+ CaEntry group(GroupEntryRole);
+ group.setText("testName");
+ group.setAttribute("attrName1", "attrVal1");
+ group.setEntryTypeName("test");
+ group.setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(group);
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(group);
+ QVERIFY(!resultGroup1.isNull());
+ QVERIFY(!resultGroup2.isNull());
+
+ QList<int> ids;
+ ids.append(resultGroup1->id());
+ ids.append(resultGroup2->id());
+ QVERIFY(service->removeEntries(ids));
+ QSharedPointer<CaEntry> storageGroup1 = service->getEntry(resultGroup1->id());
+ QSharedPointer<CaEntry> storageGroup2 = service->getEntry(resultGroup2->id());
+ QVERIFY(storageGroup1.isNull()); // entry not present in the storage
+ QVERIFY(storageGroup2.isNull()); // entry not present in the storage
+
+ QSharedPointer<CaEntry> resultGroup3 = service->createEntry(group);
+ QSharedPointer<CaEntry> resultGroup4 = service->createEntry(group);
+ QVERIFY(!resultGroup3.isNull());
+ QVERIFY(!resultGroup4.isNull());
+
+ QList<QSharedPointer<CaEntry> > entries;
+ entries.append(resultGroup3);
+ entries.append(resultGroup4);
+
+ QVERIFY(service->removeEntries(entries));
+ QSharedPointer<CaEntry> storageGroup3 = service->getEntry(resultGroup3->id());
+ QSharedPointer<CaEntry> storageGroup4 = service->getEntry(resultGroup4->id());
+ QVERIFY(storageGroup3.isNull()); // entry not present in the storage
+ QVERIFY(storageGroup4.isNull()); // entry not present in the storage
+
+ //cleanup
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*resultGroup2);
+ service->removeEntry(*resultGroup3);
+ service->removeEntry(*resultGroup4);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestRemoveGroupsFail()
+{
+ {
+ QSharedPointer<CaEntry> group(new CaEntry(GroupEntryRole));
+ group->setText("testName");
+ group->setAttribute("attrName1", "attrVal1");
+ group->setEntryTypeName("test");
+ group->setFlags(RemovableEntryFlag);
+
+ QSharedPointer<CaService> service = CaService::instance();
+ QSharedPointer<CaEntry> resultGroup1 = service->createEntry(*group);
+ QVERIFY(!resultGroup1.isNull());
+
+ QList<int> ids;
+ ids.append(resultGroup1->id());
+ ids.append(9999);// not present in the storage
+ QVERIFY(!service->removeEntries(ids));
+ QSharedPointer<CaEntry> storageGroup1 = service->getEntry(resultGroup1->id());
+ QVERIFY(!storageGroup1.isNull()); // entry present in the storage
+
+ QSharedPointer<CaEntry> resultGroup2 = service->createEntry(*group);
+ QVERIFY(!resultGroup2.isNull());
+
+ QList< QSharedPointer<CaEntry> > entries;
+ entries.append(resultGroup2);
+ entries.append(group);//id not specified
+
+ QVERIFY(!service->removeEntries(entries));
+ QSharedPointer<CaEntry> storageGroup2 = service->getEntry(resultGroup2->id());
+ QVERIFY(!storageGroup2.isNull()); // entry present in the storage
+
+ //cleanup
+ service->removeEntry(*resultGroup1);
+ service->removeEntry(*resultGroup2);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caclientnotifier.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "t_caclientnotifier.h"
+#include "caentry.h"
+#include "canotifier.h"
+#include "canotifierfilter.h"
+#include "caservice.h"
+
+// ============================================================================
+TestCaClientNotifier::TestCaClientNotifier():
+ mEntryId(0),
+ mGroupId(0),
+ mChangeType(AddChangeType),
+ mEntry(NULL),
+ mCount(0),
+ mEntryIds(new QList<int>()),
+ mGroupIds(new QList<int>()),
+ mChangeTypes(new QList<ChangeType>()),
+ mEntries(new QList<const CaEntry *>()),
+ mFilter(NULL),
+ mNotifier(NULL)
+{
+
+}
+// ============================================================================
+TestCaClientNotifier::TestCaClientNotifier(const CaService &service, CaNotifierFilter *filter):
+ mEntryId(0),
+ mGroupId(0),
+ mChangeType(AddChangeType),
+ mEntry(NULL),
+ mCount(0),
+ mEntryIds(new QList<int>()),
+ mGroupIds(new QList<int>()),
+ mChangeTypes(new QList<ChangeType>()),
+ mEntries(new QList<const CaEntry *>())
+{
+ if (!filter) {
+ mFilter = new CaNotifierFilter();
+ mNotifier = service.createNotifier(*mFilter);
+ } else {
+ mFilter = NULL;
+ mNotifier = service.createNotifier(*filter);
+ }
+}
+
+// ============================================================================
+void TestCaClientNotifier::clean()
+{
+ mEntryId = 0;
+ mGroupId = 0;
+ mChangeType = AddChangeType;
+ mCount = 0;
+ delete mEntryIds;
+ mEntryIds = new QList<int>();
+ delete mGroupIds;
+ mGroupIds = new QList<int>();
+ delete mChangeTypes;
+ mChangeTypes = new QList<ChangeType>();
+ delete mEntries;
+ mEntries = new QList<const CaEntry *>();
+ delete mEntry;
+ mEntry = NULL;
+}
+// ============================================================================
+TestCaClientNotifier::~TestCaClientNotifier()
+{
+ delete mEntry;
+ delete mFilter;
+ delete mNotifier;
+ delete mEntryIds;
+ delete mGroupIds;
+ delete mChangeTypes;
+ delete mEntries;
+
+}
+// ============================================================================
+CaNotifier *TestCaClientNotifier::getNotifier() const
+{
+ return mNotifier;
+}
+// ============================================================================
+CaNotifierFilter *TestCaClientNotifier::getFilter() const
+{
+ return mFilter;
+}
+// ============================================================================
+void TestCaClientNotifier::entryChanged(int entryId, ChangeType changeType)
+{
+ mEntryId = entryId;
+ mChangeType = changeType;
+ mEntryIds->append(entryId);
+ mChangeTypes->append(changeType);
+ mEntries->append(NULL);
+ mGroupIds->append(0);
+ mCount++;
+}
+// ============================================================================
+void TestCaClientNotifier::entryChanged(const CaEntry &entry, ChangeType changeType)
+{
+ delete mEntry;
+ mEntry = new CaEntry(entry);
+ mEntryId = entry.id();
+ mChangeType = changeType;
+ mEntryIds->append(entry.id());
+ mChangeTypes->append(changeType);
+ mEntries->append(&entry);
+ mGroupIds->append(0);
+ mCount++;
+}
+// ============================================================================
+void TestCaClientNotifier::entryTouched(int id)
+{
+ mEntryId = id;
+ mEntryIds->append(id);
+ mChangeTypes->append(AddChangeType);
+ mEntries->append(NULL);
+ mGroupIds->append(0);
+ mCount++;
+}
+// ============================================================================
+void TestCaClientNotifier::groupContentChanged(int groupId)
+{
+ mGroupId = groupId;
+ mEntryIds->append(0);
+ mChangeTypes->append(AddChangeType);
+ mEntries->append(NULL);
+ mGroupIds->append(groupId);
+ mCount++;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/src/t_caitemmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,627 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+#include <QSignalSpy>
+
+#include "caclient_defines.h"
+#include "t_caclient.h"
+#include "caservice.h"
+#include "caquery.h"
+#include "caitemmodel.h"
+#include "caitemmodel_p.h"
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelConstruct()
+{
+ {
+ CaQuery query;
+ query.setEntryRoles(ItemEntryRole);
+ CaItemModel model(query,NULL);
+ QVERIFY(model.rowCount() > 0);
+ QCOMPARE(model.columnCount(),1);
+ QCOMPARE(model.isAutoUpdate(), true);
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelAutoUpdate()
+{
+ {
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup");
+ removeEntry("TestItem1");
+ removeEntry("TestItem2");
+ //test
+ QSharedPointer<CaEntry> group = createGroup("TestGroup","testfolder");
+ QSharedPointer<CaEntry> item1 = createItem("TestItem1","testitem");
+ QSharedPointer<CaEntry> item2 = createItem("TestItem2","testitem");
+ addItemToGroup(group->id(), item1->id());
+ CaQuery query;
+ query.setParentId(group->id());
+ CaItemModel model(query,NULL);
+ model.setAutoUpdate(true);
+ QCOMPARE(model.isAutoUpdate(), true);
+ QCOMPARE(model.rowCount() , 1);
+ addItemToGroup(group->id(), item2->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount() , 2);
+ removeItemFromGroup(group->id(), item2->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount() , 1);
+ model.setAutoUpdate(false);
+ addItemToGroup(group->id(), item2->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount() , 1);
+ QCOMPARE(model.isAutoUpdate(), false);
+ model.updateModel();
+ QCOMPARE(model.rowCount() , 2);
+ QCOMPARE(model.isAutoUpdate(), false);
+ model.setAutoUpdate(true);
+ removeEntry(item1->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount() , 1);
+ //cleanup
+ removeEntry("TestItem2");
+ removeEntry("TestItem1");
+ removeEntry("TestGroup");
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelIndex()
+{
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup");
+ removeEntry("TestItem1");
+ removeEntry("TestItem2");
+ //test
+ QSharedPointer<CaEntry> group = createGroup("TestGroup","testfolder");
+ QSharedPointer<CaEntry> item1 = createItem("TestItem1","testitem");
+ QSharedPointer<CaEntry> item2 = createItem("TestItem2","testitem");
+ addItemToGroup(group->id(), item1->id());
+ addItemToGroup(group->id(), item2->id());
+ CaQuery query;
+ query.setParentId(group->id());
+ CaItemModel model(query,NULL);
+ QCOMPARE(model.index(-1), QModelIndex());
+ QCOMPARE(model.index(0).row(), 0);
+ QCOMPARE(model.index(1).row(), 1);
+ QCOMPARE(model.index(2), QModelIndex());
+ QCOMPARE(model.parent(model.index(1)), QModelIndex());
+ QCOMPARE(model.root().row(),0);
+ QCOMPARE(model.root().column(),1);
+
+ CaQuery query2;
+ CaItemModel modelWithoutParent(query2,NULL);
+ QCOMPARE(modelWithoutParent.root().isValid(),false);
+
+ //cleanup
+ removeEntry("TestItem2");
+ removeEntry("TestItem1");
+ removeEntry("TestGroup");
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelData()
+{
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup");
+ removeEntry("TestItem1");
+ //test
+ QSharedPointer<CaEntry> group = createGroup("TestGroup","testfolder");
+ QSharedPointer<CaEntry> item1 = createItem("TestItem1","TestDescription","testitem", UsedEntryFlag);
+ QString progressString = "100";
+ item1->setAttribute(UNINSTALL_PROGRESS_APPLICATION_ATTRIBUTE_NAME, progressString);
+ QSharedPointer<CaService> service = CaService::instance();
+ service->updateEntry(*item1.data());
+ QCOMPARE(item1->attribute(UNINSTALL_PROGRESS_APPLICATION_ATTRIBUTE_NAME), progressString);
+
+ addItemToGroup(group->id(), item1->id());
+ CaQuery query;
+ query.setParentId(group->id());
+ CaItemModel model(query,NULL);
+
+ QCOMPARE(model.data(QModelIndex()),QVariant());
+
+ QModelIndex index = model.index(0);
+
+ model.setSecondLineVisibility(false);
+ QCOMPARE(model.secondLineVisibility(),false);
+ QCOMPARE(model.data(index, Qt::DisplayRole).toString(), QString("TestItem1"));
+ model.setSecondLineVisibility(true);
+ QCOMPARE(model.secondLineVisibility(),true);
+ QList<QVariant> displayRoleList = model.data(index, Qt::DisplayRole).toList();
+ QString text = displayRoleList.at(0).toString();
+ QString description = displayRoleList.at(1).toString();
+ QCOMPARE(text,QString("TestItem1"));
+ QCOMPARE(description,QString("TestDescription"));
+ QCOMPARE(model.data(index, CaItemModel::IdRole).toInt(), item1->id());
+ QCOMPARE(model.data(index, CaItemModel::TypeRole).toString(),QString("testitem"));
+ QVERIFY(model.data(index, CaItemModel::FlagsRole).value<EntryFlags>()== UsedEntryFlag);
+ QCOMPARE(model.data(index, CaItemModel::TextRole).toString(),QString("TestItem1"));
+ QCOMPARE(model.entry(index)->text(),QString("TestItem1"));
+ QCOMPARE(model.data(index, 777), QVariant(QVariant::Invalid));
+ QCOMPARE(model.data(index, CaItemModel::UninstalRole).value<int>(), progressString.toInt());
+
+ //cleanup
+ removeEntry("TestItem1");
+ removeEntry("TestGroup");
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelIconSize()
+{
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup");
+ removeEntry("TestItem1");
+ //test
+ QSharedPointer<CaEntry> group = createGroup("TestGroup","testfolder");
+ QSharedPointer<CaEntry> item1 = createItem("TestItem1","testitem");
+ addItemToGroup(group->id(), item1->id());
+ CaQuery query;
+ query.setParentId(group->id());
+ CaItemModel model(query,NULL);
+ QSizeF size1(30,30);
+ QSizeF size2(130,130);
+ model.setIconSize(size1);
+ QVERIFY(model.getIconSize() == size1);
+ model.setIconSize(size2);
+ QVERIFY(model.getIconSize() == size2);
+ //cleanup
+ removeEntry("TestItem1");
+ removeEntry("TestGroup");
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelChangeParent()
+{
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup1");
+ removeEntry("TestGroup2");
+ removeEntry("TestItem1");
+ removeEntry("TestItem2");
+ removeEntry("TestItem3");
+//test
+ QSharedPointer<CaEntry> group1 = createGroup("TestGroup1","testfolder");
+ QSharedPointer<CaEntry> group2 = createGroup("TestGroup2","testfolder");
+ QSharedPointer<CaEntry> item1 = createItem("TestItem1","testitem");
+ QSharedPointer<CaEntry> item2 = createItem("TestItem2","testitem");
+ QSharedPointer<CaEntry> item3 = createItem("TestItem3","testitem");
+ addItemToGroup(group1->id(), item1->id());
+ addItemToGroup(group2->id(), item2->id());
+ addItemToGroup(group2->id(), item3->id());
+ CaQuery query;
+ query.setParentId(group1->id());
+ CaItemModel model(query,NULL);
+ model.setAutoUpdate(true);
+ QCOMPARE(model.isAutoUpdate(), true);
+ QCOMPARE(model.rowCount() , 1);
+ QCOMPARE(itemName(model,0),QString("TestItem1"));
+ model.setFlagsOn(VisibleEntryFlag);
+ model.setFlagsOff(MissingEntryFlag);
+ model.setParentId(group2->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount() , 2);
+ QCOMPARE(itemName(model,0),QString("TestItem2"));
+ QCOMPARE(itemName(model,1),QString("TestItem3"));
+ model.setParentId(group1->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount() , 1);
+ QCOMPARE(itemName(model,0),QString("TestItem1"));
+ model.setAutoUpdate(false);
+ model.setFlagsOn(VisibleEntryFlag);
+ model.setFlagsOff(MissingEntryFlag);
+ model.setParentId(group2->id());
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount(), 2);
+ QCOMPARE(itemName(model,0),QString("TestItem2"));
+ QCOMPARE(itemName(model,1),QString("TestItem3"));
+
+ //cleanup
+ removeEntry("TestItem3");
+ removeEntry("TestItem2");
+ removeEntry("TestItem1");
+ removeEntry("TestGroup2");
+ removeEntry("TestGroup1");
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelSortOrder()
+{
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup");
+ removeEntry("ATestItem");
+ removeEntry("BTestItem");
+ //test
+ QSharedPointer<CaEntry> group = createGroup("TestGroup","testfolder");
+ QSharedPointer<CaEntry> item1 = createItem("ATestItem","testitem");
+ QSharedPointer<CaEntry> item2 = createItem("BTestItem","testitem");
+ addItemToGroup(group->id(), item2->id());
+ addItemToGroup(group->id(), item1->id());
+ CaQuery query;
+ query.setParentId(group->id());
+ CaItemModel model(query,NULL);
+ model.setAutoUpdate(false); //should work even without autoupdate
+ model.setSort(NameSortAttribute, Qt::DescendingOrder);
+ QCOMPARE(itemName(model,0),QString("BTestItem"));
+ QCOMPARE(itemName(model,1),QString("ATestItem"));
+ model.setSort(NameSortAttribute, Qt::AscendingOrder);
+ QCOMPARE(itemName(model,0),QString("ATestItem"));
+ QCOMPARE(itemName(model,1),QString("BTestItem"));
+ model.setSort(DefaultSortAttribute, Qt::DescendingOrder);
+ QCOMPARE(itemName(model,0),QString("ATestItem"));
+ QCOMPARE(itemName(model,1),QString("BTestItem"));
+ model.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QCOMPARE(itemName(model,0),QString("BTestItem"));
+ QCOMPARE(itemName(model,1),QString("ATestItem"));
+ model.setAutoUpdate(true);
+ model.setSort(NameSortAttribute, Qt::DescendingOrder);
+ QCOMPARE(itemName(model,0),QString("BTestItem"));
+ QCOMPARE(itemName(model,1),QString("ATestItem"));
+ model.setSort(NameSortAttribute, Qt::AscendingOrder);
+ QCOMPARE(itemName(model,0),QString("ATestItem"));
+ QCOMPARE(itemName(model,1),QString("BTestItem"));
+ model.setSort(DefaultSortAttribute, Qt::DescendingOrder);
+ QCOMPARE(itemName(model,0),QString("ATestItem"));
+ QCOMPARE(itemName(model,1),QString("BTestItem"));
+ model.setSort(DefaultSortAttribute, Qt::AscendingOrder);
+ QCOMPARE(itemName(model,0),QString("BTestItem"));
+ QCOMPARE(itemName(model,1),QString("ATestItem"));
+ //cleanup
+ removeEntry("BTestItem");
+ removeEntry("ATestItem");
+ removeEntry("TestGroup");
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelUpdateItem()
+{
+ // ensure that entries are not present in a storage
+ removeEntry("TestItemBeforeUpdate");
+ removeEntry("TestItemAfterUpdate");
+ removeEntry("TestItemAfterSecondUpdate");
+ //test
+ CaQuery query;
+ query.addEntryTypeName("test_item");
+ CaItemModel model(query,NULL);
+ model.setAutoUpdate(true);
+ QSharedPointer<CaEntry> item1 = createItem("TestItemBeforeUpdate","test_item");
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount(),1);
+ QCOMPARE(itemName(model,0),QString("TestItemBeforeUpdate"));
+ item1->setText("TestItemAfterUpdate");
+ CaService::instance()->updateEntry(*item1);
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount(),1);
+ QCOMPARE(itemName(model,0),QString("TestItemAfterUpdate"));
+ model.setAutoUpdate(false);
+ item1->setText("TestItemAfterSecondUpdate");
+ CaService::instance()->updateEntry(*item1);
+ QTest::qWait(50);
+ QCOMPARE(model.rowCount(),1);
+ QCOMPARE(itemName(model,0),QString("TestItemAfterUpdate"));// model not updated
+
+ //cleanup
+ removeEntry("TestItemBeforeUpdate");
+ removeEntry("TestItemAfterUpdate");
+ removeEntry("TestItemAfterSecondUpdate");
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelAddItems()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup");
+
+ removeEntry("1TestItem1");
+ removeEntry("1TestItem2");
+ removeEntry("1TestItem3");
+
+ removeEntry("2TestItem1");
+
+ removeEntry("3TestItem1");
+ removeEntry("3TestItem2");
+ removeEntry("3TestItem3");
+
+ removeEntry("0TestItem1");
+ removeEntry("0TestItem2");
+
+ removeEntry("1TestItem4");
+ removeEntry("1TestItem5");
+
+ removeEntry("2TestItem2");
+ removeEntry("2TestItem3");
+
+ removeEntry("3TestItem4");
+ removeEntry("3TestItem5");
+
+ // test group
+ QSharedPointer<CaEntry> testGroup = createGroup("TestGroup","testfolder");
+
+ // test entries
+ QList< QSharedPointer<CaEntry> > entryList;
+ entryList << createItem("1TestItem1","testitem");
+ entryList << createItem("1TestItem2","testitem");
+ entryList << createItem("1TestItem3","testitem");
+
+ entryList << createItem("2TestItem1","testitem");
+
+ entryList << createItem("3TestItem1","testitem");
+ entryList << createItem("3TestItem2","testitem");
+ entryList << createItem("3TestItem3","testitem");
+
+ // entries for inserting into sorted order - notice the names
+ entryList << createItem("0TestItem1","testitem");
+ entryList << createItem("0TestItem2","testitem");
+
+ entryList << createItem("1TestItem4","testitem");
+ entryList << createItem("1TestItem5","testitem");
+
+ entryList << createItem("2TestItem2","testitem");
+ entryList << createItem("2TestItem3","testitem");
+
+ entryList << createItem("3TestItem4","testitem");
+ entryList << createItem("3TestItem5","testitem");
+
+ // create a model to test
+ CaQuery query;
+ query.setParentId(testGroup->id());
+ CaItemModel model(query, NULL);
+ model.setAutoUpdate(true);
+
+ // create row insertion signal spyes;
+ qRegisterMetaType<QModelIndex>("QModelIndex");
+ QSignalSpy rowsAboutToBeInsertedSpy(
+ &model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
+ QSignalSpy rowsInsertedSpy(
+ &model, SIGNAL(rowsInserted(QModelIndex,int,int)));
+ QSignalSpy resetSpy(
+ &model, SIGNAL(modelReset()));
+ QList<QVariant> spyArguments;
+
+// ***[1]*** test adding 3 entries to an empty collection
+ service->appendEntriesToGroup(*testGroup, entryList.mid(0, 3));
+ QTest::qWait(50);
+
+ QCOMPARE(rowsAboutToBeInsertedSpy.count(), 1);
+ spyArguments = rowsAboutToBeInsertedSpy.takeFirst();
+ // added 3 entries to the beginning of the group
+ // first row in the signal should be 0 and the last row 2
+ QVERIFY(spyArguments.at(1).toInt() == 0);
+ QVERIFY(spyArguments.at(2).toInt() == 2);
+
+ QCOMPARE(rowsInsertedSpy.count(), 1);
+ spyArguments = rowsInsertedSpy.takeFirst();
+ QVERIFY(spyArguments.at(1).toInt() == 0);
+ QVERIFY(spyArguments.at(2).toInt() == 2);
+
+// ***[2]*** add 1 entry to a collection already containing items
+ service->appendEntryToGroup(*testGroup, *entryList[3]);
+ QTest::qWait(50);
+
+ QCOMPARE(resetSpy.count(), 1);
+
+// ***[5]*** rearrange items
+ model.setSort(DefaultSortAttribute);
+
+ QSignalSpy layoutAboutToBeChangedSpy(&model, SIGNAL(layoutAboutToBeChanged()));
+ QSignalSpy layoutChangedSpy(&model, SIGNAL(layoutChanged()));
+
+ QList<int> idList;
+ QSharedPointer<CaEntry> entry;
+ foreach(entry, entryList) {
+ idList << entry->id();
+ }
+ // swap the first and last element to trigger a layout update
+ idList.swap(0, idList.count() - 1);
+
+ service->customSort(testGroup->id(), idList);
+ QTest::qWait(50);
+
+ QCOMPARE(layoutAboutToBeChangedSpy.count(), 1);
+ QCOMPARE(layoutChangedSpy.count(), 1);
+
+
+ removeEntry("1TestItem1");
+ removeEntry("1TestItem2");
+ removeEntry("1TestItem3");
+ removeEntry("2TestItem1");
+ removeEntry("3TestItem1");
+ removeEntry("3TestItem2");
+ removeEntry("3TestItem3");
+ removeEntry("0TestItem1");
+ removeEntry("0TestItem2");
+ removeEntry("1TestItem4");
+ removeEntry("1TestItem5");
+ removeEntry("2TestItem2");
+ removeEntry("2TestItem3");
+ removeEntry("3TestItem4");
+ removeEntry("3TestItem5");
+ removeEntry("TestGroup");
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::TestCaItemModelEmptySignal()
+{
+ QSharedPointer<CaService> service = CaService::instance();
+
+ // ensure that entries are not present in a storage
+ removeEntry("TestGroup_EmptySignal");
+ removeEntry("TestItem1");
+ removeEntry("TestItem2");
+ // test group
+ QSharedPointer<CaEntry> testGroup = createGroup("TestGroup_EmptySignal","testfolder");
+
+ // test entries
+ QSharedPointer<CaEntry> entry1 = createItem("TestItem1","testitem");
+ QSharedPointer<CaEntry> entry2 = createItem("TestItem2","testitem");
+
+ // create a model to test
+ CaQuery query;
+ query.setParentId(testGroup->id());
+ CaItemModel model(query, NULL);
+
+ // create signal spyes;
+ //qRegisterMetaType<QModelIndex>("QModelIndex");
+ QSignalSpy emptySignalSpy(
+ &model, SIGNAL(empty(bool)));
+ QList<QVariant> spyArguments;
+
+ //test
+ service->appendEntryToGroup(*testGroup.data(), *entry1.data());
+ QTest::qWait(50);
+ QCOMPARE(emptySignalSpy.count(),1);
+
+ spyArguments = emptySignalSpy.takeAt(0);
+ QCOMPARE(spyArguments.at(0).toBool(), false);
+ spyArguments.clear();
+ emptySignalSpy.clear();
+
+ service->appendEntryToGroup(*testGroup.data(), *entry2.data());
+ QTest::qWait(50);
+ QCOMPARE(emptySignalSpy.count(),0);
+ removeEntry("TestItem1");
+ QTest::qWait(50);
+ QCOMPARE(emptySignalSpy.count(),0);
+ removeEntry("TestItem2");
+ QTest::qWait(50);
+ QCOMPARE(emptySignalSpy.count(),1);
+
+ spyArguments = emptySignalSpy.takeAt(0);
+ QCOMPARE(spyArguments.at(0).toBool(), true);
+
+
+ //cleanup
+ removeEntry("TestGroup_EmptySignal");
+}
+
+// ---------------------------------------------------------------------------
+// UTILS
+// ---------------------------------------------------------------------------
+//
+QSharedPointer<CaEntry> TestCaClient::createGroup(const QString &groupName, const QString &typeName)
+{
+ CaEntry item(GroupEntryRole);
+ item.setText(groupName);
+ item.setEntryTypeName(typeName);
+ QSharedPointer<CaService> service = CaService::instance();
+ return service->createEntry(item);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+QSharedPointer<CaEntry> TestCaClient::createItem(const QString &itemName, const QString &description,
+ const QString &typeName, EntryFlags flags)
+{
+ CaEntry item(ItemEntryRole);
+ item.setText(itemName);
+ item.setDescription(description);
+ item.setEntryTypeName(typeName);
+ item.setFlags(flags);
+ QSharedPointer<CaService> service = CaService::instance();
+ return service->createEntry(item);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+QSharedPointer<CaEntry> TestCaClient::createItem(const QString &itemName, const QString &typeName)
+{
+ CaEntry item(ItemEntryRole);
+ item.setText(itemName);
+ item.setEntryTypeName(typeName);
+ QSharedPointer<CaService> service = CaService::instance();
+ return service->createEntry(item);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::addItemToGroup(int groupId, int itemId)
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ service->appendEntryToGroup(groupId, itemId) ;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::removeItemFromGroup(int groupId, int itemId)
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ service->removeEntryFromGroup(groupId, itemId) ;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaClient::removeEntry(int entryId)
+{
+ QSharedPointer<CaService> service = CaService::instance();
+ service->removeEntry(entryId);
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+bool TestCaClient::removeEntry(const QString &entryName)
+{
+ bool found(false);
+ QSharedPointer<CaService> service = CaService::instance();
+ CaQuery query;
+ QList< QSharedPointer<CaEntry> > entries = service->getEntries(query);
+ foreach(QSharedPointer<CaEntry> entry, entries) {
+ if (entry->text() == entryName) {
+ service->removeEntry(*entry);
+ found = true;
+ }
+ }
+ return found;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+QString TestCaClient::itemName(const CaItemModel &model, int row)
+{
+ return model.data(model.index(row),CaItemModel::TextRole).toString();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/t_caclient.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h
+SOURCES += ./src/*.cpp
+symbian:
+{
+ HEADERS += ../../../tsrc/testutils/inc/*.h
+ SOURCES += ../../../tsrc/testutils/src/*.cpp
+ SOURCES += ../../../srvsrc/castorageproxy.cpp
+ SOURCES += ../../../srvsrc/cabackupnotifier.cpp
+ SOURCES += ../../../castorage/src/*.cpp
+
+
+ BLD_INF_RULES.prj_testexports += "data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/testing/data/t_caclient/installs/sapiapp_S60_3_X_v_1_0_0.sisx"
+ BLD_INF_RULES.prj_exports += "data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/testing/data/t_caclient/installs/sapiapp_S60_3_X_v_1_0_0.sisx"
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/t_caclient.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,113 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+CONFIG += hb mobility
+MOBILITY = serviceframework
+HB = hbcore
+include(../../../../common.pri)
+include(../../../tsrc/testutils/testutils.pri)
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib xml
+
+DEFINES += CONTENTARSENAL_UNITTEST
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+DEPENDPATH += . \
+ ./inc \
+ ./src
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../homescreensrv_plat/contentstorage_api \
+ ../../../srvinc \
+ ../../../inc \
+ ../../../cautils\inc \
+ ../../../castorage/inc \
+ ../../../../contentstorage/inc
+
+
+INCLUDEPATH += ../../../cautils/inc \
+ ../../inc
+
+LIBS += -lcaclient
+
+symbian: {
+ CONFIG += symbian_test
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ coverage: {
+ SUBDIRS += ../../../cautils
+
+ SUBDIRS += ../../../caclient
+
+ BLD_INF_RULES.prj_mmpfiles += "../../../casrv/casrvmgr/group/casrvmanager.mmp" \
+ "../../../casatinterface/group/MenuInterface.mmp" \
+ "../../../group/casathandler.mmp" \
+ "../../../group/camenu.mmp" \
+ "../../../group/camenusrv.mmp" "
+
+ CONFIG -= symbian_test
+ }
+
+ TARGET.UID2 = 0x100039CE
+ TARGET.UID3 = 0x20026FA8
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+
+ LIBS += \
+ -lapgrfx \
+ -lefsrv \
+ -lws32 \
+ -lcautils \
+ -lsqldb \
+ -lbafl \
+ -lflogger \
+ -lsysutil
+
+ export.sources = ./data/armv5/*.sisx
+ export.path = /testing/data/t_caclient/installs
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = /testing/data/t_caclient/
+
+ exportQM.sources = ./data/emailTest.qm
+ exportQM.path = /resource/qt/translations/
+
+
+ DEPLOYMENT += export \
+ exportDB \
+ exportQM
+
+}
+
+include(t_caclient.pri)
+!win32:include(t_caclient_installs_win32.pri)
+!symbian:unix:include(t_caclient_installs_unix.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/t_caclient_installs_unix.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2009 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:
+#
+#
+
+# Release - deploy only release version of the tests
+
+#
+
+
+
+r01.path = ../../../../bin/hstests
+
+r01.files = ./release/t_hsmcsserviceprovider \
+
+
+
+INSTALLS += r01
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/t_caclient_installs_win32.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2009 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:
+#
+
+testfiles.path = ../../../../../bin/debug/
+
+testfiles.files = ./release/t_caclient.exe \
+
+testfiles.files = ./debug/t_caclient.exe
+
+INSTALLS += testfiles
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_caclient/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_caclient.exe -o c:\t_caclient.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_testapp/catestapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = catestapp
+
+CONFIG(debug, debug|release) {
+ LIBS += -L../debug \
+ -lcaclient
+}
+else {
+ LIBS += -L../release \
+ -lcaclient
+
+}
+
+
+
+QT += core gui
+CONFIG += hb
+
+SOURCES += main.cpp
+
+DEPENDPATH += ./../inc
+INCLUDEPATH += ./../inc \
+ ../../../homescreensrv_plat/contentstorage_api
+
+win32:include(installs_win32.pri)
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_testapp/installs_win32.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+#
+# Release
+#
+r01.path = ../../../bin/release
+r01.files = ./release/*.exe
+
+INSTALLS += r01
+
+#
+# Debug
+#
+d01.path = ../../../bin/debug
+d01.files = ./debug/*.exe
+
+INSTALLS += d01
+
+#
+# test DB
+#
+testdb.path = ../../../bin/debug
+testdb.files = ./castorage.db
+
+INSTALLS += testdb
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/t_testapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2009 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 <QtGui>
+#include <QStandardItemModel>
+
+#include <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbmenu.h>
+#include <hbview.h>
+#include <hbmainwindow.h>
+#include <hbaction.h>
+#include <hbgridview.h>
+
+#include "caservice.h"
+#include "caentry.h"
+#include "caquery.h"
+
+QStandardItemModel *populateModel()
+{
+ QStandardItemModel *result = new QStandardItemModel();
+
+
+ QList<QStandardItem *> items;
+
+ for (int i = 0; i < 10; ++i) {
+ //items << new QStandardItem(QString("Item %1").arg(i+1));
+ }
+ QSharedPointer<CaService> service = CaService::instance();
+
+ //QList<CaEntry*> entryList = service->getEntries(QList<int>() << 1 << 3 << 4);
+ CaQuery query;
+ query.setParentId(2);
+ QList< QSharedPointer<CaEntry> > entryList = service->getEntries(query);
+ foreach(QSharedPointer<CaEntry> entry, entryList) {
+ items << new QStandardItem(entry->makeIcon(), entry->text());
+ }
+ result->appendColumn(items);
+
+ return result;
+}
+
+
+int main(int argc, char *argv[])
+{
+ // Each Orbit UI application needs to instantiate HbApplication.
+ // It is the core part of an Orbit UI application.
+ // Note: HbApplication is a specialisation of Qt's QApplication
+ // so your Orbit application does not need to instantiate a
+ // QApplication as well.
+ HbApplication app(argc, argv);
+
+ // HbMainWindow contains all your application's screen elements
+ // such as widgets and views.
+ // Also, the decorators that make up the standard Orbit UI style
+ // (e.g. indicators, softkeys, menus) are automatically created
+ // when this class is instantiated.
+ HbMainWindow mainWindow;
+
+
+
+ HbGridView *grid = new HbGridView();
+ grid->setParent(&app);
+
+ //QStandardItemModel* model = populateModel;
+ grid->setModel(populateModel());
+
+ HbView *view = new HbView();
+ view->setParent(&app);
+ view->setTitle("Test CA app");
+ view->setWidget(grid);
+
+ // Add the label widget to the HbMainWindow as a view.
+ mainWindow.addView(view);
+
+ HbMenu *menu = new HbMenu();
+ menu->addAction(QString("Exit application"), qApp, SLOT(quit()));
+ mainWindow.currentView()->setMenu(menu);
+
+ // Show the current view. There is only one view which happens to contain
+ // only a single widget, i.e. the label with the "Hello World" text, so
+ // that is what will be shown.
+ mainWindow.show();
+
+ // Start the standard Qt application event processing loop.
+ // In this application the only possible user interaction is to
+ // press the "back" button that was automatically added to
+ // the HbMainWindow.
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/caclient/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+SUBDIRS = ./t_caclient
+
+CONFIG += ordered
--- a/contentstorage/cahandler/app/resource/caapphandlerplugin.xml Thu Sep 02 20:45:03 2010 +0300
+++ b/contentstorage/cahandler/app/resource/caapphandlerplugin.xml Thu Sep 16 12:11:40 2010 +0100
@@ -10,4 +10,4 @@
<capabilities></capabilities>
<customproperty key="entryTypeName">application</customproperty>
</interface>
-</service>
+</service>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
Binary file contentstorage/cahandler/app/tsrc/t_caapphandler/data/armv5/Hello.jar has changed
Binary file contentstorage/cahandler/app/tsrc/t_caapphandler/data/armv5/sapiapp_S60_3_X_v_1_0_0.SISX has changed
Binary file contentstorage/cahandler/app/tsrc/t_caapphandler/data/winscw/Hello.jar has changed
Binary file contentstorage/cahandler/app/tsrc/t_caapphandler/data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/inc/T_caapphandlerplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_cahandler.h
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+#ifndef T_CAAPPHANDLERPLUGIN_H
+#define T_CAAPPHANDLERPLUGIN_H
+
+class CaAppHandler;
+
+#include <e32base.h>
+#include <e32def.h>
+#include <QtTest/QtTest>
+
+//------------------------------------------------------------------------------
+
+
+/**
+ *
+ * Test class.
+ *
+ */
+class T_CaHandler: public QObject
+{
+ Q_OBJECT
+public:
+ T_CaHandler();
+private slots:
+
+ //setup methods
+ void initTestCase();
+ void cleanup();
+
+ void appHandlerConstruction();
+ void appHandlerMultipleLoad();
+ void appHandlerMultipleLoadAndDelete();
+ void appHandlerOpenFails();
+ void appHandlerRemoveFails();
+ void appHandlerClose();
+ void appHandlerRunApplication();
+
+ void appHandlerRemoveApplication();
+ void appHandlerRemoveJavaApplication();
+
+ void testCCaTaskList();
+ void appHandlerCreateInstance();
+private:
+ TBool javaAppInstalled(TInt32 aUid);
+
+private:
+ CaAppHandler *iAppHandler;
+};
+
+#endif // T_CAAPPHANDLERPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2006 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: Plugin Interface
+*
+*/
+
+
+#ifndef C_WAITACTIVE_H
+#define C_WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // C_WAITACTIVE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_caapphandler_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/src/T_caapphandlerplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,523 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_caapphandlerplugin.cpp
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+// CLASS HEADER
+
+#include <w32std.h>
+#include <apgtask.h>
+#include <apgcli.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <usif/scr/scr.h>
+#include <usif/sif/sifcommon.h>
+#include <usif/scr/screntries.h>
+#include <qservicemanager.h>
+#include <QProcess>
+#include <qservicemanager.h>
+
+#include <cadefs.h>
+
+#include "T_caapphandlerplugin.h"
+#include "waitactive.h"
+#include "catasklist.h"
+#include "caapphandler.h"
+#include "caapphandlerplugin.h"
+#include "caentry.h"
+#include "caclient_defines.h"
+#include "t_cainstaller.h"
+
+template <typename RClass>
+struct RClassDeleter
+{
+ static inline void cleanup(RClass *ptr)
+ {
+ ptr->Close();
+ }
+};
+
+
+typedef RClassDeleter< RBuf > RBufDeleter;
+typedef QScopedPointer< RBuf, RBufDeleter >
+ RBufPointer;
+
+
+QTM_USE_NAMESPACE
+
+static const char caTypeApp[] = "application";
+static const char caTypePackage[] = "package";
+static const char caTypeWidget[] = "widget";
+static const char caAttrView[] = "view";
+static const char caCmdClose[] = "close";
+static const char caAttrWindowGroupId[] = "window_group_id";
+static const char caAttrComponentId[] = "component_id";
+static const char caUidAttribute[] = "application:uid";
+
+T_CaHandler::T_CaHandler():
+ iAppHandler(NULL)
+{
+}
+
+void T_CaHandler::cleanup()
+{
+ delete iAppHandler;
+ iAppHandler = NULL;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::initTestCase()
+{
+ QStringList pluginPaths;
+ QString xmlName("caapphandlerplugin.xml");
+
+ pluginPaths.append("c:/resource/qt/plugins/commandhandler");
+ pluginPaths.append("z:/resource/qt/plugins/commandhandler");
+
+ QServiceManager serviceManager;
+ foreach (QString path, pluginPaths) {
+ QApplication::addLibraryPath(path);
+ QDir dir(path);
+ if (dir.exists(xmlName)) {
+ serviceManager.addService(dir.absoluteFilePath(xmlName));
+ }
+ }
+
+ Usif::RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect() );
+
+ // Install the component
+ _LIT16( KHelloJarPath, "c:\\testing\\data\\t_caapphandler\\installs\\hello.jar" );
+ Usif::COpaqueNamedParams* arguments = NULL;
+ Usif::COpaqueNamedParams* results = NULL;
+ arguments = Usif::COpaqueNamedParams::NewLC();
+ results = Usif::COpaqueNamedParams::NewLC();
+ arguments->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
+ TRequestStatus status;
+ sif.Install( KHelloJarPath, *arguments, *results, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError( status.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+ CleanupStack::PopAndDestroy( arguments );
+
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerConstruction()
+{
+ iAppHandler = new CaAppHandler();
+ QVERIFY(iAppHandler);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerMultipleLoad()
+{
+ RPointerArray<CaAppHandler> handlerArray;
+
+ bool foundNull(false);
+ TRAPD(err,
+ CleanupResetAndDestroyPushL(handlerArray);
+ for (TInt i(0); i < 10; ++i) {
+ handlerArray.AppendL(new CaAppHandler());
+ if (handlerArray[i] == 0) {
+ foundNull = true;
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy(&handlerArray);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(!foundNull);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerMultipleLoadAndDelete()
+{
+ CaAppHandler *handlerPtr(NULL);
+ for (TInt i(0); i < 10; ++i) {
+ handlerPtr = new CaAppHandler();
+ delete handlerPtr;
+ handlerPtr = NULL;
+ }
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerOpenFails()
+{
+ appHandlerConstruction();
+
+ TInt unsuportedCommandResult(KErrNone);
+ TInt unexistingEntryOpenResult(KErrNone);
+ TInt corruptedEntryOpenResult(KErrNone);
+ TInt unsupportedEntryTypeOpenResult(KErrNone);
+
+ CaEntry *entry = new CaEntry();
+
+ // valid entry type name
+ entry->setEntryTypeName(caTypeApp);
+
+ unsuportedCommandResult =
+ iAppHandler->execute(*entry, "unsupported_command_name");
+ // invalid UID
+ entry->setAttribute(APPLICATION_UID_ATTRIBUTE_NAME, "11111");
+
+ unexistingEntryOpenResult = iAppHandler->execute(*entry, caCmdOpen);
+
+ // invalid view ID
+ entry->setAttribute(caAttrView, "not_a_hex_value");
+
+ corruptedEntryOpenResult = iAppHandler->execute(*entry, caCmdOpen);
+
+ // invalid entry type name
+ entry->setEntryTypeName("unsupported_entry_type_name");
+
+ unsupportedEntryTypeOpenResult =
+ iAppHandler->execute(*entry, caCmdOpen);
+
+ delete entry;
+ entry = NULL;
+ QCOMPARE(unsuportedCommandResult, KErrNotSupported);
+ QCOMPARE(unexistingEntryOpenResult, KErrNotFound);
+ QCOMPARE(corruptedEntryOpenResult, KErrGeneral);
+ QCOMPARE(unsupportedEntryTypeOpenResult, KErrNotSupported);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerRemoveFails()
+{
+ appHandlerConstruction();
+ TInt unpermittedRemovalResult(KErrNone);
+ TInt unexistingEntryRemovalResult(KErrNone);
+
+ CaEntry *entry = new CaEntry();
+ entry->setEntryTypeName(caTypeApp);
+
+ // invalid flags (should be removable)
+ entry->setFlags(0);
+
+ unpermittedRemovalResult =
+ iAppHandler->execute(*entry, caCmdRemove);
+
+ // set correct flags
+ entry->setFlags(RemovableEntryFlag);
+
+ // invalid UID
+ entry->setAttribute(APPLICATION_UID_ATTRIBUTE_NAME, "0");
+
+ unexistingEntryRemovalResult =
+ iAppHandler->execute(*entry, caCmdRemove);
+ delete entry;
+ entry = NULL;
+
+ QCOMPARE(unpermittedRemovalResult, KErrAccessDenied);
+ QCOMPARE(unexistingEntryRemovalResult, KErrNotFound);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerClose()
+{
+ TInt errorClose1(KErrNone);
+ TInt errorClose2(KErrNone);
+ TInt errorOpen(KErrNone);
+ bool wasRunning(false);
+ bool closedRunning(false);
+
+ const TInt KPhonebookUid(0x20022EF9);
+
+ RWsSession wsSession;
+ TRAPD(err,
+ CleanupClosePushL(wsSession);
+ User::LeaveIfError(wsSession.Connect());
+
+ TApaTaskList taskList(wsSession);
+ TApaTask taskBefore = taskList.FindApp(TUid::Uid(KPhonebookUid));
+ if (taskBefore.Exists()) {
+ taskBefore.EndTask();
+ }
+
+ appHandlerConstruction();
+
+ CaEntry *entry = new CaEntry();
+ entry->setEntryTypeName(caTypeApp);
+ entry->setAttribute(APPLICATION_UID_ATTRIBUTE_NAME,
+ QString::number(KPhonebookUid, 10));
+
+ errorClose1 = iAppHandler->execute(*entry, caCmdClose);
+ QTest::qWait(10000);
+ errorOpen = iAppHandler->execute(*entry, caCmdOpen);
+
+ QTest::qWait(10000);
+ TApaTask taskAfter = taskList.FindApp(TUid::Uid(KPhonebookUid));
+ TInt id = taskAfter.WgId();
+ QString numBuf;
+ numBuf = QString::number(id);
+ entry->setFlags(entry->flags() | RunningEntryFlag);
+ entry->setAttribute(caAttrWindowGroupId, numBuf);
+
+ wasRunning = taskAfter.Exists();
+
+ errorClose2 = iAppHandler->execute(*entry, caCmdClose);
+
+ QTest::qWait(10000);
+ closedRunning = !taskList.FindApp(TUid::Uid(KPhonebookUid)).Exists();
+ delete entry;
+ entry = NULL;
+ CleanupStack::PopAndDestroy(&wsSession);
+ );
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(errorClose1, KErrGeneral);
+ QCOMPARE(errorOpen, KErrNone);
+ QCOMPARE(errorClose2, KErrNone);
+ QVERIFY(wasRunning);
+ QVERIFY(closedRunning);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerRunApplication()
+{
+
+ TInt error(KErrNone);
+ bool started(false);
+ // we will run calculator app
+ const TInt KPhonebookUid(0x20022EF9);
+
+ RWsSession wsSession;
+
+ TRAPD(err,
+ CleanupClosePushL(wsSession);
+ User::LeaveIfError(wsSession.Connect());
+
+ TApaTaskList taskList(wsSession);
+ TApaTask taskBefore = taskList.FindApp(TUid::Uid(KPhonebookUid));
+ if (taskBefore.Exists()) {
+ taskBefore.EndTask();
+ }
+
+ appHandlerConstruction();
+
+ CaEntry *entry = new CaEntry();
+ entry->setEntryTypeName(caTypeApp);
+ entry->setAttribute(APPLICATION_UID_ATTRIBUTE_NAME,
+ QString::number(KPhonebookUid));
+
+ error = iAppHandler->execute(*entry, caCmdOpen);
+
+ QTest::qWait(1000);
+ TApaTask taskAfter = taskList.FindApp(TUid::Uid(KPhonebookUid));
+ started = taskAfter.Exists();
+ taskAfter.EndTask();
+
+ delete entry;
+ entry = NULL;
+ CleanupStack::PopAndDestroy(&wsSession);
+ );
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(error, KErrNone);
+ QVERIFY(started);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerRemoveApplication()
+{
+ bool leaveOnRemove(true);
+ bool removed(false);
+
+ _LIT(KSapiPackageFileName,
+ "c:\\testing\\data\\t_apphandler\\installs\\sapiapp_S60_3_X_v_1_0_0.sisx");
+ _LIT(KSapiAppFileName, "c:\\sys\\bin\\sapiapp.exe");
+ const TUid KSapiAppUid(TUid::Uid(0xe6bc1167));
+
+ T_CaInstaller *installer = NULL;
+ installer = T_CaInstaller::NewL();
+ CleanupStack::PushL(installer);
+ TRAPD(err, installer->InstallL(KSapiPackageFileName));
+ QCOMPARE(err, KErrNone);
+ QTest::qWait(20000);
+
+ Usif::TComponentId componentId(0);
+ TRAP(err, componentId = installer->GetComponentIdL(KSapiAppFileName));
+ QCOMPARE(err, KErrNone);
+
+ appHandlerConstruction();
+
+ CaEntry *entry = new CaEntry();
+
+ entry->setEntryTypeName(caTypeApp);
+ entry->setFlags(RemovableEntryFlag);
+ entry->setAttribute(APPLICATION_UID_ATTRIBUTE_NAME,
+ QString::number(KSapiAppUid.iUid));
+
+ entry->setAttribute(caAttrComponentId,
+ QString::number(componentId));
+
+ TRAP(err, iAppHandler->execute(*entry, caCmdRemove));
+ QCOMPARE(err, KErrNone);
+ QTest::qWait(20000);
+ delete entry;
+ entry = NULL;
+
+ // check again if installed, should be gone
+ TRAP(err, componentId = installer->GetComponentIdL(KSapiAppFileName))
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(componentId, 0);
+ CleanupStack::PopAndDestroy(installer);
+
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerRemoveJavaApplication()
+{
+ const int javaAppUid = 0x101251BB;//
+ bool removed(false);
+ int error(KErrNone);
+
+ TRAPD(err,
+ QVERIFY(javaAppInstalled(javaAppUid));
+
+ appHandlerConstruction();
+
+ CaEntry *entry = new CaEntry();
+ entry->setEntryTypeName(caTypeApp);
+ entry->setFlags(RemovableEntryFlag);
+ entry->setAttribute(APPLICATION_UID_ATTRIBUTE_NAME,
+ QString::number(javaAppUid));
+
+ Usif::RSoftwareComponentRegistry scr;
+ CleanupClosePushL(scr);
+ User::LeaveIfError(scr.Connect());
+ TUid uid;
+ Usif::TComponentId componentId =
+ scr.GetComponentIdForAppL( uid.Uid( javaAppUid ) );
+
+ if (componentId > 0) {
+ entry->setAttribute(caAttrComponentId, QString::number(componentId));
+ }
+
+ CleanupStack::PopAndDestroy(&scr);
+
+ error = iAppHandler->execute(*entry, caCmdRemove);
+ QTest::qWait(20000);
+ delete entry;
+ entry = NULL;
+ )
+ QVERIFY(!javaAppInstalled(javaAppUid));
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(error, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TBool T_CaHandler::javaAppInstalled(TInt32 aUid)
+ {
+ TBool result = EFalse;
+ Usif::RSoftwareComponentRegistry scr;
+ CleanupClosePushL(scr);
+ scr.Connect();
+ TUid uid;
+ TInt err;
+ Usif::TComponentId componentId( 0 );
+ TRAP(err, componentId =
+ scr.GetComponentIdForAppL(
+ uid.Uid( aUid ) ) )
+ if (componentId > 0 && err == KErrNone)
+ {
+ result = ETrue;
+ }
+ CleanupStack::PopAndDestroy(&scr);
+ return result;
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::testCCaTaskList()
+{
+ RWsSession wsSession;
+ User::LeaveIfError( wsSession.Connect() );
+ CleanupClosePushL<RWsSession>( wsSession );
+
+ CCaTaskList* taskList = CCaTaskList::NewL( wsSession );
+ taskList->UpdateListL();
+ QVERIFY(taskList->IsRootWindowGroup(-1) == EFalse);
+ delete taskList;
+ CleanupStack::PopAndDestroy( &wsSession );
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaHandler::appHandlerCreateInstance()
+{
+ QServiceManager serviceManager;
+ CaAppHandlerPlugin plugin;
+ QServiceFilter serviceFilter("com.nokia.homescreen.ICommandHandler");
+ serviceFilter.setCustomAttribute("entryTypeName", "application");
+ QList<QServiceInterfaceDescriptor> serviceInterfaceDescriptorList =
+ serviceManager.findInterfaces(serviceFilter);
+ int len = serviceInterfaceDescriptorList.size();
+ QVERIFY(len>0);
+ QServiceInterfaceDescriptor serviceInterfaceDescriptor =
+ serviceInterfaceDescriptorList[0];
+ QObject *handler = plugin.createInstance(
+ serviceInterfaceDescriptor, NULL, NULL);
+ QVERIFY(handler);
+ delete handler;
+}
+
+QTEST_MAIN(T_CaHandler)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006 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 "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/t_caapphandler.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ./../../inc/*.h \
+ ./../../../../tsrc/testutils/inc
+
+SOURCES += ./src/*.cpp \
+ ./../../src/*.cpp \
+ ./../../../../tsrc/testutils/src/*.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/app/tsrc/t_caapphandler/t_caapphandler.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,101 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+CONFIG += hb mobility
+MOBILITY = serviceframework
+HB = hbcore
+
+include(../../../../../common.pri)
+include(../../../../tsrc/testutils/testutils.pri)
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src \
+ ../../inc \
+ ../../src
+
+INCLUDEPATH += \
+ ./inc \
+ ../../inc \
+ ../../../../cautils/inc \
+ ../../../../castorage/inc \
+ ../../../../caclient/inc \
+ ../../../../inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_caapphandler.pri)
+
+symbian: {
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20028711
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lecom \
+ -lcautils \
+ -lapgrfx \
+ -lws32 \
+ -lapparc \
+ -lsisregistryclient \
+ -lsif \
+ -lscrclient \
+ -lxqutils \
+ -lefsrv \
+ -lcone \
+ -lcaclient
+
+ BLD_INF_RULES.prj_testexports += "./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/testing/data/t_caapphandler/installs/" \
+ "./data/winscw/Hello.jar c:/testing/data/t_caapphandler/installs/"
+
+ BLD_INF_RULES.prj_exports += "./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/testing/data/t_caapphandler/installs/" \
+ "./data/winscw/Hello.jar c:/testing/data/t_caapphandler/installs/"
+
+ exportArmSis.sources += ./data/armv5/sapiapp_S60_3_X_v_1_0_0.sisx \
+ ./data/winscw/Hello.jar
+ exportArmSis.path = c:/testing/data/t_caapphandler/installs
+ DEPLOYMENT += exportArmSis
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../..");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=./src/*\" sbs -j 4 -c winscw_udeb");
+
+ chdir("tsrc/t_catapphandler");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_catapphandler -o c:\\t_catapphandler.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../..");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o tsrc/t_catapphandler/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o tsrc/t_catapphandler/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/function_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,68 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../..");
+
+ system("call qmake -config coverage");
+ system("call bldmake bldfiles");
+ system("call abld makefile winscw");
+ system("call abld reallyclean winscw");
+
+ system('call ctcwrap -i f -C "EXCLUDE=*" -C "NO_EXCLUDE+./src/*" abld build winscw udeb');
+
+ chdir("tsrc/t_catapphandler");
+ system("call qmake -config coverage");
+ system("call bldmake bldfiles");
+ system("call abld test makefile winscw");
+ system("call abld test build winscw udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_catapphandler -o c:\\t_catapphandler.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../..");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o tsrc/t_catapphandler/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o tsrc/t_catapphandler/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/inc/t_catapphandler.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 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: Test class for homescreen::core
+ *
+ */
+
+#include <QtTest/QtTest>
+
+#include "catapphandler.h"
+
+/**
+ * @test Test class for homescreen::hsutils modules.
+ */
+class CaTappHandlerPluginTest: public QObject
+{
+Q_OBJECT
+
+private slots:
+
+ void init();
+ void cleanup();
+ void cleanupTestCase();
+ void initTestCase();
+
+ /**
+ * CaTappHandler
+ */
+ void testConstruction();
+ void testExecute();
+ void tAppHandlerCreateInstance();
+
+private:
+
+ CaTappHandler *mTappHandler;
+
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2006 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: Plugin Interface
+*
+*/
+
+
+#ifndef C_WAITACTIVE_H
+#define C_WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // C_WAITACTIVE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_catapphandler_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/src/t_catapphandler.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2009 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: Main test class for test library.
+ *
+ */
+
+//#include <QStateMachine>
+//#include <QSignalSpy>
+//#include <QDir>
+
+#include <qservicemanager.h>
+#include <apgtask.h>
+
+#include "t_catapphandler.h"
+#include "catapphandlerplugin.h"
+#include "catapphandler.h"
+#include "caentry.h"
+#include "waitactive.h"
+
+QTM_USE_NAMESPACE
+
+//const QString xmlPath = "./resource/qt/plugins/stateplugins/"
+#ifdef Q_OS_SYMBIAN
+// const QString mockedStatePluginsXml = "mockstateplugins.s60xml";
+#else
+// const QString mockedStatePluginsXml = "mockstateplugins.xml";
+#endif
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::testConstruction()
+{
+ CaTappHandler* tappHandler = new CaTappHandler();
+
+ QVERIFY(tappHandler);
+
+ delete tappHandler;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::testExecute()
+{
+ const TInt KAppUid(0x20022EF9); // contacts
+
+ CaTappHandler* tAppHandler = new CaTappHandler();
+
+ CaEntry* entry = new CaEntry();
+ entry->setAttribute("item:launchuri","appto://20022EF9?");
+ CWaitActive* wait = CWaitActive::NewL();
+
+ RWsSession wsSession;
+
+ CleanupClosePushL(wsSession);
+ User::LeaveIfError(wsSession.Connect());
+
+ TApaTaskList taskList(wsSession);
+ TApaTask taskBefore = taskList.FindApp(TUid::Uid(KAppUid));
+ if (taskBefore.Exists()) {
+ taskBefore.EndTask(); // close task if exists
+ }
+
+ tAppHandler->execute(*entry, QString("open")); // run task
+ wait->Wait(15000000);
+
+ TApaTask taskAfter = taskList.FindApp(TUid::Uid(KAppUid));
+
+ QVERIFY(taskAfter.Exists());
+ taskAfter.EndTask();
+ CleanupStack::PopAndDestroy(&wsSession);
+ delete wait;
+ delete entry;
+ delete tAppHandler;
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::tAppHandlerCreateInstance()
+{
+ QServiceManager serviceManager;
+ CaTappHandlerPlugin plugin;
+ QServiceFilter serviceFilter("com.nokia.homescreen.ICommandHandler");
+ serviceFilter.setCustomAttribute("entryTypeName", "templatedApplication");
+ QList<QServiceInterfaceDescriptor> serviceInterfaceDescriptorList =
+ serviceManager.findInterfaces(serviceFilter);
+ int len = serviceInterfaceDescriptorList.size();
+ QVERIFY(len>0);
+ QServiceInterfaceDescriptor serviceInterfaceDescriptor =
+ serviceInterfaceDescriptorList[0];
+ QScopedPointer<QObject> handler(plugin.createInstance(
+ serviceInterfaceDescriptor, NULL, NULL));
+ QVERIFY(!handler.isNull());
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::init()
+{
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::cleanup()
+{
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::initTestCase()
+{
+ QStringList pluginPaths;
+ QString xmlName("catapphandlerplugin.xml");
+
+ pluginPaths.append("c:/resource/qt/plugins/commandhandler");
+ pluginPaths.append("z:/resource/qt/plugins/commandhandler");
+
+ QServiceManager serviceManager;
+ foreach (QString path, pluginPaths) {
+ QApplication::addLibraryPath(path);
+ QDir dir(path);
+ if (dir.exists(xmlName)) {
+ serviceManager.addService(dir.absoluteFilePath(xmlName));
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CaTappHandlerPluginTest::cleanupTestCase()
+{
+
+}
+
+QTEST_MAIN(CaTappHandlerPluginTest)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2006 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 "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+{
+ CTimer::ConstructL();
+ iActiveScheduler = new (ELeave) CActiveSchedulerWait();
+}
+
+CWaitActive* CWaitActive::NewL()
+{
+ CWaitActive* self = new (ELeave) CWaitActive;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+}
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive() :
+ CTimer(EPriorityStandard)
+{
+ CActiveScheduler::Add(this);
+}
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+{
+ Cancel();
+ delete iActiveScheduler;
+}
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+{
+ After(anInterval);
+ iActiveScheduler->Start();
+
+}
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+{
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/t_catapphandler.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 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:
+#
+
+#Header files
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+ ../../../../caclient/inc/cahandler.h
+
+#Source files
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/tapp/tsrc/t_catapphandler/t_catapphandler.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,67 @@
+# Copyright (c) 2009 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:
+TEMPLATE = app
+
+CONFIG += hb mobility
+MOBILITY = serviceframework
+HB = hbcore
+
+include(../../../../../common.pri)
+CONFIG(debug, debug|release):DESTDIR = debug
+else:DESTDIR = release
+CONFIG += debug_and_release \
+ console
+QT += testlib
+coverage:DEFINES += COVERAGE_MEASUREMENT
+DEPENDPATH += . \
+ ./inc \
+ ./src \
+ ../../inc \
+ ../../src \
+ ../../../../caclient/inc
+INCLUDEPATH += ./inc \
+ ../../inc \
+ ../../../inc \
+ ../../../../caclient/s60/inc \
+ ../../../../cautils/inc \
+ ../../../../caclient/inc \
+ ../../../caclient/inc \
+ ../../caclient/inc
+include(t_catapphandler.pri)
+LIBS += -lxqservice \
+ -lcautils \
+ -lws32 \
+ -lapgrfx \
+ -lcaclient
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20028714
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+}
--- a/contentstorage/cahandler/url/resource/caurlhandlerplugin.xml Thu Sep 02 20:45:03 2010 +0300
+++ b/contentstorage/cahandler/url/resource/caurlhandlerplugin.xml Thu Sep 16 12:11:40 2010 +0100
@@ -10,4 +10,4 @@
<capabilities></capabilities>
<customproperty key="entryTypeName">url</customproperty>
</interface>
-</service>
+</service>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/inc/T_caurlhandlerplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_cahandler.h
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+#ifndef T_CAURLHANDLERPLUGIN_H
+#define T_CAURLHANDLERPLUGIN_H
+
+class CaUrlHandler;
+
+#include <e32def.h>
+#include <QtTest/QtTest>
+
+/**
+ *
+ * Test class.
+ *
+ */
+class T_CaUrlHandler: public QObject
+{
+ Q_OBJECT
+public:
+ T_CaUrlHandler();
+private slots:
+
+ //setup methods
+ void cleanup();
+ void initTestCase();
+
+ void urlHandlerConstruction();
+ void urlHandlerMultipleLoad();
+ void urlHandlerMultipleLoadAndDelete();
+ void urlHandlerOpenFails();
+ /* uncomment and check test when browser is in TB10.1 platfrom */
+ void urlHandlerRunApplication();
+ void urlHandlerCreateInstance();
+
+private:
+ CaUrlHandler *iUrlHandler;
+};
+
+#endif // T_CAURLHANDLERPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2006 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: Plugin Interface
+*
+*/
+
+
+#ifndef C_WAITACTIVE_H
+#define C_WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // C_WAITACTIVE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_caurlhandler_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/src/T_caurlhandlerplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,266 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_caapphandlerplugin.cpp
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+// for CleanupResetAndDestroyPushL
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <w32std.h>
+#include <apgtask.h>
+#include <apgcli.h>
+#include <qservicemanager.h>
+
+#include <cadef.h>
+
+#include "T_caurlhandlerplugin.h"
+#include "waitactive.h"
+#include "caurlhandler.h"
+#include "caurlhandlerplugin.h"
+#include "caentry.h"
+
+QTM_USE_NAMESPACE
+
+const TInt KBrowserUid = { 0x10008D39 };
+static const char caUrlAddress[] = "http://www.nokia.com";
+static const char caTypeUrl[] = "url";
+static const char caAttrUrl[] = "url";
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+T_CaUrlHandler::T_CaUrlHandler():
+ iUrlHandler(NULL)
+{
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::cleanup()
+{
+ delete iUrlHandler;
+ iUrlHandler = NULL;
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::initTestCase()
+{
+ QStringList pluginPaths;
+ QString xmlName("caurlhandlerplugin.xml");
+
+ pluginPaths.append("c:/resource/qt/plugins/commandhandler");
+ pluginPaths.append("z:/resource/qt/plugins/commandhandler");
+
+ QServiceManager serviceManager;
+ foreach (QString path, pluginPaths) {
+ QApplication::addLibraryPath(path);
+ QDir dir(path);
+ if (dir.exists(xmlName)) {
+ serviceManager.addService(dir.absoluteFilePath(xmlName));
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::urlHandlerConstruction()
+{
+ delete iUrlHandler;
+ iUrlHandler = NULL;
+ TInt error = KErrNone;
+ QT_TRYCATCH_ERROR(error, iUrlHandler = new CaUrlHandler());
+ QCOMPARE(error, KErrNone);
+ QVERIFY(iUrlHandler);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::urlHandlerMultipleLoad()
+{
+ RPointerArray<CaUrlHandler> handlerArray;
+ bool foundNull(false);
+ TRAPD(err,
+ CleanupResetAndDestroyPushL(handlerArray);
+ for (TInt i(0); i < 10; ++i) {
+ handlerArray.AppendL(
+ new CaUrlHandler());
+ if (handlerArray[i] == NULL) {
+ foundNull = true;
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy(&handlerArray);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(!foundNull);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::urlHandlerMultipleLoadAndDelete()
+{
+ bool foundNull(false);
+ CaUrlHandler *handlerPtr(NULL);
+ for (TInt i(0); i < 10; ++i) {
+ handlerPtr = new CaUrlHandler();
+ if (handlerPtr == NULL) {
+ foundNull = true;
+ break;
+ };
+ delete handlerPtr;
+ handlerPtr = NULL;
+ }
+ QVERIFY(!foundNull);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::urlHandlerOpenFails()
+{
+ urlHandlerConstruction();
+ TInt errorUnsupportedCommand(KErrNone);
+ TInt errorOpen(KErrNone);
+ bool notStarted(false);
+
+ RWsSession wsSession;
+ TRAPD(err,
+ CleanupClosePushL(wsSession);
+ User::LeaveIfError(wsSession.Connect());
+
+ TApaTaskList taskList(wsSession);
+ TApaTask taskBefore = taskList.FindApp(TUid::Uid(KBrowserUid));
+
+ if (taskBefore.Exists()) {
+ taskBefore.EndTask();
+ }
+
+ CaEntry *entry = new CaEntry();
+
+ // valid entry type name
+ entry->setEntryTypeName(caTypeUrl);
+
+ //invalid command name
+ errorUnsupportedCommand = iUrlHandler->execute(
+ *entry, "unsupported_command_name");
+
+ // no attribute
+ errorOpen = iUrlHandler->execute(*entry, caCmdOpen);
+ QTest::qWait(3000);
+
+
+ TApaTask taskAfter = taskList.FindApp(TUid::Uid(KBrowserUid));
+ notStarted = !taskAfter.Exists();
+
+ delete entry;
+ entry = NULL;
+ CleanupStack::PopAndDestroy(&wsSession);
+ );
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(errorUnsupportedCommand, errorUnsupportedCommand);
+ //QCOMPARE(errorUnsupportedCommand, KErrNotSupported);
+ QVERIFY(notStarted);
+ QCOMPARE(errorOpen, KErrGeneral);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+/* uncomment and check test when browser is in TB10.1 platfrom */
+void T_CaUrlHandler::urlHandlerRunApplication()
+{
+ urlHandlerConstruction();
+
+ TInt errorOpen(KErrNone);
+ bool started(false);
+ TRAPD(err,
+ CaEntry *entry = new CaEntry();
+
+ RWsSession wsSession;
+ CleanupClosePushL(wsSession);
+ User::LeaveIfError(wsSession.Connect());
+
+ TApaTaskList taskList(wsSession);
+ TApaTask taskBefore = taskList.FindApp(TUid::Uid(KBrowserUid));
+
+ if (taskBefore.Exists()) {
+ taskBefore.EndTask();
+ }
+
+ // valid data needed to launch url
+ entry->setEntryTypeName(caTypeUrl);
+ entry->setAttribute(caAttrUrl,caUrlAddress);
+
+ errorOpen = iUrlHandler->execute(*entry, caCmdOpen);
+ QTest::qWait(3000);
+
+ TApaTask taskAfter = taskList.FindApp(TUid::Uid(KBrowserUid));
+ started = taskAfter.Exists();
+ taskAfter.EndTask();
+
+ delete entry;
+ entry = NULL;
+ CleanupStack::PopAndDestroy(&wsSession);
+ );
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(errorOpen, KErrNone);
+ //QEXPECT_FAIL("", "No web browser now, so the check for running browser is expect to fail.\n"
+ // "Ensure once the browser is available this failure expectation is removed.",
+ // Continue);
+ QVERIFY(started);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaUrlHandler::urlHandlerCreateInstance()
+{
+ QServiceManager serviceManager;
+ CaUrlHandlerPlugin plugin;
+ QServiceFilter serviceFilter("com.nokia.homescreen.ICommandHandler");
+ serviceFilter.setCustomAttribute("entryTypeName", "application");
+ QList<QServiceInterfaceDescriptor> serviceInterfaceDescriptorList =
+ serviceManager.findInterfaces(serviceFilter);
+ int len = serviceInterfaceDescriptorList.size();
+ QVERIFY(len>0);
+ QServiceInterfaceDescriptor serviceInterfaceDescriptor =
+ serviceInterfaceDescriptorList[0];
+ QObject *handler = plugin.createInstance(
+ serviceInterfaceDescriptor, NULL, NULL);
+ QVERIFY(handler);
+ delete handler;
+}
+
+QTEST_MAIN(T_CaUrlHandler)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006 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 "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/t_caurlhandler.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ./../../inc/*.h
+
+SOURCES += ./src/*.cpp \
+ ./../../src/*.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/cahandler/url/tsrc/t_caurlhandler/t_caurlhandler.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,88 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+CONFIG += hb mobility
+MOBILITY = serviceframework
+HB = hbcore
+
+include(../../../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src \
+ ../../inc \
+ ../../src
+
+INCLUDEPATH += ./inc \
+ ../../../../inc \
+ ../../../../cautils/inc \
+ ../../../../castorage/inc \
+ ../../../../caclient/inc \
+ ../../cahandler/url/inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_caurlhandler.pri)
+
+symbian: {
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x2002DCF1
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lecom \
+ -lcautils \
+ -lapgrfx \
+ -lws32 \
+ -lapparc \
+ -lsisregistryclient \
+ -lxqutils \
+ -lcaclient
+
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/camificonengine/tsrc/t_camificonengine/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
Binary file contentstorage/camificonengine/tsrc/t_camificonengine/data/example.mbm has changed
Binary file contentstorage/camificonengine/tsrc/t_camificonengine/data/example.mif has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/camificonengine/tsrc/t_camificonengine/inc/T_camificonengine.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_camificonengine.h
+ *
+ * Created on: 2010-08-10
+ * Author:
+ */
+
+#ifndef T_CAMIFICONENGINE_H
+#define T_CAMIFICONENGINE_H
+
+#include <QtTest/QtTest>
+
+//------------------------------------------------------------------------------
+
+
+/**
+ *
+ * Test class.
+ *
+ */
+class T_CaMifIconEngine: public QObject
+{
+ Q_OBJECT
+private slots:
+
+ void initEngine();
+ void mifIconKey();
+ void mbmIconKey();
+ void mifIconAddFile();
+ void mbmIconAddFile();
+ void mifIconPixmap();
+ void mbmIconPixmap();
+};
+
+#endif // T_CAMIFICONENGINE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/camificonengine/tsrc/t_camificonengine/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_camificonengine_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\sis\rd.cer -key ..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/camificonengine/tsrc/t_camificonengine/src/T_camificonengine.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,150 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_camificonengine.cpp
+ *
+ * Created on: 2010-08-10
+ * Author:
+ */
+
+// CLASS HEADERS
+
+#include <QPainter>
+#include <QIconEnginePlugin>
+
+#include "T_camificonengine.h"
+#include "camificonengine.h"
+#include "cambmiconengine.h"
+
+class CaMifIconPlugin : public QIconEnginePluginV2
+{
+public:
+ QStringList keys() const;
+ QIconEngineV2 *create(const QString &filename = QString());
+};
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::initEngine()
+{
+ CaMifIconPlugin plugin;
+ QStringList keys;
+ keys << "mif" << "mbm";
+ QVERIFY(plugin.keys() == keys);
+ QIconEngineV2 *engine =
+ plugin.create("c:/testing/data/t_camificonengine/example.mbm");
+ QVERIFY(engine);
+ delete engine;
+ engine = NULL;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::mifIconKey()
+{
+ CaMifIconEngine engine;
+ QCOMPARE(engine.key(), QString("mif"));
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::mbmIconKey()
+{
+ CaMbmIconEngine engine;
+ QCOMPARE(engine.key(), QString("mbm"));
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::mifIconAddFile()
+{
+ CaMifIconEngine engine;
+ QSize testSize(1, 1);
+ engine.addFile("c:/testing/data/t_camificonengine/example.mif",
+ testSize, QIcon::Normal, QIcon::On);
+ engine.addFile("not important", testSize, QIcon::Normal, QIcon::On);
+ QSize size = engine.actualSize(testSize, QIcon::Normal, QIcon::On);
+ QVERIFY(size == testSize);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::mbmIconAddFile()
+{
+ CaMbmIconEngine engine;
+ QSize testSize(1, 1);
+ engine.addFile("c:/testing/data/t_camificonengine/example.mbm",
+ testSize, QIcon::Normal, QIcon::On);
+ engine.addFile("not important", testSize, QIcon::Normal, QIcon::On);
+ QSize size = engine.actualSize(testSize, QIcon::Normal, QIcon::On);
+ QVERIFY(size == testSize);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::mifIconPixmap()
+{
+ CaMifIconEngine engine;
+ QSize testSize(1, 1);
+ engine.addFile("c:/testing/data/t_camificonengine/example.mif",
+ testSize, QIcon::Normal, QIcon::On);
+ QPixmap pixmap = engine.pixmap(testSize, QIcon::Normal, QIcon::On);
+ QSize size = pixmap.size();
+ QVERIFY(size.width()>0);
+ QVERIFY(size.height()>0);
+ engine.addPixmap(pixmap, QIcon::Normal, QIcon::On);
+ QPainter painter;
+ engine.paint(&painter, QRect(QPoint(0, 0), size),
+ QIcon::Normal, QIcon::On);
+ QIconEngineV2 *clonedEngine = engine.clone();
+ QVERIFY(size ==
+ clonedEngine->pixmap(testSize, QIcon::Normal, QIcon::On).size());
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaMifIconEngine::mbmIconPixmap()
+{
+ CaMbmIconEngine engine;
+ QSize testSize(1, 1);
+ engine.addFile("c:/testing/data/t_camificonengine/example.mbm",
+ testSize, QIcon::Normal, QIcon::On);
+ QPixmap pixmap = engine.pixmap(testSize, QIcon::Normal, QIcon::On);
+ QSize size = pixmap.size();
+ QVERIFY(size.width()>0);
+ QVERIFY(size.height()>0);
+ engine.addPixmap(pixmap, QIcon::Normal, QIcon::On);
+ QPainter painter;
+ engine.paint(&painter, QRect(QPoint(0, 0), size),
+ QIcon::Normal, QIcon::On);
+ QIconEngineV2 *clonedEngine = engine.clone();
+ QVERIFY(size ==
+ clonedEngine->pixmap(testSize, QIcon::Normal, QIcon::On).size());
+}
+
+QTEST_MAIN(T_CaMifIconEngine)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/camificonengine/tsrc/t_camificonengine/t_camificonengine.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ./../../inc/*.h
+
+SOURCES += ./src/*.cpp \
+ ./../../src/*.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/camificonengine/tsrc/t_camificonengine/t_camificonengine.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,84 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+CONFIG += hb mobility
+MOBILITY = serviceframework
+HB = hbcore
+
+include(../../../../common.pri)
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src \
+ ../../inc \
+ ../../src
+
+INCLUDEPATH += \
+ ./inc \
+ ../../inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_camificonengine.pri)
+
+symbian: {
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20028711
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lcamificon \
+ -laknicon \
+ -lavkon
+
+ BLD_INF_RULES.prj_testexports += "./data/example.mif c:/testing/data/t_camificonengine/" \
+ "./data/example.mbm c:/testing/data/t_camificonengine/"
+ BLD_INF_RULES.prj_exports += "./data/example.mif c:/testing/data/t_camificonengine/" \
+ "./data/example.mbm c:/testing/data/t_camificonengine/"
+
+ exportArm.sources += ./data/example.mif \
+ ./data/example.mbm
+ exportArm.path = c:/testing/data/t_camificonengine
+ DEPLOYMENT += exportArm
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/data/MIDPTestIcons.jad Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+MIDlet-1: Icon PNG, /Duke.png, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-10: Icon WMF, /AN04369_.WMF, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-11: Icon WMF2, /TR00232_.WMF, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-12: Icon WBMP, /happy.wbmp, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-2: Icon GIF, /gs_98x98.gif, com.nokia.midp.test.midptest.NoUIMIDlet
+MIDlet-3: Icon GIF2, /gs_16x16.gif, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-4: Icon BMP, /logo.bmp, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-5: Icon JPG, /j_131x155.jpg, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-6: Icon JPG2, /j_29x29.jpg, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-7: Icon MNG, /DUTCH1.mng, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-8: Icon TIF, /Sample_UPC_TIF.tif, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-9: Icon ICO, /favicon.ico, com.nokia.midp.test.midptest.MIDPTest
+MIDlet-Data-Size: 0
+MIDlet-Delete-Confirm: This is delete confirm text....
+MIDlet-Description: Testing support for several icon formats
+MIDlet-Icon: /Duke.png
+MIDlet-Jar-Size: 174409
+MIDlet-Jar-URL: MIDPTestIcons.jar
+MIDlet-Name: MIDP Test Icon
+MIDlet-Vendor: Nokia - OMJ Testing
+MIDlet-Version: 3.91.2
+MicroEdition-Configuration: CLDC-1.0
+MicroEdition-Profile: MIDP-1.0
+Nokia-MIDlet-no-exit: true
+UserDefined1: Foo value
Binary file contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/data/MIDPTestIcons.jar has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,54 @@
+#
+# Copyright (c) 2010 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+system("call qmake -config coverage");
+system("call sbs clean -c winscw_udeb");
+system("call sbs clean -c winscw_udeb.test");
+system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../../src/*\" sbs -j 4 -c winscw_udeb");
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_casoftwareregistry.exe -o c:\\t_casoftwareregistry.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/inc/t_casoftwareregistry.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef T_CA_SERVICE_REGISTRY_H
+#define T_CA_SERVICE_REGISTRY_H
+
+#include <QtTest/QtTest>
+#include "casoftwareregistry.h"
+
+/**
+ *
+ * Test class.
+ *
+ */
+class T_CaSoftwareRegistry: public QObject
+{
+ Q_OBJECT
+public:
+ T_CaSoftwareRegistry();
+private slots:
+
+ //setup methods
+ void initTestCase();
+ void cleanup();
+
+ void testSoftwareRegistryCreate();
+#ifdef Q_OS_SYMBIAN
+ void testExtractingDetailsFromEntry();
+ void testExtractingDetailsFromJavaEntry();
+ void testUninstallDetails();
+ void testGetLogEntries();
+ void testApplicationsUids();
+ // tests for caprogressscanner
+ void testProgresScannerNew();
+ void testProgressStartOperationHandler();
+ void testProgressProgressOperationHandler();
+ void testProgressEndOperationHandler();
+ void testCreateUninstallNotifier();
+#endif
+ void testEntryDetails();
+
+ void testUninstallDetailsBadComponentId();
+
+private:
+ QSharedPointer<CaSoftwareRegistry> mSoftwareRegistry;
+};
+
+#endif // T_CA_SERVICE_REGISTRY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_casoftwareregistry_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\sis\rd.cer -key ..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/src/t_caprogresscaner.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2010 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 "caprogresscanner.h"
+#include "cauninstallobserver.h"
+#include "t_casoftwareregistry.h"
+
+#ifdef Q_OS_SYMBIAN
+#include <e32base.h>
+#include <e32def.h>
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <usif/scr/scr.h>
+#include <usif/scr/screntries.h>
+
+#include <xqconversions.h>
+using namespace Usif;
+#include <caarraycleanup.inl>
+#endif
+
+
+
+#ifdef Q_OS_SYMBIAN
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testProgresScannerNew()
+ {
+ bool result(false);
+ CaUninstallObserver* uninstallObserver = new CaUninstallObserver();
+ TRAPD(err,
+ CCaProgresScanner *progresScanner =
+ CCaProgresScanner::NewL(uninstallObserver);
+ result = progresScanner != NULL;
+ delete progresScanner;
+ );
+ delete uninstallObserver;
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testProgressStartOperationHandler()
+ {
+ TInt err( KErrNone );
+
+ _LIT(KGlobalCompId, "abc");
+ _LIT(KComponentName, "compName");
+ _LIT(KIconPath, "iconPath");
+ _LIT(KComponentIcon, "iconName");
+ _LIT(KSoftwareType, "Native");
+
+ TUint key = 123456;
+ TPtrC globalCompId(KGlobalCompId);
+ TPtrC compName(KComponentName);
+ TPtrC iconPath(KIconPath);
+ TPtrC compIcon(KComponentIcon);
+ TPtrC softwareType(KSoftwareType);
+ TSifOperationPhase operationPhase = TSifOperationPhase(EInstalling);
+
+ TInt compSize = 0;
+ RPointerArray<HBufC> appNameArray;
+ CleanupResetAndDestroyPushL(appNameArray);
+ RPointerArray<HBufC> appIconArray;
+ CleanupResetAndDestroyPushL(appIconArray);
+ CSifOperationStartData* startdata = CSifOperationStartData::NewLC(
+ globalCompId, compName, appNameArray, appIconArray,
+ compSize, iconPath, compIcon, softwareType, operationPhase);
+ CaUninstallObserver* uninstallObserver = new CaUninstallObserver();
+ CCaProgresScanner *progresScanner =
+ CCaProgresScanner::NewL(uninstallObserver);
+
+ TRAP(err, progresScanner->StartOperationHandler(key, *startdata));
+ delete uninstallObserver;
+ delete progresScanner;
+ CleanupStack::PopAndDestroy(3, &appNameArray);
+ QCOMPARE(err, KErrNone);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testProgressProgressOperationHandler()
+ {
+ TInt err( KErrNone );
+
+ _LIT(KGlobalCompId, "abc");
+
+ TPtrC globalCompIdProgress(KGlobalCompId);
+ TInt phase=0, subPhase=0, curProgress=0, total=0;
+
+ TSifOperationPhase enumPhase = static_cast<TSifOperationPhase>(phase);
+ TSifOperationSubPhase enumSubPhase = static_cast<TSifOperationSubPhase>(subPhase);
+ CaUninstallObserver* uninstallObserver = new CaUninstallObserver();
+ CSifOperationProgressData* progressdata = CSifOperationProgressData::NewLC(
+ globalCompIdProgress, enumPhase, enumSubPhase, curProgress, total);
+
+ CCaProgresScanner *progresScanner =
+ CCaProgresScanner::NewL(uninstallObserver);
+
+ TRAP(err, progresScanner->ProgressOperationHandler( *progressdata));
+ delete uninstallObserver;
+ delete progresScanner;
+ CleanupStack::PopAndDestroy(progressdata);
+ QCOMPARE(err, KErrNone);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testProgressEndOperationHandler()
+ {
+ TInt err( KErrNone );
+ _LIT(KGlobalCompId, "abc");
+ _LIT(KErrMsg, "errMsg");
+ _LIT(KErrMsgDetails, "errMsgDetails");
+
+ TPtrC errMsg(KErrMsg), errMsgDetails(KErrMsgDetails);
+ TInt errCat(0), errCode(0);
+ TPtrC globalCompIdEnd(KGlobalCompId);
+
+ TErrorCategory enumErrCat = static_cast<TErrorCategory>(errCat);
+ CSifOperationEndData* enddata = CSifOperationEndData::NewLC(
+ globalCompIdEnd, enumErrCat, errCode, errMsg, errMsgDetails);
+
+ CaUninstallObserver* uninstallObserver = new CaUninstallObserver();
+ CCaProgresScanner *progresScanner =
+ CCaProgresScanner::NewL(uninstallObserver);
+ TRAP(err, progresScanner->EndOperationHandler( *enddata ));
+ delete uninstallObserver;
+ delete progresScanner;
+ QCOMPARE(err, KErrNone);
+ CleanupStack::PopAndDestroy(enddata);
+ }
+
+#endif // Q_OS_SYMBIAN
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/src/t_casoftwareregistry.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,468 @@
+/*
+* Copyright (c) 2010 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 <HbParameterLengthLimiter>
+#include <HbExtendedLocale>
+#include "casoftwareregistry.h"
+#include "casoftwareregistry_p.h"
+
+#include "t_casoftwareregistry.h"
+
+#ifdef Q_OS_SYMBIAN
+#include <e32base.h>
+#include <e32def.h>
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <usif/scr/scr.h>
+#include <usif/scr/screntries.h>
+
+#include <usif/sif/sif.h>
+#include <usif/scr/scr.h>
+
+#include <xqconversions.h>
+using namespace Usif;
+#include <caarraycleanup.inl>
+#endif
+
+T_CaSoftwareRegistry::T_CaSoftwareRegistry():
+ mSoftwareRegistry(NULL)
+{
+}
+
+void T_CaSoftwareRegistry::cleanup()
+{
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::initTestCase()
+{
+
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testSoftwareRegistryCreate()
+{
+
+ QVERIFY(CaSoftwareRegistry::create());
+ QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
+ QVERIFY(CaSoftwareRegistry::create().data() == scr.data());
+}
+
+#ifdef Q_OS_SYMBIAN
+
+void T_CaSoftwareRegistry::testExtractingDetailsFromEntry()
+{
+ // set up expexted values..
+ _LIT(KName, "appname");
+ _LIT(KVendor, "xxx");
+
+ TDriveList installedDrives;
+
+ QString expectedDrives;
+
+ const TInt driveListLen(installedDrives.Length());
+ for (TInt i( 0 ); i < driveListLen; ++i) {
+ if (i == 3 || i == 4) {
+ installedDrives[i] = '\1';
+ expectedDrives = expectedDrives.append(QChar('A'+ i)).append(":");
+ } else {
+ installedDrives[i] = '\0';
+ }
+ }
+
+ _LIT(KVersion, "ver 1.1");
+ _LIT(KSwType, "software type");
+ const TInt64 KSize = 2048; // i.e 2k
+
+ // definition below are provided just to satisfy CComponentEntry::NewL
+ _LIT(KGlobalId, "");
+ TBool KRemovable(EFalse);
+ TScomoState KScomoState;
+ TComponentId KId;
+ _LIT(KInstallTime, "");
+ TBool KDrmProtected(EFalse);
+ TBool KHidden(EFalse);
+ TBool KKnownRevoked(EFalse);
+ TBool KOriginVerified(EFalse);
+
+
+ QScopedPointer<CComponentEntry> entry;
+
+ QT_TRAP_THROWING(entry.reset(
+ CComponentEntry::NewL(
+ KId,
+ KName,
+ KVendor,
+ KSwType,
+ KGlobalId,
+ KRemovable,
+ KSize,
+ KScomoState,
+ installedDrives,
+ KVersion,
+ KInstallTime,
+ KDrmProtected,
+ KHidden,
+ KKnownRevoked,
+ KOriginVerified)
+ )
+ );
+
+ CaSoftwareRegistryPrivate scr(NULL);
+ CaSoftwareRegistry::DetailMap detailMap = scr.entryDetailsL(*entry);
+
+ QCOMPARE(detailMap.size(), 6);
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentNameKey()],
+ XQConversions::s60DescToQString(KName));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentVersionKey()],
+ XQConversions::s60DescToQString(KVersion));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentVendorKey()],
+ XQConversions::s60DescToQString(KVendor));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentDriveInfoKey()],
+ expectedDrives);
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentSizeKey()],
+ QString(HbParameterLengthLimiter("txt_applib_dialog_l1_kb")
+ .arg(QString().setNum(static_cast<double>(KSize / 1024)))));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentTypeKey()],
+ XQConversions::s60DescToQString(KSwType));
+
+ for (TInt i( 0 ); i < driveListLen; ++i) {
+ installedDrives[i]= '\0';
+ }
+
+ QT_TRAP_THROWING(entry.reset(
+ CComponentEntry::NewL(
+ KId,
+ _L(""), // name
+ _L(""), // vendor
+ _L(""), // sw type
+ KGlobalId,
+ KRemovable,
+ 0, // size
+ KScomoState,
+ installedDrives,
+ _L(""), // version
+ KInstallTime,
+ KDrmProtected,
+ KHidden,
+ KKnownRevoked,
+ KOriginVerified)
+ )
+ );
+
+ detailMap = scr.entryDetailsL(*entry);
+
+ QCOMPARE(detailMap.size(), 6);
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentNameKey()],
+ QString(""));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentVersionKey()],
+ QString(""));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentVendorKey()],
+ QString(""));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentDriveInfoKey()],
+ QString(""));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentSizeKey()],
+ QString(HbParameterLengthLimiter("txt_applib_dialog_l1_kb")
+ .arg(QString().setNum(
+ static_cast<double>(0)))));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentTypeKey()],
+ QString(""));
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testExtractingDetailsFromJavaEntry()
+{
+ static const int javaUid = 270026627;
+
+ Usif::RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect() );
+
+ // Install the component
+ _LIT16( KMIDPTestIconsJadPath, "c:\\testing\\data\\t_casoftwareregistry\\installs\\MIDPTestIcons.jad" );
+ Usif::COpaqueNamedParams* arguments = NULL;
+ Usif::COpaqueNamedParams* results = NULL;
+ arguments = Usif::COpaqueNamedParams::NewLC();
+ results = Usif::COpaqueNamedParams::NewLC();
+ arguments->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
+ TRequestStatus status;
+ sif.Install( KMIDPTestIconsJadPath, *arguments, *results, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError( status.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+
+ int componentId(0);
+ TRAPD(err,
+ RSoftwareComponentRegistry scr;
+ CleanupClosePushL(scr);
+ User::LeaveIfError(scr.Connect());
+ componentId = scr.GetComponentIdForAppL(TUid::Uid(javaUid));
+ CleanupStack::PopAndDestroy(&scr);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(componentId != 0);
+
+ QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
+ CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId);
+
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentTypeKey()],
+ QString("java"));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentProtectionDomainKey()],
+ QString("txt_java_inst_setlabel_cert_domain_val_untrusted_third_party,javaapplicationinstaller"));
+ QCOMPARE(detailMap[CaSoftwareRegistry::componentDescriptionKey()],
+ QString("Testing support for several icon formats"));
+
+ TComponentId localComponentId( componentId );
+ results = Usif::COpaqueNamedParams::NewLC();
+ TRequestStatus status2;
+ sif.Uninstall( localComponentId, *arguments, *results, status2 );
+ User::WaitForRequest( status2 );
+ User::LeaveIfError( status2.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+ CleanupStack::PopAndDestroy( arguments );
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testUninstallDetails()
+{
+ static const int javaUid = 270026627;
+
+ Usif::RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect() );
+
+ // Install the component
+ _LIT16( KMIDPTestIconsJadPath, "c:\\testing\\data\\t_casoftwareregistry\\installs\\MIDPTestIcons.jad" );
+ Usif::COpaqueNamedParams* arguments = NULL;
+ Usif::COpaqueNamedParams* results = NULL;
+ arguments = Usif::COpaqueNamedParams::NewLC();
+ results = Usif::COpaqueNamedParams::NewLC();
+ arguments->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
+ TRequestStatus status;
+ sif.Install( KMIDPTestIconsJadPath, *arguments, *results, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError( status.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+
+ QSharedPointer<CaSoftwareRegistry> registry = CaSoftwareRegistry::create();
+ QVERIFY(registry);
+ QString componentName;
+ QStringList appUids;
+ QString confirmationMessage;
+ int componentId(0);
+ TRAPD(err,
+ RSoftwareComponentRegistry scr;
+ CleanupClosePushL(scr);
+ User::LeaveIfError(scr.Connect());
+ componentId = scr.GetComponentIdForAppL(TUid::Uid(javaUid));
+ CleanupStack::PopAndDestroy(&scr);
+ );
+ QCOMPARE(err, KErrNone);
+ bool success = registry->getUninstallDetails(
+ componentId, componentName, appUids, confirmationMessage);
+ QVERIFY(success);
+ QCOMPARE(componentName, QString("MIDP Test Icon"));
+ QCOMPARE(confirmationMessage, QString("This is delete confirm text...."));
+ QCOMPARE(appUids.length(), 12);
+ QVERIFY(appUids.contains(QString::number(javaUid)));
+
+ TComponentId localComponentId( componentId );
+ results = Usif::COpaqueNamedParams::NewLC();
+ TRequestStatus status2;
+ sif.Uninstall( localComponentId, *arguments, *results, status2 );
+ User::WaitForRequest( status2 );
+ User::LeaveIfError( status2.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+ CleanupStack::PopAndDestroy( arguments );
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testGetLogEntries()
+{
+ RSoftwareComponentRegistry scr;
+ CleanupClosePushL(scr);
+ User::LeaveIfError(scr.Connect());
+
+ RPointerArray<CScrLogEntry> logEntries;
+ CleanupResetAndDestroyPushL( logEntries );
+
+ scr.RetrieveLogEntriesL(logEntries);
+
+ QSharedPointer<CaSoftwareRegistry> registry
+ = CaSoftwareRegistry::create();
+ QList<CaSoftwareRegistry::DetailMap> logMap
+ = registry->retrieveLogEntries();
+ // 50 log items or less - ui spec
+ TInt lastLog(0);
+ const int maxLogsCount = 20;
+ if (logEntries.Count() > maxLogsCount) {
+ lastLog = logEntries.Count() - maxLogsCount;
+ }
+ // iteration through most recent log to the last
+ for (TInt i = logEntries.Count() - 1; i >= lastLog; i--) {
+ CScrLogEntry* entry = logEntries[i];
+ QString iComponentName = XQConversions::s60DescToQString(
+ entry->ComponentName());
+ QString iVersion = XQConversions::s60DescToQString(
+ entry->ComponentVersion());
+
+ TTime iRecordTime = entry->OperationTime();
+ TDateTime dt = iRecordTime.DateTime();
+ QDate date(dt.Year(), dt.Month()+1, dt.Day()+1);
+ HbExtendedLocale hbLoc;
+ QString strDateTime = hbLoc.format(date, r_qtn_date_usual_with_zero);
+
+ TScrComponentOperationType iOpType = entry->OperationType();
+ QString opType;
+ switch (iOpType) {
+ case EScrCompInstall:
+ opType = CaSoftwareRegistry::componentInstallValue();
+ break;
+ case EScrCompUnInstall:
+ opType = CaSoftwareRegistry::componentUninstallValue();
+ break;
+ case EScrCompUpgrade:
+ opType = CaSoftwareRegistry::componentUpgradeValue();
+ break;
+ case EScrCompHidden:
+ opType = CaSoftwareRegistry::componentHiddenValue();
+ break;
+ }
+
+ QCOMPARE(iComponentName,
+ logMap[(logEntries.Count() - 1) - i].value(CaSoftwareRegistry::componentNameKey()));
+ QCOMPARE(iVersion,
+ logMap[(logEntries.Count() - 1) - i].value(CaSoftwareRegistry::componentVersionKey()));
+ QCOMPARE(strDateTime,
+ logMap[(logEntries.Count() - 1) - i].value(CaSoftwareRegistry::componentTimeKey()));
+ QCOMPARE(opType,
+ logMap[(logEntries.Count() - 1) - i].value(
+ CaSoftwareRegistry::componentOperationTypeKey()));
+ }
+ CleanupStack::PopAndDestroy( &logEntries );
+ CleanupStack::PopAndDestroy(&scr);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSoftwareRegistry::testApplicationsUids()
+{
+ static const int javaUid = 270026627;
+
+ Usif::RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect() );
+
+ // Install the component
+ _LIT16( KMIDPTestIconsJadPath, "c:\\testing\\data\\t_casoftwareregistry\\installs\\MIDPTestIcons.jad" );
+ Usif::COpaqueNamedParams* arguments = NULL;
+ Usif::COpaqueNamedParams* results = NULL;
+ arguments = Usif::COpaqueNamedParams::NewLC();
+ results = Usif::COpaqueNamedParams::NewLC();
+ arguments->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
+ TRequestStatus status;
+ sif.Install( KMIDPTestIconsJadPath, *arguments, *results, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError( status.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+
+
+ QSharedPointer<CaSoftwareRegistry> registry = CaSoftwareRegistry::create();
+ QVERIFY(registry);
+ QStringList appUids;
+ int componentId(0);
+ TRAPD(err,
+ RSoftwareComponentRegistry scr;
+ CleanupClosePushL(scr);
+ User::LeaveIfError(scr.Connect());
+ componentId = scr.GetComponentIdForAppL(TUid::Uid(javaUid));
+ CleanupStack::PopAndDestroy(&scr);
+ );
+ QCOMPARE(err, KErrNone);
+ bool success = registry->getApplicationsUids(componentId, appUids);
+ QVERIFY(success);
+ QCOMPARE(appUids.length(), 12);
+ QVERIFY(appUids.contains(QString::number(javaUid)));
+
+ TComponentId localComponentId( componentId );
+ results = Usif::COpaqueNamedParams::NewLC();
+ TRequestStatus status2;
+ sif.Uninstall( localComponentId, *arguments, *results, status2 );
+ User::WaitForRequest( status2 );
+ User::LeaveIfError( status2.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+ CleanupStack::PopAndDestroy( arguments );
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+}
+
+#endif // Q_OS_SYMBIAN
+
+void T_CaSoftwareRegistry::testEntryDetails()
+{
+ const int componentId = 0; // not reffering to any application
+ QSharedPointer<CaSoftwareRegistry> scr = CaSoftwareRegistry::create();
+ CaSoftwareRegistry::DetailMap detailMap = scr->entryDetails(componentId);
+
+ QCOMPARE(detailMap, CaSoftwareRegistry::DetailMap());
+}
+
+void T_CaSoftwareRegistry::testUninstallDetailsBadComponentId()
+{
+ QSharedPointer<CaSoftwareRegistry> registry = CaSoftwareRegistry::create();
+ QVERIFY(registry);
+ QString componentName;
+ QStringList appUids;
+ QString confirmationMessage;
+ registry->getUninstallDetails(0, componentName, appUids, confirmationMessage);
+ QCOMPARE(componentName, QString());
+ QCOMPARE(confirmationMessage, QString());
+ QCOMPARE(appUids.length(), 0);
+}
+
+void T_CaSoftwareRegistry::testCreateUninstallNotifier()
+ {
+ CaUninstallNotifier* notifier = CaSoftwareRegistry::create()->createUninstallNotifier();
+ QVERIFY(notifier);
+ }
+QTEST_MAIN(T_CaSoftwareRegistry)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/t_casoftwareregistry.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2010 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:
+#
+
+HEADERS += ./inc/t_casoftwareregistry.h \
+ ../../../../homescreensrv_plat/contentstorage_api/casoftwareregistry.h \
+ ../../../../homescreensrv_plat/contentstorage_api/cauninstallnotifier.h
+SOURCES += ./src/*.cpp ../../src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/t_casoftwareregistry.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,99 @@
+# Copyright (c) 2010 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:
+
+
+TEMPLATE = app
+DEFINES += CACLIENT_TEST
+include(../../../../common.pri)
+
+CONFIG += hb
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src \
+ ../../inc \
+ ../../src \
+ ../../../../homescreensrv_plat/contentstorage_api
+
+INCLUDEPATH += ./inc \
+ ../../inc \
+ ../../../../homescreensrv_plat/contentstorage_api \
+ ../../../cautils/inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_casoftwareregistry.pri)
+
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x2002DCF6
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lscrclient \
+ -lbafl \
+ -lestor \
+ -lefsrv \
+ -lxqutils \
+ -lPlatformEnv \
+ -lsifnotification \
+ -lsif
+
+ BLD_INF_RULES.prj_testexports += "./data/MIDPTestIcons.jad c:/testing/data/t_casoftwareregistry/installs/" \
+ "./data/MIDPTestIcons.jar c:/testing/data/t_casoftwareregistry/installs/"
+
+ BLD_INF_RULES.prj_exports += "./data/MIDPTestIcons.jad c:/testing/data/t_casoftwareregistry/installs/" \
+ "./data/MIDPTestIcons.jar c:/testing/data/t_casoftwareregistry/installs/"
+
+ exportArmSis.sources += ./data/MIDPTestIcons.jad \
+ ./data/MIDPTestIcons.jar
+ exportArmSis.path = c:/testing/data/t_casoftwareregistry/installs
+ DEPLOYMENT += exportArmSis
+
+
+include (t_casoftwareregistry_s60.pri)
+}
+
+win32: {
+include (t_casoftwareregistry_stub.pri)
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/t_casoftwareregistry_s60.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2010 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:
+#
+DEPENDPATH += ../../s60/inc \
+ ../../s60/src
+INCLUDEPATH += ../../s60/inc
+HEADERS += ../../s60/inc/*.h
+SOURCES += ../../s60/src/*.cpp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry/t_casoftwareregistry_stub.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2010 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:
+#
+DEPENDPATH += ../../stub/inc \
+ ../../stub/src
+INCLUDEPATH += ../../stub/inc
+HEADERS += ../../stub/inc/*.h
+SOURCES += ../../stub/src/*.cpp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casoftwareregistry/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2010 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:
+#
+
+TEMPLATE = subdirs
+SUBDIRS = t_casoftwareregistry
+
+CONFIG += ordered
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/AccuWeather_W3C.wgt has changed
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/HelloWorld.jar has changed
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/SmokeTestUnsigned.wgt has changed
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/armv5/sapiapp_S60_3_X_v_1_0_0.sisx has changed
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/castorage.db has changed
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/mmchistory has changed
Binary file contentstorage/casrv/caappscanner/tsrc/t_caappscanner/data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE+../../src/*" -C "NO_EXCLUDE+../../../../srvsrc/cainstallnotifier.cpp" -C "NO_EXCLUDE+../../../../srvsrc/casrvmmchistory.cpp" -C "NO_EXCLUDE+../../../../cautils/src/cautils.cpp" abld build winscw udeb
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system('ctcwrap -i fd -2comp -C "EXCLUDE=*" -C "NO_EXCLUDE+../../src/*" -C "NO_EXCLUDE+../../../../srvsrc/cainstallnotifier.cpp" -C "NO_EXCLUDE+../../../../srvsrc/casrvmmchistory.cpp" -C "NO_EXCLUDE+../../../../cautils/src/cautils.cpp" sbs -j 4 -c winscw_udeb');
+
+ }
+
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_caappscanner -o c:\\t_caapscanner.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/inc/T_casrvAppScaner.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2009 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:
+ *
+ */
+
+#ifndef __T_casrvAppScaner_H__
+#define __T_casrvAppScaner_H__
+
+#include <QtTest/QtTest>
+
+#include "casrvplugin.h"
+#include "casrvmanager.h"
+
+// FORWARD DECLARATIONS
+class CTestUtils;
+class CCaStorageProxy;
+class CCaSrvEngUtils;
+namespace Usif{
+ class RSoftwareComponentRegistry;
+}
+
+#include <e32def.h>
+
+class T_CaInstaller;
+
+class T_casrvAppScaner : public QObject
+{
+ Q_OBJECT
+public:
+ T_casrvAppScaner();
+private slots:
+ void initTestCase();
+ void init();
+ void testNew();
+ void testHandler_LoadPlugin();
+ void testHandler_New();
+ void testUninstalled();
+ void testInstalled();
+ void testAddNewApp();
+ void testNoUpdate();
+ void testRemoveMmcApp();
+ void testRemoveMmcAttr();
+ void testRemoveMissingFlag();
+ void testRemoveMissingFlag01();
+ void testAddMissingFlag();
+ void testSatApp();
+ void testHsApp();
+ void testAddRemovable();
+ void testRemoveRemovable();
+ void testRunError();
+ void testInstallNotifier();
+ void testDownloadCollectionAdd();
+ void testDownloadCollectionUpdate();
+ void testDownloadCollectionRemove();
+ void testCreatePredefinedCollection();
+ void testGetAllCollectionIdL();
+ void testUpdateComponentIdL();
+ void testSave();
+ void testInsert();
+ void testSetCWRTAppL();
+ void testSetJavaAppL();
+ void cleanup();
+ void cleanupTestCase();
+private: // Data
+ //setup methods
+
+ void Setup_UninstalledL();
+ void Setup_AddNewAppL();
+ void Setup_NoUpdateL();
+ void Setup_RemoveMmcAppL();
+ void Setup_RemoveMmcAttrL();
+ void Setup_RemoveMissingFlagL();
+ void Setup_RemoveMissingFlag01L();
+ void Setup_AddMissingFlagL();
+ void Setup_SatAppL();
+ void Setup_HsAppL();
+ void Setup_AddRemovableL();
+ void Setup_RemoveRemovableL();
+
+
+ CTestUtils *iTestUtils;
+
+ CCaStorageProxy *iStorage;
+
+ CCaSrvEngUtils *iSrvEngUtils;
+
+ Usif::RSoftwareComponentRegistry *iScr;
+
+ T_CaInstaller *iInstaller;
+};
+
+#endif // __T_casrvAppScaner_H__
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/inc/casrvtestutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+//utility class for tests
+//all utility methods should be implemented here
+
+#include <usif/usifcommon.h>
+
+#include "casrvengutils.h"
+#include "casrvplugin.h"
+
+class CCaStorageProxy;
+class CCaInnerEntry;
+
+class CTestUtils: public CBase
+{
+public:
+
+ /**/
+ virtual ~CTestUtils();
+
+ /**/
+ static CTestUtils* NewL();
+
+ /**/
+ static CTestUtils* NewLC();
+
+ /**/
+ TUint FindAppUidL( const TDesC& aName, CCaStorageProxy* aStorage );
+
+ /**/
+ TInt LaunchApplicationL( const TUid aUid );
+
+ /**/
+ TInt SimpleCloseTaskL(TInt aUid);
+
+ /**/
+ void WaitL(TInt aMicroSec);
+
+ /**/
+ void InstallFinishedL();
+
+ /**
+ * Gets RProperty
+ */
+ TInt GetRProperty( TUid aCategory, TUint aKey, TDes& aValue );
+
+ /**
+ * Gets RProperty
+ */
+ TInt GetRProperty( TUid aCategory, TUint aKey, TInt& aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt SetRProperty( TUid aCategory, TUint aKey, const TDesC& aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt SetRProperty( TUid aCategory, TUint aKey, TInt aValue );
+
+ /**
+ * Copys test Db
+ */
+ TInt CopyDb();
+
+ /**
+ * Checks if app exists in Db
+ */
+ TBool AppExistsInStorageL( TInt aComponentId, CCaStorageProxy* aStorage);
+
+ TBool ComponentExistsInStorageL( Usif::TComponentId aComponentId,
+ CCaStorageProxy* aStorage);
+
+ CCaInnerEntry* GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage);
+
+ TInt AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage);
+
+ TInt GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage);
+
+ void RemoveAppL( TInt aUid, CCaStorageProxy* aStorage);
+ void CopyMmcHistory();
+
+ CCaSrvPlugin* LoadPluginL( TUid aImplUid, TPluginParams aPluginParams );
+
+private:
+
+ /**
+ * Copys files
+ */
+ TInt Copy( const TDesC& aSource, const TDesC& aDest );
+
+ CTestUtils();
+
+ void ConstructL();
+
+ RFs iFs;
+ CFileMan* iFileManager;
+
+ /**
+ * Local Active Sheduler.
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveWait;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/inc/testconsts.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * testconsts.h
+ *
+ * Created on: 2009-08-24
+ *
+ */
+
+#ifndef TESTCONSTS_H_
+#define TESTCONSTS_H_
+
+// CONSTANTS
+
+//test utils
+
+_LIT(KTestDbSource, "C:\\testing\\data\\t_caappscanner\\castorage.db");
+_LIT(KTestDbDest, "C:\\castorage.db");
+
+_LIT(KTestMmcHistSource, "C:\\testing\\data\\t_caappscanner\\mmchistory");
+_LIT(KTestMmcHistDest, "C:\\private\\2002870E\\mmchistory");
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+
+
+//app scanner
+const TInt noteApp = 0xA0000230;
+const TInt notInstalledUid = 0xA0000232;// uid of not installed app
+const TInt installedUid = 0xE6BC1167; // installed app
+const TInt systemApp = 0x20022EF9;
+
+_LIT( KMmcIdValue, "00000001" );
+
+_LIT( KSapiAppFileName, "c:\\sys\\bin\\sapiapp.exe");
+
+
+_LIT( KSapiPackageFileName, "c:\\testing\\data\\t_caappscanner\\installs\\sapiapp_S60_3_X_v_1_0_0.sisx" );
+
+_LIT( KWRTMiniViewAppId, "940bed665487f773b39481523f200e54cd589764" );
+_LIT( KWRTAppId, "aaf1aaa161de8b76dc2f00a7884c10b6def6b2b1" );
+_LIT( KWrtMiniViewAppName, "AccuWeather-W3C" );
+_LIT( KWrtAppName, "UnsignedSmokeTestWGT" );
+_LIT(KTennis,"SpruceTennis");
+_LIT(KDog,"SheepdogMIDlet");
+_LIT(KHelloWorld,"HelloWorld");
+_LIT(KPhotoBrowser,"photobrowser");
+_LIT(KPhotoSuiteLauncher,"PhotoSuiteLauncher");
+_LIT(KCalendar, "Calendar");
+_LIT( KJavaAppName, "HelloWorld" );
+
+#endif /* TESTCONSTS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2006 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: Plugin Interface
+*
+*/
+
+
+#ifndef C_WAITACTIVE_H
+#define C_WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // C_WAITACTIVE_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_caappscanner_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/src/T_casrvAppScaner.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,1479 @@
+/*
+* 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 <e32cmn.h>
+#include <w32std.h>
+#include <apgtask.h>
+#include <usif/sif/sifcommon.h>
+#include <usif/sif/sif.h>
+
+#include <QScopedPointer>
+// CLASS HEADER
+#include "T_casrvAppScaner.h"
+
+// EXTERNAL INCLUDES
+
+#include <cadef.h>
+
+#include "castoragefactory.h"
+#include "castorageproxy.h"
+#include "casrvengutils.h"
+#include "casrvappscanner.h"
+#include "caappscannerhandler.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvmmchistory.h"
+
+#include "t_cainstaller.h"
+// INTERNAL INCLUDES
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+#ifdef COVERAGE_MEASUREMENT
+const double TIMEOUT_FACTOR = 1.2;
+#else
+const double TIMEOUT_FACTOR = 1.0;
+#endif
+
+template <typename RClass>
+struct RClassDeleter
+{
+ static inline void cleanup(RClass *ptr)
+ {
+ ptr->Close();
+ }
+};
+
+typedef RClassDeleter< RPointerArray<CCaInnerEntry> > RInnerEntryArrayDeleter;
+typedef QScopedPointer< RPointerArray<CCaInnerEntry>, RInnerEntryArrayDeleter >
+ InnerEntryRArrayPointer;
+
+typedef RClassDeleter< RBuf > RBufDeleter;
+typedef QScopedPointer< RBuf, RBufDeleter >
+ RBufPointer;
+
+using namespace Usif;
+
+const TUid KAppScannerHandlerPluginUid = {0x20026FAF};
+
+void T_casrvAppScaner::initTestCase()
+{
+
+ if (iTestUtils == NULL) {
+ TRAPD(err, iTestUtils = CTestUtils::NewL());
+ QCOMPARE(err, KErrNone);
+ }
+
+ QT_TRAP_THROWING(iInstaller = T_CaInstaller::NewL());
+
+ iTestUtils->CopyMmcHistory();
+
+ delete iTestUtils;
+ iTestUtils = NULL;
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::init()
+{
+ TRAPD(err,
+ iTestUtils = CTestUtils::NewL();
+ iTestUtils->CopyDb();
+
+ iStorage = CCaStorageProxy::NewL();
+ iSrvEngUtils = CCaSrvEngUtils::NewL();
+ iScr = new Usif::RSoftwareComponentRegistry;
+ User::LeaveIfError(iScr->Connect());
+ );
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::cleanup()
+{
+ delete iSrvEngUtils;
+ iSrvEngUtils = NULL;
+ delete iStorage;
+ iStorage = NULL;
+ delete iTestUtils;
+ iTestUtils = NULL;
+ iScr->Close();
+ delete iScr;
+ iScr = NULL;
+}
+
+void T_casrvAppScaner::cleanupTestCase()
+{
+ Usif::TComponentId wrtComponentId(0);
+
+ TRAP_IGNORE(wrtComponentId =
+ iInstaller->GetComponentIdForAppIdL(KWRTAppId));
+ TRAP_IGNORE(iInstaller->UninstallL(wrtComponentId));
+
+ Usif::TComponentId wrtMiniViewComponentId(0);
+ TRAP_IGNORE(wrtMiniViewComponentId =
+ iInstaller->GetComponentIdForAppIdL(KWRTMiniViewAppId));
+ TRAP_IGNORE(iInstaller->UninstallL(wrtMiniViewComponentId));
+
+ REComSession::FinalClose();
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_UninstalledL()
+{
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(notInstalledUid);
+ innerEntry->SetFlags(EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+T_casrvAppScaner::T_casrvAppScaner():
+ iTestUtils(NULL),
+ iStorage(NULL),
+ iSrvEngUtils(NULL),
+ iScr(NULL)
+{
+
+}
+
+void T_casrvAppScaner::testHandler_LoadPlugin()
+{
+ TPluginParams params;
+ params.engUtils = iSrvEngUtils;
+ params.storageProxy = iStorage;
+ params.softwareRegistry = iScr;
+
+ bool result(false);
+
+ TRAPD(err,
+ CCaSrvPlugin *plug = iTestUtils->LoadPluginL(KAppScannerHandlerPluginUid, params);
+ result = plug != NULL;
+ delete plug;
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testHandler_New()
+{
+ TPluginParams params;
+ params.engUtils = iSrvEngUtils;
+ params.storageProxy = iStorage;
+ params.softwareRegistry = iScr;
+
+ bool result(false);
+ TRAPD(err,
+ CCaAppScannerHandler *appScanerHandler = CCaAppScannerHandler::NewL(¶ms);
+ result = appScanerHandler != NULL;
+ delete appScanerHandler;
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testNew()
+{
+ bool result(false);
+ TRAPD(err,
+ Usif::RSoftwareComponentRegistry scr;
+ User::LeaveIfError(scr.Connect());
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr,*iSrvEngUtils);
+ result = appScanner != NULL;
+ scr.Close();
+ delete appScanner;
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testUninstalled()
+{
+ bool exists(false);
+ bool is_missing(false);
+ TRAPD(err,
+ Setup_UninstalledL();
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //visible flag update
+ exists = iTestUtils->AppExistsInStorageL(notInstalledUid,
+ iStorage) == TRUE;
+ is_missing = (iTestUtils->GetAppFlagsL(notInstalledUid, iStorage)
+ & EMissing) == TRUE;
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(exists);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testInstalled()
+{
+ bool result(false);
+ TRAPD(err,
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //visible flag update
+ result = ((iTestUtils->GetAppFlagsL(systemApp, iStorage)
+ & EVisible) != FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testAddNewApp()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_AddNewAppL();
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ // new app added
+ result = ((iTestUtils->GetAppFlagsL(systemApp,iStorage)
+ & EVisible) != FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testNoUpdate()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_NoUpdateL();
+
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //no flag update
+ result = ((iTestUtils->GetAppFlagsL(systemApp, iStorage)
+ & EVisible) != FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testRemoveMmcApp()
+{
+ bool exist(false);
+ TInt flags(0);
+ TRAPD(err,
+ Setup_RemoveMmcAppL();
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //remove mmc attr
+ exist = iTestUtils->AppExistsInStorageL(notInstalledUid, iStorage);
+ flags = iTestUtils->GetAppFlagsL(notInstalledUid, iStorage);
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ TBool visible(ETrue);
+ visible = flags & EVisible;
+ QVERIFY(!visible);
+ QVERIFY(exist);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_casrvAppScaner::testRemoveMmcAttr()
+{
+ bool entryExists(false);
+ bool noMmcAttr(false);
+ TRAPD(err,
+ Setup_RemoveMmcAttrL();
+ iInstaller->InstallL(KSapiPackageFileName);
+
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //remove mmc attr
+
+ CCaInnerEntry *entry = iTestUtils->GetAppEntryL(installedUid, iStorage);
+ entryExists = entry != NULL;
+
+ CleanupStack::PushL(entry);
+ RBuf value;
+ value.CleanupClosePushL();
+ value.CreateL(KCaMassStorage);
+ if (entryExists) {
+ noMmcAttr = (entry->FindAttribute(KCaAttrMmcId, value) == FALSE);
+ }
+ CleanupStack::PopAndDestroy(&value);
+ CleanupStack::PopAndDestroy(entry);
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(entryExists);
+ QVERIFY(noMmcAttr);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_casrvAppScaner::testSetCWRTAppL()
+{
+ RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect() );
+
+ // Install the component
+ _LIT16( KSmokeTestUnsigned, "c:\\testing\\data\\t_caappscanner\\installs\\SmokeTestUnsigned.wgt" );
+ COpaqueNamedParams* arguments;
+ COpaqueNamedParams* results;
+ arguments = COpaqueNamedParams::NewLC();
+ results = COpaqueNamedParams::NewLC();
+ arguments->AddIntL( KSifInParam_InstallSilently, 1 );
+ TRequestStatus status;
+ sif.Install( KSmokeTestUnsigned, *arguments, *results, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError( status.Int() );
+ CleanupStack::PopAndDestroy( results );
+
+ // Install the component
+ _LIT16( KAccuWeather, "c:\\testing\\data\\t_caappscanner\\installs\\AccuWeather_W3C.wgt" );
+ results = COpaqueNamedParams::NewLC();
+ TRequestStatus status2;
+ sif.Install( KAccuWeather, *arguments, *results, status2, EFalse );
+ User::WaitForRequest( status2 );
+ User::LeaveIfError( status2.Int() );
+ CleanupStack::PopAndDestroy( results );
+ CleanupStack::PopAndDestroy( arguments );
+
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+
+
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(
+ *iStorage, *iScr, *iSrvEngUtils)));
+
+ QVERIFY(!appScanner.isNull());
+
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //remove mmc attr
+
+ QScopedPointer<CCaInnerEntry> entry;
+
+ TInt wrtUid(0);
+ TRAP_IGNORE( wrtUid = iTestUtils->FindAppUidL(KWrtAppName, iStorage));
+ TRAPD(err, entry.reset(iTestUtils->GetAppEntryL(wrtUid, iStorage)));
+ QCOMPARE(err, KErrNone);
+ QVERIFY(!entry.isNull());
+
+ QCOMPARE(err, KErrNone);
+
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+
+ TInt wrtMiniViewUid(0);
+
+ TRAP_IGNORE( wrtMiniViewUid =
+ iTestUtils->FindAppUidL( KWrtMiniViewAppName, iStorage ));
+ TRAP(err, entry.reset(iTestUtils->GetAppEntryL(wrtMiniViewUid, iStorage)));
+ QCOMPARE(err, KErrNone);
+ QVERIFY(!entry.isNull());
+
+ bool exists(false);
+ bool match(false);
+ TRAP(err,
+ RBuf value;
+ value.CleanupClosePushL();
+ value.CreateL(KCaMaxAttrLenght);
+ exists = (entry->FindAttribute(KCaAttrAppWidgetUri, value) != 0);
+ match = (value == KCaAttrAppWidgetUriCWRTValue);
+ CleanupStack::PopAndDestroy(&value);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(exists);
+ QVERIFY(match);
+
+ exists = false;
+ TRAP(err,
+ RBuf value;
+ value.CleanupClosePushL();
+ value.CreateL(KCaMaxAttrLenght);
+ exists = (entry->FindAttribute(KCaAttrAppWidgetParamWebAppId, value) != 0);
+ CleanupStack::PopAndDestroy(&value);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(exists);
+
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testRemoveMissingFlag()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_RemoveMissingFlagL();
+
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //remove missing flag
+ result = (iTestUtils->AppExistsInStorageL(notInstalledUid,
+ iStorage) != FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_casrvAppScaner::testRemoveMissingFlag01()
+{
+ bool exists(false);
+ bool noMissingFlag(false);
+ TRAPD(err,
+ Setup_RemoveMissingFlag01L();
+ iInstaller->InstallL(KSapiPackageFileName);
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //remove missing flag
+ exists = ((iTestUtils->GetAppFlagsL(
+ installedUid, iStorage) & EVisible) != FALSE);
+ noMissingFlag =((iTestUtils->GetAppFlagsL(
+ installedUid, iStorage) & EMissing) == FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(exists);
+ QVERIFY(noMissingFlag);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testAddMissingFlag()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_AddMissingFlagL();
+ QTest::qWait(1000);
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //Add missing flag
+ result = (iTestUtils->GetAppFlagsL(notInstalledUid, iStorage)
+ & EMissing) != FALSE;
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testSatApp()
+{
+ bool visibleFlag(false);
+ bool missingFlag(false);
+ TRAPD(err,
+ Setup_SatAppL();
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //sat app should not be updated by app scanner
+ visibleFlag = ((iTestUtils->GetAppFlagsL(
+ KSatUid.iUid, iStorage) & EVisible) != FALSE);
+ missingFlag = ((iTestUtils->GetAppFlagsL(
+ KSatUid.iUid, iStorage) & EMissing) != FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(visibleFlag);
+ QVERIFY(missingFlag);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testHsApp()
+{
+ bool visibleFlag;
+ TRAPD(err,
+ Setup_HsAppL();
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //HS app should not be updated by app scanner
+ visibleFlag = ((iTestUtils->GetAppFlagsL(
+ KHsAppUid.iUid, iStorage) & EVisible) != FALSE);
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(!visibleFlag);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_casrvAppScaner::testAddRemovable()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_AddRemovableL();
+ iInstaller->InstallL(KSapiPackageFileName);
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ //add removable flag to not visible app
+ result = ((iTestUtils->GetAppFlagsL(
+ installedUid, iStorage) & ERemovable) != FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testRemoveRemovable()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_RemoveRemovableL();
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000);
+ //remove removable flag to not visible app
+ result = ((iTestUtils->GetAppFlagsL(systemApp, iStorage)
+ & ERemovable) == FALSE);
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testRunError()
+{
+ bool result(false);
+ TRAPD(err,
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ result = (!appScanner->RunError(1));
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_casrvAppScaner::testInstallNotifier()
+{
+ bool existsBeforeUninstall(false);
+ bool existsAfterUninstall(false);
+
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils)))
+
+ //test
+ TInt err(KErrNone);
+ TRAP(err, iInstaller->InstallL(KSapiPackageFileName))
+ QCOMPARE(err, KErrNone);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+
+ TComponentId componentId(0);
+ TRAP(err, componentId = iInstaller->GetComponentIdL(installedUid));
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err, existsBeforeUninstall = (iTestUtils->ComponentExistsInStorageL(
+ componentId, iStorage) != FALSE));
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err, iInstaller->UninstallL(componentId))
+ QCOMPARE(err, KErrNone);
+
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+
+ TRAP(err, existsAfterUninstall = (iTestUtils->ComponentExistsInStorageL(
+ componentId, iStorage) != FALSE))
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(existsBeforeUninstall);
+ QVERIFY(existsAfterUninstall);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testDownloadCollectionAdd()
+{
+ cleanup();
+ init();
+ TInt countAfterInstall(0);
+ TInt countBeforeInstall(0);
+ bool existsAfterInstall(false);
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils)))
+
+ // ensure the application is not installed
+ TComponentId unComponentId;
+
+ TRAP_IGNORE(unComponentId = iInstaller->GetComponentIdL(installedUid))
+
+ if( unComponentId > 0 )
+ {
+ TRAP_IGNORE(iInstaller->UninstallL(unComponentId));
+ }
+
+ RPointerArray<CCaInnerEntry> array;
+ InnerEntryRArrayPointer resultArray(&array);
+
+ QScopedPointer<CDesC16ArrayFlat> appType;
+
+ QT_TRAP_THROWING(appType.reset(new(ELeave) CDesC16ArrayFlat(1)));
+
+ TRAPD(error, appType->AppendL(KCaTypeApp));
+ QCOMPARE(error, KErrNone);
+
+ QScopedPointer<CCaInnerQuery> query;
+
+ TRAP(error, query.reset(CCaInnerQuery::NewL()));
+ QCOMPARE(error, KErrNone);
+
+ query->SetEntryTypeNames(appType.take());
+
+ QTest::qWait(20000 * TIMEOUT_FACTOR);
+
+ TInt dcID(0);
+
+ TRAP(error, dcID = appScanner->GetCollectionDownloadIdL());
+ QCOMPARE(error, KErrNone);
+
+ query->SetParentId(dcID);
+ query->SetFlagsOn(EVisible);
+ query->SetFlagsOff(EMissing);
+
+ TRAP(error, iStorage->GetEntriesL(query.data(), *resultArray));
+ QCOMPARE(error, KErrNone);
+ countBeforeInstall = resultArray->Count();
+
+ TRAP(error, iInstaller->InstallL(KSapiPackageFileName));
+ QCOMPARE(error, KErrNone);
+
+ QTest::qWait(20000 * TIMEOUT_FACTOR);
+
+ TComponentId componentId(0);
+ TRAP(error, componentId = iInstaller->GetComponentIdL(installedUid));
+ QCOMPARE(error, KErrNone);
+
+ TRAP(error, iStorage->GetEntriesL(query.data(), *resultArray));
+ QCOMPARE(error, KErrNone);
+ countAfterInstall = resultArray->Count();
+
+ existsAfterInstall = (iTestUtils->ComponentExistsInStorageL(
+ componentId, iStorage));
+
+ TRAP(error, iInstaller->UninstallL(componentId));
+ QCOMPARE(error, KErrNone);
+
+ QVERIFY(countAfterInstall == countBeforeInstall + 1);
+ QVERIFY(existsAfterInstall);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testDownloadCollectionUpdate()
+{
+ TInt countAfterInstall(0);
+ TInt countBeforeInstall(0);
+ bool existsAfterInstall(false);
+
+ TComponentId unComponentId;
+ TRAP_IGNORE(unComponentId = iInstaller->GetComponentIdL(installedUid))
+
+ if( unComponentId > 0 )
+ {
+ TRAP_IGNORE(iInstaller->UninstallL(unComponentId));
+ }
+
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(*iStorage,*iScr,
+ *iSrvEngUtils)))
+
+
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+
+ RPointerArray<CCaInnerEntry> array;
+ InnerEntryRArrayPointer resultArray(&array);
+
+ QScopedPointer<CDesC16ArrayFlat> appType;
+
+ QT_TRAP_THROWING(appType.reset(new(ELeave) CDesC16ArrayFlat(1)))
+
+ TRAPD(err, appType->AppendL(KCaTypeApp))
+ QCOMPARE(err, KErrNone);
+
+ QScopedPointer<CCaInnerQuery> query;
+
+ QT_TRAP_THROWING(query.reset(CCaInnerQuery::NewL()));
+
+ query->SetEntryTypeNames(appType.take());
+ TRAP(err, query->SetParentId(appScanner->GetCollectionDownloadIdL()));
+ QCOMPARE(err, KErrNone);
+ query->SetFlagsOn(EVisible);
+ query->SetFlagsOff(EMissing);
+
+ TRAP(err, iStorage->GetEntriesL(query.data(), *resultArray))
+ QCOMPARE(err, KErrNone);
+
+ countBeforeInstall = resultArray->Count();
+ resultArray->Reset();
+
+ TRAP(err, iInstaller->InstallL(KSapiPackageFileName))
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err, iInstaller->InstallL(KSapiPackageFileName))
+ QCOMPARE(err, KErrNone);
+
+ QTest::qWait(20000 * TIMEOUT_FACTOR);
+
+ TComponentId componentId(0);
+ TRAP(err, componentId = iInstaller->GetComponentIdL(installedUid));
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err, iStorage->GetEntriesL(query.data(), *resultArray))
+ QCOMPARE(err, KErrNone);
+
+ countAfterInstall = resultArray->Count();
+
+ TRAP(err, existsAfterInstall =
+ (iTestUtils->ComponentExistsInStorageL(
+ componentId, iStorage) != FALSE));
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err, iInstaller->UninstallL(componentId))
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(countAfterInstall == countBeforeInstall + 1);
+ QVERIFY(existsAfterInstall);
+}
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testDownloadCollectionRemove()
+{
+ TInt countBeforeInstall(0);
+ TInt countAfterInstall(0);
+ TInt countAfterRemove(0);
+ bool existsAfterInstall(false);
+
+ // ensure the application is not installed
+ TComponentId unComponentId;
+ TRAP_IGNORE(unComponentId = iInstaller->GetComponentIdL(installedUid))
+
+ if( unComponentId > 0 )
+ {
+ TRAP_IGNORE(iInstaller->UninstallL(unComponentId));
+ }
+
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(*iStorage,*iScr,
+ *iSrvEngUtils)))
+
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+
+ RPointerArray<CCaInnerEntry> array;
+ InnerEntryRArrayPointer resultArray(&array);
+
+ QScopedPointer<CDesC16ArrayFlat> appType;
+
+ TRAPD(error, appType.reset(new(ELeave) CDesC16ArrayFlat(1)));
+ QCOMPARE(error, KErrNone);
+
+ QScopedPointer<CCaInnerQuery> query;
+
+ TRAP(error, query.reset(CCaInnerQuery::NewL()));
+ QCOMPARE(error, KErrNone);
+
+ appType->AppendL(KCaTypeApp);
+
+ query->SetEntryTypeNames(appType.take());
+
+ TInt dcID(0);
+
+ TRAP(error, dcID = appScanner->GetCollectionDownloadIdL());
+ QCOMPARE(error, KErrNone);
+
+ query->SetParentId(dcID);
+ query->SetFlagsOn(EVisible);
+ query->SetFlagsOff(EMissing);
+
+ TRAP(error, iStorage->GetEntriesL(query.data(), *resultArray));
+ QCOMPARE(error, KErrNone);
+ countBeforeInstall = resultArray->Count();
+
+ TRAP(error, iInstaller->InstallL(KSapiPackageFileName));
+ QCOMPARE(error, KErrNone);
+
+ QTest::qWait(20000 * TIMEOUT_FACTOR);
+
+ TComponentId componentId(0);
+ TRAP(error, componentId = iInstaller->GetComponentIdL(installedUid));
+ QCOMPARE(error, KErrNone);
+
+ TRAP(error, iStorage->GetEntriesL(query.data(), *resultArray));
+ QCOMPARE(error, KErrNone);
+ countAfterInstall = resultArray->Count();
+
+ if (countAfterInstall >= 1) {
+ TRAP(error, appScanner->RemoveEntryFromDownloadedL(
+ (*resultArray)[countAfterInstall-1]->GetId()));
+ QCOMPARE(error, KErrNone);
+ }
+
+ RPointerArray<CCaInnerEntry> arrayA;
+ InnerEntryRArrayPointer resultArrayA(&arrayA);
+
+ TRAP(error, iStorage->GetEntriesL(query.data(), *resultArrayA));
+ QCOMPARE(error, KErrNone);
+ countAfterRemove = resultArrayA->Count();
+
+ TRAP(error, existsAfterInstall =
+ iTestUtils->ComponentExistsInStorageL(componentId, iStorage));
+ QCOMPARE(error, KErrNone);
+
+ TRAP(error, iInstaller->UninstallL(componentId));
+ QCOMPARE(error, KErrNone);
+
+ QVERIFY(countAfterInstall == countBeforeInstall + 1);
+ QVERIFY(countBeforeInstall == countAfterRemove);
+ QVERIFY(existsAfterInstall);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testCreatePredefinedCollection()
+{
+ _LIT16( KPredefinedCollection, "Predefined" );
+
+ TInt predefinedCollectionId( 0 );
+
+ TRAPD(err,
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ // create predefined collection
+ predefinedCollectionId = appScanner->CreatePredefinedCollectionL(
+ KPredefinedCollection );
+
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE( err, KErrNone );
+
+ // clean db after test
+ if (predefinedCollectionId) {
+ RArray<TInt> idsToRemove;
+ CleanupClosePushL(idsToRemove);
+ TRAP(err, idsToRemove.AppendL( predefinedCollectionId );
+ iStorage->RemoveL(idsToRemove));
+ CleanupStack::PopAndDestroy( &idsToRemove );
+ }
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(predefinedCollectionId); // all collection id from db
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testGetAllCollectionIdL()
+{
+ TInt allCollectionId(0);
+ const TInt referenceAllCollectionId(1);
+
+ TRAPD(err,
+ CCaSrvAppScanner *appScanner = CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils);
+ CleanupStack::PushL(appScanner);
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+ // get all collection id
+ allCollectionId = appScanner->GetAllCollectionIdL();
+
+ CleanupStack::PopAndDestroy(appScanner);
+ );
+ QCOMPARE( err, KErrNone );
+ QCOMPARE( allCollectionId, referenceAllCollectionId );
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_casrvAppScaner::testUpdateComponentIdL()
+{
+ TBool updatedWhenNotExists = EFalse;
+ TBool updatedAfterInstall = EFalse;
+ TBool updatedWhenNoChange = EFalse;
+
+ RBuf actualComponentId;
+ RBufPointer actualComponentIdPointer(&actualComponentId);
+ TBool componentIdAttributeFoundWhenNotExists = EFalse;
+ TBool componentIdAttributeFoundAfterInstall = EFalse;
+
+ // create app scanner to test
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(*iStorage,
+ *iScr, *iSrvEngUtils)))
+
+ QScopedPointer<CCaInnerEntry> entry;
+ QT_TRAP_THROWING(entry.reset(CCaInnerEntry::NewL()))
+
+ // case 1: pass non existing application description
+ entry->SetUid(0);
+
+ TRAPD(err, updatedWhenNotExists =
+ appScanner->UpdateComponentIdL(*entry))
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err, actualComponentIdPointer->CreateL(KCaMaxAttrValueLen))
+ QCOMPARE(err, KErrNone);
+
+ componentIdAttributeFoundWhenNotExists =
+ entry->FindAttribute(KCaComponentId, *actualComponentIdPointer);
+
+
+ // case 2: add component id once application is installed
+
+ // ensure the application is not installed
+ TComponentId unComponentId;
+ TRAP_IGNORE(unComponentId = iInstaller->GetComponentIdL(installedUid))
+
+ if( unComponentId > 0 )
+ {
+ TRAP_IGNORE(iInstaller->UninstallL(unComponentId));
+ }
+
+ TRAP(err, iInstaller->InstallL(KSapiPackageFileName))
+ QCOMPARE(err, KErrNone);
+
+ TComponentId componentId(0);
+ TRAP(err, componentId = iInstaller->GetComponentIdL(installedUid));
+ QCOMPARE(err, KErrNone);
+
+ entry->SetUid(installedUid);
+ TRAP(err, updatedAfterInstall =
+ appScanner->UpdateComponentIdL(*entry));
+ QCOMPARE(err, KErrNone);
+
+ actualComponentIdPointer->Close();
+ TRAP(err, actualComponentIdPointer->CreateL(KCaMaxAttrValueLen))
+ QCOMPARE(err, KErrNone);
+
+ componentIdAttributeFoundAfterInstall =
+ entry->FindAttribute(KCaComponentId, *actualComponentIdPointer);
+
+ // case 3: update for application which has component id not changed
+ TRAP(err, updatedWhenNoChange =
+ appScanner->UpdateComponentIdL(*entry))
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(!updatedWhenNotExists);
+ QVERIFY(!componentIdAttributeFoundWhenNotExists);
+ QVERIFY(updatedAfterInstall);
+ QVERIFY(componentIdAttributeFoundAfterInstall);
+ QVERIFY(!updatedWhenNoChange);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testSave()
+{
+ bool result(false);
+ TRAPD(err,
+ RFs fs;
+ User::LeaveIfError(fs.Connect());
+ {
+ CCaSrvMmcHistory* mmcHist = CCaSrvMmcHistory::NewL();
+ CleanupStack::PushL( mmcHist );
+ mmcHist->InsertL(1);
+ mmcHist->SaveL(fs, _L("c:\\testing\\data\\t_caappscanner\\testmmchist"));
+ CleanupStack::PopAndDestroy( mmcHist );
+
+ mmcHist = CCaSrvMmcHistory::NewL();
+ CleanupStack::PushL( mmcHist );
+ mmcHist->LoadL(fs, _L("c:\\testing\\data\\t_caappscanner\\testmmchist"));
+ result = (mmcHist->Find(1) != KErrNotFound);
+ CleanupStack::PopAndDestroy( mmcHist );
+ }
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::testInsert()
+{
+ bool result(false);
+ TRAPD(err,
+ CCaSrvMmcHistory* mmcHist = CCaSrvMmcHistory::NewL();
+ CleanupStack::PushL( mmcHist );
+ mmcHist->InsertL(1);
+ result = (mmcHist->Find(1) != KErrNotFound);
+ CleanupStack::PopAndDestroy( mmcHist );
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_AddNewAppL()
+{
+
+ TBool exists = iTestUtils->AppExistsInStorageL(systemApp, iStorage);
+ if (exists) {
+ iTestUtils->RemoveAppL(systemApp, iStorage);
+ exists = iTestUtils->AppExistsInStorageL(systemApp, iStorage);
+ if (exists) {
+ User::Leave(KErrNotReady);
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_NoUpdateL()
+{
+
+ TInt flags(KErrNotFound);
+ CCaInnerQuery *satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid(systemApp);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ iStorage->GetEntriesL(satAppQuery, resultArray);
+
+ if (resultArray.Count()) {
+ CCaInnerEntry *innerEntry = resultArray[0];
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(systemApp);
+ innerEntry->SetFlags(innerEntry->GetFlags() | EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(satAppQuery);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_RemoveMmcAppL()
+{
+
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(notInstalledUid);
+ innerEntry->SetFlags(EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+ innerEntry->AddAttributeL(KCaAttrMmcId, KCaMassStorage);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_RemoveMmcAttrL()
+{
+
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(installedUid);
+ innerEntry->SetFlags(EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+ innerEntry->AddAttributeL(KCaAttrMmcId, KCaMassStorage);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_RemoveMissingFlagL()
+{
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(notInstalledUid);
+ innerEntry->SetFlags(EVisible | EMissing);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_RemoveMissingFlag01L()
+{
+
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(installedUid);
+ innerEntry->SetFlags(EVisible | EMissing);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_AddMissingFlagL()
+{
+ iTestUtils->CopyMmcHistory();
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(notInstalledUid);
+ innerEntry->SetFlags(EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+ innerEntry->AddAttributeL(KCaAttrMmcId, KMmcIdValue);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_SatAppL()
+{
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(KSatUid.iUid);
+ innerEntry->SetFlags(EVisible | EMissing);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_HsAppL()
+{
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("HsApplication"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(KHsAppUid.iUid);
+ innerEntry->SetFlags(0);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_AddRemovableL()
+{
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(installedUid);
+ innerEntry->SetFlags(innerEntry->GetFlags() & ~ERemovable | EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_casrvAppScaner::Setup_RemoveRemovableL()
+{
+ TInt flags(KErrNotFound);
+ CCaInnerQuery *satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid(systemApp);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ iStorage->GetEntriesL(satAppQuery, resultArray);
+
+ if (resultArray.Count()) {
+ CCaInnerEntry *innerEntry = resultArray[0];
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("testname_old"));
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(systemApp);
+ innerEntry->SetFlags(innerEntry->GetFlags() | ERemovable);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrShortName, testName);
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(satAppQuery);
+}
+
+void T_casrvAppScaner::testSetJavaAppL()
+{
+ RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect() );
+
+ // Install the component
+ _LIT16( KHelloWorldJarPath, "c:\\testing\\data\\t_caappscanner\\HelloWorld.jar" );
+ COpaqueNamedParams* arguments = NULL;
+ COpaqueNamedParams* results = NULL;
+ arguments = COpaqueNamedParams::NewLC();
+ results = COpaqueNamedParams::NewLC();
+ arguments->AddIntL( KSifInParam_InstallSilently, 1 );
+ TRequestStatus status;
+ sif.Install( KHelloWorldJarPath, *arguments, *results, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError( status.Int() );
+
+ CleanupStack::PopAndDestroy( results );
+ CleanupStack::PopAndDestroy( arguments );
+
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+
+
+ QScopedPointer<CCaSrvAppScanner> appScanner;
+ QT_TRAP_THROWING(appScanner.reset(CCaSrvAppScanner::NewL(
+ *iStorage, *iScr, *iSrvEngUtils)));
+
+ QVERIFY(!appScanner.isNull());
+
+ QTest::qWait(7000 * TIMEOUT_FACTOR);
+
+ QScopedPointer<CCaInnerEntry> entry;
+
+ TInt javaUid(0);
+ TRAP_IGNORE( javaUid = iTestUtils->FindAppUidL(KJavaAppName, iStorage));
+ TRAPD(err, entry.reset(iTestUtils->GetAppEntryL(javaUid, iStorage)));
+ QCOMPARE(err, KErrNone);
+ QVERIFY(!entry.isNull());
+
+ QCOMPARE(err, KErrNone);
+
+ bool exists(false);
+ bool match(false);
+ TRAP(err,
+ RBuf value;
+ value.CleanupClosePushL();
+ value.CreateL(KCaMaxAttrLenght);
+ exists = (entry->FindAttribute(KCaAttrAppType, value) != 0);
+ match = (value == KCaAttrAppTypeValueJava);
+ CleanupStack::PopAndDestroy(&value);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(exists);
+ QVERIFY(match);
+}
+
+
+
+QTEST_MAIN(T_casrvAppScaner);
+
+// END OF FILE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/src/casrvtestutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,493 @@
+/*
+* Copyright (c) 2009 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 <W32STD.H>
+#include <e32property.h>
+#include <cadef.h>
+#include <badesca.h>
+#include <apgtask.h>
+#include <AknTaskList.h>
+#include <apgcli.h>
+#include <APACMDLN.h>
+#include <EIKENV.h>
+
+#include "castorageproxy.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvplugin.h"
+
+
+#include "waitactive.h"
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTRUCTION
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewL()
+ {
+ CTestUtils* self = CTestUtils::NewLC();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewLC()
+ {
+ CTestUtils* self = new( ELeave ) CTestUtils();
+ CleanupStack::PushL( self );
+
+ self->ConstructL();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+// ---------------------------------------------------------------------------
+//
+CTestUtils::~CTestUtils()
+ {
+ iFileManager->Delete(KTestDbDest);
+ iFileManager->Delete(KTestMmcHistDest);
+ delete iFileManager; iFileManager = NULL;
+ iFs.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CTestUtils::CTestUtils()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second phase construct
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::ConstructL()
+ {
+ User::LeaveIfError( iFs.Connect() );
+ iFileManager = CFileMan::NewL( iFs );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::WaitL(TInt aMicroSec)
+ {
+ CWaitActive* wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::GetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::GetRProperty( TUid aCategory, TUint aKey, TDes& aValue )
+ {
+ return RProperty::Get( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::GetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::GetRProperty( TUid aCategory, TUint aKey, TInt& aValue )
+ {
+ return RProperty::Get( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::SetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::SetRProperty( TUid aCategory, TUint aKey, const TDesC& aValue )
+ {
+ return RProperty::Set( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::SetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::SetRProperty( TUid aCategory, TUint aKey, TInt aValue )
+ {
+ return RProperty::Set( aCategory, aKey, aValue );
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::Copy( const TDesC& aSource, const TDesC& aDest )
+ {
+ return iFileManager->Copy(aSource, aDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::CopyDb()
+ {
+ return Copy(KTestDbSource, KTestDbDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TBool CTestUtils::AppExistsInStorageL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TBool exists(EFalse);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ exists = ETrue;
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return exists;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TBool CTestUtils::ComponentExistsInStorageL( Usif::TComponentId aComponentId,
+ CCaStorageProxy* aStorage)
+ {
+ TBool exists(EFalse);
+ CCaInnerQuery* appQuery = CCaInnerQuery::NewLC();
+ RBuf componentIdDes;
+ componentIdDes.CleanupClosePushL();
+ componentIdDes.CreateL( sizeof(Usif::TComponentId) + 1 );
+ componentIdDes.AppendNum( aComponentId );
+
+ appQuery->AddAttributeL( KCaComponentId, componentIdDes );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( appQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ exists = ETrue;
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( &componentIdDes );
+ CleanupStack::PopAndDestroy( appQuery );
+
+ return exists;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+CCaInnerEntry* CTestUtils::GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerEntry* entry = NULL;
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ entry = resultArray[0];
+ resultArray.Remove(0);
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return entry;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ satAppQuery->SetFlagsOff( aFlags );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TInt count = resultArray.Count();
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return count;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TInt flags(0);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ flags = resultArray[0]->GetFlags();
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return flags;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+void CTestUtils::RemoveAppL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ RArray<TInt> idsToRemove;
+ CleanupClosePushL(idsToRemove);
+ idsToRemove.AppendL( resultArray[0]->GetId() );
+ aStorage->RemoveL(idsToRemove);
+ CleanupStack::PopAndDestroy( &idsToRemove );
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+void CTestUtils::CopyMmcHistory()
+{
+ iFileManager->Copy( KTestMmcHistSource, KTestMmcHistDest );
+}
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TUint CTestUtils::FindAppUidL( const TDesC& aName, CCaStorageProxy* aStorage )
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TUint appUid(0);
+ for ( TInt i = 0; i < resultArray.Count(); i++ )
+ {
+ if ( resultArray[i]->GetText() == aName )
+ {
+ appUid = resultArray[i]->GetUid();
+ }
+ }
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return appUid;
+ }
+
+// -----------------------------------------------------------------------------
+//
+TInt CTestUtils::SimpleCloseTaskL(TInt aUid)
+ {
+ RWsSession session;
+ TInt error = session.Connect();
+ TUid uidApp( TUid::Uid( aUid )) ;
+ TApaTaskList taskList( session );
+ TApaTask task = taskList.FindApp( uidApp );
+
+ if( task.Exists() )
+ {
+ task.EndTask();
+ }
+ else
+ {
+ error = KErrNotFound;
+ }
+
+ WaitL( 4000000 );
+ session.Close();
+ WaitL( 1000000 );
+
+ return error;
+ }
+
+// ----------------------------------------------------------------------------
+//
+void CTestUtils::InstallFinishedL()
+ {
+ iActiveWait->AsyncStop();
+ }
+
+
+// ---------------------------------------------------------
+// CTestUtils::LaunchApplicationL
+// ---------------------------------------------------------
+
+CCaSrvPlugin* CTestUtils::LoadPluginL( TUid aImplUid, TPluginParams aPluginParams )
+ {
+ RImplInfoPtrArray infoArray;
+
+ // Note that a special cleanup function is required to reset and destroy
+ // all items in the array, and then close it.
+ CleanupResetAndDestroyPushL( infoArray );
+ CCaSrvPlugin::ListAllImplementationsL( infoArray );
+
+ // Loop through each info for each implementation
+ // and create and use each in turn
+ CCaSrvPlugin* plug = NULL;
+ for( TInt i = 0; i < infoArray.Count(); i++ )
+ {
+ // Slice off first sub-section in the data section
+ TUid current_plugin = infoArray[i]->ImplementationUid();
+ if ( current_plugin == aImplUid )
+ {
+ plug = CCaSrvPlugin::NewL( current_plugin, &aPluginParams );
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy( &infoArray );
+ return plug;
+ }
+
+
+
+
+// ---------------------------------------------------------
+// CTestUtils::LaunchApplicationL
+// ---------------------------------------------------------
+//
+TInt CTestUtils::LaunchApplicationL( const TUid aUid )
+ {
+ RWsSession wsSession;
+ User::LeaveIfError( wsSession.Connect() );
+ CleanupClosePushL<RWsSession>( wsSession );
+
+ CAknTaskList* taskList = CAknTaskList::NewL( wsSession );
+ TApaTask task = taskList->FindRootApp( aUid );
+ delete taskList;
+
+ if ( task.Exists() )
+ {
+ task.BringToForeground();
+ }
+ else
+ {
+ TApaAppInfo appInfo;
+ TApaAppCapabilityBuf capabilityBuf;
+ RApaLsSession appArcSession;
+ User::LeaveIfError( appArcSession.Connect() );
+ CleanupClosePushL<RApaLsSession>( appArcSession );
+
+ User::LeaveIfError( appArcSession.GetAppInfo( appInfo, aUid ) );
+ User::LeaveIfError( appArcSession.GetAppCapability( capabilityBuf, aUid ) );
+
+ TApaAppCapability& caps = capabilityBuf();
+ TFileName appName = appInfo.iFullName;
+ CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+ cmdLine->SetExecutableNameL( appName );
+
+ if ( caps.iLaunchInBackground )
+ {
+ cmdLine->SetCommandL( EApaCommandBackground );
+ }
+ else
+ {
+ cmdLine->SetCommandL( EApaCommandRun );
+ }
+
+ User::LeaveIfError( appArcSession.StartApp( *cmdLine ) );
+
+ CleanupStack::PopAndDestroy( cmdLine );
+ CleanupStack::PopAndDestroy( &appArcSession );
+ }
+ CleanupStack::PopAndDestroy( &wsSession );
+
+ //verification if app has really launched
+ WaitL(20000000);
+ RWsSession verWsSession;
+ User::LeaveIfError( verWsSession.Connect() );
+ CleanupClosePushL<RWsSession>( verWsSession );
+
+ CAknTaskList* verTaskList = CAknTaskList::NewL( verWsSession );
+ TApaTask verTask = verTaskList->FindRootApp( aUid );
+ delete verTaskList;
+
+ TInt result(KErrGeneral);
+ if ( verTask.Exists() )
+ {
+ result = KErrNone;
+ }
+ CleanupStack::PopAndDestroy( &verWsSession );
+ return result;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006 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 "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/t_caappscanner.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+ ../../../../tsrc/testutils/inc
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp \
+ ../../../../srvsrc/cainstallnotifier.cpp \
+ ../../../../srvsrc/cainstallstrategy.cpp \
+ ../../../../srvsrc/casrvengutils.cpp \
+ ../../../../srvsrc/castorageproxy.cpp \
+ ../../../../srvsrc/casrvnotifier.cpp \
+ ../../../../srvsrc/casrv.cpp \
+ ../../../../srvsrc/casrvmmchistory.cpp \
+ ../../../../srvsrc/casrvsession.cpp \
+ ../../../../srvsrc/cabackupnotifier.cpp \
+ ../../../casrvmgr/src/casrvmanager.cpp \
+ ../../../../cautils/src/*.cpp \
+ ../../../../castorage/src/*.cpp \
+ ../../../../tsrc/testutils/src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/t_caappscanner.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,133 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../../common.pri)
+include(../../../../tsrc/testutils/testutils.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../../../srvinc \
+ ../../../../cautils/inc \
+ ../../../casrvmgr/inc \
+ ../../../../castorage/inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_caappscanner.pri)
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x2002870E
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+ LIBS += \
+ -lapparc \
+ -lapgrfx \
+ -lefsrv \
+ -leuser \
+ -lPlatformEnv \
+ -lbafl \
+ -lcamenu \
+ -lcasathandler \
+ -lcalocalizerscanner \
+ -lcommdb \
+ -lefsrv \
+ -lestor \
+ -lapparc \
+ -lplatformenv \
+ -lsysutil \
+ -lapgrfx \
+ -lws32 \
+ -lavkon \
+ -lcone \
+ -lecom \
+ -lsisregistryclient \
+ -lWidgetRegistryClient \
+ -lsqldb \
+ -lcomsdbgutil \
+ -lscrclient \
+ -lsifnotification
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = c:/testing/data/t_caappscanner/
+
+ exportWRT.sources = ./data/*.wgt
+ exportWRT.path = c:/testing/data/t_caappscanner/installs/
+
+ exportMMCHistory.sources = ./data/mmchistory
+ exportMMCHistory.path = c:/testing/data/t_caappscanner/
+
+ exportARMSis.sources = ./data/armv5/sapiapp_S60_3_X_v_1_0_0.sisx
+ exportARMSis.path = c:/testing/data/t_caappscanner/installs/
+
+ exportWINSCWSis.sources = ./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx
+ exportWINSCWSis.path = c:/testing/data/t_caappscanner/installs/
+
+ exportJava.sources = ./data/*.jar
+ exportJava.path = c:/testing/data/t_caappscanner/
+
+ BLD_INF_RULES.prj_exports += "./data/mmchistory c:/testing/data/t_caappscanner/"
+ BLD_INF_RULES.prj_exports += "./data/castorage.db c:/testing/data/t_caappscanner/"
+ BLD_INF_RULES.prj_exports += "./data/AccuWeather_W3C.wgt c:/testing/data/t_caappscanner/installs/"
+ BLD_INF_RULES.prj_exports += "./data/SmokeTestUnsigned.wgt c:/testing/data/t_caappscanner/installs/"
+ BLD_INF_RULES.prj_exports += "./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx c:/testing/data/t_caappscanner/installs/"
+ BLD_INF_RULES.prj_exports += "./data/HelloWorld.jar c:/testing/data/t_caappscanner/"
+
+ DEPLOYMENT += exportDB exportWRT exportMMCHistory exportARMSis exportJava
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} $${exportDB.path}$$basename(exportDB.sources)"
+ BLD_INF_RULES.prj_testexports += "./data/AccuWeather_W3C.wgt c:/testing/data/t_caappscanner/installs/"
+ BLD_INF_RULES.prj_testexports += "./data/SmokeTestUnsigned.wgt c:/testing/data/t_caappscanner/installs/"
+ BLD_INF_RULES.prj_testexports += "$${exportMMCHistory.sources} $${exportMMCHistory.path}$$basename(exportMMCHistory.sources)"
+ BLD_INF_RULES.prj_testexports += "$${exportWINSCWSis.sources} $${exportWINSCWSis.path}$$basename(exportWINSCWSis.sources)"
+ BLD_INF_RULES.prj_testexports += "./data/HelloWorld.jar c:/testing/data/t_caappscanner/"
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/t_caappscanner/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_caappscanner.exe -o c:\t_caappscanner.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/caappscanner/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS = t_caappscanner
+
+CONFIG += ordered
Binary file contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/data/castorage.db has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,45 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call cd ..
+call cd ..
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call make distclean
+call qmake -r
+call bldmake bldfiles
+call abld makefile winscw
+call abld reallyclean winscw
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE+./src/*" abld build winscw udeb
+
+call cd tsrc
+call cd t_calocalizerscanner
+call make distclean
+call qmake -r
+call bldmake bldfiles
+call abld makefile winscw
+call abld reallyclean winscw
+call abld build winscw udeb
+call \epoc32\release\winscw\udeb\t_calocalizerscanner.exe -o c:\log_dec.txt
+call cd ..
+call cd ..
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../..");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE+./src/*\" sbs -j 4 -c winscw_udeb");
+
+ chdir("tsrc/t_calocalizerscanner");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_calocalizerscanner -o c:\\t_calocalizerscanner.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../..");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o tsrc/t_calocalizerscanner/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o tsrc/t_calocalizerscanner/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/inc/t_calocalizerscanner.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+#ifndef T_CALOCALIZER_H
+#define T_CALOCALIZER_H
+
+#include <QtTest/QtTest>
+
+#include <e32base.h>
+#include <W32STD.H>
+#include "casrvplugin.h"
+
+class CCaInnerEntry;
+class CCaStorageProxy;
+class CFileMan;
+/**
+ * @test Test class for hsmcsserviceprovider library.
+ */
+class TestCaLocalizerScanner : public QObject
+{
+ Q_OBJECT
+
+private slots:
+
+
+ /**
+ * initialize
+ */
+ void initTestCase();
+
+/* void init();
+
+ *
+ * cleanup
+
+
+ void cleanup();*/
+
+ void cleanupTestCase();
+
+// tests
+
+ void TestInitializeScannerProxy();
+
+ void TestLoadLocalizerPlugin();
+
+
+private:
+
+ //helper function to ommit debuging restriction under a trap
+ void TestInitializeScannerProxyTrapped();
+
+ //helpers
+ CCaInnerEntry* GetEntryById(TInt aId);
+ CCaSrvPlugin* LoadPluginL( TUid aImplUid, TPluginParams aPluginParams );
+
+ CCaStorageProxy* iStorageProxy;
+ CFileMan* iFileManager;
+ RFs iFs;
+
+};
+
+
+#endif//T_CALOCALIZER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_calocalizerscanner_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/src/t_calocalizerscanner.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+//s60
+#include <e32base.h>
+#include <W32STD.H>
+#include "cadef.h"
+
+#include "t_calocalizerscanner.h"
+
+//local
+#include "calocalizerscannerproxy.h"
+#include "castorageproxy.h"
+#include "cainnerquery.h"
+#include "cainnerentry.h"
+
+#include <XQConversions>
+
+/*
+Test must be compiled with flag
+test database "./data/castorage.db " must be exported to KDBSource
+*/
+
+ _LIT(KDBSource, "C:\\testing\\data\\localizer\\castorage.db");
+ _LIT(KDBDest, "c:\\castorage.db");
+ _LIT(KTextForeign, "TestString");
+ _LIT(KTextLocal, "Recently added");
+ const TUid KLocalizerScannerPluginUid = {0x20028709};
+// ---------------------------------------------------------------------------
+//
+void TestCaLocalizerScanner::initTestCase()
+{
+ iFs.Connect();
+
+ QT_TRAP_THROWING(
+ //copy prepared database
+ iFileManager = CFileMan::NewL(iFs);
+ iFileManager->Copy(KDBSource, KDBDest);
+ iStorageProxy = CCaStorageProxy::NewL();
+ );
+}
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaLocalizerScanner::cleanupTestCase()
+ {
+ iFileManager->Delete(KDBDest);
+ delete iFileManager;
+ delete iStorageProxy;
+ }
+/// TESTS
+
+/*void TestCaLocalizerScanner::TestLoadTranslator()
+ {
+ CCaLocalizerScannerProxy* localizerProxy;
+ localizerProxy = new CCaLocalizerScannerProxy(iStorageProxy);
+ localizerProxy->loadTranslator(QString("filename"));
+ }*/
+
+void TestCaLocalizerScanner::TestLoadLocalizerPlugin()
+ {
+ TPluginParams params;
+ params.storageProxy = iStorageProxy;
+ QScopedPointer<CCaSrvPlugin> plug;
+ TRAP_IGNORE(plug.reset(LoadPluginL( KLocalizerScannerPluginUid, params)));
+ QVERIFY2(plug, "plugin not loaded");
+ }
+
+void TestCaLocalizerScanner::TestInitializeScannerProxy()
+ {
+ TRAP_IGNORE(
+ TestInitializeScannerProxyTrapped();
+ );
+ }
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void TestCaLocalizerScanner::TestInitializeScannerProxyTrapped()
+ {
+ CCaLocalizerScannerProxy* localizerProxy;
+ CCaInnerEntry* entry;
+ // 2 is entryId of downloaded collection.
+ //In the test database EN_TEXT of downl. col. is 'TestString'
+ // after localization on english epoc it should be 'Downloaded'
+ entry = GetEntryById(2);
+ //iStorageProxy->SetDBPropertyL( KCaDbPropLanguage, KCaDbPropLanguage );
+ QVERIFY2(entry->GetText().CompareC(KTextForeign) == 0, "wrong database");
+ //do the localization
+ // localizerProxy = CCaLocalizerScannerProxy::NewL(iStorageProxy);
+ TPluginParams params;
+ params.storageProxy = iStorageProxy;
+ CCaSrvPlugin* plug = LoadPluginL( KLocalizerScannerPluginUid, params);
+
+ entry = GetEntryById(2);
+ qDebug() << "entry->GetText()";
+ qDebug() << XQConversions::s60DescToQString(entry->GetText()).toLatin1();
+ QVERIFY2(entry->GetText().CompareC(KTextLocal) == 0,
+ "localization went wrong");
+ delete plug;
+ }
+
+// ***************************************** helper functions
+
+CCaInnerEntry* TestCaLocalizerScanner::GetEntryById(TInt aId)
+ {
+ QScopedPointer<CCaInnerQuery> query;
+ CCaInnerEntry* entry(0);
+ QT_TRAP_THROWING(query.reset(CCaInnerQuery::NewL()));
+ TRAP_IGNORE(
+ RArray<TInt> array;
+ CleanupClosePushL(array);
+ array.Append(aId); // entry
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupClosePushL(resultArray);
+ query->SetIdsL(array);
+ iStorageProxy->GetEntriesL(query.data(), resultArray);
+ if (resultArray.Count())
+ {
+ entry = resultArray[0];
+ resultArray.Remove(0);
+ }
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::Pop(&array);
+ );
+ return entry;
+ }
+
+
+CCaSrvPlugin* TestCaLocalizerScanner::LoadPluginL( TUid aImplUid, TPluginParams aPluginParams )
+ {
+ CCaSrvPlugin* plug = NULL;
+
+ RImplInfoPtrArray infoArray;
+
+ // Note that a special cleanup function is required to reset and destroy
+ // all items in the array, and then close it.
+ CleanupClosePushL( infoArray );
+ CCaSrvPlugin::ListAllImplementationsL( infoArray );
+
+ // Loop through each info for each implementation
+ // and create and use each in turn
+ for( TInt i = 0; i < infoArray.Count(); i++ )
+ {
+ // Slice off first sub-section in the data section
+ TUid current_plugin = infoArray[i]->ImplementationUid();
+ if ( current_plugin == aImplUid )
+ {
+ plug = CCaSrvPlugin::NewL( current_plugin, &aPluginParams );
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy( &infoArray );
+
+ return plug;
+ }
+//#endif //Q_OS_SYMBIAN
+
+QTEST_MAIN(TestCaLocalizerScanner)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/t_calocalizerscanner.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h
+SOURCES += ./src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/t_calocalizerscanner.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,116 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../../../srvinc \
+ ../../../../cautils/inc \
+ ../../../casrvmgr/inc \
+ ../../../../castorage/inc \
+ ../../../../srvinc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_calocalizerscanner.pri)
+
+
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+coverage: {
+ SUBDIRS += ../../
+}
+ CONFIG += symbian_test hb
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x100039CE
+ TARGET.UID3 = 0x2002870C
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ SOURCES += ../../src/*.cpp
+
+ SOURCES += ../../../../srvsrc/castorageproxy.cpp
+ SOURCES += ../../../../srvsrc/casrvengutils.cpp
+ SOURCES += ../../../../srvsrc/casrv.cpp
+ SOURCES += ../../../../srvsrc/casrvsession.cpp
+ SOURCES += ../../../../srvsrc/casrvnotifier.cpp
+ SOURCES += ../../../../srvsrc/cabackupnotifier.cpp
+
+ SOURCES += ../../../../castorage/src/*.cpp
+
+
+ LIBS += -leuser \
+ -lecom \
+ -lcautils \
+ -lcamenu \
+ -lsqldb \
+ -lefsrv \
+ -lbafl \
+ -lflogger \
+ -lestor \
+ -lapgrfx \
+ -lapparc \
+ -lcasrvmanager \
+ -lsysutil \
+ -lscrclient \
+ -lxqutils \
+ -lsifnotification
+
+
+ exports1.sources += ./data/castorage.db
+ exports1.path = c:/testing/data/localizer
+
+ DEPLOYMENT += exports1
+
+ BLD_INF_RULES.prj_testexports += "./data/castorage.db c:/testing/data/localizer/"
+
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/t_calocalizerscanner_installs_unix.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2009 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:
+#
+#
+
+# Release - deploy only release version of the tests
+
+#
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/t_calocalizerscanner_installs_win32.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2009 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:
+#
+
+testfiles.path = ../../../../bin/debug/
+
+testfiles.files = ./release/t_calocalizerscanner.exe \
+
+testfiles.files = ./debug/t_calocalizerscanner.exe
+
+INSTALLS += testfiles
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_calocalizerscanner.exe -o c:\t_calocalizerscanner.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/calocalizerscanner/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+SUBDIRS = t_calocalizerscanner
+
+CONFIG += ordered
+
Binary file contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/data/castorage.db has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../../group");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE+../src/*\" sbs -j 4 -c winscw_udeb");
+
+ chdir("../tsrc/t_carunningappmonitor");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_carunningappmonitor -o c:\\t_carunningappmonitor.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../../group");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../tsrc/t_carunningappmonitor/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../tsrc/t_carunningappmonitor/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/inc/carunningappmonitortestutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+//utility class for tests
+//all utility methods should be implemented here
+#ifndef CA_RUNNING_APP_MONITOR_TEST_UTILS_H
+#define CA_RUNNING_APP_MONITOR_TEST_UTILS_H
+
+#include "casrvengutils.h"
+#include "casrvplugin.h"
+
+class CCaStorageProxy;
+class CCaInnerEntry;
+
+class CTestUtils: public CBase
+{
+public:
+ /**/
+ virtual ~CTestUtils();
+
+ /**/
+ static CTestUtils* NewL();
+
+ /**/
+ static CTestUtils* NewLC();
+
+ TInt CopyDb();
+
+ TInt LaunchApplicationL( const TUid aUid );
+
+ TInt TerminateApplicationL( const TUid aUid );
+
+ void WaitL(TInt aMicroSec);
+
+ TBool IsRunningL(TUid aAppUid, CCaStorageProxy& aStorage)const;
+
+private:
+ /**
+ * Copys files
+ */
+ TInt Copy( const TDesC& aSource, const TDesC& aDest );
+
+ CTestUtils();
+
+ void ConstructL();
+
+ RFs iFs;
+ CFileMan* iFileManager;
+
+ /**
+ * Local Active Sheduler.
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveWait;
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/inc/t_carunningappmonitor.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2007 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:
+*
+*/
+
+
+#ifndef T_CA_RUNNING_APP_MONITOR_H
+#define T_CA_RUNNING_APP_MONITOR_H
+
+
+class CCaSrvPlugin;
+class CTestUtils;
+class CCaStorageProxy;
+class CCaSrvEngUtils;
+#include <e32def.h>
+#include <QtTest/QtTest>
+
+class T_CaRunningAppMonitor : public QObject
+ {
+ Q_OBJECT
+
+private slots:
+
+ //setup methods
+ void init();
+ void cleanup();
+ void initTestCase();
+ void cleanupTestCase();
+ //tests
+ void T_Constuction();
+
+ void T_RunL();
+
+private:
+ CCaSrvPlugin* iPlugin;
+
+ CTestUtils* iTestUtils;
+
+ CCaStorageProxy* iStorage;
+
+ CCaSrvEngUtils* iSrvEngUtils;
+
+
+ };
+
+#endif // __T_casrvAppScaner_H__
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/inc/testconsts.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * testconsts.h
+ *
+ * Created on: 2009-08-24
+ *
+ */
+
+#ifndef TESTCONSTS_H_
+#define TESTCONSTS_H_
+
+// CONSTANTS
+
+//test utils
+_LIT(KTestDbSource, "C:\\testing\\data\\t_carunningappmonitor\\castorage.db");
+_LIT(KTestDbDest, "C:\\castorage.db");
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+_LIT8( KMidletMimeType, "application/java-archive" );
+
+//app scanner
+const TInt noteApp = 0xA0000230;
+const TInt notInstalledUid = 0xA0000232;// uid of not installed app
+const TInt installedUid = 0xE6BC1167; // installed app
+const TInt systemApp = 0x10005901;// system app eg. clock
+
+_LIT( KMmcIdValue, "00000001" );
+
+
+_LIT(KTennis,"SpruceTennis");
+_LIT(KDog,"SheepdogMIDlet");
+_LIT(KHelloWorld,"HelloWorld");
+_LIT(KPhotoBrowser,"photobrowser");
+_LIT(KPhotoSuiteLauncher,"PhotoSuiteLauncher");
+_LIT(KCalendar, "Calendar");
+
+#endif /* TESTCONSTS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2006 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: Plugin Interface
+*
+*/
+
+
+#ifndef C_WAITACTIVE_H
+#define C_WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // C_WAITACTIVE_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_carunningappmonitor_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/src/carunningappmonitortestutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2009 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 <W32STD.H>
+#include <e32property.h>
+#include <cadef.h>
+#include <badesca.h>
+#include <apgtask.h>
+#include <AknTaskList.h>
+#include <apgcli.h>
+#include <APACMDLN.h>
+#include <EIKENV.h>
+
+
+#include "cadef.h"
+#include "castorageproxy.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvplugin.h"
+
+
+#include "waitactive.h"
+#include "carunningappmonitortestutils.h"
+#include "testconsts.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTRUCTION
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewL()
+ {
+ CTestUtils* self = CTestUtils::NewLC();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewLC()
+ {
+ CTestUtils* self = new( ELeave ) CTestUtils();
+ CleanupStack::PushL( self );
+
+ self->ConstructL();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+// ---------------------------------------------------------------------------
+//
+CTestUtils::~CTestUtils()
+ {
+ iFileManager->Delete(KTestDbDest);
+ delete iFileManager; iFileManager = NULL;
+ iFs.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CTestUtils::CTestUtils()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second phase construct
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::ConstructL()
+ {
+ User::LeaveIfError( iFs.Connect() );
+ iFileManager = CFileMan::NewL( iFs );
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::Copy( const TDesC& aSource, const TDesC& aDest )
+ {
+ return iFileManager->Copy(aSource, aDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::CopyDb()
+ {
+ return Copy(KTestDbSource, KTestDbDest);
+ }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+TInt CTestUtils::LaunchApplicationL( const TUid aUid )
+ {
+ RWsSession wsSession;
+ User::LeaveIfError( wsSession.Connect() );
+ CleanupClosePushL<RWsSession>( wsSession );
+
+ CAknTaskList* taskList = CAknTaskList::NewL( wsSession );
+ TApaTask task = taskList->FindRootApp( aUid );
+ delete taskList;
+
+ if ( task.Exists() )
+ {
+ task.BringToForeground();
+ }
+ else
+ {
+ TApaAppInfo appInfo;
+ TApaAppCapabilityBuf capabilityBuf;
+ RApaLsSession appArcSession;
+ User::LeaveIfError( appArcSession.Connect() );
+ CleanupClosePushL<RApaLsSession>( appArcSession );
+
+ User::LeaveIfError( appArcSession.GetAppInfo( appInfo, aUid ) );
+ User::LeaveIfError( appArcSession.GetAppCapability( capabilityBuf, aUid ) );
+
+ TApaAppCapability& caps = capabilityBuf();
+ TFileName appName = appInfo.iFullName;
+ CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+ cmdLine->SetExecutableNameL( appName );
+
+ if ( caps.iLaunchInBackground )
+ {
+ cmdLine->SetCommandL( EApaCommandBackground );
+ }
+ else
+ {
+ cmdLine->SetCommandL( EApaCommandRun );
+ }
+
+ User::LeaveIfError( appArcSession.StartApp( *cmdLine ) );
+
+ CleanupStack::PopAndDestroy( cmdLine );
+ CleanupStack::PopAndDestroy( &appArcSession );
+ }
+ CleanupStack::PopAndDestroy( &wsSession );
+
+ //verification if app has really launched
+ WaitL(2000000);
+ RWsSession verWsSession;
+ User::LeaveIfError( verWsSession.Connect() );
+ CleanupClosePushL<RWsSession>( verWsSession );
+
+ CAknTaskList* verTaskList = CAknTaskList::NewL( verWsSession );
+ TApaTask verTask = verTaskList->FindRootApp( aUid );
+ delete verTaskList;
+
+ TInt result(KErrGeneral);
+ if ( verTask.Exists() )
+ {
+ result = KErrNone;
+ }
+ CleanupStack::PopAndDestroy( &verWsSession );
+ return result;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::TerminateApplicationL( const TUid aUid )
+ {
+ TApaTaskList taskList(CEikonEnv::Static()->WsSession());
+ TApaTask task = taskList.FindApp(aUid);
+ if (!task.Exists())
+ {
+ return KErrNotFound;
+ }
+ task.EndTask();
+ WaitL(2000000);
+ TApaTaskList newTaskList(CEikonEnv::Static()->WsSession());
+ return newTaskList.FindApp(aUid).Exists() ? KErrGeneral : KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::WaitL(TInt aMicroSec)
+ {
+ CWaitActive* wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TBool CTestUtils::IsRunningL(TUid aAppUid, CCaStorageProxy& aStorage)const
+ {
+ TBool retVal(EFalse);
+ RPointerArray<CCaInnerEntry> array;
+ CleanupResetAndDestroyPushL(array);
+
+ CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
+ allAppQuery->SetUid(static_cast<TUint>(aAppUid.iUid));
+ aStorage.GetEntriesL(allAppQuery, array);
+ CleanupStack::PopAndDestroy( allAppQuery );
+
+ if(0 >= array.Count())
+ {
+ User::Leave(KErrNotFound);
+ }
+ CCaInnerEntry* entry = array[0];
+ if( entry->GetFlags() & ERunning )
+ {
+ RBuf value;
+ CleanupClosePushL(value);
+ value.CreateL(KCaMaxAttrValueLen);
+ if( entry->FindAttribute(KCaAttrWindowGroupId, value) )
+ {
+ retVal = ETrue;
+ }
+ CleanupStack::PopAndDestroy(&value);
+ }
+ CleanupStack::PopAndDestroy(&array);
+ return retVal;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/src/t_carunningappmonitor.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,143 @@
+/*
+* 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006 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 "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/t_carunningappmonitor.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp \
+ ../../../../srvsrc/cainstallnotifier.cpp \
+ ../../../../srvsrc/cainstallstrategy.cpp \
+ ../../../../srvsrc/casrvengutils.cpp \
+ ../../../../srvsrc/castorageproxy.cpp \
+ ../../../../srvsrc/casrvnotifier.cpp \
+ ../../../../srvsrc/casrv.cpp \
+ ../../../../srvsrc/casrvmmchistory.cpp \
+ ../../../../srvsrc/casrvsession.cpp \
+ ../../../../srvsrc/cabackupnotifier.cpp \
+ ../../../casrvmgr/src/casrvmanager.cpp \
+ ../../../../cautils/src/*.cpp \
+ ../../../../castorage/src/*.cpp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/t_carunningappmonitor.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,118 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../../../srvinc \
+ ../../../../cautils/inc \
+ ../../../casrvmgr/inc \
+ ../../../../castorage/inc \
+ ../../../../srvinc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_carunningappmonitor.pri)
+coverage: {
+BLD_INF_RULES.prj_mmpfiles += "../../group/carunningappmonitor.mmp"
+}
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20026FB1
+ TARGET.CAPABILITY = ALL \
+ -TCB -DRM
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+ INCLUDEPATH += \
+ ../../../../inc \
+ ../../../casrvmgr/inc \
+ ../../../../srvinc \
+ ../../../../cautils/inc \
+ ../../../../castorage/inc
+
+ LIBS += \
+ -lcastorage \
+ -lcautils \
+ -lcasathandler \
+ -lcasrvmanager \
+ -lefsrv \
+ -lestor \
+ -lapparc \
+ -ldrmrightsinfo \
+ -lplatformenv \
+ -lsysutil \
+ -ldrmserverinterfaces \
+ -lswinstcli \
+ -leuser \
+ -lapgrfx \
+ -lWidgetRegistryClient \
+ -lws32 \
+ -lbafl \
+ -lavkon \
+ -lcone \
+ -lecom \
+ -lsisregistryclient \
+ -lsqldb \
+ -lflogger \
+ -lscrclient \
+ -lsifnotification
+
+
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = c:/testing/data/t_carunningappmonitor/
+
+ DEPLOYMENT += exportDB
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} $${exportDB.path}"
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_carunningappmonitor.exe -o c:\t_carunningappmonitor.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/carunningappmonitor/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS = t_carunningappmonitor
+
+CONFIG += ordered
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,22 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call cd ../../../group
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
Binary file contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/data/castorage.db has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call cd ../../group
+
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE=../src/*" abld build winscw udeb
+
+call cd ../tsrc/t_satmonitor/
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call abld build winscw udeb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../../group");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../src/*\" sbs -j 4 -c winscw_udeb");
+
+
+ chdir("../tsrc/t_satmonitor");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_satmonitor -o c:\\t_satmonitor.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../../group");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../tsrc/t_satmonitor/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../tsrc/t_satmonitor/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/inc/T_casatmonitor.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_casatmonitor.h
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+#ifndef T_CASATMONITOR_H
+#define T_CASATMONITOR_H
+
+class CTestUtils;
+class CCaStorageProxy;
+class CCaSrvManager;
+#include <QtTest/QtTest>
+
+#include <e32def.h>
+
+// CLASS DEFINITION
+class CSatMonitor;
+/**
+ *
+ * Test class.
+ *
+ */
+class T_CaSatMonitor: public QObject
+{
+ Q_OBJECT
+
+private:
+
+ void WaitL(TInt aMicroSec);
+
+private slots:
+
+ //setup methods
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+
+ //tests for sat monitor/notifier
+ void testSatChange();
+
+private:
+
+ CTestUtils *iTestUtils;
+
+ CCaStorageProxy *iStorage;
+
+ RBuf iSatName;
+
+ TInt iSatVis;
+
+ CCaSrvManager *iSrvManager;
+};
+
+#endif // T_CASATHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/inc/casatmonitortestutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef CA_SAT_MONITOR_TEST_UTILS_H
+#define CA_SAT_MONITOR_TEST_UTILS_H
+
+#include "f32file.h"
+#include "casrvplugin.h"
+
+
+class CCaStorageProxy;
+class CCaInnerEntry;
+
+class CTestUtils: public CBase
+{
+public:
+
+ /**/
+ virtual ~CTestUtils();
+
+ /**/
+ static CTestUtils* NewL();
+
+ /**/
+ static CTestUtils* NewLC();
+
+ /**/
+ TUint FingAppUidL( const TDesC& aName, CCaStorageProxy* aStorage );
+
+ /**/
+ void WaitL(TInt aMicroSec);
+
+ /**
+ * Gets RProperty
+ */
+ TInt GetRProperty( TUid aCategory, TUint aKey, TDes& aValue );
+
+ /**
+ * Gets RProperty
+ */
+ TInt GetRProperty( TUid aCategory, TUint aKey, TInt& aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt SetRProperty( TUid aCategory, TUint aKey, const TDesC& aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt SetRProperty( TUid aCategory, TUint aKey, TInt aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt DefineIntRProperty( TUid aCategory, TUint aKey );
+
+ /**
+ * Sets RProperty
+ */
+ TInt DefineTextRProperty( TUid aCategory, TUint aKey );
+
+ /**
+ * Copys test Db
+ */
+ TInt CopyDb();
+
+ /**
+ * Checks if app exists in Db
+ */
+ TBool AppExistsInStorageL( TInt aUid, CCaStorageProxy* aStorage);
+
+ CCaInnerEntry* GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage);
+
+ TInt AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage);
+
+ TInt GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage);
+
+ void RemoveAppL( TInt aUid, CCaStorageProxy* aStorage);
+
+ CCaSrvPlugin* LoadPluginL( TUid aImplUid, TPluginParams aPluginParams );
+
+private:
+
+ /**
+ * Copys files
+ */
+ TInt Copy( const TDesC& aSource, const TDesC& aDest );
+
+ CTestUtils();
+
+ void ConstructL();
+
+ RFs iFs;
+ CFileMan* iFileManager;
+
+ /**
+ * Local Active Sheduler.
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveWait;
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/inc/testconsts.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * testconsts.h
+ *
+ * Created on: 2009-08-24
+ *
+ */
+
+#ifndef TESTCONSTS_H_
+#define TESTCONSTS_H_
+
+// CONSTANTS
+
+//test utils
+_LIT(KTestDbSource, "C:\\testing\\data\\t_satmonitor\\castorage.db");
+_LIT(KTestDbDest, "C:\\castorage.db");
+
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+
+
+//app scanner
+const TInt noteApp = 0xA0000230;
+const TInt notInstalledUid = 0xA0000232;// uid of not installed app
+const TInt installedUid = 0xE6BC1167; // installed app
+const TInt systemApp = 0x10005901;// system app eg. clock
+
+_LIT( KMmcIdValue, "00000001" );
+
+_LIT(KTennis,"SpruceTennis");
+_LIT(KDog,"SheepdogMIDlet");
+_LIT(KHelloWorld,"HelloWorld");
+_LIT(KPhotoBrowser,"photobrowser");
+_LIT(KPhotoSuiteLauncher,"PhotoSuiteLauncher");
+_LIT(KCalendar, "Calendar");
+
+#endif /* TESTCONSTS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 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: CWaitActive declaration
+*
+*/
+
+#ifndef WAITACTIVE_H
+#define WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // WAITACTIVE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_satmonitor_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/src/T_casatmonitor.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_casatmonitor.cpp
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+// CLASS HEADER
+
+
+#include <ecom/ecom.h>
+#include "ca2internalCRkeys.h"
+#include "T_casatmonitor.h"
+#include "casatmonitortestutils.h"
+#include "cadef.h"
+#include "waitactive.h"
+#include "casrvengutils.h"
+#include "castorageproxy.h"
+#include "casrvmanager.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+
+
+const TUid KSatPluginUid = {0x20026FAE};
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatMonitor::WaitL(TInt aMicroSec)
+{
+ CWaitActive *wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatMonitor::initTestCase()
+{
+}
+
+void T_CaSatMonitor::cleanupTestCase()
+{
+}
+
+void T_CaSatMonitor::init()
+{
+ iTestUtils = CTestUtils::NewL();
+ iTestUtils->CopyDb();
+
+ iStorage = CCaStorageProxy::NewL();
+ //iSrvEngUtils = CCaSrvEngUtils::NewL();
+
+ ///remember preconditions
+ iTestUtils->GetRProperty(KCRUidCa, KCaSatUIName, iSatName);
+ iTestUtils->GetRProperty(KCRUidCa, KCaShowSatUI, iSatVis);
+ iTestUtils->WaitL(1000000);
+ ///
+
+ RBuf satName;
+ satName.CleanupClosePushL();
+ satName.CreateL(_L("testname_old"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(KSatUid.iUid);
+ innerEntry->SetTextL(satName);
+ innerEntry->AddAttributeL(KCaAttrShortName, satName);
+
+ iStorage->AddL(innerEntry);
+
+ TInt err = iTestUtils->DefineIntRProperty(KCRUidCa, KCaShowSatUI);
+ err = iTestUtils->DefineTextRProperty(KCRUidCa, KCaSatUIName);
+ err = iTestUtils->SetRProperty(KCRUidCa, KCaShowSatUI, 1);
+ iTestUtils->WaitL(1000000);
+ iTestUtils->SetRProperty(KCRUidCa, KCaSatUIName, _L("testname_old"));
+ iTestUtils->WaitL(1000000);
+
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&satName);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatMonitor::cleanup()
+{
+ ///restore preconditions
+ iTestUtils->SetRProperty(KCRUidCa, KCaSatUIName, iSatName);
+ iTestUtils->SetRProperty(KCRUidCa, KCaShowSatUI, iSatVis);
+
+ delete iStorage;
+ iStorage = NULL;
+ delete iTestUtils;
+ iTestUtils = NULL;
+ REComSession::FinalClose();
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatMonitor::testSatChange()
+{
+ bool nonEmptySatList(false);
+ bool nameMatches(false);
+ TInt err(KErrNone);
+
+ TPluginParams params;
+ params.engUtils = 0;
+ params.storageProxy = iStorage;
+
+ TRAP(err,
+ CCaSrvPlugin *plug = iTestUtils->LoadPluginL(KSatPluginUid, params);
+ iTestUtils->WaitL(10000000);//load plugin
+
+ RBuf newSatName;
+ newSatName.CleanupClosePushL();
+ newSatName.CreateL(_L("testname"));
+
+ TInt err = iTestUtils->SetRProperty(
+ KCRUidCa, KCaSatUIName, newSatName);
+ err = iTestUtils->SetRProperty(
+ KCRUidCa, KCaShowSatUI, 1);
+ iTestUtils->WaitL(10000000);
+ delete plug;
+ CCaInnerQuery *satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid(KSatUid.iUid);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ iStorage->GetEntriesL(satAppQuery, resultArray);
+
+ nonEmptySatList = (resultArray.Count() >= 1);
+ nameMatches = newSatName.Compare(resultArray[0]->GetText()) == 0;
+
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(satAppQuery);
+ CleanupStack::PopAndDestroy(&newSatName);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(nonEmptySatList);
+ QVERIFY(nameMatches);
+}
+
+QTEST_MAIN(T_CaSatMonitor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/src/casatmonitortestutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,367 @@
+/*
+* Copyright (c) 2009 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 <W32STD.H>
+#include <e32property.h>
+#include <cadef.h>
+#include <badesca.h>
+#include <apgtask.h>
+#include <AknTaskList.h>
+#include <apgcli.h>
+#include <APACMDLN.h>
+#include <EIKENV.h>
+
+
+#include "castorageproxy.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvplugin.h"
+#include "waitactive.h"
+#include "casatmonitortestutils.h"
+#include "testconsts.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTRUCTION
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewL()
+ {
+ CTestUtils* self = CTestUtils::NewLC();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewLC()
+ {
+ CTestUtils* self = new( ELeave ) CTestUtils();
+ CleanupStack::PushL( self );
+
+ self->ConstructL();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+// ---------------------------------------------------------------------------
+//
+CTestUtils::~CTestUtils()
+ {
+ iFileManager->Delete(KTestDbDest);
+ delete iFileManager; iFileManager = NULL;
+ iFs.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CTestUtils::CTestUtils()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second phase construct
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::ConstructL()
+ {
+ User::LeaveIfError( iFs.Connect() );
+ iFileManager = CFileMan::NewL( iFs );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::WaitL(TInt aMicroSec)
+ {
+ CWaitActive* wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::GetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::GetRProperty( TUid aCategory, TUint aKey, TDes& aValue )
+ {
+ return RProperty::Get( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::GetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::GetRProperty( TUid aCategory, TUint aKey, TInt& aValue )
+ {
+ return RProperty::Get( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::SetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::SetRProperty( TUid aCategory, TUint aKey, const TDesC& aValue )
+ {
+ return RProperty::Set( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::SetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::SetRProperty( TUid aCategory, TUint aKey, TInt aValue )
+ {
+ return RProperty::Set( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::DefineRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::DefineTextRProperty( TUid aCategory, TUint aKey )
+ {
+ return RProperty::Define( aCategory, aKey, RProperty::EText );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::DefineIntRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::DefineIntRProperty( TUid aCategory, TUint aKey )
+ {
+ return RProperty::Define( aCategory, aKey, RProperty::EInt );
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::Copy( const TDesC& aSource, const TDesC& aDest )
+ {
+ return iFileManager->Copy(aSource, aDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::CopyDb()
+ {
+ return Copy(KTestDbSource, KTestDbDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TBool CTestUtils::AppExistsInStorageL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TBool exists(EFalse);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ exists = ETrue;
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return exists;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+CCaInnerEntry* CTestUtils::GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerEntry* entry = NULL;
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ entry = resultArray[0];
+ resultArray.Remove(0);
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return entry;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ satAppQuery->SetFlagsOff( aFlags );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TInt count = resultArray.Count();
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return count;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TInt flags(0);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ flags = resultArray[0]->GetFlags();
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return flags;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+void CTestUtils::RemoveAppL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ RArray<TInt> idsToRemove;
+ CleanupClosePushL(idsToRemove);
+ idsToRemove.AppendL( resultArray[0]->GetId() );
+ aStorage->RemoveL(idsToRemove);
+ CleanupStack::PopAndDestroy( &idsToRemove );
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TUint CTestUtils::FingAppUidL( const TDesC& aName, CCaStorageProxy* aStorage )
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TUint appUid(0);
+ for ( TInt i = 0; i < resultArray.Count(); i++ )
+ {
+ if ( resultArray[i]->GetText() == aName )
+ {
+ appUid = resultArray[i]->GetUid();
+ }
+ }
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return appUid;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+CCaSrvPlugin* CTestUtils::LoadPluginL( TUid aImplUid, TPluginParams aPluginParams )
+ {
+ RImplInfoPtrArray infoArray;
+
+ // Note that a special cleanup function is required to reset and destroy
+ // all items in the array, and then close it.
+ CleanupResetAndDestroyPushL( infoArray );
+ CCaSrvPlugin::ListAllImplementationsL( infoArray );
+
+ // Loop through each info for each implementation
+ // and create and use each in turn
+ CCaSrvPlugin* plug;
+ for( TInt i = 0; i < infoArray.Count(); i++ )
+ {
+ // Slice off first sub-section in the data section
+ TUid current_plugin = infoArray[i]->ImplementationUid();
+ if ( current_plugin == aImplUid )
+ {
+ plug = CCaSrvPlugin::NewL( current_plugin, &aPluginParams );
+ CleanupStack::PushL( plug );
+ TInt32 key = current_plugin.iUid;
+ //iPluginMap.InsertL( key, plug );
+ CleanupStack::Pop( plug );
+ break;
+ }
+ plug = NULL;
+ }
+ CleanupStack::PopAndDestroy( &infoArray );
+ return plug;
+ }
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2009 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: CWaitActive implementation
+*
+*/
+
+#include "waitactive.h"
+
+#include "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/t_satmonitor.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp \
+ ../../../../srvsrc/cainstallnotifier.cpp \
+ ../../../../srvsrc/cainstallstrategy.cpp \
+ ../../../../srvsrc/casrvengutils.cpp \
+ ../../../../srvsrc/castorageproxy.cpp \
+ ../../../../srvsrc/casrvnotifier.cpp \
+ ../../../../srvsrc/casrv.cpp \
+ ../../../../srvsrc/casrvmmchistory.cpp \
+ ../../../../srvsrc/casrvsession.cpp \
+ ../../../../srvsrc/cabackupnotifier.cpp \
+ ../../../casrvmgr/src/casrvmanager.cpp \
+ ../../../../cautils/src/*.cpp \
+ ../../../../castorage/src/*.cpp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/t_satmonitor.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,104 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+coverage: {
+BLD_INF_RULES.prj_mmpfiles += "../../group/casatmonitor.mmp"
+}
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../../../srvinc \
+ ../../../../extinc \
+ ../../../../cautils/inc \
+ ../../../casrvmgr/inc \
+ ../../../../castorage/inc \
+ ../../../../srvinc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_satmonitor.pri)
+
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x2002870F
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lefsrv \
+ -lestor \
+ -lapparc \
+ -lapgrfx \
+ -lcautils \
+ -lsysutil \
+ -lsqldb \
+ -lws32 \
+ -lbafl \
+ -lecom \
+ -lcasrvmanager \
+ -lflogger \
+ -lscrclient \
+ -lsifnotification
+
+
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = c:/testing/data/t_satmonitor/
+
+ DEPLOYMENT += exportDB
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} $${exportDB.path}"
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/t_satmonitor/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_satmonitor.exe -o c:\t_satmonitor.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/casatmonitor/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS = t_satmonitor
+
+CONFIG += ordered
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
Binary file contentstorage/casrv/causifscanner/tsrc/t_causifscanner/data/armv5/sapiapp_S60_3_X_v_1_0_0.sisx has changed
Binary file contentstorage/casrv/causifscanner/tsrc/t_causifscanner/data/castorage.db has changed
Binary file contentstorage/casrv/causifscanner/tsrc/t_causifscanner/data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE+../../src/*" abld build winscw udeb
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../../src/*\" -C \"NO_EXCLUDE+../../../../srvsrc/cainstallstrategy.cpp\" sbs -j 4 -c winscw_udeb");
+
+ }
+
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_causifscanner -o c:\\t_causifscanner.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/inc/T_caUsifScaner.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009 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:
+ *
+ */
+
+#ifndef __T_caUsifScanner_H__
+#define __T_caUsifScanner_H__
+
+#include <QtTest/QtTest>
+
+#include "casrvplugin.h"
+#include "casrvmanager.h"
+
+// FORWARD DECLARATIONS
+class CTestUtils;
+class CCaStorageProxy;
+class CCaSrvEngUtils;
+class T_CaInstaller;
+
+namespace Usif{
+ class RSoftwareComponentRegistry;
+}
+
+#include <e32def.h>
+
+class T_caUsifScaner : public QObject
+{
+ Q_OBJECT
+public:
+
+ T_caUsifScaner();
+
+private slots:
+
+ void initTestCase();
+ void init();
+
+ void testNew();
+ void testLoadPlugin();
+ void testInstalled();
+ void testAddNewApp();
+ void testAddRemovable();
+ void testInstallNotifier();
+
+ void testJavaStrategy();
+ void testSwiStrategy();
+ void testUsifStrategy();
+
+
+ void cleanup();
+ void cleanupTestCase();
+
+
+
+private: // Data
+ //setup methods
+
+ void Setup_AddNewAppL();
+ void Setup_AddRemovableL();
+
+ CTestUtils *iTestUtils;
+
+ CCaStorageProxy *iStorage;
+
+ CCaSrvEngUtils *iSrvEngUtils;
+
+ TPluginParams iPluginParams;
+
+ T_CaInstaller *iInstaller;
+
+ Usif::RSoftwareComponentRegistry *iScr;
+};
+
+#endif // __T_caUsifScanner_H__
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/inc/casrvtestutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+//utility class for tests
+//all utility methods should be implemented here
+
+#include "casrvengutils.h"
+#include "casrvplugin.h"
+
+class CCaStorageProxy;
+class CCaInnerEntry;
+
+class CTestUtils: public CBase
+{
+public:
+
+ /**/
+ virtual ~CTestUtils();
+
+ /**/
+ static CTestUtils* NewL();
+
+ /**/
+ static CTestUtils* NewLC();
+
+ /**/
+ TUint FindAppUidL( const TDesC& aName, CCaStorageProxy* aStorage );
+
+ /**/
+ TInt LaunchApplicationL( const TUid aUid );
+
+ /**/
+ TInt SimpleCloseTaskL(TInt aUid);
+
+ /**/
+ void WaitL(TInt aMicroSec);
+
+ /**/
+ void InstallFinishedL();
+
+ /**
+ * Gets RProperty
+ */
+ TInt GetRProperty( TUid aCategory, TUint aKey, TDes& aValue );
+
+ /**
+ * Gets RProperty
+ */
+ TInt GetRProperty( TUid aCategory, TUint aKey, TInt& aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt SetRProperty( TUid aCategory, TUint aKey, const TDesC& aValue );
+
+ /**
+ * Sets RProperty
+ */
+ TInt SetRProperty( TUid aCategory, TUint aKey, TInt aValue );
+
+ /**
+ * Copys test Db
+ */
+ TInt CopyDb();
+
+ /**
+ * Checks if app exists in Db
+ */
+ TBool AppExistsInStorageL( TInt aUid, CCaStorageProxy* aStorage);
+
+ CCaInnerEntry* GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage);
+
+ TInt AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage);
+
+ TInt GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage);
+
+ TInt GetPackageFlagsL( const TDesC& aSource, CCaStorageProxy* aStorage);
+
+ void RemoveAppL( TInt aUid, CCaStorageProxy* aStorage);
+ void CopyMmcHistory();
+
+ CCaSrvPlugin* LoadPluginL( TUid aImplUid, TPluginParams aPluginParams );
+
+private:
+
+ /**
+ * Copys files
+ */
+ TInt Copy( const TDesC& aSource, const TDesC& aDest );
+
+ CTestUtils();
+
+ void ConstructL();
+
+ RFs iFs;
+ CFileMan* iFileManager;
+
+ /**
+ * Local Active Sheduler.
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveWait;
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/inc/testconsts.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * testconsts.h
+ *
+ * Created on: 2009-08-24
+ *
+ */
+
+#ifndef TESTCONSTS_H_
+#define TESTCONSTS_H_
+
+// CONSTANTS
+
+//test utils
+
+_LIT(KTestDbSource, "C:\\testing\\data\\t_causifscanner\\castorage.db");
+_LIT(KTestDbDest, "C:\\castorage.db");
+
+_LIT( KSapiPackageFileName,
+ "c:\\testing\\data\\t_causifscanner\\installs\\sapiapp_S60_3_X_v_1_0_0.sisx" );
+_LIT( KSapiAppFileName,
+ "c:\\sys\\bin\\sapiapp.exe" );
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+
+//usif scanner
+const TInt noteApp = 0xA0000230;
+const TInt notInstalledUid = 0xA0000232;// uid of not installed app
+const TInt installedUid = 0xE6BC1167; // installed app
+const TInt systemApp = 0x20022EF9;
+
+
+_LIT(KTennis,"SpruceTennis");
+_LIT(KDog,"SheepdogMIDlet");
+_LIT(KHelloWorld,"HelloWorld");
+_LIT(KPhotoBrowser,"photobrowser");
+_LIT(KPhotoSuiteLauncher,"PhotoSuiteLauncher");
+_LIT(KCalendar, "Calendar");
+_LIT(KSapiApp, "sapiapp");
+
+#endif /* TESTCONSTS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2006 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: Plugin Interface
+*
+*/
+
+
+#ifndef C_WAITACTIVE_H
+#define C_WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // C_WAITACTIVE_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_causifscanner_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/src/T_caUsifScaner.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,285 @@
+/*
+* 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 <w32std.h>
+#include <apgtask.h>
+#include <usif/sif/sifcommon.h>
+#include <usif/sif/sif.h>
+
+// CLASS HEADER
+#include "T_caUsifScaner.h"
+
+// EXTERNAL INCLUDES
+
+#include <cadef.h>
+
+#include "castoragefactory.h"
+#include "castorageproxy.h"
+#include "casrvengutils.h"
+#include "causifscanner.h"
+#include "causifscanner.hrh"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvmmchistory.h"
+
+// INTERNAL INCLUDES
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+#include "t_cainstaller.h"
+
+#ifdef COVERAGE_MEASUREMENT
+const unsigned int TIMEOUT_FACTOR = 2;
+#else
+const unsigned int TIMEOUT_FACTOR = 1;
+#endif
+
+// ---------------------------------------------------------------------------
+//
+T_caUsifScaner::T_caUsifScaner():
+ iTestUtils(NULL),
+ iStorage(NULL),
+ iSrvEngUtils(NULL)
+{
+}
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::initTestCase()
+{
+ if (iTestUtils == NULL) {
+ TRAPD(err, iTestUtils = CTestUtils::NewL());
+ QCOMPARE(err, KErrNone);
+ }
+ QT_TRAP_THROWING(iInstaller = T_CaInstaller::NewL());
+ TRAP_IGNORE(iInstaller->InstallL(KSapiPackageFileName));
+ QTest::qWait(10000);
+
+ delete iTestUtils;
+ iTestUtils = NULL;
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::init()
+{
+ TRAPD(err,
+ iTestUtils = CTestUtils::NewL();
+ iTestUtils->CopyDb();
+
+ iStorage = CCaStorageProxy::NewL();
+ iSrvEngUtils = CCaSrvEngUtils::NewL();
+
+ iScr = new Usif::RSoftwareComponentRegistry;
+ User::LeaveIfError( iScr->Connect() );
+
+ iPluginParams.storageProxy = iStorage;
+ iPluginParams.engUtils = iSrvEngUtils;
+ iPluginParams.softwareRegistry = iScr;
+ );
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::cleanup()
+{
+ iPluginParams.storageProxy = NULL;
+ iPluginParams.engUtils = NULL;
+ iScr->Close();
+ iPluginParams.softwareRegistry = NULL;
+
+ delete iSrvEngUtils;
+ iSrvEngUtils = NULL;
+ delete iStorage;
+ iStorage = NULL;
+ delete iTestUtils;
+ iTestUtils = NULL;
+ delete iScr;
+ iScr = NULL;
+}
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::cleanupTestCase()
+{
+ TRAPD(err, iInstaller->UninstallL(KSapiAppFileName));
+ QCOMPARE(err, KErrNone);
+
+ delete iTestUtils;
+ iTestUtils = NULL;
+
+ delete iInstaller;
+ REComSession::FinalClose();
+}
+
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testNew()
+{
+ bool result(false);
+ TRAPD(err,
+ CCaUsifScanner *usifScanner = CCaUsifScanner::NewL(&iPluginParams);
+ result = usifScanner != NULL;
+ QTest::qWait(5000);
+ delete usifScanner;
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testLoadPlugin()
+{
+ bool result(false);
+ TRAPD(err, CCaSrvPlugin *plug = iTestUtils->LoadPluginL(
+ TUid::Uid(KCaSrvUsifScannerPlugin), iPluginParams);
+ result = plug != NULL;
+
+ QTest::qWait(5000);
+ delete plug;
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testInstalled()
+{
+ bool flags(false);
+ TRAPD(err,
+ CCaUsifScanner *usifScaner = CCaUsifScanner::NewL(&iPluginParams);
+ CleanupStack::PushL(usifScaner);
+ QTest::qWait(5000);
+ //visible flag update
+ flags = ((iTestUtils->GetPackageFlagsL(KSapiApp, iStorage)
+ & (EVisible | ERemovable) ) != FALSE);
+ CleanupStack::PopAndDestroy(usifScaner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(flags);
+}
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testAddNewApp()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_AddNewAppL();
+ CCaUsifScanner *usifScaner = CCaUsifScanner::NewL(&iPluginParams);
+ CleanupStack::PushL(usifScaner);
+ QTest::qWait(5000);
+ // new app added
+ result = ((iTestUtils->GetPackageFlagsL(KSapiApp,iStorage)
+ & (EVisible | ERemovable)) != FALSE);
+
+ CleanupStack::PopAndDestroy(usifScaner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testAddRemovable()
+{
+ bool result(false);
+ TRAPD(err,
+ Setup_AddRemovableL();
+ CCaUsifScanner *usifScaner = CCaUsifScanner::NewL(&iPluginParams);
+ CleanupStack::PushL(usifScaner);
+ QTest::qWait(5000 * TIMEOUT_FACTOR);
+ //add removable flag to installed app
+ result = ((iTestUtils->GetPackageFlagsL(KSapiApp, iStorage)
+ & (ERemovable | EVisible)) != FALSE);
+
+ CleanupStack::PopAndDestroy(usifScaner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testInstallNotifier()
+{
+ bool existsAfterInstall(false);
+ TRAPD(err,
+ CCaUsifScanner *usifScanner = CCaUsifScanner::NewL(&iPluginParams);
+ CleanupStack::PushL(usifScanner);
+ iInstaller->InstallL(KSapiPackageFileName);
+ QTest::qWait(20000 * TIMEOUT_FACTOR);
+ existsAfterInstall = iTestUtils->GetPackageFlagsL(KSapiApp, iStorage);
+ CleanupStack::PopAndDestroy(usifScanner);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(existsAfterInstall);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::Setup_AddNewAppL()
+{
+ TBool exists = iTestUtils->AppExistsInStorageL(installedUid, iStorage);
+ if (exists) {
+ iTestUtils->RemoveAppL(installedUid, iStorage);
+ exists = iTestUtils->AppExistsInStorageL(installedUid, iStorage);
+ if (exists) {
+ User::Leave(KErrNotReady);
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::Setup_AddRemovableL()
+{
+ RBuf testName;
+ testName.CleanupClosePushL();
+ testName.CreateL(_L("Removable"));
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetEntryTypeNameL(KCaTypeApp);
+ innerEntry->SetUid(installedUid);
+ innerEntry->SetFlags(innerEntry->GetFlags() & ~ERemovable | EVisible);
+ innerEntry->SetTextL(testName);
+ innerEntry->AddAttributeL(KCaAttrComponentId, _L("10"));
+
+ iStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+ CleanupStack::PopAndDestroy(&testName);
+}
+
+QTEST_MAIN(T_caUsifScaner);
+
+// END OF FILE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/src/T_installNotifier.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,143 @@
+/*
+* 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 <swinstdefs.h>
+#include <swinstapi.h>
+#include <w32std.h>
+#include <apgtask.h>
+
+// CLASS HEADER
+#include "T_caUsifScaner.h"
+
+// EXTERNAL INCLUDES
+
+#include <cadef.h>
+
+#include "castoragefactory.h"
+#include "castorageproxy.h"
+#include "casrvengutils.h"
+#include "causifscanner.h"
+#include "causifscanner.hrh"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvmmchistory.h"
+#include "cainstallnotifier.h"
+#include "cammcwatcher.h"
+#include "cainstallstrategy.h"
+
+// INTERNAL INCLUDES
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+#ifdef COVERAGE_MEASUREMENT
+const unsigned int TIMEOUT_FACTOR = 2;
+#else
+const unsigned int TIMEOUT_FACTOR = 1;
+#endif
+
+class TTestsListener : public MCaInstallListener, public MMmcWatcherCallback
+ {
+public:
+ void HandleInstallNotifyL(TInt aEvent)
+ {
+ iStatus = ETrue;
+ }
+
+ virtual void MmcChangeL()
+ {
+ iStatus = ETrue;
+ }
+
+ TBool iStatus;
+ };
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testJavaStrategy()
+{
+ bool result(false);
+
+ TTestsListener listener;
+ listener.iStatus = EFalse;
+
+ TRAPD(err,
+ RProperty property;
+ CCaJavaInstallStrategy *installStrategy =
+ CCaJavaInstallStrategy::NewL( property );
+
+ installStrategy->NotifyListenerL( property, listener );
+ result = installStrategy != NULL;
+ delete installStrategy;
+ property.Close();
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+ QVERIFY(listener.iStatus != EFalse);
+}
+
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testUsifStrategy()
+{
+
+ bool result(false);
+
+ TTestsListener listener;
+ listener.iStatus = EFalse;
+
+ TRAPD(err,
+ RProperty property;
+ CCaUsifUninstallStrategy *installStrategy =
+ CCaUsifUninstallStrategy::NewL( property );
+ result = installStrategy != NULL;
+ installStrategy->NotifyListenerL( property, listener );
+
+ delete installStrategy;
+ property.Close();
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+ QVERIFY(listener.iStatus == EFalse);
+}
+
+// ---------------------------------------------------------------------------
+//
+void T_caUsifScaner::testSwiStrategy()
+{
+
+ bool result(false);
+
+ TTestsListener listener;
+ listener.iStatus = EFalse;
+
+ TRAPD(err,
+ RProperty property;
+ CCaSwiInstallStrategy *installStrategy =
+ CCaSwiInstallStrategy::NewL( property );
+
+ installStrategy->NotifyListenerL( property, listener );
+ result = installStrategy != NULL;
+ delete installStrategy;
+ property.Close();
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+ QVERIFY(listener.iStatus != EFalse);
+}
+
+
+// END OF FILE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/src/casrvtestutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,496 @@
+/*
+* Copyright (c) 2009 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 <W32STD.H>
+#include <e32property.h>
+#include <cadef.h>
+#include <badesca.h>
+#include <apgtask.h>
+#include <AknTaskList.h>
+#include <apgcli.h>
+#include <APACMDLN.h>
+#include <EIKENV.h>
+
+
+#include "castorageproxy.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvplugin.h"
+
+
+#include "waitactive.h"
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTRUCTION
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewL()
+ {
+ CTestUtils* self = CTestUtils::NewLC();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewLC()
+ {
+ CTestUtils* self = new( ELeave ) CTestUtils();
+ CleanupStack::PushL( self );
+
+ self->ConstructL();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+// ---------------------------------------------------------------------------
+//
+CTestUtils::~CTestUtils()
+ {
+ iFileManager->Delete(KTestDbDest);
+ delete iFileManager; iFileManager = NULL;
+ iFs.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CTestUtils::CTestUtils()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second phase construct
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::ConstructL()
+ {
+ User::LeaveIfError( iFs.Connect() );
+ iFileManager = CFileMan::NewL( iFs );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::WaitL(TInt aMicroSec)
+ {
+ CWaitActive* wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::GetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::GetRProperty( TUid aCategory, TUint aKey, TDes& aValue )
+ {
+ return RProperty::Get( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::GetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::GetRProperty( TUid aCategory, TUint aKey, TInt& aValue )
+ {
+ return RProperty::Get( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::SetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::SetRProperty( TUid aCategory, TUint aKey, const TDesC& aValue )
+ {
+ return RProperty::Set( aCategory, aKey, aValue );
+ }
+
+// ---------------------------------------------------------------------------
+// CTestUtils::SetRProperty
+// ---------------------------------------------------------------------------
+//
+TInt CTestUtils::SetRProperty( TUid aCategory, TUint aKey, TInt aValue )
+ {
+ return RProperty::Set( aCategory, aKey, aValue );
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::Copy( const TDesC& aSource, const TDesC& aDest )
+ {
+ return iFileManager->Copy(aSource, aDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::CopyDb()
+ {
+ return Copy(KTestDbSource, KTestDbDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TBool CTestUtils::AppExistsInStorageL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TBool exists(EFalse);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ exists = ETrue;
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return exists;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+CCaInnerEntry* CTestUtils::GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerEntry* entry = NULL;
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ entry = resultArray[0];
+ resultArray.Remove(0);
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return entry;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ satAppQuery->SetFlagsOff( aFlags );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TInt count = resultArray.Count();
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return count;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TInt flags(0);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ flags = resultArray[0]->GetFlags();
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return flags;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::GetPackageFlagsL(
+ const TDesC& aSource, CCaStorageProxy* aStorage)
+ {
+ TInt flags(0);
+
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypePackage );
+ satAppQuery->SetEntryTypeNames( appType );
+ CleanupStack::Pop( appType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ for( TInt i = 0; i < resultArray.Count(); i++ )
+ {
+ if ( resultArray[i]->GetText().Compare( aSource ) == KErrNone )
+ {
+ flags = resultArray[i]->GetFlags();
+ }
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return flags;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+void CTestUtils::RemoveAppL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* appQuery = CCaInnerQuery::NewLC();
+ appQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( appQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ RArray<TInt> idsToRemove;
+ CleanupClosePushL(idsToRemove);
+ idsToRemove.AppendL( resultArray[0]->GetId() );
+ aStorage->RemoveL(idsToRemove);
+ CleanupStack::PopAndDestroy( &idsToRemove );
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( appQuery );
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+
+void CTestUtils::CopyMmcHistory()
+{
+// iFileManager->Copy( KTestMmcHistSource, KTestMmcHistDest );
+}
+
+
+//-----------------------------------------------------------------------
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TUint CTestUtils::FindAppUidL( const TDesC& aName, CCaStorageProxy* aStorage )
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TUint appUid(0);
+ for ( TInt i = 0; i < resultArray.Count(); i++ )
+ {
+ if ( resultArray[i]->GetText() == aName )
+ {
+ appUid = resultArray[i]->GetUid();
+ }
+ }
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return appUid;
+ }
+
+// -----------------------------------------------------------------------------
+//
+TInt CTestUtils::SimpleCloseTaskL(TInt aUid)
+ {
+ RWsSession session;
+ TInt error = session.Connect();
+ TUid uidApp( TUid::Uid( aUid )) ;
+ TApaTaskList taskList( session );
+ TApaTask task = taskList.FindApp( uidApp );
+
+ if( task.Exists() )
+ {
+ task.EndTask();
+ }
+ else
+ {
+ error = KErrNotFound;
+ }
+
+ WaitL( 4000000 );
+ session.Close();
+ WaitL( 1000000 );
+
+ return error;
+ }
+
+// ----------------------------------------------------------------------------
+//
+void CTestUtils::InstallFinishedL()
+ {
+ iActiveWait->AsyncStop();
+ }
+
+
+// ---------------------------------------------------------
+// CTestUtils::LaunchApplicationL
+// ---------------------------------------------------------
+
+CCaSrvPlugin* CTestUtils::LoadPluginL( TUid aImplUid, TPluginParams aPluginParams )
+ {
+ RImplInfoPtrArray infoArray;
+
+ // Note that a special cleanup function is required to reset and destroy
+ // all items in the array, and then close it.
+ CleanupResetAndDestroyPushL( infoArray );
+ CCaSrvPlugin::ListAllImplementationsL( infoArray );
+
+ // Loop through each info for each implementation
+ // and create and use each in turn
+ CCaSrvPlugin* plug = NULL;
+ for( TInt i = 0; i < infoArray.Count(); i++ )
+ {
+ // Slice off first sub-section in the data section
+ TUid current_plugin = infoArray[i]->ImplementationUid();
+ if ( current_plugin == aImplUid )
+ {
+ plug = CCaSrvPlugin::NewL( current_plugin, &aPluginParams );
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy( &infoArray );
+ return plug;
+ }
+
+
+
+
+// ---------------------------------------------------------
+// CTestUtils::LaunchApplicationL
+// ---------------------------------------------------------
+//
+TInt CTestUtils::LaunchApplicationL( const TUid aUid )
+ {
+ RWsSession wsSession;
+ User::LeaveIfError( wsSession.Connect() );
+ CleanupClosePushL<RWsSession>( wsSession );
+
+ CAknTaskList* taskList = CAknTaskList::NewL( wsSession );
+ TApaTask task = taskList->FindRootApp( aUid );
+ delete taskList;
+
+ if ( task.Exists() )
+ {
+ task.BringToForeground();
+ }
+ else
+ {
+ TApaAppInfo appInfo;
+ TApaAppCapabilityBuf capabilityBuf;
+ RApaLsSession appArcSession;
+ User::LeaveIfError( appArcSession.Connect() );
+ CleanupClosePushL<RApaLsSession>( appArcSession );
+
+ User::LeaveIfError( appArcSession.GetAppInfo( appInfo, aUid ) );
+ User::LeaveIfError( appArcSession.GetAppCapability( capabilityBuf, aUid ) );
+
+ TApaAppCapability& caps = capabilityBuf();
+ TFileName appName = appInfo.iFullName;
+ CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
+ cmdLine->SetExecutableNameL( appName );
+
+ if ( caps.iLaunchInBackground )
+ {
+ cmdLine->SetCommandL( EApaCommandBackground );
+ }
+ else
+ {
+ cmdLine->SetCommandL( EApaCommandRun );
+ }
+
+ User::LeaveIfError( appArcSession.StartApp( *cmdLine ) );
+
+ CleanupStack::PopAndDestroy( cmdLine );
+ CleanupStack::PopAndDestroy( &appArcSession );
+ }
+ CleanupStack::PopAndDestroy( &wsSession );
+
+ //verification if app has really launched
+ WaitL(20000000);
+ RWsSession verWsSession;
+ User::LeaveIfError( verWsSession.Connect() );
+ CleanupClosePushL<RWsSession>( verWsSession );
+
+ CAknTaskList* verTaskList = CAknTaskList::NewL( verWsSession );
+ TApaTask verTask = verTaskList->FindRootApp( aUid );
+ delete verTaskList;
+
+ TInt result(KErrGeneral);
+ if ( verTask.Exists() )
+ {
+ result = KErrNone;
+ }
+ CleanupStack::PopAndDestroy( &verWsSession );
+ return result;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006 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 "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/t_causifscanner.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+ ./../../../../tsrc/testutils/inc
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp \
+ ../../../../srvsrc/cainstallnotifier.cpp \
+ ../../../../srvsrc/cainstallstrategy.cpp \
+ ../../../../srvsrc/casrvengutils.cpp \
+ ../../../../srvsrc/castorageproxy.cpp \
+ ../../../../srvsrc/casrvnotifier.cpp \
+ ../../../../srvsrc/casrv.cpp \
+ ../../../../srvsrc/casrvmmchistory.cpp \
+ ../../../../srvsrc/casrvsession.cpp \
+ ../../../../srvsrc/cabackupnotifier.cpp \
+ ../../../../cautils/src/*.cpp \
+ ../../../../castorage/src/*.cpp \
+ ../../../casrvmgr/src/casrvmanager.cpp \
+ ../../../../tsrc/testutils/src/*.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/t_causifscanner.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,117 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../../common.pri)
+include(../../../../tsrc/testutils/testutils.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../../../srvinc \
+ ../../../../cautils/inc \
+ ../../../../castorage/inc \
+ ../../../casrvmgr/inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_causifscanner.pri)
+
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x2002DCF2
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -lapparc \
+ -lapgrfx \
+ -lefsrv \
+ -leuser \
+ -lPlatformEnv \
+ -lbafl \
+ -lcamenu \
+ -lcasathandler \
+ -lcalocalizerscanner \
+ -lcommdb \
+ -lefsrv \
+ -lestor \
+ -lapparc \
+ -lplatformenv \
+ -lsysutil \
+ -lswinstcli \
+ -lapgrfx \
+ -lws32 \
+ -lavkon \
+ -lcone \
+ -lecom \
+ -lsisregistryclient \
+ -lsqldb \
+ -lcomsdbgutil \
+ -lsif \
+ -lscrclient \
+ -lsifnotification
+
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = c:/testing/data/t_causifscanner/
+
+ exportARMSis.sources = ./data/armv5/sapiapp_S60_3_X_v_1_0_0.sisx
+ exportARMSis.path = c:/testing/data/t_causifscanner/installs/
+
+ exportWINSCWSis.sources = ./data/winscw/sapiapp_S60_3_X_v_1_0_0.sisx
+ exportWINSCWSis.path = c:/testing/data/t_causifscanner/installs/
+
+ DEPLOYMENT += exportARMSis \
+ exportDB
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} $${exportDB.path}$$basename(exportDB.sources)"
+ BLD_INF_RULES.prj_testexports += "$${exportWINSCWSis.sources} $${exportWINSCWSis.path}$$basename(exportWINSCWSis.sources)"
+ BLD_INF_RULES.prj_exports += "$${exportDB.sources} $${exportDB.path}$$basename(exportDB.sources)"
+ BLD_INF_RULES.prj_exports += "$${exportWINSCWSis.sources} $${exportWINSCWSis.path}$$basename(exportWINSCWSis.sources)"
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/causifscanner/tsrc/t_causifscanner/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_causifscanner.exe -o c:\t_causifscanner.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
Binary file contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/castorage.db has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/createsisx.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,31 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+makesis validwidget1.pkg
+signsis validwidget1.SIS validwidget1.SISX c:\cert\rd.cer c:\cert\rd-key.pem
+del validwidget1.SIS
+
+makesis validwidget2.pkg
+signsis validwidget2.SIS validwidget2.SISX c:\cert\rd.cer c:\cert\rd-key.pem
+del validwidget2.SIS
+
+makesis validwidget3.pkg
+signsis validwidget3.SIS validwidget3.SISX c:\cert\rd.cer c:\cert\rd-key.pem
+del validwidget3.SIS
+
+makesis validwidget4.pkg
+signsis validwidget4.SIS validwidget4.SISX c:\cert\rd.cer c:\cert\rd-key.pem
+del validwidget4.SIS
\ No newline at end of file
Binary file contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget1.SISX has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget1.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<hswidgetmanifest>
+ <library>testwidgetprovider</library>
+ <uri>testwidget</uri>
+ <title>TestWidget</title>
+ <icon>test.png</icon>
+</hswidgetmanifest>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget1.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+;
+; Copyright (c) 2009 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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard sis file header
+#{"validWidget"},(0x20053785),1,0,0
+
+;Localised Vendor name
+%{"Forum Nokia"}
+
+;Unique Vendor name
+:"Forum Nokia"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Files to include. Check the source paths they match your SDK setup.
+"validwidget1.manifest" - "c:\private\140d33a9\import\widgetregistry\20053785\validwidget1.manifest"
+"validwidget1.manifest" - "c:\private\a14e9d99\import\widgetregistry\20053785\validwidget1.manifest"
+"validwidget1.manifest" - "c:\private\20022F35\import\widgetregistry\20053785\validwidget1.manifest"
\ No newline at end of file
Binary file contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget2.SISX has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget2.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<hswidgetmanifest>
+ <library>testwidgetprovider22</library>
+ <uri>testwidget22</uri>
+ <title>txt_applib_subtitle_downloads</title>
+ <translationfile>widgettranslation</translationfile>
+ <icon>test.png</icon>
+</hswidgetmanifest>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget2.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+;
+; Copyright (c) 2009 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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard sis file header
+#{"validWidget"},(0x20053785),1,0,0
+
+;Localised Vendor name
+%{"Forum Nokia"}
+
+;Unique Vendor name
+:"Forum Nokia"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Files to include. Check the source paths they match your SDK setup.
+"validwidget2.manifest" - "c:\private\140d33a9\import\widgetregistry\20053785\validwidget2.manifest"
+"validwidget2.manifest" - "c:\private\a14e9d99\import\widgetregistry\20053785\validwidget2.manifest"
+"validwidget2.manifest" - "c:\private\20022F35\import\widgetregistry\20053785\validwidget2.manifest"
+"widgettranslation_en_GB.qm" - "c:\resource\qt\translations\widgettranslation_en_GB.qm"
\ No newline at end of file
Binary file contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget3.SISX has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget3.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<hswidgetmanifest>
+ <library>testwidgetprovider33</library>
+ <uri>testwidget22</uri>
+ <title>TestWidget3</title>
+ <icon>test.png</icon>
+</hswidgetmanifest>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget3.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+;
+; Copyright (c) 2009 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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard sis file header
+#{"validWidget"},(0x20053785),1,0,0
+
+;Localised Vendor name
+%{"Forum Nokia"}
+
+;Unique Vendor name
+:"Forum Nokia"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Files to include. Check the source paths they match your SDK setup.
+"validwidget3.manifest" - "c:\private\140d33a9\import\widgetregistry\20053785\validwidget3.manifest"
+"validwidget3.manifest" - "c:\private\a14e9d99\import\widgetregistry\20053785\validwidget3.manifest"
+"validwidget3.manifest" - "c:\private\20022F35\import\widgetregistry\20053785\validwidget3.manifest"
+
Binary file contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget4.SISX has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget4.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<hswidgetmanifest>
+ <uri>testwidget44</uri>
+ <title>TestWidget4</title>
+ <icon>test.png</icon>
+</hswidgetmanifest>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/validwidget4.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+;
+; Copyright (c) 2009 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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard sis file header
+#{"validWidget"},(0x20053785),1,0,0
+
+;Localised Vendor name
+%{"Forum Nokia"}
+
+;Unique Vendor name
+:"Forum Nokia"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Files to include. Check the source paths they match your SDK setup.
+"validwidget4.manifest" - "c:\private\140d33a9\import\widgetregistry\20053785\validwidget4.manifest"
+"validwidget4.manifest" - "c:\private\a14e9d99\import\widgetregistry\20053785\validwidget4.manifest"
+"validwidget4.manifest" - "c:\private\20022F35\import\widgetregistry\20053785\validwidget4.manifest"
+
Binary file contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/data/widgettranslation_en_GB.qm has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE=../../src/*" abld build winscw udeb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../../src/*\" sbs -j 4 -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_cawidgetscanner -o c:\\t_cawidgetscanner.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/inc/cawidgetscannertestutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef CA_WIDGET_SCANNER_TEST_UTILS_H
+#define CA_WIDGET_SCANNER_TEST_UTILS_H
+//utility class for tests
+//all utility methods should be implemented here
+
+//#include "casrvengutils.h"
+#include "f32file.h"
+#include "casrvplugin.h"
+
+
+class CCaStorageProxy;
+class CCaInnerEntry;
+class CCaWidgetDescription;
+
+class CTestUtils: public CBase
+{
+public:
+
+ /**/
+ virtual ~CTestUtils();
+
+ /**/
+ static CTestUtils* NewL();
+
+ /**/
+ static CTestUtils* NewLC();
+
+ TUint FindAppUidL( const TDesC& aName, CCaStorageProxy* aStorage );
+
+ /**/
+ /**/
+ TInt SimpleCloseTaskL(TInt aUid);
+ void WaitL(TInt aMicroSec);
+ /**/
+ void InstallFinishedL();
+
+ /**
+ * Copys test Db
+ */
+ TInt CopyDb();
+
+ /**
+ * Checks if app exists in Db
+ */
+ TInt WidgetsCountL( CCaStorageProxy* aStorage );
+
+ TBool WidgetExistsInStorageL( const TDesC& aName, const TDesC& aValue, CCaStorageProxy* aStorage);
+
+ CCaInnerEntry* GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage);
+
+ CCaWidgetDescription* GetWidgetEntryL( const TDesC& aText, CCaStorageProxy* aStorage);
+
+ TInt GetWidgetFlagsL(const TDesC& aText, CCaStorageProxy* aStorage);
+
+ TInt AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage);
+
+ TInt GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage);
+
+ void RemoveAppL( TInt aUid, CCaStorageProxy* aStorage);
+
+ CCaSrvPlugin* LoadPluginL( TUid aImplUid, TPluginParams* aPluginParams );
+
+ /**
+ * Copys files
+ */
+ TInt Copy( const TDesC& aSource, const TDesC& aDest );
+
+ TInt RemoveL( const TDesC& aFile );
+
+private:
+
+
+ CTestUtils();
+
+ void ConstructL();
+
+ RFs iFs;
+ CFileMan* iFileManager;
+
+ /**
+ * Local Active Sheduler.
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveWait;
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/inc/t_cawidgetscanner.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_cahswidgetscanner.h
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+#ifndef T_CAWIDGETSCANNER_H
+#define T_CAWIDGETSCANNER_H
+
+class CTestUtils;
+class CCaStorageProxy;
+class CCaSrvManager;
+class CCaSrvEngUtils;
+class T_CaInstaller;
+class CCaSrvPlugin;
+
+#include <QtTest/QtTest>
+
+#include <e32def.h>
+#include <f32file.h>
+
+
+
+namespace Usif{
+ class RSoftwareComponentRegistry;
+}
+
+
+class T_CaWidgetScanner: public QObject
+ {
+ Q_OBJECT
+
+private:
+
+ void WaitL(TInt aMicroSec);
+ TInt AppendMmcIdL(const TDesC& aText);
+ TBool MmcAttributeSetL(TInt aId);
+ void createImportDirectoryL();
+
+ void testUpdateWidgetTrapped();
+ void testUpdateTheSameWidgetTrapped();
+ void testUpdateMmcRemoveInsertTrapped();
+
+private slots:
+
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+
+ //tests for widget scanner
+
+ void testPluginNewL();
+ void testRemoveMmcWidget();
+ void testUpdateMmcRemoveInsert();
+ void testAddWidget();
+ void testUpdateWidget();
+ void testUpdateTheSameWidget();
+ void testRemoveWidget();
+ void testSetMissingFlag();
+ void testSetLocalizationsL();
+ void testUtils();
+ void testParsePreviewImageName();
+ void testParseIconName();
+ void testCloneWidgetDescriptionL();
+
+
+private:
+
+ CTestUtils* iTestUtils;
+
+ CCaSrvEngUtils* iSrvEngUtils;
+
+ Usif::RSoftwareComponentRegistry *iScr;
+
+ CCaStorageProxy* iStorage;
+
+ RFs iFs;
+
+ RBuf iImportPath;
+ RBuf iWidgetScanFolder;
+ RBuf iWidgetScanFile1;
+
+ CCaSrvPlugin* iPlugin;
+
+
+ CCaSrvManager* iSrvManager;
+
+ T_CaInstaller *iInstaller;
+ };
+
+#endif // T_CAWIDGETSCANNER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/inc/testconsts.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * testconsts.h
+ *
+ * Created on: Oct 15, 2009
+ * Author: michal.wojcik
+ */
+
+#ifndef TESTCONSTS_H_
+#define TESTCONSTS_H_
+
+// CONSTANTS
+
+//test utils
+_LIT( KTestDbSource, "C:\\testing\\data\\t_cawidgetscanner\\castorage.db" );
+_LIT( KTestDbDest, "C:\\castorage.db" );
+
+// hswidgets
+
+_LIT( KHSWidget1, "C:\\testing\\data\\t_cawidgetscanner\\validwidget1.manifest" );
+_LIT( KHSWidget2, "C:\\testing\\data\\t_cawidgetscanner\\validwidget2.manifest" );
+_LIT( KHSWidgetRemoveFolder, "import\\widgetregistry\\20053785\\validwidget1.manifest" );
+_LIT( KHSWidgetScanFolder, "import\\widgetregistry\\20053785\\" );
+_LIT( KDriveC, "c:" );
+_LIT( KPrivate, "C:\\private\\20022F35\\" );
+
+_LIT( KImport, "\\import" );
+_LIT( KManifestFile1, "validwidget1.manifest" );
+_LIT( KManifestFile2, "validwidget2.manifest" );
+
+
+
+
+#endif /* TESTCONSTS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/inc/waitactive.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 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: CWaitActive declaration
+*
+*/
+
+#ifndef WAITACTIVE_H
+#define WAITACTIVE_H
+
+#include <e32base.h>
+
+/**
+ * Helper wait active class
+ */
+ class CWaitActive : public CTimer
+ {
+
+public:
+
+
+ static CWaitActive* NewL( );
+
+ ~CWaitActive();
+
+ void Wait(TTimeIntervalMicroSeconds32 anInterval);
+
+protected:
+
+ /**
+ * From CActive, RunL.
+ * Handles the active object’s request completion event
+ */
+ void RunL();
+
+
+private:
+
+ CWaitActive();
+
+ void ConstructL();
+
+private:
+
+ /*
+ * Own.
+ */
+ CActiveSchedulerWait* iActiveScheduler;
+ };
+
+
+#endif // WAITACTIVE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_cawidgetscanner_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\..\sis\rd.cer -key ..\..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/src/cawidgetscannertestutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,474 @@
+/*
+* Copyright (c) 2009 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 <W32STD.H>
+#include <e32property.h>
+#include <cadef.h>
+#include <badesca.h>
+#include <apgtask.h>
+#include <AknTaskList.h>
+#include <apgcli.h>
+#include <APACMDLN.h>
+#include <EIKENV.h>
+
+
+#include "castorageproxy.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "casrvplugin.h"
+#include "waitactive.h"
+#include "cawidgetscannertestutils.h"
+#include "testconsts.h"
+#include "WidgetScannerUtils.h"
+#include "CaWidgetDescription.h"
+
+#include "cawidgetscannerdef.h"
+
+//-----------------------------------------------------------------------
+// CONSTRUCTION
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewL()
+ {
+ CTestUtils* self = CTestUtils::NewLC();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewLC()
+ {
+ CTestUtils* self = new( ELeave ) CTestUtils();
+ CleanupStack::PushL( self );
+
+ self->ConstructL();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+// ---------------------------------------------------------------------------
+//
+CTestUtils::~CTestUtils()
+ {
+ iFileManager->Delete(KTestDbDest);
+ delete iFileManager; iFileManager = NULL;
+ iFs.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CTestUtils::CTestUtils()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second phase construct
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::ConstructL()
+ {
+ User::LeaveIfError( iFs.Connect() );
+ iFileManager = CFileMan::NewL( iFs );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::WaitL(TInt aMicroSec)
+ {
+ CWaitActive* wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::Copy( const TDesC& aSource, const TDesC& aDest )
+ {
+ iFs.MkDirAll(aDest);
+ return iFileManager->Copy( aSource, aDest );
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::RemoveL( const TDesC& aFile )
+ {
+ return iFs.Delete( aFile );
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::CopyDb()
+ {
+ return Copy( KTestDbSource, KTestDbDest );
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::WidgetsCountL( CCaStorageProxy* aStorage )
+ {
+ TInt count(0);
+ CCaInnerQuery* widQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType = new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeWidget );
+ widQuery->SetEntryTypeNames(appType);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( widQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ count = resultArray.Count();
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( widQuery );
+
+ return count;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TBool CTestUtils::WidgetExistsInStorageL( const TDesC& aAtrName, const TDesC& aValue, CCaStorageProxy* aStorage)
+ {
+ TBool exists(EFalse);
+ CCaInnerQuery* widQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType = new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeWidget );
+ widQuery->SetEntryTypeNames(appType);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ RCaEntryAttrArray attrArray;
+ //CleanupResetAndDestroyPushL( attrArray );
+ aStorage->GetEntriesL( widQuery, resultArray );
+ RBuf library;
+ library.Create(KCaMaxAttrLenght);
+
+ if ( resultArray.Count() )
+ {
+ for(int i(0); i<resultArray.Count();i++)
+ {
+ attrArray = resultArray[i]->GetAttributes();
+ attrArray.Find( aAtrName, library );
+ if(library.Length()>0 && library == aValue)
+ {
+ exists = ETrue;
+ }
+ }
+ }
+ library.Close();
+ // CleanupStack::PopAndDestroy( &attrArray );
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( widQuery );
+
+ return exists;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+CCaInnerEntry* CTestUtils::GetAppEntryL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerEntry* entry = NULL;
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ entry = resultArray[0];
+ resultArray.Remove(0);
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return entry;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+CCaWidgetDescription* CTestUtils::GetWidgetEntryL(const TDesC& aText, CCaStorageProxy* aStorage)
+ {
+ CCaWidgetDescription* widget = NULL;
+
+ CCaInnerQuery* query = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* widgetType = new ( ELeave ) CDesC16ArrayFlat(
+ KGranularityOne );
+ CleanupStack::PushL( widgetType );
+ widgetType->AppendL( KCaTypeWidget );
+ query->SetEntryTypeNames( widgetType );//transfers ownership to query
+ CleanupStack::Pop( widgetType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( query, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ for (TInt i=0; i< resultArray.Count(); i++)
+ {
+ if ( resultArray[i]->GetText() == aText )
+ {
+ widget = CCaWidgetDescription::NewLC(resultArray[i]);
+ CleanupStack::Pop( widget );
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( query );
+
+ return widget;
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::GetWidgetFlagsL(const TDesC& aText, CCaStorageProxy* aStorage)
+ {
+
+ TInt flags(0);
+ CCaInnerQuery* query = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* widgetType = new ( ELeave ) CDesC16ArrayFlat(
+ KGranularityOne );
+ CleanupStack::PushL( widgetType );
+ widgetType->AppendL( KCaTypeWidget );
+ query->SetEntryTypeNames( widgetType );//transfers ownership to query
+ CleanupStack::Pop( widgetType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( query, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ for (TInt i=0; i< resultArray.Count(); i++)
+ {
+ if ( resultArray[i]->GetText() == aText )
+ {
+
+ CCaInnerEntry* poin = resultArray[i];
+ flags = resultArray[i]->GetFlags();
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( query );
+
+ return flags;
+ }
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::AppsWithFlagsOffL( TInt aFlags, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ satAppQuery->SetFlagsOff( aFlags );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TInt count = resultArray.Count();
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return count;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::GetAppFlagsL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ TInt flags(0);
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ flags = resultArray[0]->GetFlags();
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return flags;
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+void CTestUtils::RemoveAppL( TInt aUid, CCaStorageProxy* aStorage)
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ satAppQuery->SetUid( aUid );
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ if ( resultArray.Count() )
+ {
+ CCaInnerEntry* dbg = resultArray[0];
+ RArray<TInt> idsToRemove;
+ CleanupClosePushL(idsToRemove);
+ idsToRemove.AppendL( resultArray[0]->GetId() );
+ aStorage->RemoveL(idsToRemove);
+ CleanupStack::PopAndDestroy( &idsToRemove );
+ }
+
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::PopAndDestroy( satAppQuery );
+ }
+
+
+
+
+TUint CTestUtils::FindAppUidL( const TDesC& aName, CCaStorageProxy* aStorage )
+ {
+ CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* appType =
+ new (ELeave) CDesC16ArrayFlat( 1 );
+ CleanupStack::PushL( appType );
+ appType->AppendL( KCaTypeApp );
+ satAppQuery->SetEntryTypeNames( appType );
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL( resultArray );
+ aStorage->GetEntriesL( satAppQuery, resultArray );
+
+ TUint appUid(0);
+ for ( TInt i = 0; i < resultArray.Count(); i++ )
+ {
+ if ( resultArray[i]->GetText() == aName )
+ {
+ appUid = resultArray[i]->GetUid();
+ }
+ }
+ CleanupStack::PopAndDestroy( &resultArray );
+ CleanupStack::Pop( appType );
+ CleanupStack::PopAndDestroy( satAppQuery );
+
+ return appUid;
+ }
+
+// -----------------------------------------------------------------------------
+//
+TInt CTestUtils::SimpleCloseTaskL(TInt aUid)
+ {
+ RWsSession session;
+ TInt error = session.Connect();
+ TUid uidApp( TUid::Uid( aUid )) ;
+ TApaTaskList taskList( session );
+ TApaTask task = taskList.FindApp( uidApp );
+
+ if( task.Exists() )
+ {
+ task.EndTask();
+ }
+ else
+ {
+ error = KErrNotFound;
+ }
+
+ WaitL( 4000000 );
+ session.Close();
+ WaitL( 1000000 );
+
+ return error;
+ }
+
+// ----------------------------------------------------------------------------
+//
+void CTestUtils::InstallFinishedL()
+ {
+ iActiveWait->AsyncStop();
+ }
+
+CCaSrvPlugin* CTestUtils::LoadPluginL( TUid aImplUid, TPluginParams* aPluginParams )
+ {
+ RImplInfoPtrArray infoArray;
+
+ // Note that a special cleanup function is required to reset and destroy
+ // all items in the array, and then close it.
+ CleanupResetAndDestroyPushL( infoArray );
+ CCaSrvPlugin::ListAllImplementationsL( infoArray );
+
+ // Loop through each info for each implementation
+ // and create and use each in turn
+ CCaSrvPlugin* plug;
+ for( TInt i = 0; i < infoArray.Count(); i++ )
+ {
+ // Slice off first sub-section in the data section
+ TUid current_plugin = infoArray[i]->ImplementationUid();
+ if ( current_plugin == aImplUid )
+ {
+ plug = CCaSrvPlugin::NewL( current_plugin, aPluginParams );
+ CleanupStack::PushL( plug );
+ TInt32 key = current_plugin.iUid;
+ //iPluginMap.InsertL( key, plug );
+ CleanupStack::Pop( plug );
+ break;
+ }
+ plug = NULL;
+ }
+ CleanupStack::PopAndDestroy( &infoArray );
+ return plug;
+ }
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/src/t_cawidgetscanner.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,1025 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_cahswidgetscanner.cpp
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+// CLASS HEADER
+
+
+#include <ecom/ecom.h>
+#include <QScopedPointer>
+#include <utf.h>
+#include <xml/dom/xmlengdocument.h>
+#include <XQConversions>
+#include <usif/sif/sifcommon.h>
+#include <usif/sif/sif.h>
+#include <xmlengelement.h>
+#include <driveinfo.h>
+
+#include "t_cawidgetscanner.h"
+#include "cawidgetscannertestutils.h"
+#include "waitactive.h"
+#include "casrvengutils.h"
+#include "castorageproxy.h"
+#include "casrvmanager.h"
+#include "casrvplugin.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+#include "testconsts.h"
+#include "cadef.h"
+#include "castorage_global.h"
+
+#include "cawidgetscannerparser.h"
+#include "cawidgetstoragehandler.h"
+#include "cawidgetscannerplugin.h"
+#include "cawidgetscannerdef.h"
+#include "WidgetScannerUtils.h"
+
+
+#include "t_cainstaller.h"
+
+const TUid KHsWidgetPluginUid = {0x20026FB1};
+const TInt installedUid = 0x20053785;
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+_LIT( KTestLibrary, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\testwidget" );
+_LIT8( KWidgetUID, "testwidgetprovider.dll" );
+_LIT( KWidgetLibrary2, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\testwidget22" );
+_LIT( KWidgetLibrary3, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\testwidget33" );
+
+_LIT( KWidget1PackageName, "c:\\testing\\data\\Installs\\validwidget1.SISX" );
+_LIT( KWidget2PackageName, "c:\\testing\\data\\Installs\\validwidget2.SISX" );
+_LIT( KWidget3PackageName, "c:\\testing\\data\\Installs\\validwidget3.SISX" );
+_LIT( KWidget4PackageName, "c:\\testing\\data\\Installs\\validwidget4.SISX" );
+_LIT( KWidget1ManifestName, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\validwidget1.manifest" );
+_LIT( KWidget2ManifestName, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\validwidget2.manifest" );
+_LIT( KWidget3ManifestName, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\validwidget3.manifest" );
+_LIT( KWidget4ManifestName, "C:\\private\\20022F35\\import\\widgetregistry\\20053785\\validwidget4.manifest" );
+_LIT( KWidgetQmFolder, "c:\\resource\\qt\\translations\\" );
+_LIT( KWidgetQmFolderAndFile, "c:\\resource\\qt\\translations\\" );
+_LIT( KWidgetQmFile, "c:\\testing\\data\\t_cawidgetscanner\\widgettranslation_en_GB.qm" );
+_LIT( KWidgetUri1, "testwidget" );
+_LIT( KWidgetUri2, "testwidget22" );
+_LIT( KWidgetUri3, "testwidget33" );
+_LIT( KWidgetUri4, "testwidget44" );
+_LIT( KTranslationFileNameAsInManifest, "widgettranslation" );
+
+template <typename RClass>
+struct RClassDeleter
+{
+ static inline void cleanup(RClass *ptr)
+ {
+ ptr->Close();
+ }
+};
+
+typedef QScopedPointer<RBuf,
+ RClassDeleter<RBuf> > RBufGuard;
+typedef QScopedPointer<RBuf8,
+ RClassDeleter<RBuf8> > RBuf8Guard;
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::WaitL(TInt aMicroSec)
+ {
+ CWaitActive* wait = CWaitActive::NewL();
+ wait->Wait(aMicroSec);
+ delete wait;
+ }
+
+void T_CaWidgetScanner::initTestCase()
+ {
+ const TUid KWidgetHandlerPluginUid = {0x20028707};
+ TRAPD(err,
+ iTestUtils = CTestUtils::NewL();
+ iTestUtils->CopyDb();
+
+ // remove hswidget
+ iStorage = CCaStorageProxy::NewL();
+ iSrvEngUtils = CCaSrvEngUtils::NewL();
+ iScr = new Usif::RSoftwareComponentRegistry;
+ User::LeaveIfError(iScr->Connect());
+
+ iFs.Connect();
+ iImportPath.CreateL( KMaxPath );
+
+ createImportDirectoryL();
+
+ iInstaller = T_CaInstaller::NewL();
+ TPluginParams params;
+ params.engUtils = iSrvEngUtils;
+ params.storageProxy = iStorage;
+ params.softwareRegistry = iScr;
+ iPlugin = iTestUtils->LoadPluginL( KWidgetHandlerPluginUid, ¶ms);
+
+ );
+ }
+
+void T_CaWidgetScanner::cleanupTestCase()
+ {
+ QTest::qWait(5000);
+
+ iTestUtils->RemoveL(KTestDbDest);
+ delete iPlugin;
+ delete iInstaller;
+ delete iStorage;
+ iStorage = NULL;
+ delete iTestUtils;
+ iTestUtils = NULL;
+ delete iSrvEngUtils;
+ iSrvEngUtils = NULL;
+ iScr->Close();
+ delete iScr;
+ iScr = NULL;
+ iFs.Close();
+ REComSession::FinalClose();
+ iImportPath.Close();
+ iWidgetScanFolder.Close();
+
+ iWidgetScanFile1.Close();
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::init()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::cleanup()
+ {
+ QTest::qWait(100);
+ }
+
+
+
+void T_CaWidgetScanner::createImportDirectoryL()
+ {
+ //create "parsed" directory if it doesn't exist yet;
+ // create directory on C: drive
+ iWidgetScanFolder.Close();
+ iWidgetScanFile1.Close();
+ iWidgetScanFolder.CreateL(KMaxPath);
+ iWidgetScanFile1.CreateL(KMaxPath);
+ iWidgetScanFolder.Append( KPrivate );
+ iWidgetScanFolder.Append( KHSWidgetScanFolder );
+ iWidgetScanFile1.Append(iWidgetScanFolder);
+ iWidgetScanFile1.Append(KManifestFile1);
+ }
+
+//
+// TESTS --------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+void T_CaWidgetScanner::testPluginNewL()
+{
+//Check only if plugin was created correctly
+ QVERIFY( iPlugin != NULL);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+
+
+void T_CaWidgetScanner::testAddWidget()
+ {
+ bool widgetExistsInStorage(false);
+ TInt err(KErrNone);
+
+
+ TRAP_IGNORE(iInstaller->InstallL(KWidget1PackageName));
+
+ QTest::qWait(3000);
+
+ TRAP_IGNORE(widgetExistsInStorage = ( iTestUtils->WidgetExistsInStorageL(
+ KAttrWidgetLibrary, KTestLibrary, iStorage ) != EFalse ));
+
+ // clean after test
+ TRAP_IGNORE(iInstaller->UninstallL(KWidget1ManifestName))
+ QTest::qWait(3000);
+
+ QVERIFY(widgetExistsInStorage);
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testUpdateWidget()
+ {
+ TInt err(KErrNone);
+
+ TRAP(err,
+ testUpdateWidgetTrapped()
+ );
+ }
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testUpdateWidgetTrapped()
+ {
+ TInt err(KErrNone);
+
+ TInt expectedCount(0);
+ TInt actualCount(0);
+ bool widgetAExistsInStorage(false);
+ bool widgetBExistsInStorage(false);
+
+ iInstaller->InstallL(KWidget2PackageName);
+
+ QTest::qWait(3000);
+
+ expectedCount = iTestUtils->WidgetsCountL(iStorage);
+
+ widgetAExistsInStorage = (iTestUtils->WidgetExistsInStorageL(
+ KAttrWidgetLibrary, KWidgetLibrary2, iStorage) != FALSE);
+
+
+ iInstaller->InstallL(KWidget3PackageName);
+ QTest::qWait(3000);
+
+ widgetBExistsInStorage = (iTestUtils->WidgetExistsInStorageL(
+ KAttrWidgetUri, KWidgetUri2, iStorage) != FALSE);
+
+ actualCount = iTestUtils->WidgetsCountL(iStorage);
+ TRAP_IGNORE(iInstaller->UninstallL(KWidget2ManifestName))
+ QTest::qWait(3000);
+ TRAP_IGNORE(iInstaller->UninstallL(KWidget3ManifestName))
+ QTest::qWait(3000);
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(widgetAExistsInStorage);
+ QVERIFY(widgetBExistsInStorage);
+ QCOMPARE(actualCount, expectedCount);
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testRemoveMmcWidget()
+ {
+ TInt err(KErrNone);
+ TInt id(KErrNotFound);
+ bool widgetExistsInStorage(false);
+ bool mmcIdAttributeSet1(false);
+ bool mmcIdAttributeSet2(false);
+
+ TRAP(err,
+
+ //test
+ iInstaller->InstallL(KWidget1PackageName);
+ QTest::qWait(3000);
+
+ id = AppendMmcIdL(_L("TestWidget"));
+
+ mmcIdAttributeSet1 = MmcAttributeSetL(id);
+
+ // after unistall mmc id should be removed
+ iInstaller->UninstallL(KWidget1ManifestName);
+
+ QTest::qWait(3000);
+
+ mmcIdAttributeSet2 = MmcAttributeSetL(id);
+
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(mmcIdAttributeSet1);
+ QVERIFY(!mmcIdAttributeSet2);
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testUpdateTheSameWidget()
+ {
+ TInt err(KErrNone);
+ TRAP(err,
+ testUpdateTheSameWidgetTrapped()
+ );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testUpdateTheSameWidgetTrapped()
+ {
+ _LIT( KWText, "TestWidget" );
+ TUint flags0(0U);
+ TUint flags1(0U);
+ TUint flags2(0U);
+ TInt err(KErrNone);
+ TInt expectedCount(0);
+ TInt actualCount(0);
+
+ iInstaller->InstallL( KWidget1PackageName );
+
+ QTest::qWait(3000);
+
+ flags0 = iTestUtils->GetWidgetFlagsL( KWText, iStorage );
+
+ expectedCount = iTestUtils->WidgetsCountL( iStorage );
+
+ CCaWidgetDescription* widget = iTestUtils->GetWidgetEntryL( KWText, iStorage );
+
+ if (widget == NULL)
+ {
+ User::Leave(KErrNotFound);
+ }
+
+ CleanupStack::PushL( widget );
+ CCaInnerEntry* innerEntry = widget->GetEntryLC();
+ iStorage->TouchL( innerEntry );
+ QTest::qWait( 500 );
+
+ flags1 = iTestUtils->GetWidgetFlagsL( KWText, iStorage );
+
+ iInstaller->InstallL( KWidget1PackageName );
+ QTest::qWait(3000);
+
+ flags2 = iTestUtils->GetWidgetFlagsL( KWText, iStorage );
+
+ actualCount = iTestUtils->WidgetsCountL(iStorage);
+
+ CleanupStack::PopAndDestroy( innerEntry );
+ CleanupStack::PopAndDestroy( widget );
+
+
+ // clean after test
+ iInstaller->UninstallL(KWidget1ManifestName);
+ QTest::qWait(3000);
+// QCOMPARE(err, KErrNone);
+ QVERIFY( ~(flags0 & EUsed) );
+ QVERIFY( (flags1 & EUsed) );
+ QVERIFY( ~(flags2 & EUsed) );
+ QCOMPARE(actualCount, expectedCount);
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testUpdateMmcRemoveInsertTrapped()
+ {
+ _LIT( KWTextCanNotTranslate, "txt_applib_subtitle_downloads" );
+ TPluginParams params;
+ params.engUtils = 0;
+ params.storageProxy = iStorage;
+ params.softwareRegistry = iScr;
+ _LIT( KWTextTranslated, "Downloads" );
+ TUint flags0(0U);
+ TUint flags1(0U);
+ TUint flags2(0U);
+ TUint flags3(0U);
+ TInt err(KErrNone);
+
+
+
+ iTestUtils->Copy( KWidgetQmFile, KWidgetQmFolder );
+
+ CCaWidgetStorageHandler* handler = CCaWidgetStorageHandler::NewL(
+ iStorage, *iScr, iFs );
+
+ iInstaller->InstallL( KWidget2PackageName );
+ QTest::qWait(3000);
+ //get translated widget
+ RBuf widgetName;
+ widgetName.CreateL( KWTextTranslated );
+ CCaWidgetDescription* widget = iTestUtils->GetWidgetEntryL(
+ KWTextTranslated, iStorage );
+ if( !widget )
+ {
+ widgetName.Close();
+ widgetName.CreateL( KWTextCanNotTranslate );
+ //qm file has not found
+ widget = iTestUtils->GetWidgetEntryL(
+ KWTextCanNotTranslate, iStorage );
+ }
+ flags0 = iTestUtils->GetWidgetFlagsL( widgetName, iStorage );
+ CleanupStack::PushL( widget );
+ CCaInnerEntry* innerEntry = widget->GetEntryLC();
+ iStorage->TouchL( innerEntry );
+ QTest::qWait( 500 );
+
+ flags1 = iTestUtils->GetWidgetFlagsL( widgetName, iStorage );
+
+ CCaWidgetDescription* widget2 = iTestUtils->GetWidgetEntryL( widgetName, iStorage );
+ CleanupStack::PushL( widget2 );
+
+ // set missing
+ handler->SetMissingFlagL( widget2 );
+ flags2 = iTestUtils->GetWidgetFlagsL( widgetName, iStorage );
+
+ iInstaller->InstallL( KWidget2PackageName );
+ QTest::qWait( 4000 );
+
+ flags3 = iTestUtils->GetWidgetFlagsL( widgetName, iStorage );
+ widgetName.Close();
+ CleanupStack::PopAndDestroy( widget2 );
+ CleanupStack::PopAndDestroy( innerEntry );
+ CleanupStack::PopAndDestroy( widget );
+ iTestUtils->RemoveL( KWidgetQmFolderAndFile );
+
+
+ // clean after test
+ iInstaller->UninstallL(KWidget2ManifestName);
+
+ QTest::qWait(3000);
+ QCOMPARE(err, KErrNone);
+ QVERIFY( ~(flags0 & EUsed) );
+ QVERIFY( flags1 & EUsed );
+ QVERIFY( ~(flags1 & EMissing) );
+ QVERIFY( flags2 & EUsed );
+ QVERIFY( flags2 & EMissing );
+ QVERIFY( flags3 & ~EUsed );
+ QVERIFY( flags3 & ~EMissing );
+ }
+
+void T_CaWidgetScanner::testUpdateMmcRemoveInsert()
+ {
+ TInt err(KErrNone);
+ TRAP(err,
+ testUpdateMmcRemoveInsertTrapped()
+ );
+ }
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testRemoveWidget()
+ {
+ TInt err(KErrNone);
+ bool widgetExistedInStorage(false);
+ bool widgetRemovedFromStorage(false);
+
+
+ TRAP(err,
+
+ iInstaller->InstallL(KWidget1PackageName);
+
+ QTest::qWait(3000);
+
+ widgetExistedInStorage =( iTestUtils->WidgetExistsInStorageL(
+ KAttrWidgetLibrary, KTestLibrary, iStorage ) != FALSE);
+
+ iInstaller->UninstallL(KWidget1ManifestName);
+
+ QTest::qWait(3000);
+
+ widgetRemovedFromStorage = ((iTestUtils->WidgetExistsInStorageL(
+ KAttrWidgetLibrary, KTestLibrary, iStorage )) != FALSE);
+
+
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(widgetExistedInStorage);
+ QVERIFY(widgetRemovedFromStorage);
+ }
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testSetMissingFlag()
+ {
+ _LIT( KWText, "TestWidget" );
+
+ TInt err(KErrNone);
+ TUint flags(0U);
+
+ TRAP(err,
+
+ CCaWidgetStorageHandler* handler = CCaWidgetStorageHandler::NewL(
+ iStorage, *iScr, iFs);
+ iInstaller->InstallL(KWidget1PackageName);
+ QTest::qWait(3000);
+
+ CCaWidgetDescription* widget = iTestUtils->GetWidgetEntryL( KWText, iStorage);
+ handler->SetMissingFlagL( widget );
+ delete widget;
+
+ flags = iTestUtils->GetWidgetFlagsL(KWText, iStorage);
+
+ delete handler;
+ );
+
+ // clean after test
+ TRAP_IGNORE(iInstaller->UninstallL(KWidget1ManifestName));
+ QTest::qWait(3000);
+ QCOMPARE(err, KErrNone);
+ QVERIFY( flags & EMissing );
+ QVERIFY( ~(flags & EVisible) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testSetLocalizationsL()
+ {
+ CCaWidgetDescription* widget = CCaWidgetDescription::NewLC();
+ widget->SetUriL(KWidgetUri1());
+ widget->SetTranslationFileNameL(KTranslationFileNameAsInManifest());
+ widget->SetTitleL( _L("txt_applib_subtitle_downloads") );
+
+ widget->LocalizeTextsL();
+
+ QVERIFY(!widget->GetStringIdTitle().Compare(_L("txt_applib_subtitle_downloads")));
+ QVERIFY(!widget->GetStringIdDescription().Compare( KNullDesC ));
+
+ RPointerArray<CCaLocalizationEntry> resultContainer;
+ CleanupResetAndDestroyPushL( resultContainer );
+ iStorage->GetLocalizationsL( resultContainer );
+ int a = resultContainer.Count();
+ resultContainer.Reset();
+
+ CCaWidgetStorageHandler* handler = CCaWidgetStorageHandler::NewL(
+ iStorage, *iScr, iFs );
+
+ widget->SetStringidTitleL( _L("titleId") );
+ handler->SetLocalizationsL( widget, 2000 );
+
+ iStorage->GetLocalizationsL( resultContainer );
+ int b = resultContainer.Count();
+
+ QCOMPARE( a+1, b );
+
+ delete handler;
+ CleanupStack::PopAndDestroy( &resultContainer );
+ CleanupStack::PopAndDestroy( widget );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testUtils()
+ {
+ RBuf mmcId;
+ mmcId.CleanupClosePushL();
+ mmcId.CreateL(KMassStorageIdLength);
+ WidgetScannerUtils::CurrentMmcId(iFs, mmcId);
+ TInt mmcDrive;
+ if( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage,
+ mmcDrive ) == KErrNone )
+ {
+ QVERIFY(mmcId.Length() > 0);
+ }
+
+ CleanupStack::PopAndDestroy( &mmcId );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testParsePreviewImageName()
+{
+ TInt err(KErrNone);
+ TChar drive = 'c';
+
+ RBuf expectedPreviewFileName;
+ RBufGuard expectedPreviewFileNameGuard(&expectedPreviewFileName);
+
+ QScopedPointer < CCaWidgetScannerParser > parser;
+ QScopedPointer < CCaWidgetDescription > widgetDescriptor;
+ QT_TRAP_THROWING(parser.reset(CCaWidgetScannerParser::NewL(iFs)));
+ QT_TRAP_THROWING(widgetDescriptor.reset( CCaWidgetDescription::NewL()) );
+
+ _LIT8( KPreviewFileName8, "preview.png" );
+ _LIT( KPreviewFileName, "preview.png" );
+ _LIT( KWidgetPackageId, "12345678" );
+
+ TXmlEngElement element;
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KPreviewImageElementName());
+ element.AddTextL(KPreviewFileName8());
+ parser->ParsePreviewImageNameL( element, KWidgetPackageId(),
+ widgetDescriptor.data(), drive);
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err,
+ HBufC *manifestPath = parser->GetManifestDirectoryPathLC(
+ KWidgetPackageId(), drive );
+ expectedPreviewFileName.CreateL(manifestPath->Length() +
+ KPreviewFileName().Length());
+ expectedPreviewFileName.Append(*manifestPath);
+ expectedPreviewFileName.Append(KPreviewFileName());
+ CleanupStack::PopAndDestroy( manifestPath );
+ );
+ QCOMPARE(err, KErrNone);
+ {
+ const QString exp = XQConversions::s60DescToQString(expectedPreviewFileName);
+ const QString act =
+ XQConversions::s60DescToQString(
+ widgetDescriptor->GetPreviewImageName());
+ QCOMPARE(exp, act);
+ }
+
+ RBuf expectedPreviewSkinId;
+ RBufGuard expectedPreviewSkinIdGuard(&expectedPreviewSkinId);
+
+ _LIT8( KPreviewSkinId, "skin_id" );
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KPreviewImageElementName());
+ element.AddTextL(KPreviewSkinId());
+ parser->ParsePreviewImageNameL( element, KWidgetPackageId(),
+ widgetDescriptor.data(), drive);
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err,
+ expectedPreviewSkinId.Assign(
+ CnvUtfConverter::ConvertToUnicodeFromUtf8L(KPreviewSkinId()));
+ );
+ QCOMPARE(err, KErrNone);
+ {
+ const QString exp = XQConversions::s60DescToQString(expectedPreviewSkinId);
+ const QString act =
+ XQConversions::s60DescToQString(
+ widgetDescriptor->GetPreviewImageName());
+
+ QCOMPARE(exp, act);
+ }
+
+ RBuf8 attributeValueTooLong;
+ RBuf8Guard attributeValueTooLongGuard(&attributeValueTooLong);
+ attributeValueTooLong.CreateL(KCaMaxAttrValueLen + 1);
+
+ for (int i = KCaMaxAttrValueLen; i >= 0 ; --i)
+ {
+ attributeValueTooLong.Append(_L8("a"));
+ }
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KPreviewImageElementName());
+ element.AddTextL(attributeValueTooLong);
+
+ parser->ParsePreviewImageNameL( element, KWidgetPackageId(),
+ widgetDescriptor.data(), drive);
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+ QCOMPARE(err, KErrNone);
+ {
+ QCOMPARE(widgetDescriptor->GetPreviewImageName().Length(),
+ KCaMaxAttrValueLen + 1);
+ }
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KPreviewImageElementName());
+ element.AddTextL(KNullDesC8);
+
+ parser->ParsePreviewImageNameL( element, KWidgetPackageId(),
+ widgetDescriptor.data(), drive);
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+ QCOMPARE(err, KErrNone);
+ {
+ const QString exp = XQConversions::s60DescToQString(KNullDesC);;
+ const QString act = XQConversions::s60DescToQString(
+ widgetDescriptor->GetPreviewImageName());
+ QCOMPARE(exp, act);
+ }
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaWidgetScanner::testParseIconName()
+{
+ TInt err(KErrNone);
+
+ TChar drive = 'c';
+
+ RBuf expectedIconFileName;
+ RBufGuard expectedIconFileNameGuard(&expectedIconFileName);
+
+ QScopedPointer < CCaWidgetScannerParser > parser;
+ QScopedPointer < CCaWidgetDescription > widgetDescriptor;
+ QT_TRAP_THROWING(parser.reset(CCaWidgetScannerParser::NewL(iFs)));
+ QT_TRAP_THROWING(widgetDescriptor.reset( CCaWidgetDescription::NewL()) );
+
+ _LIT8( KIconName8, "preview.png" );
+ _LIT( KIconName, "preview.png" );
+ _LIT( KWidgetPackageId, "12345678" );
+ TXmlEngElement element;
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KIcon());
+ element.AddTextL(KIconName8());
+ parser->ParseIconL( element, KWidgetPackageId(), widgetDescriptor.data(), drive );
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err,
+ HBufC *manifestPath = parser->GetManifestDirectoryPathLC( KWidgetPackageId(), drive );
+ expectedIconFileName.CreateL(manifestPath->Length() + KIconName().Length());
+ expectedIconFileName.Append(*manifestPath);
+ expectedIconFileName.Append(KIconName());
+ CleanupStack::PopAndDestroy(manifestPath);
+ );
+ QCOMPARE(err, KErrNone);
+ {
+ const QString exp = XQConversions::s60DescToQString(expectedIconFileName);
+ const QString act =
+ XQConversions::s60DescToQString(
+ widgetDescriptor->GetIconUri());
+ QCOMPARE(exp, act);
+ }
+
+ RBuf expectedIconSkinId;
+ RBufGuard expectedIconSkinIdGuard(&expectedIconSkinId);
+
+ _LIT8( KIconSkinId, "skin_id" );
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KIcon());
+ element.AddTextL(KIconSkinId());
+
+ parser->ParseIconL(element, KWidgetPackageId(), widgetDescriptor.data(), drive);
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err,
+ expectedIconSkinId.Assign(
+ CnvUtfConverter::ConvertToUnicodeFromUtf8L(KIconSkinId()));
+ );
+ QCOMPARE(err, KErrNone);
+ {
+ const QString exp = XQConversions::s60DescToQString(expectedIconSkinId);
+ const QString act =
+ XQConversions::s60DescToQString(
+ widgetDescriptor->GetIconUri());
+
+ QCOMPARE(exp, act);
+ }
+
+ RBuf8 veryLongAttributeValue;
+ RBuf8Guard veryLongAttributeValueGuard(&veryLongAttributeValue);
+ veryLongAttributeValue.CreateL(KCaMaxAttrValueLen + 1);
+
+ for (int i = KCaMaxAttrValueLen; i >= 0 ; --i)
+ {
+ veryLongAttributeValue.Append(_L8("a"));
+ }
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KIcon());
+ element.AddTextL(veryLongAttributeValue);
+
+ parser->ParseIconL(element, KWidgetPackageId(), widgetDescriptor.data(), drive );
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ {
+ QCOMPARE(widgetDescriptor->GetIconUri().Length(),
+ KCaMaxAttrValueLen + 1);
+ }
+
+ TRAP(err,
+ RXmlEngDOMImplementation domImpl;
+ CleanupClosePushL(domImpl);
+ domImpl.OpenL();
+ RXmlEngDocument doc;
+ CleanupClosePushL(doc);
+ doc.OpenL(domImpl);
+
+ TXmlEngElement element =
+ doc.CreateDocumentElementL(KIcon());
+ element.AddTextL(KNullDesC8);
+
+ parser->ParseIconL(element, KWidgetPackageId(), widgetDescriptor.data(), drive );
+ CleanupStack::PopAndDestroy(&doc);
+ CleanupStack::PopAndDestroy(&domImpl);
+ );
+
+ QCOMPARE(err, KErrNone);
+ {
+ const QString exp = XQConversions::s60DescToQString(KNullDesC);;
+ const QString act = XQConversions::s60DescToQString(
+ widgetDescriptor->GetIconUri());
+ QCOMPARE(exp, act);
+ }
+}
+
+void T_CaWidgetScanner::testCloneWidgetDescriptionL()
+{
+ QScopedPointer<CCaWidgetDescription> descriptionA;
+ QT_TRAP_THROWING(descriptionA.reset(CCaWidgetDescription::NewL()));
+ QScopedPointer<CCaWidgetDescription> descriptionB(
+ descriptionA->CloneL());
+
+ QVERIFY(descriptionA->Compare(*descriptionB)
+ != static_cast<TInt>(EFalse));
+
+ _LIT( KTestDescription, "GetDescription()" );
+
+ QT_TRAP_THROWING(
+ descriptionA->SetDescriptionL( KTestDescription )
+ )
+
+ QVERIFY(descriptionA->Compare(*descriptionB)
+ == static_cast<TInt>(EFalse));
+
+ QScopedPointer<CCaWidgetDescription> descriptionC(
+ descriptionA->CloneL());
+
+ QVERIFY(descriptionA->Compare(*descriptionC)
+ != static_cast<TInt>(EFalse));
+
+ QVERIFY(descriptionA->GetDescription().Compare( KTestDescription ) == 0);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt T_CaWidgetScanner::AppendMmcIdL(const TDesC& aText)
+ {
+ //get mmc id
+ RBuf mmcId;
+ mmcId.CleanupClosePushL();
+ mmcId.CreateL(_L("mass_storage"));
+
+ //append mmc id to the entry
+ CCaInnerQuery* query = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat* widgetType = new ( ELeave ) CDesC16ArrayFlat(
+ KGranularityOne );
+ CleanupStack::PushL( widgetType );
+ widgetType->AppendL( KCaTypeWidget );
+ query->SetEntryTypeNames( widgetType );//transfers ownership to query
+ CleanupStack::Pop( widgetType );
+
+ RPointerArray<CCaInnerEntry> entries;
+ CleanupResetAndDestroyPushL( entries );
+ iStorage->GetEntriesL( query, entries );
+ TInt id(0);
+ for( TInt i = 0; i < entries.Count(); i++ )
+ {
+ if(entries[i]->GetText().Compare(aText)==0)
+ {
+ entries[i]->AddAttributeL(KCaAttrMmcId, mmcId);
+ id = entries[i]->GetId();
+ iStorage->AddL(entries[i]);
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy( &entries );
+ CleanupStack::PopAndDestroy( query );
+ CleanupStack::PopAndDestroy( &mmcId );
+ return id;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TBool T_CaWidgetScanner::MmcAttributeSetL(TInt aId)
+ {
+ TBool result(EFalse);
+ CCaInnerQuery* query = CCaInnerQuery::NewLC();
+ RArray<TInt> ids;
+ CleanupClosePushL(ids);
+ ids.AppendL(aId);
+ query->SetIdsL(ids);
+ CleanupStack::PopAndDestroy(&ids);
+ RPointerArray<CCaInnerEntry> entries;
+ CleanupResetAndDestroyPushL( entries );
+ iStorage->GetEntriesL( query, entries );
+ if (entries.Count() == 1)
+ {
+ TPtrC temp(KNullDesC);
+ result = entries[0]->FindAttribute(KCaAttrMmcId, temp);
+ }
+ CleanupStack::PopAndDestroy( &entries );
+ CleanupStack::PopAndDestroy( query );
+
+ return result;
+ }
+
+
+
+
+
+QTEST_MAIN(T_CaWidgetScanner);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/src/waitactive.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2009 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: CWaitActive implementation
+*
+*/
+
+#include "waitactive.h"
+
+#include "waitactive.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+void CWaitActive::ConstructL()
+ {
+ CTimer::ConstructL();
+ iActiveScheduler = new ( ELeave ) CActiveSchedulerWait();
+ }
+
+
+CWaitActive* CWaitActive::NewL()
+ {
+ CWaitActive* self = new( ELeave ) CWaitActive;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+// ----------------------------------------------------------------------------
+// CIsvTelCallAppTelephony::CIsvTelCallAppTelephony()
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CWaitActive::CWaitActive()
+ :CTimer( EPriorityStandard )
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+CWaitActive::~CWaitActive()
+ {
+ Cancel();
+ delete iActiveScheduler;
+ }
+
+// ---------------------------------------------------------------------------
+// destructor
+// ---------------------------------------------------------------------------
+void CWaitActive::Wait(TTimeIntervalMicroSeconds32 anInterval)
+ {
+ After(anInterval);
+ iActiveScheduler->Start();
+
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// void CIsvTelCallAppTelephony::RunL()
+// Handles the active object’s request completion event.
+// ----------------------------------------------------------------------------
+//
+void CWaitActive::CWaitActive::RunL()
+ {
+ // CActiveScheduler::Stop();
+ iActiveScheduler->AsyncStop();
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/t_cawidgetscanner.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+ ../../../../tsrc/testutils/inc
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp \
+ ../../../../srvsrc/cainstallnotifier.cpp \
+ ../../../../srvsrc/cainstallstrategy.cpp \
+ ../../../../srvsrc/casrvengutils.cpp \
+ ../../../../srvsrc/castorageproxy.cpp \
+ ../../../../srvsrc/casrvnotifier.cpp \
+ ../../../../srvsrc/casrv.cpp \
+ ../../../../srvsrc/casrvmmchistory.cpp \
+ ../../../../srvsrc/cabackupnotifier.cpp \
+ ../../../../srvsrc/casrvsession.cpp \
+ ../../../casrvmgr/src/casrvmanager.cpp \
+ ../../../../cautils/src/*.cpp \
+ ../../../../castorage/src/*.cpp \
+ ../../../../tsrc/testutils/src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/t_cawidgetscanner.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,129 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../../common.pri)
+include(../../../../tsrc/testutils/testutils.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../../../srvinc \
+ ../../../../extinc \
+ ../../../../cautils/inc \
+ ../../../casrvmgr/inc \
+ ../../../../castorage/inc \
+ ../../../../srvinc \
+ /epoc32/include/mw/hb/hbcore \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_cawidgetscanner.pri)
+
+symbian: {
+
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20028705
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lestor \
+ -lapparc \
+ -lapgrfx \
+ -lcautils \
+ -lsysutil \
+ -lplatformenv \
+ -lcasrvmanager \
+ -lws32 \
+ -lecom \
+ -lxmlengineDOM \
+ -lcharconv \
+ -lplatformenv \
+ -lsisregistryclient \
+ -lsqldb \
+ -lbafl \
+ -lefsrv \
+ -lflogger \
+ -lcamenu \
+ -lscrclient \
+ -lsifnotification \
+ -lsif \
+ -lhbcore \
+ -lxmlengineDOM \
+ -lxqutils
+
+ exportDB.sources = ./data/castorage.db ./data/widgettranslation_en_GB.qm
+ exportDB.path = c:/testing/data/t_cawidgetscanner/
+
+ exportManifest.sources = ./data/validwidget1.manifest ./data/validwidget2.manifest ./data/validwidget3.manifest ./data/validwidget4.manifest
+ exportManifest.path = c:/testing/data/t_cawidgetscanner
+
+ exportSis.path = c:/testing/data/installs
+ exportSis.sources = ./data/validwidget1.SISX ./data/validwidget2.SISX ./data/validwidget3.SISX ./data/validwidget4.SISX
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} $${exportDB.path}"
+
+ for(exportManifest, exportManifest.sources):{
+ BLD_INF_RULES.prj_testexports += \
+ "./$$exportManifest $$exportManifest.path/$$basename(exportManifest)"
+ }
+
+ for(exportSis, exportSis.sources): {
+ BLD_INF_RULES.prj_testexports += \
+ "./$$exportSis $$exportSis.path/$$basename(exportSis)"
+ }
+
+ DEPLOYMENT += exportDB exportManifest exportSis
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_cawidgetscanner.exe -o c:\t_cawidgetscanner.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/casrv/cawidgetscanner/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS = t_cawidgetscanner
+
+CONFIG += ordered
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/data/castorage.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_castorage.exe -o c:\t_castorage.log
Binary file contentstorage/castorage/tsrc/t_castorage/data/castorage.db has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/data/castoragedb_create.sql Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,225 @@
+DROP TABLE IF EXISTS CA_ENTRY;
+DROP TABLE IF EXISTS CA_GROUP_ENTRY;
+DROP TABLE IF EXISTS CA_ICON;
+DROP TABLE IF EXISTS CA_LAUNCH;
+DROP TABLE IF EXISTS CA_ATTRIBUTE;
+DROP TABLE IF EXISTS CA_LOCALIZATION_TEXT;
+DROP TABLE IF EXISTS CA_DB_PROPERTIES;
+
+SELECT "CREATE TABLE CA_ENTRY" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_ENTRY( ENTRY_ID INTEGER PRIMARY KEY,
+ EN_TEXT TEXT NOT NULL COLLATE NOCASE,
+ EN_DESCRIPTION TEXT COLLATE NOCASE,
+ EN_ROLE INTEGER default 1,
+ EN_TYPE_NAME TEXT NOT NULL,
+ EN_ICON_ID INTEGER,
+ EN_CREATION_TIME BIGINT default -1 NOT NULL,
+ EN_UID INTEGER UNIQUE,
+ EN_FLAGS INTEGER default 8,
+ FOREIGN KEY(EN_ICON_ID) REFERENCES CA_ICON(ICON_ID) );
+CREATE INDEX EntryText_CAIndex ON CA_ENTRY(EN_TEXT);
+CREATE INDEX EntryCreationTime_CAIndex ON CA_ENTRY(EN_CREATION_TIME);
+
+SELECT "CREATE TABLE CA_GROUP_ENTRY" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_GROUP_ENTRY( GROUP_ENTRY_ID INTEGER PRIMARY KEY ,
+ GE_GROUP_ID INTEGER NOT NULL,
+ GE_ENTRY_ID INTEGER NOT NULL,
+ GE_POSITION INTEGER,
+ UNIQUE( GE_GROUP_ID, GE_ENTRY_ID ),
+ FOREIGN KEY(GE_GROUP_ID) REFERENCES CA_ENTRY(ENTRY_ID),
+ FOREIGN KEY(GE_ENTRY_ID) REFERENCES CA_ENTRY(ENTRY_ID) );
+CREATE INDEX GroupGE_POSITION_CAIndex ON CA_GROUP_ENTRY(GE_POSITION);
+CREATE TRIGGER update_position_in_ca_group_entry_after_remove AFTER DELETE ON CA_GROUP_ENTRY
+BEGIN
+ UPDATE CA_GROUP_ENTRY SET GE_POSITION = GE_POSITION - 1 WHERE GE_POSITION > old.GE_POSITION AND GE_GROUP_ID = old.GE_GROUP_ID;
+END;
+CREATE TRIGGER update_position_in_ca_group_entry_before_insert BEFORE INSERT ON CA_GROUP_ENTRY
+BEGIN
+ UPDATE CA_GROUP_ENTRY SET GE_POSITION = GE_POSITION + 1 WHERE GE_POSITION >= new.GE_POSITION AND GE_GROUP_ID = new.GE_GROUP_ID;
+END;
+
+SELECT "CREATE TABLE CA_ICON" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_ICON( ICON_ID INTEGER PRIMARY KEY ,
+ IC_FILENAME TEXT,
+ IC_SKIN_ID TEXT,
+ IC_APP_ID TEXT,
+ UNIQUE( IC_FILENAME, IC_SKIN_ID, IC_APP_ID ) );
+
+SELECT "CREATE TABLE CA_LAUNCH" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_LAUNCH( LAUNCH_ID INTEGER PRIMARY KEY ,
+ LA_ENTRY_ID INTEGER NOT NULL,
+ LA_LAUNCH_TIME INTEGER NOT NULL,
+ FOREIGN KEY(LA_ENTRY_ID) REFERENCES CA_ENTRY(ENTRY_ID) );
+CREATE INDEX LaunchLaunchTime_CAIndex ON CA_LAUNCH(LA_LAUNCH_TIME);
+
+SELECT "CREATE TABLE CA_ATTRIBUTE" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_ATTRIBUTE( ATTRIBUTE_ID INTEGER PRIMARY KEY ,
+ AT_ENTRY_ID INTEGER NOT NULL,
+ AT_NAME TEXT NOT NULL,
+ AT_VALUE TEXT NOT NULL,
+ UNIQUE( AT_ENTRY_ID, AT_NAME ),
+ FOREIGN KEY(AT_ENTRY_ID) REFERENCES CA_ENTRY(ENTRY_ID) );
+
+SELECT "CREATE TABLE CA_LOCALIZATION_TEXT" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_LOCALIZATION_TEXT( LOC_TEXT_ID INTEGER PRIMARY KEY ,
+ LT_TABLE_NAME TEXT ,
+ LT_ATTRIBUTE_NAME TEXT ,
+ LT_STRING_ID TEXT ,
+ LT_QMFILENAME TEXT,
+ LT_ROW_ID INTEGER );
+
+SELECT "CREATE TABLE CA_DB_PROPERTIES" AS " ";
+SELECT "------------------------------------" AS " ";
+CREATE TABLE CA_DB_PROPERTIES( DB_PROPERTIES_ID INTEGER PRIMARY KEY ,
+ DB_PROPERTY TEXT UNIQUE,
+ DB_VALUE TEXT );
+
+
+
+-- CREATE VIEW COLLECTION
+SELECT "------------------------------------" AS " ";
+SELECT "CREATE VIEW COLLECTION" AS " ";
+DROP VIEW IF EXISTS COLLECTION;
+CREATE VIEW COLLECTION
+ AS SELECT
+ "" AS "COLLECTION_NAME",
+ "" AS "COL_LOCNAME",
+ "" AS "ICON";
+
+SELECT " CREATE TRIGGER collection_insert" AS " ";
+CREATE TRIGGER collection_insert INSTEAD OF INSERT ON COLLECTION
+BEGIN
+ -- INSERT ICON
+ INSERT INTO CA_ICON (IC_FILENAME)
+ VALUES ( new.ICON);
+ -- DELETE IF ICON IS NULL OR IF IT IS DUPLICATE
+ DELETE FROM CA_ICON WHERE ICON_ID = last_insert_rowid() AND
+ (IC_FILENAME IS NULL OR (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON AND ICON_ID <> last_insert_rowid()) IS NOT NULL);
+ -- INSERT ENTRY
+ INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_FLAGS, EN_ICON_ID )
+ VALUES ( new.COLLECTION_NAME , 2, "collection", 12, (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON ));
+ -- LOCALIZATION
+ INSERT INTO CA_LOCALIZATION_TEXT ( LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_ROW_ID )
+ VALUES ( 'CA_ENTRY', 'EN_TEXT', new.COL_LOCNAME, ( SELECT last_insert_rowid() ) );
+ DELETE FROM CA_LOCALIZATION_TEXT WHERE LT_STRING_ID IS NULL AND LOC_TEXT_ID = last_insert_rowid() ;
+ -- RELATION TO MAIN COLLECTION (ADD TO GROUP: )
+ INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION)
+ VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TYPE_NAME = "menucollections") ,
+ (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME),
+ (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TYPE_NAME = "menucollections")) );
+ -- ADD ATTRIBUTE
+ INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+ VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME AND (EN_TYPE_NAME = "collection::downloaded" OR EN_TYPE_NAME = "collection") ), "appgroup_name", new.COLLECTION_NAME );
+END;
+
+-- CREATE VIEW ITEM_TO_COLLECTION
+SELECT "------------------------------------" AS " ";
+SELECT "CREATE VIEW ITEM_TO_COLLECTION" AS " ";
+DROP VIEW IF EXISTS ITEM_TO_COLLECTION;
+CREATE VIEW ITEM_TO_COLLECTION
+ AS SELECT
+ "" AS "ITEM_TYPE",
+ "" AS "ITEM_NAME",
+ "" AS "ICON",
+ "" AS "ITEM_DEST",
+ "" AS "COLLECTION_NAME";
+
+SELECT " CREATE TRIGGER item_to_collection_insert_app" AS " ";
+CREATE TRIGGER item_to_collection_insert_app INSTEAD OF INSERT ON ITEM_TO_COLLECTION WHEN new.ITEM_TYPE="application"
+BEGIN
+ -- INSERT ENTRY
+ INSERT OR IGNORE INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_UID )
+ VALUES ( new.ITEM_NAME, 1, "application", new.ITEM_DEST );
+ -- RELATION TO MAIN COLLECTION (ADD TO GROUP: )
+ INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION)
+ VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME) ,
+ (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME),
+ (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME)) );
+END;
+
+SELECT " CREATE TRIGGER item_to_collection_insert_url" AS " ";
+CREATE TRIGGER item_to_collection_insert_url INSTEAD OF INSERT ON ITEM_TO_COLLECTION WHEN new.ITEM_TYPE="url"
+BEGIN
+ -- INSERT ICON
+ INSERT OR IGNORE INTO CA_ICON (IC_FILENAME)
+ VALUES ( new.ICON);
+ DELETE FROM CA_ICON WHERE ICON_ID = last_insert_rowid() AND
+ (IC_FILENAME IS NULL OR (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON AND ICON_ID <> last_insert_rowid()) IS NOT NULL);
+ -- INSERT ENTRY
+ INSERT OR IGNORE INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID )
+ VALUES ( new.ITEM_NAME, 1, "url", (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON ));
+ INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+ VALUES ( ( SELECT last_insert_rowid() ) ,"url",new.ITEM_DEST);
+ -- RELATION TO MAIN COLLECTION (ADD TO GROUP: )
+ INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION)
+ VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME) ,
+ (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME),
+ (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME)) );
+END;
+
+
+-- CREATE VIEW WIDGET _TO_COLLECTION
+SELECT "------------------------------------" AS " ";
+SELECT "CREATE VIEW WIDGET_TO_COLLECTION" AS " ";
+DROP VIEW IF EXISTS WIDGET_TO_COLLECTION;
+CREATE VIEW WIDGET_TO_COLLECTION
+ AS SELECT
+ "" AS "ITEM_TYPE",
+ "" AS "ITEM_NAME",
+ "" AS "ICON",
+ "" AS "PACKAGE_UID",
+ "" AS "LIBRARY",
+ "" AS "URI",
+ "" AS "COLLECTION_NAME" ;
+
+SELECT " CREATE TRIGGER insert_widget_to_collection" AS " ";
+CREATE TRIGGER item_to_collection_insert_widget INSTEAD OF INSERT ON WIDGET_TO_COLLECTION WHEN new.ITEM_TYPE="widget"
+BEGIN
+ -- INSERT ICON
+ INSERT OR IGNORE INTO CA_ICON (IC_FILENAME)
+ VALUES ( new.ICON);
+ DELETE FROM CA_ICON WHERE ICON_ID = last_insert_rowid() AND
+ (IC_FILENAME IS NULL OR (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON AND ICON_ID <> last_insert_rowid()) IS NOT NULL);
+ -- INSERT ENTRY
+ INSERT OR IGNORE INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID )
+ VALUES ( new.ITEM_NAME, 1, "widget", (SELECT ICON_ID FROM CA_ICON WHERE IC_FILENAME = new.ICON ));
+ -- INSERT ATTRIBUTES
+ INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+ VALUES ( ( SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME ) ,"packageuid",new.PACKAGE_UID);
+ INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+ VALUES ( ( SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME ) ,"widget:library",new.LIBRARY);
+ INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+ VALUES ( ( SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME ) ,"widget:uri",new.URI);
+ -- RELATION TO MAIN COLLECTION (ADD TO GROUP: )
+ INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION)
+ VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME) ,
+ (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.ITEM_NAME),
+ (SELECT IFNULL(MAX(GE_POSITION)+1, 1) FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TEXT = new.COLLECTION_NAME)) );
+END;
+
+
+
+
+SELECT "INSERT INITIAL DATA TO CA_DB_PROPERTIES" AS " ";
+
+SELECT "------------------------------------" AS " ";
+INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE )
+VALUES ( 'Version', '00001' );
+INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE )
+VALUES ( 'Language', 'en_GB' );
+INSERT INTO CA_DB_PROPERTIES ( DB_PROPERTY, DB_VALUE )
+VALUES ( 'QMfile', 'db_textmap_' );
+
+
+
+
+SELECT "------------------------------------" AS " ";
+SELECT "castorage.db_create - END" AS " ";
+SELECT "------------------------------------" AS " ";
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/data/castoragedb_variant.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,5 @@
+@echo off
+del castorage.db
+sqlite3 castorage.db ".read castoragedb_create.sql"
+sqlite3 castorage.db ".genfkey --exec"
+sqlite3 castorage.db ".read castoragedb_variant.sql"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/data/castoragedb_variant.sql Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,82 @@
+SELECT "------------------------------------" AS " ";
+SELECT "castoragedb_variant - BEGIN" AS " ";
+
+-- insert neccessary items
+SELECT "INSERT GROUPS" AS " ";
+SELECT "." AS " ";
+INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID, EN_UID )
+VALUES ( 'Menu', 2, "folder", NULL , NULL );
+
+INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+VALUES ( last_insert_rowid(), "appgroup_name", "Menu" );
+
+SELECT "INSERT menucollections ENTRY" AS " ";
+INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID, EN_UID )
+VALUES ( 'AllCollections', 2, "menucollections", NULL , NULL );
+
+INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+VALUES ( last_insert_rowid(), "appgroup_name", "AllCollections" );
+
+SELECT "." AS " ";
+INSERT INTO CA_ICON (IC_FILENAME)
+VALUES ( 'c:\data\Images\kqticaicons\google1.png');
+
+INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID, EN_UID, EN_FLAGS )
+VALUES ( 'Application Library', 2, "applicationlibrary", ( SELECT last_insert_rowid() ), NULL, 8 );
+
+INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+VALUES ( last_insert_rowid(), "appgroup_name", " Application Library" );
+
+SELECT "------------------------------------" AS " ";
+SELECT "INSERT Downloaded collection ENTRY" AS " ";
+INSERT INTO CA_ICON (IC_FILENAME)
+VALUES ( "qtg_large_applications_download");
+
+INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID, EN_FLAGS )
+VALUES ( 'Downloaded', 2, "collection::downloaded", last_insert_rowid() , 8 );
+
+INSERT OR IGNORE INTO CA_ATTRIBUTE (AT_ENTRY_ID, AT_NAME, AT_VALUE )
+VALUES ( last_insert_rowid(), "appgroup_name", " Downloaded" );
+
+INSERT INTO CA_LOCALIZATION_TEXT ( LT_TABLE_NAME, LT_ATTRIBUTE_NAME, LT_STRING_ID, LT_ROW_ID )
+VALUES ( 'CA_ENTRY', 'EN_TEXT', "txt_applib_dblist_downloaded", ( SELECT last_insert_rowid() ) );
+
+INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID, GE_ENTRY_ID, GE_POSITION)
+VALUES ( (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TYPE_NAME = "menucollections") ,
+ (SELECT ENTRY_ID FROM CA_ENTRY WHERE EN_TYPE_NAME = "collection::downloaded"),
+ 1 );
+
+-- insert additional items
+
+INSERT INTO COLLECTION (COLLECTION_NAME, COL_LOCNAME, ICON) VALUES ( 'Office', "txt_applib_dblist_office", "qtg_large_applications_user");
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'calendar', 268458241, 'Office' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'Phonebook', 537014009, 'Office' );
+
+INSERT INTO COLLECTION (COLLECTION_NAME, ICON) VALUES ( 'Multimedia', "qtg_large_applications_user" );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'Themes', 268458546, 'Multimedia' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'Paint Cursor', 537001564, 'Multimedia' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'Videoplayer', 537006590, 'Multimedia' );
+
+INSERT INTO COLLECTION (COLLECTION_NAME, ICON) VALUES ( 'Utils', "qtg_large_applications_user" );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'ControlPanel', 537026521, 'Utils' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'Bluetooth', 268458321, 'Utils' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'SW update', 537001519, 'Utils' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'eshell', 270498535, 'Utils' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("application", 'Conn. mgr.', 270501072, 'Utils' );
+
+
+INSERT INTO COLLECTION (COLLECTION_NAME, COL_LOCNAME, ICON) VALUES ( 'Games', "txt_applib_dblist_games", "qtg_large_applications_user" );
+
+SELECT "castoragedb_variant - END" AS " ";
+SELECT "------------------------------------" AS " ";
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/data/castoragedb_variant_test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,5 @@
+@echo off
+del castorage.db
+sqlite3 castorage.db ".read castoragedb_create.sql"
+sqlite3 castorage.db ".genfkey --exec"
+sqlite3 castorage.db ".read castoragedb_variant_test.sql"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/data/castoragedb_variant_test.sql Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+-- ONLY IF YOU SURE THAT WANT DEFAULT CONTENT
+.read castoragedb_variant.sql
+
+SELECT "castoragedb_variant test - BEGIN" AS " ";
+
+
+SELECT "." AS " ";
+INSERT INTO CA_ICON (IC_FILENAME)
+VALUES ( 'z:\resource\apps\wsficons.mif');
+
+SELECT "." AS " ";
+INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_UID, EN_ICON_ID )
+VALUES ( 'RealPlayer', 1, "application", 268458558 , 4 );
+
+SELECT "." AS " ";
+INSERT INTO CA_ENTRY (EN_TEXT, EN_ROLE, EN_TYPE_NAME, EN_UID, EN_ICON_ID )
+VALUES ( 'Videos & TV', 1, "application", 537006586 , 4 );
+
+
+-- insert collection
+INSERT INTO COLLECTION (COLLECTION_NAME, ICON) VALUES ( 'Favorites', "qtg_large_applications_user" );
+
+-- insert example urls
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ICON,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("url", 'Facebook', 'c:\data\Images\kqticaicons\facebook.png', "http://www.facebook.com/", 'Favorites' );
+ INSERT INTO ITEM_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ICON,ITEM_DEST, COLLECTION_NAME)
+ VALUES ("url", 'Google', 'c:\data\Images\kqticaicons\google.png', "http://www.google.com/", 'Favorites' );
+
+-- insert example widgets
+ INSERT INTO WIDGET_TO_COLLECTION (ITEM_TYPE,ITEM_NAME,ICON, PACKAGE_UID, LIBRARY, URI, COLLECTION_NAME)
+ VALUES ("widget", 'aClock', 'Z:\private\20022F35\import\widgetregistry\20022F6C\tclock.png', '20022f43', 'Z:\private\20022F35\import\widgetregistry\20022F43\hsclockwidgetprovider.dll', 'homescreen.nokia.com/widget/clock', 'Office' );
+
+
+
+SELECT "castoragedb_variant test - END" AS " ";
\ No newline at end of file
Binary file contentstorage/castorage/tsrc/t_castorage/data/corruptedcastoragedb has changed
Binary file contentstorage/castorage/tsrc/t_castorage/data/kqticaicons/facebook.png has changed
Binary file contentstorage/castorage/tsrc/t_castorage/data/kqticaicons/google.png has changed
Binary file contentstorage/castorage/tsrc/t_castorage/data/kqticaicons/myspace.png has changed
Binary file contentstorage/castorage/tsrc/t_castorage/data/kqticaicons/youtube.png has changed
Binary file contentstorage/castorage/tsrc/t_castorage/data/versioncastoragedb has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../../src/*\" sbs -j 4 -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_castorage -o c:\\t_castorage.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/inc/castoragetest.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2009 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:
+ *
+ */
+#ifndef CASTORAGETEST_H
+#define CASTORAGETEST_H
+
+// INCLUDES
+#include <e32svr.h>
+#include <e32math.h>
+#include <f32file.h>
+#include <QtTest/QtTest>
+#include <QString>
+
+#include "cainnerquery.h"
+
+class CCaStorage;
+class CCaInnerEntry;
+
+class CCAStorageTest : public QObject
+{
+ Q_OBJECT
+
+private slots:
+
+ /**
+ * Test methods are listed below.
+ */
+
+
+
+ //tests for add command
+ void testAdd();
+ //tests for add command without icon
+ void testAddEmptyIcon();
+ //tests for add command with icon
+ void testAddWithIcon();
+ //tests for add command with existing icon
+ void testAddWithExistingIcon();
+ //tests for add command with existing icon where only filename specified
+ void testAddWithExistingIconOnlyFileName();
+ //tests for add command with partly matching icon
+ void testAddWithPartlyMatchingIcon();
+ //tests for add command with partly matching icon when not all icon params where set
+ void testAddWithPartlyMatchingIconNotAllParams();
+ //tests for add command with not complete icon
+ void testAddWithNotCompleteIcon();
+ //tests for add command to update icon
+ void testAddUpdateIcon();
+ //tests for add command to update icon with the same one
+ void testAddUpdateIconOnlyFewParams();
+ //tests for add command to update icon
+ void testAddUpdateWithEmptyIcon();
+ //tests for add command to update icon
+ void testAddUpdateWithEmptyIconAdvanced();
+ //tests for add command to update icon, to an already existing icon
+ void testAddUpdateWithExistingIcon();
+ //tests for add command - add attributes
+ void testAddAttributes();
+ //tests for add command - update attributes
+ void testUpdateAttributes();
+ //tests for add command - remove attributes
+ void testDeleteAttributes();
+ //tests for remove command
+ void testRemoveOneEntryWithIcon();
+
+ void testRemoveOneEntryWhenIconIsUseByOtherEntry();
+
+ void testRemoveTwoEntriesWithSameIcon();
+
+ void testRemoveOneEntryWithoutIcon();
+
+ void testRemove5Entries();
+
+ void testRemoveEntriesWithIdOutOFBound();
+
+ void testTouch();
+
+ void testTouch2Times();
+
+ void testTouch5Entries();
+
+ void testRemoveOldFromLaunch();
+
+ void testRemoveOldWhen2DifferentLaunchTimes();
+
+ //tests getentries by id.
+ void testGetEntriesById();
+
+ //tests getentries by group id.
+ void testGetEntriesByGroupId();
+
+ //tests getentries by group id.
+ void testGetEntriesByTypeName();
+
+ //tests getentries sorted by name.
+ void testGetEntriesSortByName();
+
+ //tests getentries sorted by created timestamp.
+ void testGetEntriesSortByCreatedTimestamp();
+
+ //tests getentries sorted by most used timestamp.
+ void testGetEntriesSortByMostUsedTimestamp();
+
+ //tests getentries sorted by last used timestamp.
+ void testGetEntriesSortByLastUsedTimestamp();
+
+ //tests getentries sorted by default.
+ void testGetEntriesSortByDefault();
+
+ //tests getentries by flags.
+ void testGetEntriesByFlags();
+
+ //tests getentries by flags off.
+ void testGetEntriesByFlagsOff();
+
+ //tests getentries by flags on.
+ void testGetEntriesByFlagsOn();
+
+ //tests getentries by flags on.
+ void testGetEntriesByRole();
+
+ //tests getentries by flags.
+ void testGetEntriesByUid();
+
+ //tests getentries by attributes.
+ void testGetEntriesByAttributes();
+
+ //tests getentries by attributes.
+ void testGetEntriesByAttributes2();
+
+ //tests getentries by child Id.
+ void testGetEntriesByChildId();
+
+ //tests organize remove.
+ void testOrganizeRemove();
+
+ //tests organize append.
+ void testOrganizeAppend();
+
+ //tests organize prepend.
+ void testOrganizePrepend();
+
+ //tests organize insert new entry into group.
+ void testOrganizeInsertNewIntoGroup();
+
+ //tests organize get entries' ids.
+ void testGetEntriesIds();
+
+ //tests organize bad parameters case.
+ void testOrganizeBadParams();
+
+ void testGetNewEntryWithAttributes();
+
+ void testGetNewEntryWithAttributesByUid();
+
+ void testGetEntriesWhenLimitSetTo();
+
+ //tests custom sort
+ void testCustomSort();
+
+ //tests get parent ids
+ void testGetParentIds();
+
+ void testGetParentIdsInLoop();
+
+ //tests properties
+ void testPropertyGetDbVersion();
+
+ void testPropertyGetLanguage();
+
+ void testLoadDBFromROM();
+
+ //tests localization
+ void testRemoveFromLocalizationAfterNameChange();
+
+ void testGetLocalizations();
+
+ void testLocalizeEntry();
+
+ void testAddLocalizationEntry();
+
+ void testUpdateLocalizationEntry();
+
+ void testSaveRestoreDatabase();
+
+
+ //unused
+ //void testBadDBVersion();
+
+ void init(); // called before each test method
+ void cleanup(); // called after each test method
+ void initTestCase(); // called once before all test methods
+ void cleanupTestCase(); // caled once after all test methods
+ /**
+ * Utility methods are listed below.
+ */
+
+ // Test that two data arrays have opposite order.
+
+
+private:
+ TInt locEntriesCount();
+
+
+protected:
+
+
+ /**
+ * Utils methods are listed below.
+ */
+ TInt verifyOppositeOrder(RPointerArray<CCaInnerEntry>& aArray1,
+ RPointerArray<CCaInnerEntry>& aArray2);
+
+ TInt testSortingBySortOrder(CCaInnerQuery::TSortAttribute sortAttr1,
+ CCaInnerQuery::TSortAttribute sortAttr2);
+
+ TInt testSortingBySortOrder(CCaInnerQuery *aInnerQuery1,
+ CCaInnerQuery *aInnerQuery2);
+ void RestoreDatabase();
+ void CopyFile(const TDesC &aSorcePath, const TDesC &aDestinationPath);
+ QString descToQString(const TDesC &descriptor);
+private:
+
+ CCaStorage *mStorage;
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/inc/castoragetestsqlcommands.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2009 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:
+ *
+ */
+
+#ifndef CASTORAGETESTSQLCOMMANDS_H_
+#define CASTORAGETESTSQLCOMMANDS_H_
+
+_LIT(KSQLGetEntryTimestamp, "SELECT EN_CREATION_TIME AS Data FROM CA_ENTRY where ENTRY_ID = :ENTRY_ID0 ");
+
+// add tests
+_LIT(KTestName, "AddTest");
+_LIT(KTestName1, "TestName1");
+_LIT(KTestName2, "TestName2");
+_LIT(KTestNameUpdate, "AddTestUpdate");
+_LIT(KTypeName, "Folder");
+_LIT(KTypeName2, "application");
+const TUint flag = 4;
+const TUint flagUpdate = 8;
+
+_LIT(KAttrName_1, "Attribute_Name_1");
+_LIT(KAttrName_2, "Attribute_Name_2");
+_LIT(KAttrName_3, "Attribute_Name_3");
+_LIT(KAttrValue_1, "Attribute_Value_1");
+_LIT(KAttrValue_2, "Attribute_Value_2");
+_LIT(KAttrValue_3, "Attribute_Value_3");
+
+_LIT(KSQLCheckAttribute, "SELECT * FROM CA_ATTRIBUTE \
+WHERE AT_ENTRY_ID = :ENTRY_ID");
+
+_LIT(KSQLGetAttribute, "SELECT * FROM CA_ATTRIBUTE WHERE AT_ENTRY_ID = :AT_ENTRY_ID");
+
+// remove tests
+_LIT(KSQLGetIdCountFromEntryTable,"SELECT COUNT(*) AS Data FROM CA_ENTRY");
+_LIT(KSQLGetIdCountFromIconTable,"SELECT COUNT(*) AS Data FROM CA_ICON");
+
+// touch
+_LIT(KSQLGetIdCountFromLaunchTable,"SELECT COUNT(*) AS Data FROM CA_LAUNCH");
+_LIT(KSQLGetUsedFlagCountFromEntryTable, "SELECT COUNT(*) AS Data FROM CA_ENTRY \
+WHERE EN_FLAGS & :EN_FLAGS = :EN_FLAGS");
+
+const TInt KErrNoData = 1001;
+const TInt KErrWrongData = 1002;
+const TInt KErrBadParams = 1003;
+
+const TInt KAllCollectionsGroupId = 2;
+const TInt KMaxFlagsMask = 63;
+const TInt KMaxFlagsMaskForCombinedTest = 15;
+const TInt KCalendarAppUid = 268458241;
+const TInt KTestAppUid = 268458111;
+const TInt KTestAppUid2 = 268458112;
+
+_LIT(KTypeNameApplication, "application");
+_LIT(KTypeNameFolder, "folder");
+
+//organize tests
+_LIT(KSQLGetUnexistingIdFromGroup,"SELECT MAX(GE_ENTRY_ID) + 1 AS Data FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = :GE_GROUP_ID");
+
+// GE_ENTRY_ID AS GE_GROUP_ID because we don't have proper execute
+_LIT(KSQLGetEntryIdsFromGroupInPositionOrder, "SELECT GE_ENTRY_ID AS GE_GROUP_ID FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = :GE_GROUP_ID ORDER BY GE_POSITION");
+
+//get entries tests
+_LIT(KSQLGetEntriesCountFromSpecificGroup, "SELECT COUNT(*) AS Data FROM CA_GROUP_ENTRY \
+WHERE GE_GROUP_ID = :GE_GROUP_ID");
+
+_LIT(KSQLGetEntriesCountAsParentsForSpecificEntry, "SELECT COUNT(*) AS Data FROM CA_GROUP_ENTRY \
+WHERE GE_ENTRY_ID = :GE_ENTRY_ID");
+
+_LIT(KSQLGetIdEntryFromSpecificGroup, "SELECT GE_ENTRY_ID AS ENTRY_ID FROM CA_GROUP_ENTRY \
+WHERE GE_GROUP_ID = :GE_GROUP_ID");
+const TUint KFlagsOnTable[5] = { 0, 2, 5, 36, 60 };
+const TUint KFlagsOffTable[5] = { 1, 2, 6, 18, 25 };
+const TUint KFlagsOffTableMasks[5] = { 30, 29, 25, 13, 6 };
+
+// localization
+_LIT(KSQLCountFromLocalizationTable,"SELECT COUNT(*) AS Data FROM CA_LOCALIZATION_TEXT");
+
+
+#endif /* CASTORAGETESTSQLCOMMANDS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_castorage_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\sis\rd.cer -key ..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castorageapiutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2009 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 "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include <f32file.h>
+#include <XQConversions>
+
+// constants
+const QString srcDbFileName("c:/testing/data/t_castorage/castorage.db");
+const QString dstDbFileName("c:/castorage.db");
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+void CCAStorageTest::initTestCase()
+{
+ QFile leftOverDbFile(dstDbFileName);
+ leftOverDbFile.open(QIODevice::ReadWrite);
+ leftOverDbFile.remove();
+
+}
+
+void CCAStorageTest::cleanupTestCase()
+{
+ QFile leftOverDbFile(dstDbFileName);
+ leftOverDbFile.open(QIODevice::ReadWrite);
+ leftOverDbFile.remove();
+}
+
+// -----------------------------------------------------------------------------
+//
+void CCAStorageTest::init()
+{
+ RestoreDatabase();
+
+ TRAPD(err,
+ mStorage = CaStorageFactory::NewDatabaseL();
+ );
+
+ QCOMPARE(err, KErrNone);
+}
+// -----------------------------------------------------------------------------
+//
+void CCAStorageTest::cleanup()
+{
+ delete mStorage;
+ mStorage = NULL;
+}
+
+// -----------------------------------------------------------------------------
+//
+void CCAStorageTest::RestoreDatabase()
+{
+ QFile leftOverDbFile(dstDbFileName);
+ leftOverDbFile.open(QIODevice::ReadWrite);
+ leftOverDbFile.remove();
+ leftOverDbFile.close();
+
+ QFile srcDbFile(srcDbFileName);
+ srcDbFile.open(QIODevice::ReadWrite);
+ srcDbFile.copy(dstDbFileName);
+ QTest::qWait(1000);
+}
+
+// -----------------------------------------------------------------------------
+//
+void CCAStorageTest::CopyFile(const TDesC &aSorcePath,
+ const TDesC &aDestinationPath)
+{
+ RFs fs;
+ User::LeaveIfError(fs.Connect());
+
+ CFileMan *fileMan = CFileMan::NewL(fs);
+ CleanupStack::PushL(fileMan);
+
+ TInt error = fileMan->Copy(aSorcePath, aDestinationPath);
+
+ CleanupStack::PopAndDestroy(fileMan);
+
+ fs.Close();
+}
+
+
+QString CCAStorageTest::descToQString(const TDesC &descriptor)
+{
+ return XQConversions::s60DescToQString(descriptor);
+}
+
+
+
+QTEST_MAIN(CCAStorageTest);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestadd.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,1047 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestadd.cpp
+ *
+ * Created on: 2009-08-05
+ * Author: michal.czerwiec
+ */
+
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+#include "caarraycleanup.inl"
+#include <QMap>
+#include <QString>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAdd()
+{
+ __UHEAP_MARK;
+ TInt entryId(0);
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ mStorage->AddL(innerEntry);
+ entryId = innerEntry->GetId();
+
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(entryId > 0);
+
+ __UHEAP_MARKEND;
+
+}
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddEmptyIcon()
+{
+ TInt entryId(0);
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(KNullDesC, KNullDesC, KNullDesC);
+ mStorage->AddL(innerEntry);
+ entryId = innerEntry->GetId();
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(entryId > 0);
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddWithIcon()
+{
+ __UHEAP_MARK;
+ TInt entryId(0);
+ TInt iconId(0);
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("qtg_large_applications_user"), KNullDesC, KNullDesC);
+ mStorage->AddL(innerEntry);
+
+ entryId = innerEntry->GetId();
+ iconId = innerEntry->GetIconId();
+
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddWithExistingIcon()
+{
+ __UHEAP_MARK;
+ TInt entryId1(0);
+ TInt iconId1(0);
+ TInt entryId2(0);
+ TInt iconId2(0);
+ TInt countIconsAfterFirstAdd (0);
+ TInt countIconsAfterSecondAdd (0);
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+ mStorage->AddL(innerEntry);
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterFirstAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ // Add second entry with the some icon
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Group);
+ innerEntry2->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+ mStorage->AddL(innerEntry2);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterSecondAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId1 = innerEntry->GetId();
+ iconId1 = innerEntry->GetIconId();
+
+ entryId2 = innerEntry2->GetId();
+ iconId2 = innerEntry2->GetIconId();
+
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ // No new icon created; Icon which is the same should be shared by newly added entries
+ QCOMPARE(countIconsAfterFirstAdd, countIconsAfterSecondAdd);
+
+ QVERIFY(entryId1 > 0);
+ QVERIFY(iconId1 > 0);
+ QVERIFY(entryId2 > 0);
+ QVERIFY(iconId2 > 0);
+ QVERIFY(!(entryId1 == entryId2));
+ QCOMPARE(iconId1, iconId2);
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddWithExistingIconOnlyFileName()
+{
+ __UHEAP_MARK;
+ TInt entryId1(0);
+ TInt iconId1(0);
+ TInt entryId2(0);
+ TInt iconId2(0);
+ TInt countIconsAfterFirstAdd (0);
+ TInt countIconsAfterSecondAdd (0);
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("qtg_large_applications_user"), KNullDesC, KNullDesC);
+ mStorage->AddL(innerEntry);
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterFirstAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ // Add second entry with the some icon
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Group);
+ innerEntry2->SetIconDataL(_L("qtg_large_applications_user"), KNullDesC, KNullDesC);
+ mStorage->AddL(innerEntry2);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterSecondAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId1 = innerEntry->GetId();
+ iconId1 = innerEntry->GetIconId();
+
+ entryId2 = innerEntry2->GetId();
+ iconId2 = innerEntry2->GetIconId();
+
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ // No new icon created; Icon which is the same should be shared by newly added entries
+ QCOMPARE(countIconsAfterFirstAdd, countIconsAfterSecondAdd);
+
+
+ QVERIFY(entryId1 > 0);
+ QVERIFY(iconId1 > 0);
+ QVERIFY(entryId2 > 0);
+ QVERIFY(iconId2 > 0);
+ QVERIFY(!(entryId1 == entryId2));
+ QCOMPARE(iconId1, iconId2);
+
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddWithPartlyMatchingIcon()
+{
+ __UHEAP_MARK;
+ TInt entryId1(0);
+ TInt iconId1(0);
+ TInt entryId2(0);
+ TInt iconId2(0);
+ TInt countIconsAfterFirstAdd (0);
+ TInt countIconsAfterSecondAdd (0);
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+ mStorage->AddL(innerEntry);
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterFirstAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ // Add second entry with the some icon
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Group);
+ innerEntry2->SetIconDataL(_L("filename"), _L("skinId2"), _L("111111111"));
+ mStorage->AddL(innerEntry2);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterSecondAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId1 = innerEntry->GetId();
+ iconId1 = innerEntry->GetIconId();
+
+ entryId2 = innerEntry2->GetId();
+ iconId2 = innerEntry2->GetIconId();
+
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ // New icon should be added
+ QCOMPARE(countIconsAfterSecondAdd - countIconsAfterFirstAdd, 1);
+
+ QVERIFY(entryId1 > 0);
+ QVERIFY(iconId1 > 0);
+ QVERIFY(entryId2 > 0);
+ QVERIFY(iconId2 > 0);
+ QVERIFY(!(entryId1 == entryId2));
+ QVERIFY(!(iconId1 == iconId2));
+
+ __UHEAP_MARKEND;
+}
+
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddWithPartlyMatchingIconNotAllParams()
+{
+ __UHEAP_MARK;
+ TInt entryId1(0);
+ TInt iconId1(0);
+ TInt entryId2(0);
+ TInt iconId2(0);
+ TInt countIconsAfterFirstAdd (0);
+ TInt countIconsAfterSecondAdd (0);
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), KNullDesC);
+ mStorage->AddL(innerEntry);
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterFirstAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ // Add second entry with the some icon
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Group);
+ innerEntry2->SetIconDataL(KNullDesC, _L("skinId"), KNullDesC);
+ mStorage->AddL(innerEntry2);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterSecondAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId1 = innerEntry->GetId();
+ iconId1 = innerEntry->GetIconId();
+
+ entryId2 = innerEntry2->GetId();
+ iconId2 = innerEntry2->GetIconId();
+
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ // New icon should be added
+ QCOMPARE(countIconsAfterSecondAdd - countIconsAfterFirstAdd, 1);
+
+ QVERIFY(entryId1 > 0);
+ QVERIFY(iconId1 > 0);
+ QVERIFY(entryId2 > 0);
+ QVERIFY(iconId2 > 0);
+ QVERIFY(!(entryId1 == entryId2));
+ QVERIFY(!(iconId1 == iconId2));
+
+ __UHEAP_MARKEND;
+}
+
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddWithNotCompleteIcon()
+{
+ TInt entryId(0);
+ TInt iconId(0);
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("fake"), KNullDesC, KNullDesC);
+ mStorage->AddL(innerEntry);
+
+ entryId = innerEntry->GetId();
+ iconId = innerEntry->GetIconId();
+
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddUpdateIcon()
+{
+ TInt entryId(0);
+ TInt iconId(0);
+ TInt updatedEntryId(0);
+ TInt updatedIconId(0);
+ TInt countIconsAfterAdd (0);
+ TInt countIconsAfterUpdate (0);
+
+ RBuf updatedIconFileName;
+ RBuf updatedIconSkinId;
+ RBuf updatedIconAppId;
+ TInt updatedIconIdFormIcon(0);
+
+ __UHEAP_MARK;
+ updatedIconFileName.CreateL( KMaxFileName );
+ updatedIconSkinId.CreateL( KMaxFileName );
+ updatedIconAppId.CreateL( KMaxUidName );
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+ mStorage->AddL(innerEntry);
+
+ // Check db after add with icon
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId = innerEntry->GetId();
+ iconId = innerEntry->GetIconId();
+
+ innerEntry->SetTextL(KTestNameUpdate);
+ innerEntry->SetFlags(flagUpdate);
+ innerEntry->SetIconDataL( _L("filename2"), _L("skinId2"), _L("537001519"));
+ mStorage->AddL(innerEntry);
+
+ // Check db after update with icon
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterUpdate);
+ CleanupStack::PopAndDestroy(query);
+
+ updatedEntryId = innerEntry->GetId();
+ updatedIconId = innerEntry->GetIconId();
+
+ updatedIconFileName = innerEntry->Icon()->FileName();
+ updatedIconSkinId= innerEntry->Icon()->SkinId();
+ updatedIconAppId = innerEntry->Icon()->ApplicationId();
+ updatedIconIdFormIcon = innerEntry->Icon()->Id();
+
+
+
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+ QCOMPARE(updatedEntryId, entryId);
+ QCOMPARE(updatedIconId, iconId);
+ QCOMPARE(updatedIconIdFormIcon, updatedIconId);
+ QVERIFY(!updatedIconFileName.Compare(_L("filename2")));
+ QVERIFY(!updatedIconSkinId.Compare(_L("skinId2")));
+ QVERIFY(!updatedIconAppId.Compare(_L("537001519")));
+
+ // No new icon should be added to DB
+ QCOMPARE(countIconsAfterAdd, countIconsAfterUpdate);
+
+
+ updatedIconFileName.Close();
+ updatedIconSkinId.Close();
+ updatedIconAppId.Close();
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddUpdateIconOnlyFewParams()
+{
+ TInt entryId(0);
+ TInt iconId(0);
+ TInt updatedEntryId(0);
+ TInt updatedIconId(0);
+ TInt countIconsAfterAdd (0);
+ TInt countIconsAfterUpdate (0);
+
+
+ RBuf updatedIconFileName;
+ RBuf updatedIconSkinId;
+ RBuf updatedIconAppId;
+ TInt updatedIconIdFormIcon(0);
+
+ __UHEAP_MARK;
+ updatedIconFileName.CreateL( KMaxFileName );
+ updatedIconSkinId.CreateL( KMaxFileName );
+ updatedIconAppId.CreateL( KMaxUidName );
+
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), KNullDesC, _L("268458321"));
+ mStorage->AddL(innerEntry);
+
+ // Check db after add with icon
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterAdd);
+ CleanupStack::PopAndDestroy(query);
+
+
+ entryId = innerEntry->GetId();
+ iconId = innerEntry->GetIconId();
+
+ innerEntry->SetTextL(KTestNameUpdate);
+ innerEntry->SetFlags(flagUpdate);
+ innerEntry->SetIconDataL( _L("filename2"), KNullDesC, _L("537001519"));
+ mStorage->AddL(innerEntry);
+
+ // Check db after update with icon
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterUpdate);
+ CleanupStack::PopAndDestroy(query);
+
+
+ updatedEntryId = innerEntry->GetId();
+ updatedIconId = innerEntry->GetIconId();
+
+ updatedIconFileName = innerEntry->Icon()->FileName();
+ updatedIconSkinId= innerEntry->Icon()->SkinId();
+ updatedIconAppId = innerEntry->Icon()->ApplicationId();
+ updatedIconIdFormIcon = innerEntry->Icon()->Id();
+
+
+
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+ QCOMPARE(updatedEntryId, entryId);
+ QCOMPARE(updatedIconId, iconId);
+ QCOMPARE(updatedIconIdFormIcon, updatedIconId);
+ QVERIFY(!updatedIconFileName.Compare(_L("filename2")));
+ QVERIFY(!updatedIconSkinId.Compare(KNullDesC));
+ QVERIFY(!updatedIconAppId.Compare(_L("537001519")));
+ // No new icon should be added to DB
+ QCOMPARE(countIconsAfterAdd, countIconsAfterUpdate);
+
+ updatedIconFileName.Close();
+ updatedIconSkinId.Close();
+ updatedIconAppId.Close();
+ __UHEAP_MARKEND;
+}
+
+
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddUpdateWithEmptyIcon()
+{
+ TInt countIconsAfterAdd(0);
+ TInt countIconsAfterUpdateWithEmptyIcon(0);
+ TInt entryId(0);
+ TInt iconId(0);
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+ // Add entry with icon - not null icon
+ mStorage->AddL(innerEntry);
+
+ // Check db after add with icon
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+
+ query->ExecuteL(countIconsAfterAdd);
+
+
+ CleanupStack::PopAndDestroy(query);
+
+ entryId = innerEntry->GetId();
+ iconId = innerEntry->GetIconId();
+
+ //CCaInnerEntry::TIconAttributes attr;
+ innerEntry->SetTextL(KTestNameUpdate);
+ innerEntry->SetFlags(flagUpdate);
+ //innerEntry->SetIconId( 0 );
+ innerEntry->SetIconDataL(KNullDesC, KNullDesC, KNullDesC);
+ //attr = innerEntry->GetIcon();
+ // Update entry with empty icon
+ mStorage->AddL(innerEntry);
+
+ // Check db after update with empty icon
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterUpdateWithEmptyIcon);
+
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+ // icon should be removed from db because we set params to NULL
+ QCOMPARE(countIconsAfterAdd - countIconsAfterUpdateWithEmptyIcon, 1);
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddUpdateWithEmptyIconAdvanced()
+{
+ TInt countIconsAfterAdd(0);
+ TInt countIconsAfterUpdateWithEmptyIcon(0);
+ TInt entryId(0);
+ TInt iconId(0);
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+ // Add entry with icon - not null icon
+ mStorage->AddL(innerEntry);
+
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Group);
+ innerEntry2->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ // Add second entry with the some icon - not null icon
+ mStorage->AddL(innerEntry2);
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+
+ query->ExecuteL(countIconsAfterAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId = innerEntry->GetId();
+
+ iconId = innerEntry->GetIconId();
+
+ innerEntry->SetTextL(KTestNameUpdate);
+ innerEntry->SetFlags(flagUpdate);
+ //innerEntry->SetIconId( 0 );
+ innerEntry->SetIconDataL(KNullDesC, KNullDesC, KNullDesC);
+ // Update entry with empty icon
+ mStorage->AddL(innerEntry);
+
+
+ // Check db after update with empty icon
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterUpdateWithEmptyIcon);
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+
+ // icon shouldn't be removed from db because it is use by other entry
+ QCOMPARE(countIconsAfterUpdateWithEmptyIcon, countIconsAfterAdd);
+
+ __UHEAP_MARKEND;
+}
+
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddUpdateWithExistingIcon()
+{
+ TInt countIconsAfterAdd(0);
+ TInt countIconsAfterUpdateWithEmptyIcon(0);
+ TInt entryId(0);
+ TInt iconId(0);
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("158321"));
+ // Add entry with icon - not null icon
+ mStorage->AddL(innerEntry);
+
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Group);
+ innerEntry2->SetIconDataL(_L("filename2"), _L("skinId2"), KNullDesC);
+
+ // Add second entry with the some icon - not null icon
+ mStorage->AddL(innerEntry2);
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+
+ query->ExecuteL(countIconsAfterAdd);
+ CleanupStack::PopAndDestroy(query);
+
+ entryId = innerEntry->GetId();
+
+ iconId = innerEntry->GetIconId();
+
+ innerEntry->SetTextL(KTestNameUpdate);
+ innerEntry->SetFlags(flagUpdate);
+ //innerEntry->SetIconId( 0 );
+ innerEntry->SetIconDataL(_L("filename2"), _L("skinId2"), KNullDesC);
+ // Update entry with empty icon
+ mStorage->AddL(innerEntry);
+
+
+ // Check db after update with empty icon
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ query->ExecuteL(countIconsAfterUpdateWithEmptyIcon);
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+
+ // icon shouldn't be removed from db because it is use by other entry
+ QCOMPARE(countIconsAfterUpdateWithEmptyIcon, countIconsAfterAdd);
+
+ __UHEAP_MARKEND;
+}
+
+
+
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testAddAttributes()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+ TRAP(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewL();
+ RPointerArray<CCaInnerEntry> innerEntryArray;
+ CleanupResetAndDestroyPushL(innerEntryArray);
+ innerEntryArray.AppendL(innerEntry);
+
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+ // check status
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLCheckAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindEntryIdL(innerEntry->GetId());
+ RPointerArray<CCaInnerEntry> entryArray;
+ CleanupResetAndDestroyPushL(entryArray);
+ TInt count = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+ CleanupStack::PopAndDestroy(&entryArray);
+
+ if (innerEntry->GetId() > 0)
+ if (innerEntry->GetIconId() > 0)
+ if (innerEntry->GetAttributes().Count() == count) {
+ err = KErrNone;
+ } else
+ err = KErrArgument;
+ else
+ err = KErrNotFound;
+ else
+ err = KErrNotFound;
+
+ if (!err) {
+ query->SetQueryL(KSQLGetAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindValuesForAddAttributeL(innerEntry, NULL);
+ query->ExecuteL(innerEntryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+ RCaEntryAttrArray attributes = innerEntry->GetAttributes();
+
+ if (!(
+ (attributes[0])->Name().Compare(KAttrName_1)
+ && (attributes[0])->Value().Compare(KAttrValue_1)
+ && (attributes[1])->Name().Compare(KAttrName_2)
+ && (attributes[1])->Value().Compare(KAttrValue_2)
+ && (attributes[2])->Name().Compare(KAttrName_3)
+ && (attributes[2])->Value().Compare(KAttrValue_3)
+ ))
+ err = KErrNone;
+ else
+ err = KErrNotSupported;
+ }
+
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(&innerEntryArray);
+ );
+
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testUpdateAttributes()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+// TRAP(err,
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewL();
+ RPointerArray<CCaInnerEntry> innerEntryArray;
+ CleanupResetAndDestroyPushL(innerEntryArray);
+ innerEntryArray.AppendL(innerEntry);
+
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+ // check status
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLCheckAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindEntryIdL(innerEntry->GetId());
+ RPointerArray<CCaInnerEntry> entryArray;
+ CleanupResetAndDestroyPushL(entryArray);
+ TInt count = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+ CleanupStack::PopAndDestroy(&entryArray);
+
+ if (innerEntry->GetId() > 0)
+ if (innerEntry->GetIconId() > 0)
+ if (innerEntry->GetAttributes().Count() == count) {
+ err = KErrNone;
+ } else
+ err = KErrArgument;
+ else
+ err = KErrNotFound;
+ else
+ err = KErrNotFound;
+
+ if (!err) {
+ innerEntry->AddAttributeL(KAttrName_2, KAttrName_1);
+ mStorage->AddL(innerEntry);
+ // check status
+ query->SetQueryL(KSQLCheckAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindEntryIdL(innerEntry->GetId());
+ RPointerArray<CCaInnerEntry> entryArray;
+ CleanupResetAndDestroyPushL(entryArray);
+ TInt count = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+ CleanupStack::PopAndDestroy(&entryArray);
+
+ RCaEntryAttrArray attributes = innerEntry->GetAttributes();
+ if (innerEntry->GetAttributes().Count() == count) {
+ if (!(
+ (attributes[0])->Name().Compare(KAttrName_1)
+ && (attributes[0])->Value().Compare(KAttrValue_1)
+ && (attributes[1])->Name().Compare(KAttrName_2)
+ && (attributes[1])->Value().Compare(KAttrValue_1)
+ && (attributes[2])->Name().Compare(KAttrName_3)
+ && (attributes[2])->Value().Compare(KAttrValue_3)
+ )) {
+ innerEntry->RemoveAttributeL(KAttrName_1);
+ innerEntry->RemoveAttributeL(KAttrName_2);
+ innerEntry->RemoveAttributeL(KAttrName_3);
+ query->SetQueryL(KSQLGetAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindValuesForAddAttributeL(innerEntry, NULL);
+ query->ExecuteL(innerEntryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+
+ RCaEntryAttrArray newAttributes = innerEntry->GetAttributes();
+ if (!(
+ (newAttributes[0])->Name().Compare(KAttrName_1)
+ && (newAttributes[0])->Value().Compare(KAttrValue_1)
+ && (newAttributes[1])->Name().Compare(KAttrName_2)
+ && (newAttributes[1])->Value().Compare(KAttrValue_1)
+ && (newAttributes[2])->Name().Compare(KAttrName_3)
+ && (newAttributes[2])->Value().Compare(KAttrValue_3)
+ ))
+ err = KErrNone;
+ else
+ err = KErrNotSupported;
+ } else {
+ err = KErrNotReady;
+ }
+ } else
+ err = KErrNotReady;
+ }
+
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(&innerEntryArray);
+// );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testDeleteAttributes()
+{
+ TInt entryId(0);
+ TInt iconId(0);
+ TInt attributesACount(0);
+ TInt queryAResultCount(0);
+ TInt attributesBCount(0);
+ TInt queryBResultCount(0);
+ __UHEAP_MARK;
+ TRAPD(err,
+ // A query section starts
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Group);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+ // check status
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLCheckAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindEntryIdL(innerEntry->GetId());
+ RPointerArray<CCaInnerEntry> entryArray;
+ CleanupResetAndDestroyPushL(entryArray);
+ queryAResultCount = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+ CleanupStack::PopAndDestroy(&entryArray);
+
+ if (!err) {
+ entryId = innerEntry->GetId();
+ iconId = innerEntry->GetIconId();
+ attributesACount = innerEntry->GetAttributes().Count();
+
+ // B query section starts
+
+ innerEntry->RemoveAttributeL(KAttrName_1);
+ innerEntry->RemoveAttributeL(KAttrName_2);
+ innerEntry->RemoveAttributeL(KAttrName_3);
+ mStorage->AddL(innerEntry);
+ // check status
+ query->SetQueryL(KSQLCheckAttribute);
+ query->SetTableType(CCaSqlQuery::EAttributeTable);
+ query->PrepareL();
+ query->BindEntryIdL(innerEntry->GetId());
+ RPointerArray<CCaInnerEntry> entryArray;
+ CleanupResetAndDestroyPushL(entryArray);
+ queryBResultCount= query->ExecuteL(entryArray, CCaSqlQuery::EAttribute);
+ query->CloseStatement();
+ CleanupStack::PopAndDestroy(&entryArray);
+ attributesBCount = innerEntry->GetAttributes().Count();
+ }
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ __UHEAP_MARKEND;
+
+ QVERIFY(entryId > 0);
+ QVERIFY(iconId > 0);
+ QCOMPARE(queryAResultCount, attributesACount);
+ QCOMPARE(queryBResultCount, 0);
+ QCOMPARE(queryBResultCount, attributesBCount);
+}
+// end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestbackup.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestgetparentids.cpp
+ *
+ * Created on: 2009-09-14
+ * Author: michal.czerwiec
+ */
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+
+
+
+void CCAStorageTest::testSaveRestoreDatabase()
+{
+
+ TBool result = EFalse;
+ TRAPD(err,
+ RFs fs;
+ User::LeaveIfError(fs.Connect());
+
+ CCaSqLiteStorage *storage = dynamic_cast<CCaSqLiteStorage *>(mStorage);
+ if( BaflUtils::FileExists( fs, storage->iPrivatePathCDriveDbBackup) )
+ {
+ BaflUtils::DeleteFile(fs, storage->iPrivatePathCDriveDbBackup);
+ }
+
+ mStorage->SaveDatabaseL();
+
+ mStorage->RestoreDatabaseL();
+
+
+ if( BaflUtils::FileExists( fs, storage->iPrivatePathCDriveDbBackup) )
+ {
+ result = ETrue;
+ BaflUtils::DeleteFile(fs, storage->iPrivatePathCDriveDbBackup);
+ }
+ fs.Close();
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(result);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestgetentries.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,1480 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestgetentries.cpp
+ *
+ * Created on: 2009-08-05
+ * Author: michal.czerwiec
+ */
+
+#include <e32cmn.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <badesca.h>
+#include <e32math.h>
+#include <qglobal.h>
+
+#include "castoragetest.h"
+#include "cainnerquery.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "cadef.h"
+
+
+// ---------------------------------------------------------------------------
+// Test that two data arrays have opposite order.
+//
+// ---------------------------------------------------------------------------
+//
+TInt CCAStorageTest::verifyOppositeOrder(RPointerArray<CCaInnerEntry>& aArray1,
+ RPointerArray<CCaInnerEntry>& aArray2)
+{
+ TInt err;
+
+ __UHEAP_MARK;
+
+ err = (aArray1.Count() == aArray2.Count())? KErrNone : KErrWrongData;
+ if (!err) {
+ TInt count(aArray1.Count());
+ for (TInt i = 0; i < aArray1.Count(); i++) {
+ if (aArray1[i]->GetId() != aArray2[count-1-i]->GetId()) {
+ err = KErrWrongData;
+ break;
+ }
+ }
+ }
+
+ __UHEAP_MARKEND;
+
+ return err;
+}
+
+// ---------------------------------------------------------------------------
+// Test Sorting Order giving different attributes.
+//
+// ---------------------------------------------------------------------------
+//
+TInt CCAStorageTest::testSortingBySortOrder(CCaInnerQuery::TSortAttribute sortAttr1,
+ CCaInnerQuery::TSortAttribute sortAttr2)
+{
+
+ __UHEAP_MARK;
+
+ TRAPD(err,
+ CCaInnerQuery *innerQuery1 = CCaInnerQuery::NewLC();
+ innerQuery1->SetSort(sortAttr1);
+
+ CCaInnerQuery *innerQuery2 = CCaInnerQuery::NewLC();
+ innerQuery2->SetSort(sortAttr2);
+
+ err = testSortingBySortOrder(innerQuery1, innerQuery2);
+
+ CleanupStack::PopAndDestroy(innerQuery2);
+ CleanupStack::PopAndDestroy(innerQuery1);
+ );
+ __UHEAP_MARKEND;
+
+ return err;
+}
+
+
+// ---------------------------------------------------------------------------
+// Test Sorting Order giving different attributes.
+//
+// ---------------------------------------------------------------------------
+//
+TInt CCAStorageTest::testSortingBySortOrder(CCaInnerQuery *aInnerQuery1,
+ CCaInnerQuery *aInnerQuery2)
+{
+ __UHEAP_MARK;
+ TInt err(KErrNone);
+ RPointerArray<CCaInnerEntry> resultArray;
+ TRAP(err,
+ CleanupResetAndDestroyPushL(resultArray);
+ mStorage->GetEntriesL(aInnerQuery1,resultArray);
+
+ RPointerArray<CCaInnerEntry> resultArrayDesc;
+ CleanupResetAndDestroyPushL(resultArrayDesc);
+ mStorage->GetEntriesL(aInnerQuery2,resultArrayDesc);
+
+ err = (resultArray.Count() > 0)? KErrNone : KErrWrongData;
+
+ if (err == KErrNone) {
+ err = (resultArrayDesc.Count() > 0)? KErrNone : KErrWrongData;
+ }
+
+ if (err == KErrNone) {
+ err = verifyOppositeOrder(resultArray, resultArrayDesc);
+ }
+ CleanupStack::PopAndDestroy(&resultArrayDesc);
+ CleanupStack::PopAndDestroy(&resultArray);
+ );
+
+
+ __UHEAP_MARKEND;
+
+ return err;
+}
+// ---------------------------------------------------------------------------
+// Test Select several entries by id.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesById()
+{
+ __UHEAP_MARK;
+ {
+ QList<TInt> expectedIdList;
+ expectedIdList << 1 << 2 << 3 << 4 << 5 << 6;
+ QList<TInt> actualIdList;
+
+
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ RArray<TInt> idArray;
+ CleanupClosePushL(idArray);
+ idArray.AppendL(expectedIdList[0]);
+ idArray.AppendL(expectedIdList[1]);
+ idArray.AppendL(expectedIdList[2]);
+ idArray.AppendL(expectedIdList[3]);
+ idArray.AppendL(expectedIdList[4]);
+ idArray.AppendL(expectedIdList[5]);
+
+ innerQuery->SetIdsL(idArray);
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+ mStorage->GetEntriesL(innerQuery,resultArray);
+
+ // check if the actual items were returned
+ for (TInt i = 0; i < resultArray.Count(); i++) {
+ actualIdList << resultArray[i]->GetId();
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(&idArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(actualIdList, expectedIdList);
+ }
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+// Test Select entries by group id.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByGroupId()
+{
+ TInt expectedGroupEntryCount(0);
+ TInt actualGroupEntryCount(0);
+
+ __UHEAP_MARK;
+
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+
+ // check before test entries count in sfecific group
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetEntriesCountFromSpecificGroup);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEIdGroup), KAllCollectionsGroupId);
+
+ query->ExecuteL(expectedGroupEntryCount);
+
+ CleanupStack::PopAndDestroy(query);
+
+ innerQuery->SetParentId(KAllCollectionsGroupId);
+
+ // get entries from specific group
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ actualGroupEntryCount = resultArray.Count();
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(actualGroupEntryCount, expectedGroupEntryCount);
+}
+
+// ---------------------------------------------------------------------------
+// Test Select entries by group id.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByTypeName()
+{
+ bool nonWidgetEntryFound(false);
+ const int expectedNumberOfWidgets(2);
+ int numberOfWidgetsFound(0);
+
+ __UHEAP_MARK;
+
+ _LIT(KTypeNameWidget, "Widget");
+
+ TRAPD(err,
+ // add 2 new entries - typename widget
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName1);
+ innerEntry->SetEntryTypeNameL(KTypeNameWidget);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Item);
+ mStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+
+ innerEntry = CCaInnerEntry::NewLC();
+ innerEntry->SetTextL(KTestName2);
+ innerEntry->SetEntryTypeNameL(KTypeNameWidget);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Item);
+ mStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(innerEntry);
+
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ CDesC16ArrayFlat *typenameArray = new(ELeave) CDesC16ArrayFlat(KDefaultGranularity);
+ CleanupStack::PushL(typenameArray);
+
+ TBufC<20> typeName(KTypeNameWidget);
+ typenameArray->AppendL(typeName);
+
+ innerQuery->SetEntryTypeNames(typenameArray);
+ CleanupStack::Pop(typenameArray);
+
+ // get entries from specific group
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+
+ // get entries - widgets
+ mStorage->GetEntriesL(innerQuery,resultArray);
+
+ numberOfWidgetsFound = resultArray.Count();
+ // check results
+ for (TInt i = 0; i < numberOfWidgetsFound; ++i) {
+ if ((resultArray[i]->GetEntryTypeName()).Compare(
+ KTypeNameWidget) != 0) {
+ nonWidgetEntryFound = true;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(numberOfWidgetsFound, expectedNumberOfWidgets);
+ QVERIFY(!nonWidgetEntryFound);
+}
+
+// ---------------------------------------------------------------------------
+// Test Select entries sorted by name alphabetically.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesSortByName()
+{
+ __UHEAP_MARK;
+ {
+ TInt entriesACount(0);
+ QMap<QString, bool> comparisonAResults;
+ TInt entriesBCount(0);
+ QMap<QString, bool> comparisonBResults;
+ bool orderCheckPassed(false);
+
+ TRAPD(err,
+ // test ascending
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetSort(CCaInnerQuery::Name);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ mStorage->GetEntriesL(innerQuery,resultArray);
+
+ // change all odd entries texts to be lower case
+ for (TInt i = 0; i < resultArray.Count(); ++i) {
+ if (resultArray[i]->GetId() % 2 == 1) {
+ RBuf tempBuf;
+ tempBuf.CleanupClosePushL();
+ tempBuf.CreateL(resultArray[i]->GetText());
+ tempBuf.LowerCase();
+ resultArray[i]->SetTextL(tempBuf);
+ CleanupStack::PopAndDestroy(&tempBuf);
+ mStorage->AddL(resultArray[i]);
+ }
+ }
+ // fetch the table again
+ resultArray.ResetAndDestroy();
+ mStorage->GetEntriesL(innerQuery,resultArray);
+
+ entriesACount = resultArray.Count();
+
+ RBuf previousText;
+ previousText.CleanupClosePushL();
+ RBuf currentText;
+ currentText.CleanupClosePushL();
+ if (!err) {
+ for (TInt i = 0; i < resultArray.Count(); i++) {
+ currentText.CreateL(resultArray[i]->GetText());
+ currentText.LowerCase();
+
+ comparisonAResults[descToQString(currentText)] = true;
+
+ if (i!=0 && currentText.Compare(previousText) < 0) {
+ comparisonAResults[descToQString(currentText)] = false;
+ err = KErrWrongData;
+ break;
+ }
+ currentText.Close();
+ previousText.Close();
+ previousText.CreateL(resultArray[i]->GetText());
+ previousText.LowerCase();
+ }
+ }
+ // test descending
+ CCaInnerQuery *innerQuery2 = CCaInnerQuery::NewLC();
+ innerQuery2->SetSort(CCaInnerQuery::NameDesc);
+ RPointerArray<CCaInnerEntry> resultArrayDesc;
+ CleanupResetAndDestroyPushL(resultArrayDesc);
+ mStorage->GetEntriesL(innerQuery2,resultArrayDesc);
+
+ entriesBCount = resultArrayDesc.Count();
+
+ previousText.Close();
+ currentText.Close();
+
+ if (!err) {
+ for (TInt i = 0; i < resultArrayDesc.Count(); i++) {
+ currentText.CreateL(resultArrayDesc[i]->GetText());
+ currentText.LowerCase();
+
+ comparisonBResults[descToQString(currentText)] = true;
+
+ if (i!=0 && resultArrayDesc[i]->GetText().Compare(previousText) > 0) {
+ comparisonBResults[descToQString(currentText)] = false;
+ break;
+ }
+ currentText.Close();
+ previousText.Close();
+ previousText.CreateL(resultArrayDesc[i]->GetText());
+ previousText.LowerCase();
+ }
+ }
+
+ if (!err) {
+ orderCheckPassed = verifyOppositeOrder(resultArray, resultArrayDesc) == 0;
+ }
+
+ CleanupStack::PopAndDestroy(&resultArrayDesc);
+ CleanupStack::PopAndDestroy(innerQuery2);
+ CleanupStack::PopAndDestroy(¤tText);
+ CleanupStack::PopAndDestroy(&previousText);
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+ QCOMPARE(err, KErrNone);
+ foreach(QString str, comparisonAResults.keys()) {
+ QVERIFY2(comparisonAResults[str], str.toUtf8());
+ };
+ QCOMPARE(comparisonAResults.size(), entriesACount);
+
+
+ foreach(QString str, comparisonAResults.keys()) {
+ QVERIFY2(comparisonBResults[str], str.toUtf8());
+ };
+ QCOMPARE(comparisonBResults.size(), entriesBCount);
+
+ QVERIFY(orderCheckPassed);
+ }
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+// tests getentries sorted by created timestamp ascending.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesSortByCreatedTimestamp()
+{
+
+ __UHEAP_MARK;
+ {
+ QMap<int, bool> ascendingOrderCheckResults;
+ QMap<int, bool> descendingOrderCheckResults;
+
+ TRAPD(err,
+ // check ascending
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetSort(CCaInnerQuery::CreatedTimestamp);
+ mStorage->GetEntriesL(innerQuery,resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+
+ TInt64 previousTimestamp(0);
+ for (TInt i = 0; i<resultArray.Count() ; i++) {
+ innerQuery = CCaInnerQuery::NewLC();
+ RArray<TInt> ids;
+ CleanupClosePushL(ids);
+ const TInt id = resultArray[i]->GetId();
+ ids.AppendL(id);
+ innerQuery->SetIdsL(ids);
+
+ TInt64 timestamp(0);
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(STATIC_CAST(CCaSqLiteStorage *,mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetEntryTimestamp);
+ query->PrepareL();
+ query->BindIdsL(ids, KSQLEntryId);
+ query->ExecuteL(timestamp);
+
+ if (i != 0 && timestamp < previousTimestamp) {
+ ascendingOrderCheckResults[id] = false;
+ break;
+ }
+ previousTimestamp = timestamp;
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(&ids);
+ CleanupStack::PopAndDestroy(innerQuery);
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+
+ // check descending
+ CleanupResetAndDestroyPushL(resultArray);
+ innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetSort(CCaInnerQuery::CreatedTimestampDesc);
+ mStorage->GetEntriesL(innerQuery,resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+
+ previousTimestamp = 0;
+ for (TInt i = 0; i<resultArray.Count() ; i++) {
+ innerQuery = CCaInnerQuery::NewLC();
+ RArray<TInt> ids;
+ CleanupClosePushL(ids);
+ ids.AppendL(resultArray[i]->GetId());
+ const TInt id = ids[0];
+ innerQuery->SetIdsL(ids);
+
+ TInt64 timestamp(0);
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(STATIC_CAST(CCaSqLiteStorage *,mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetEntryTimestamp);
+ query->PrepareL();
+ query->BindIdsL(ids, KSQLEntryId);
+ query->ExecuteL(timestamp);
+ if (i != 0 && timestamp > previousTimestamp) {
+ descendingOrderCheckResults[id] = false;
+ break;
+ }
+ previousTimestamp = timestamp;
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(&ids);
+ CleanupStack::PopAndDestroy(innerQuery);
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ );
+
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(ascendingOrderCheckResults.size(), 0);
+ QCOMPARE(descendingOrderCheckResults.size(), 0);
+ }
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+// tests getentries sorted by used timestamp.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesSortByMostUsedTimestamp()
+{
+ __UHEAP_MARK;
+
+ const TInt mostUsedIds[3] = {14, 9, 2};
+
+ const TInt mostUsedIdsSize = sizeof(mostUsedIds) / sizeof(TInt);
+
+ TInt err(KErrNone);
+
+ TRAP(err,
+
+ for (TInt i = 0; i < mostUsedIdsSize; ++i) {
+ for (TInt j = mostUsedIdsSize - i; j >= 0; --j) {
+ mStorage->TouchL(mostUsedIds[i], ETrue);
+ }
+ }
+
+ CCaInnerQuery *innerQuery1 = CCaInnerQuery::NewLC();
+ innerQuery1->SetSort(CCaInnerQuery::MostUsedDesc);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+
+ // get entries - most used desscending
+ mStorage->GetEntriesL(innerQuery1, resultArray);
+
+ if (resultArray.Count() < mostUsedIdsSize) {
+ err = KErrNotFound;
+} else {
+ for (TInt i = 0; i < mostUsedIdsSize; ++i) {
+ if (resultArray[i]->GetId() != mostUsedIds[i]) {
+ err = KErrGeneral;
+ break;
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery1);
+ );
+
+ QCOMPARE(err, KErrNone);
+
+
+ TRAP(err,
+ CCaInnerQuery *innerQuery1 = CCaInnerQuery::NewLC();
+ innerQuery1->SetSort(CCaInnerQuery::MostUsed);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+
+ // get entries - most used desscending
+ mStorage->GetEntriesL(innerQuery1, resultArray);
+
+ const TInt resultCount = resultArray.Count();
+
+ if (resultCount < mostUsedIdsSize) {
+ err = KErrNotFound;
+} else {
+ for (TInt i = 0; i < mostUsedIdsSize; ++i) {
+ if (resultArray[resultCount - i - 1]->GetId() != mostUsedIds[i]) {
+ err = KErrGeneral;
+ break;
+ }
+ }
+ }
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery1);
+ );
+ __UHEAP_MARKEND;
+
+
+}
+
+
+// ---------------------------------------------------------------------------
+// tests getentries sorted by used timestamp ascending.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesSortByLastUsedTimestamp()
+{
+ __UHEAP_MARK;
+
+ const TInt lastUsedIds[3] = {14, 9, 2};
+
+ const TInt lastUsedIdsSize = sizeof(lastUsedIds) / sizeof(TInt);
+
+ TInt err(KErrNone);
+
+ TRAP(err,
+
+ for (TInt i = lastUsedIdsSize - 1; i >= 0 ; --i) {
+ mStorage->TouchL(lastUsedIds[i], EFalse);
+ }
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetSort(CCaInnerQuery::LastUsedDesc);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+
+ // get entries - last used descending
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+
+ if (resultArray.Count() < lastUsedIdsSize) {
+ err = KErrNotFound;
+} else {
+ for (TInt i = 0; i < lastUsedIdsSize; ++i) {
+ if (resultArray[i]->GetId() != lastUsedIds[i]) {
+ err = KErrGeneral;
+ break;
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+
+ QCOMPARE(err, KErrNone);
+
+ TRAP(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetSort(CCaInnerQuery::LastUsed);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+
+ // get entries - last used descending
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ const TInt resultCount = resultArray.Count();
+
+ if (resultCount < lastUsedIdsSize) {
+ err = KErrNotFound;
+} else {
+ for (TInt i = 0; i < lastUsedIdsSize; ++i) {
+ if (resultArray[resultCount - 1 - i]->GetId() !=
+ lastUsedIds[i]) {
+ err = KErrGeneral;
+ break;
+ }
+ }
+ }
+
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+// tests getentries sorted by default ascending.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesSortByDefault()
+{
+
+ __UHEAP_MARK;
+
+ TRAPD(err,
+
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdEntryFromSpecificGroup);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEIdGroup), KAllCollectionsGroupId);
+ RArray<TInt> resultHelpArray;
+ CleanupClosePushL(resultHelpArray);
+ query->ExecuteL(resultHelpArray, CCaSqlQuery::EEntryTable);
+ query->CloseStatement();
+
+ CCaInnerQuery *innerQuery1 = CCaInnerQuery::NewLC();
+ innerQuery1->SetSort(CCaInnerQuery::Default);
+ innerQuery1->SetParentId(KAllCollectionsGroupId);
+
+ CCaInnerQuery *innerQuery2 = CCaInnerQuery::NewLC();
+ innerQuery2->SetSort(CCaInnerQuery::DefaultDesc);
+ innerQuery2->SetParentId(KAllCollectionsGroupId);
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+ // get entries - bu default from group
+ mStorage->GetEntriesL(innerQuery1, resultArray);
+
+ // check results - compare Entry_Id
+ for (TInt i=0; i<resultArray.Count(); i++) {
+ if (resultArray[i]->GetId() != resultHelpArray[i]) {
+ err = KErrWrongData;
+ }
+ }
+
+ if (!err) {
+ err = testSortingBySortOrder(innerQuery1, innerQuery2);
+ }
+
+ // clear after test
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery2);
+ CleanupStack::PopAndDestroy(innerQuery1);
+ CleanupStack::PopAndDestroy(&resultHelpArray);
+ CleanupStack::PopAndDestroy(query);
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+
+// ---------------------------------------------------------------------------
+// tests getentries sorted by used timestamp ascending.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByFlags()
+{
+
+ __UHEAP_MARK;
+
+ TRAPD(err,
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+// test all flags on in KMaxFlagsMask range
+ for (TUint flagsOnMask = 0; flagsOnMask <= KMaxFlagsMask; flagsOnMask++) {
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ innerQuery->SetFlagsOn(flagsOnMask);
+ mStorage->GetEntriesL(innerQuery,resultArray);
+ TInt entryCount = resultArray.Count();
+ if (entryCount > 0) {
+ for (TInt j = 0; j < entryCount; j++) {
+ if (resultArray[j]->GetFlags() & flagsOnMask != flagsOnMask) {
+ err = KErrWrongData;
+ }
+ }
+ }
+ innerQuery->SetFlagsOn(0);
+ CleanupStack::PopAndDestroy(&resultArray);
+ }
+
+// test all flags off in KMaxFlagsMask range
+ for (TUint flagsOffMask = 0; flagsOffMask <= KMaxFlagsMask; flagsOffMask++) {
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ innerQuery->SetFlagsOff(flagsOffMask);
+ mStorage->GetEntriesL(innerQuery,resultArray);
+ TInt entryCount = resultArray.Count();
+ if (entryCount > 0) {
+ for (TInt j = 0; j < entryCount; j++) {
+ if ((!resultArray[j]->GetFlags()) & flagsOffMask != flagsOffMask) {
+ err = KErrWrongData;
+ }
+ }
+ }
+ innerQuery->SetFlagsOff(0);
+ CleanupStack::PopAndDestroy(&resultArray);
+ }
+
+// test combination of flags on flags off
+ for (TUint flagsOnMask = 0; flagsOnMask <= KMaxFlagsMaskForCombinedTest; flagsOnMask++) {
+ for (TUint flagsOffMask = 0; flagsOffMask
+ <= KMaxFlagsMaskForCombinedTest; flagsOffMask++) {
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ innerQuery->SetFlagsOff(flagsOffMask);
+ innerQuery->SetFlagsOn(flagsOnMask);
+ mStorage->GetEntriesL(innerQuery,resultArray);
+ TInt entryCount = resultArray.Count();
+ if (entryCount > 0) {
+ for (TInt j = 0; j < entryCount; j++) {
+ if ((!resultArray[j]->GetFlags()) & flagsOffMask != flagsOffMask
+ && resultArray[j]->GetFlags() & flagsOnMask != flagsOnMask) {
+ err = KErrWrongData;
+ }
+ }
+ }
+ innerQuery->SetFlagsOff(0);
+ innerQuery->SetFlagsOn(0);
+ CleanupStack::PopAndDestroy(&resultArray);
+ }
+ }
+
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+// tests getentries with flags which are on
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByFlagsOn()
+{
+
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ RPointerArray<CCaInnerEntry> resultArrayTemp;
+ CleanupResetAndDestroyPushL(resultArrayTemp);
+ RArray<TInt> testEntries;
+ CleanupClosePushL(testEntries);
+
+ mStorage->GetEntriesL(innerQuery,resultArrayTemp);
+
+ TInt entryCount = resultArrayTemp.Count();
+
+ // Change five random elements' flags
+ err = (entryCount >= 5) ? err : KErrNoData;
+ // Set all flags on to test flags on.
+ for (TInt i = 0; i < entryCount; i++) {
+ resultArrayTemp[i]->SetFlags(0);
+ mStorage->AddL(resultArrayTemp[i]);
+ }
+
+ // get random entries to test on
+ TInt testIdCount(0);
+ while (testEntries.Count() < 5) {
+ TInt randomEntryInArray = Math::Random() % entryCount;
+ TBool exists(EFalse);
+ for (TInt i = 0; i < testEntries.Count(); i++) {
+ if (testEntries[i]== randomEntryInArray) {
+ exists = ETrue;
+ break;
+ }
+ }
+ if (!exists) {
+ testEntries.AppendL(randomEntryInArray);
+ }
+ }
+
+ // test flags on with flags from KFlagsOnTable
+
+ CCaInnerQuery *innerQueryFlagsOn = CCaInnerQuery::NewLC();
+ for (TInt j = 0; j < 5; j++) {
+ // fill database with flag
+ for (TInt i = 0; i < 5; i++) {
+ TInt x = testEntries[i];
+ resultArrayTemp[x]->SetFlags(KFlagsOnTable[j]);
+ mStorage->AddL(resultArrayTemp[x]);
+ }
+
+ // check filled database
+ RPointerArray<CCaInnerEntry> resultArrayFlagsOn;
+ CleanupResetAndDestroyPushL(resultArrayFlagsOn);
+ innerQueryFlagsOn->SetFlagsOn(KFlagsOnTable[j]);
+ mStorage->GetEntriesL(innerQueryFlagsOn,resultArrayFlagsOn);
+ TInt count = resultArrayFlagsOn.Count();
+ err = (resultArrayFlagsOn.Count() >= 5) ? err : KErrWrongData;
+
+ // check that the right entries were fetched
+ for (TInt i = 0; i < 5; i++) {
+ for (TInt j = 0; j < resultArrayFlagsOn.Count(); j++) {
+ if (resultArrayFlagsOn[j]->GetId() ==
+ resultArrayTemp[testEntries[i]]->GetId()) {
+ break;
+ } else if (j == resultArrayFlagsOn.Count()-1) {
+ err = KErrWrongData;
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArrayFlagsOn);
+ }
+ CleanupStack::PopAndDestroy(innerQueryFlagsOn);
+ CleanupStack::PopAndDestroy(&testEntries);
+ CleanupStack::PopAndDestroy(&resultArrayTemp);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+
+// ---------------------------------------------------------------------------
+// tests getentries with flags which are off
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByFlagsOff()
+{
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ RPointerArray<CCaInnerEntry> resultArrayTemp;
+ CleanupResetAndDestroyPushL(resultArrayTemp);
+ RArray<TInt> testEntries;
+ CleanupClosePushL(testEntries);
+
+ mStorage->GetEntriesL(innerQuery,resultArrayTemp);
+
+ TInt entryCount = resultArrayTemp.Count();
+
+ // Change five random elements' flags
+ err = (entryCount >= 5) ? err : KErrNoData;
+ // Set all flags off to test flags off assuming that there are 5 flags (63 bitwise)
+ for (TInt i = 0; i < entryCount; i++) {
+ resultArrayTemp[i]->SetFlags(63);
+ mStorage->AddL(resultArrayTemp[i]);
+ }
+
+ // get random entries to test on
+ TInt testIdCount(0);
+ while (testEntries.Count() < 5) {
+ TInt randomEntryInArray = Math::Random() % entryCount;
+ TBool exists(EFalse);
+ for (TInt i = 0; i < testEntries.Count(); i++) {
+ if (testEntries[i]== randomEntryInArray) {
+ exists = ETrue;
+ break;
+ }
+ }
+ if (!exists) {
+ testEntries.AppendL(randomEntryInArray);
+ }
+ }
+
+ // test flags on with flags from KFlagsOffTable
+
+ CCaInnerQuery *innerQueryFlagsOff = CCaInnerQuery::NewLC();
+ for (TInt j = 0; j < 5; j++) {
+ // fill database with flag
+ for (TInt i = 0; i < 5; i++) {
+ TInt x = testEntries[i];
+ resultArrayTemp[x]->SetFlags(KFlagsOffTable[j]);
+ mStorage->AddL(resultArrayTemp[x]);
+ }
+
+ // check filled database
+ RPointerArray<CCaInnerEntry> resultArrayFlagsOff;
+ CleanupResetAndDestroyPushL(resultArrayFlagsOff);
+ innerQueryFlagsOff->SetFlagsOff(KFlagsOffTableMasks[j]);
+ mStorage->GetEntriesL(innerQueryFlagsOff,resultArrayFlagsOff);
+ TInt count = resultArrayFlagsOff.Count();
+ err = (resultArrayFlagsOff.Count() >= 5) ? err : KErrWrongData;
+
+ // check that the right entries were fetched
+ for (TInt i = 0; i < 5; i++) {
+ for (TInt j = 0; j < resultArrayFlagsOff.Count(); j++) {
+ if (resultArrayFlagsOff[j]->GetId() ==
+ resultArrayTemp[testEntries[i]]->GetId()) {
+ break;
+ } else if (j == resultArrayFlagsOff.Count()-1) {
+ err = KErrWrongData;
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArrayFlagsOff);
+ }
+ CleanupStack::PopAndDestroy(innerQueryFlagsOff);
+ CleanupStack::PopAndDestroy(&testEntries);
+ CleanupStack::PopAndDestroy(&resultArrayTemp);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+
+// ---------------------------------------------------------------------------
+// tests getentries by uid.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByUid()
+{
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetUid(KCalendarAppUid);
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+ mStorage->GetEntriesL(innerQuery,resultArray);
+
+ TInt entryCount = resultArray.Count();
+
+ err = (entryCount == 1 && resultArray[0]->GetUid() == KCalendarAppUid)
+ ? err : KErrWrongData;
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+// tests getentries by uid.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesIds()
+{
+ __UHEAP_MARK;
+
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ RArray<TInt> idArray;
+ CleanupClosePushL(idArray);
+
+ mStorage->GetEntriesIdsL(innerQuery,idArray);
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+ mStorage->GetEntriesL(innerQuery,resultArray);
+
+ err = (idArray.Count() > 0) ? err : KErrNoData;
+ if (!err) {
+ err = (idArray.Count() == resultArray.Count()) ? err : KErrWrongData;
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(&idArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetNewEntryWithAttributes()
+{
+ __UHEAP_MARK;
+ TInt err(KErrGeneral);
+ TRAP(err,
+ // Check database entries count
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt entriesCount(0);
+ query->ExecuteL(entriesCount);
+ CleanupStack::PopAndDestroy(query);
+
+
+ // add new entry with attributes
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewL();
+ RPointerArray<CCaInnerEntry> innerEntryArray;
+ CleanupResetAndDestroyPushL(innerEntryArray);
+ innerEntryArray.AppendL(innerEntry);
+
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Item);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(&innerEntryArray);
+
+
+ // get new entry with attributes
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ RArray<TInt> idArray;
+ CleanupClosePushL(idArray);
+ idArray.AppendL(entriesCount + 1); // new entry
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetIdsL(idArray);
+
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ // check results
+ TInt attributesCount = resultArray[0]->GetAttributes().Count();
+
+ if (attributesCount == 3) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+
+// clear after test
+CleanupStack::PopAndDestroy(innerQuery);
+CleanupStack::PopAndDestroy(&idArray);
+CleanupStack::PopAndDestroy(&resultArray);
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetNewEntryWithAttributesByUid()
+{
+ __UHEAP_MARK;
+
+ TInt err(KErrGeneral);
+
+ TRAP(err,
+ // add new entry with attributes
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewL();
+ RPointerArray<CCaInnerEntry> innerEntryArray;
+ CleanupResetAndDestroyPushL(innerEntryArray);
+ innerEntryArray.AppendL(innerEntry);
+
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName2);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Item);
+ innerEntry->SetUid(KTestAppUid);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+ CleanupStack::PopAndDestroy(&innerEntryArray);
+
+
+ // get new entry with attributes by uid
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetUid(KTestAppUid);
+
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ // check results
+ TInt attributesCount = resultArray[0]->GetAttributes().Count();
+
+ if (attributesCount == 3) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+
+// clear after test
+CleanupStack::PopAndDestroy(innerQuery);
+CleanupStack::PopAndDestroy(&resultArray);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+// Test Select entries with limit.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesWhenLimitSetTo()
+{
+
+
+ QList<int> entryCountList;
+ entryCountList << 5 << -15 << 0 << 50;
+ __UHEAP_MARK;
+
+ int limit(0);
+ foreach(limit, entryCountList) {
+ // Check database entries count
+ TRAPD(err,
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt entriesCount(0);
+ query->ExecuteL(entriesCount);
+ CleanupStack::PopAndDestroy(query);
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+
+ innerQuery->SetCount(limit);
+
+ // limit is set to stif parser param
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+
+ // check results
+ if ((0 < limit) && (limit <= entriesCount)) {
+ if (resultArray.Count() == innerQuery->GetCount()) {
+ err = KErrNone;
+ } else {
+ err = KErrGeneral;
+ }
+ } else {
+ if (resultArray.Count() == entriesCount) {
+ err = KErrNone;
+ } else {
+ err = KErrGeneral;
+ }
+ }
+
+ // clear after test
+ CleanupStack::PopAndDestroy(innerQuery);
+ CleanupStack::PopAndDestroy(&resultArray);
+ );
+ // limit added to make easier to identify where failure occured
+ QCOMPARE(err + limit, KErrNone + limit);
+ }
+ __UHEAP_MARKEND;
+}
+
+// ---------------------------------------------------------------------------
+// Test Select entries by role.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByRole()
+{
+
+
+ __UHEAP_MARK;
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+
+ RPointerArray<CCaInnerEntry> resultArrayGroups;
+ CleanupResetAndDestroyPushL(resultArrayGroups);
+ innerQuery->SetRole(CCaInnerQuery::Group);
+ mStorage->GetEntriesL(innerQuery, resultArrayGroups);
+ TInt groupsCount = resultArrayGroups.Count();
+ CleanupStack::PopAndDestroy(&resultArrayGroups);
+
+ RPointerArray<CCaInnerEntry> resultArrayItems;
+ CleanupResetAndDestroyPushL(resultArrayItems);
+ innerQuery->SetRole(CCaInnerQuery::Item);
+ mStorage->GetEntriesL(innerQuery, resultArrayItems);
+ TInt itemsCount = resultArrayItems.Count();
+// changes the role of two items to be groups
+
+ resultArrayItems[0]->SetRole(CCaInnerQuery::Group);
+ resultArrayItems[1]->SetRole(CCaInnerQuery::Group);
+ TInt entry1Id = resultArrayItems[0]->GetId();
+ TInt entry2Id = resultArrayItems[1]->GetId();
+ mStorage->AddL(resultArrayItems[0]);
+ mStorage->AddL(resultArrayItems[1]);
+ CleanupStack::PopAndDestroy(&resultArrayItems);
+
+ RPointerArray<CCaInnerEntry> resultArrayGroups2;
+ CleanupResetAndDestroyPushL(resultArrayGroups2);
+ innerQuery->SetRole(CCaInnerQuery::Group);
+ mStorage->GetEntriesL(innerQuery, resultArrayGroups2);
+ TInt groupsCountAfterModifyRole = resultArrayGroups2.Count();
+ err = (groupsCountAfterModifyRole == groupsCount + 2)? err : KErrWrongData;
+
+// Check that entry 1 is now group
+ for (TInt i = 0; i < groupsCountAfterModifyRole; i++) {
+ if (resultArrayGroups2[i]->GetId() == entry1Id) {
+ break;
+ } else if (i == groupsCountAfterModifyRole - 1) {
+ err = KErrWrongData;
+ }
+ }
+
+// Check that entry 2 is now group
+ for (TInt i = 0; i < groupsCountAfterModifyRole; i++) {
+ if (resultArrayGroups2[i]->GetId() == entry2Id) {
+ break;
+ } else if (i == groupsCountAfterModifyRole - 1) {
+ err = KErrWrongData;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArrayGroups2);
+
+ RPointerArray<CCaInnerEntry> resultArrayItems2;
+ CleanupResetAndDestroyPushL(resultArrayItems2);
+ innerQuery->SetRole(CCaInnerQuery::Item);
+ mStorage->GetEntriesL(innerQuery, resultArrayItems2);
+ TInt itemsCountAfterModifyRole = resultArrayItems2.Count();
+ err = (itemsCountAfterModifyRole == itemsCount - 2)? err : KErrWrongData;
+ CleanupStack::PopAndDestroy(&resultArrayItems2);
+
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testGetEntriesByAttributes()
+{
+ __UHEAP_MARK;
+ int uid;
+ TInt attributesCount;
+ TInt attributesCountFromQuery;
+ TRAPD(err,
+
+ // add new entry with attributes
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName2);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Item);
+ innerEntry->SetUid(KTestAppUid);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerQuery->AddAttributeL(KAttrName_3, KAttrValue_3);
+ attributesCountFromQuery = innerQuery->GetAttributes().Count();
+
+ // get entries by attributes
+ RPointerArray<CCaInnerEntry> resultArrayItems;
+ CleanupResetAndDestroyPushL(resultArrayItems);
+ mStorage->GetEntriesL(innerQuery, resultArrayItems);
+
+ if( resultArrayItems.Count() )
+ {
+ uid = resultArrayItems[0]->GetUid();
+ attributesCount = resultArrayItems[0]->GetAttributes().Count();
+ }
+
+ CleanupStack::PopAndDestroy(&resultArrayItems);
+ CleanupStack::PopAndDestroy(innerQuery);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(uid, KTestAppUid);
+ QCOMPARE((attributesCount-1), attributesCountFromQuery);
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testGetEntriesByAttributes2()
+{
+ __UHEAP_MARK;
+ int getEntriesCount;
+ TRAPD(err,
+
+ // add new entry with attributes
+ CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
+
+ innerEntry->SetTextL(KTestName);
+ innerEntry->SetEntryTypeNameL(KTypeName2);
+ innerEntry->SetFlags(flag);
+ innerEntry->SetRole(CCaInnerQuery::Item);
+ innerEntry->SetUid(KTestAppUid);
+ innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321"));
+
+ innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2);
+ innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3);
+
+ mStorage->AddL(innerEntry);
+
+ // add new entry with attributes
+ CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC();
+
+ innerEntry2->SetTextL(KTestName2);
+ innerEntry2->SetEntryTypeNameL(KTypeName2);
+ innerEntry2->SetFlags(flag);
+ innerEntry2->SetRole(CCaInnerQuery::Item);
+ innerEntry2->SetUid(KTestAppUid2);
+
+ // add new entry with attributes
+ innerEntry2->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerEntry2->AddAttributeL(KAttrName_2, KAttrValue_2);
+
+ mStorage->AddL(innerEntry2);
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->AddAttributeL(KAttrName_1, KAttrValue_1);
+ innerQuery->AddAttributeL(KAttrName_2, KAttrValue_2);
+
+ // get entries by attributes
+ RPointerArray<CCaInnerEntry> resultArrayItems;
+ CleanupResetAndDestroyPushL(resultArrayItems);
+ mStorage->GetEntriesL(innerQuery, resultArrayItems);
+
+ TInt attributesCount = resultArrayItems[0]->GetAttributes().Count();
+ getEntriesCount = resultArrayItems.Count();
+
+ CleanupStack::PopAndDestroy(&resultArrayItems);
+ CleanupStack::PopAndDestroy(innerQuery);
+ CleanupStack::PopAndDestroy(innerEntry2);
+ CleanupStack::PopAndDestroy(innerEntry);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(getEntriesCount, 2);
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+// Test Select entries by child id.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetEntriesByChildId()
+{
+ TInt expectedGroupEntryCount(0);
+ TInt actualGroupEntryCount(0);
+
+ __UHEAP_MARK;
+
+ TRAPD(err,
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+
+ // check before test entries count in sfecific group
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetEntriesCountAsParentsForSpecificEntry);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEEntryId), 7);
+
+ query->ExecuteL(expectedGroupEntryCount);
+
+ CleanupStack::PopAndDestroy(query);
+
+ innerQuery->SetChildId(7);
+
+ // get entries from specific group
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ actualGroupEntryCount = resultArray.Count();
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(actualGroupEntryCount, expectedGroupEntryCount);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestgetparentids.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestgetparentids.cpp
+ *
+ * Created on: 2009-09-14
+ * Author: michal.czerwiec
+ */
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+
+// ---------------------------------------------------------------------------
+// Test Sorting Order giving different attributes.
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testGetParentIds()
+{
+ __UHEAP_MARK;
+
+ TRAPD(err,
+ RArray<TInt> entryIdArray;
+ CleanupClosePushL(entryIdArray);
+ entryIdArray.AppendL(15);
+ RArray<TInt> parentIdArray;
+ CleanupClosePushL(parentIdArray);
+ //TInt err(KErrNone);
+ mStorage->GetParentsIdsL(entryIdArray, parentIdArray);
+ if (parentIdArray.Count() != 3) {
+ err == KErrNotFound;
+} else if (parentIdArray.Find(2) == KErrNotFound ||
+ parentIdArray.Find(3) == KErrNotFound ||
+ parentIdArray.Find(8) == KErrNotFound) {
+ err = KErrGeneral;
+}
+
+CleanupStack::PopAndDestroy(&parentIdArray);
+CleanupStack::PopAndDestroy(&entryIdArray);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testGetParentIdsInLoop()
+{
+ __UHEAP_MARK;
+ TRAPD(err,
+ RArray<TInt> entryIdArray;
+ CleanupClosePushL(entryIdArray);
+ entryIdArray.AppendL(9);
+ RArray<TInt> parentIdArray;
+ CleanupClosePushL(parentIdArray);
+ //TInt err(KErrNone);
+ mStorage->GetParentsIdsL(entryIdArray, parentIdArray);
+ if (parentIdArray.Count() != 4) {
+ err == KErrNotFound;
+}
+
+CleanupStack::PopAndDestroy(&parentIdArray);
+CleanupStack::PopAndDestroy(&entryIdArray);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestlocalization.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestlocalization.cpp
+ *
+ * Created on: Dec 2, 2009
+ * Author: michal.wojcik
+ */
+
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "caarraycleanup.inl"
+#include "cainnerentry.h"
+#include "calocalizationentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testRemoveFromLocalizationAfterNameChange()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check before test
+ CCaSqlQuery *query = CCaSqlQuery::NewL(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ CleanupStack::PushL(query);
+ query->SetQueryL(KSQLCountFromLocalizationTable);
+ query->PrepareL();
+ TInt countLocalizationBefore(0);
+ query->ExecuteL(countLocalizationBefore);
+ CleanupStack::PopAndDestroy(query);
+
+ // Update Collection Name;
+ // CCaInnerEntry* innerEntry = CCaInnerEntry::NewLC();
+ // innerEntry->SetId( 5 );
+ // innerEntry->SetTextL( KTestName );
+ // mStorage->AddL( innerEntry );
+ // CleanupStack::PopAndDestroy( innerEntry );
+
+ mStorage->RemoveFromLocalizationL(5);
+
+
+ // Check result after name entry name update
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLCountFromLocalizationTable);
+ query->PrepareL();
+ TInt countLocalizationAfter(0);
+ query->ExecuteL(countLocalizationAfter);
+ CleanupStack::PopAndDestroy(query);
+ if ((countLocalizationBefore - countLocalizationAfter) == 1) {
+ err = KErrNone;
+}
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testGetLocalizations()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check before test
+ CCaSqlQuery *query = CCaSqlQuery::NewL(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ CleanupStack::PushL(query);
+ query->SetQueryL(KSQLCountFromLocalizationTable);
+ query->PrepareL();
+ TInt countLocalization(0);
+ query->ExecuteL(countLocalization);
+ CleanupStack::PopAndDestroy(query);
+
+ // Get Localizations from db
+ RPointerArray<CCaLocalizationEntry> resultContainer;
+ CleanupResetAndDestroyPushL(resultContainer);
+ mStorage->GetLocalizationsL(resultContainer);
+
+ if (resultContainer.Count() == countLocalization) {
+ err = KErrNone;
+ }
+
+ CleanupStack::PopAndDestroy(&resultContainer);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testLocalizeEntry()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ CCaLocalizationEntry *localizationEntry = CCaLocalizationEntry::NewLC();
+
+ const TInt KOfficeId = 5;
+
+ _LIT(KAttributeName, "EN_TEXT");
+ localizationEntry->SetAttributeNameL(KAttributeName);
+ _LIT(KNewLocalizedString, "Biurowe smietnisko");
+ localizationEntry->SetLocalizedStringL(KNewLocalizedString);
+ localizationEntry->SetRowId(KOfficeId); // office
+ _LIT(KTableName, "CA_ENTRY");
+ localizationEntry->SetTableNameL(KTableName);
+ localizationEntry->SetTextId(KOfficeId); // office
+
+ // test localize entry
+ mStorage->LocalizeEntryL(*localizationEntry);
+
+ // get this entry from db - office
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ RArray<TInt> idArray;
+ CleanupClosePushL(idArray);
+ idArray.AppendL(KOfficeId);
+ innerQuery->SetIdsL(idArray);
+
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ // check results
+ if (!resultArray[0]->GetText().CompareC(KNewLocalizedString)) {
+ err = KErrNone;
+}
+
+CleanupStack::PopAndDestroy(&resultArray);
+CleanupStack::PopAndDestroy(&idArray);
+CleanupStack::PopAndDestroy(innerQuery);
+
+CleanupStack::PopAndDestroy(localizationEntry);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+
+//-------------------------------------------------------------------------
+void CCAStorageTest::testAddLocalizationEntry()
+{
+ TInt err(KErrGeneral);
+ TInt countLocalization1(0);
+ TInt countLocalization2(0);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check before test
+
+ countLocalization1 = locEntriesCount();
+ // Get Localizations from db
+ CCaLocalizationEntry* locEntry = CCaLocalizationEntry::NewLC();
+ locEntry->SetTableNameL(_L("TestTable"));
+ locEntry->SetAttributeNameL(_L("TestAttName"));
+ locEntry->SetStringIdL(_L("TestStrId"));
+ locEntry->SetQmFilenameL(_L("TestQmFilename"));
+ locEntry->SetRowId(6667);
+ mStorage->AddLocalizationL(*locEntry);
+ countLocalization2 =locEntriesCount();
+ CleanupStack::PopAndDestroy(locEntry);
+
+ );
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(countLocalization1+1 , countLocalization2);
+
+ __UHEAP_MARKEND;
+
+}
+
+//-------------------------------------------------------------------------
+void CCAStorageTest::testUpdateLocalizationEntry()
+{
+ TInt err(KErrGeneral);
+ TInt countLocalization1(0);
+ TInt countLocalization2(0);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // Get Localizations from db
+ CCaLocalizationEntry* locEntry = CCaLocalizationEntry::NewLC();
+ locEntry->SetTableNameL(_L("TestTable"));
+ locEntry->SetAttributeNameL(_L("TestAttName"));
+ locEntry->SetStringIdL(_L("TestStrId"));
+ locEntry->SetQmFilenameL(_L("TestQmFilename"));
+ locEntry->SetRowId(6668);
+ mStorage->AddLocalizationL(*locEntry);
+
+ countLocalization1 = locEntriesCount();
+
+ locEntry->SetTableNameL(_L("TestTable"));
+ locEntry->SetAttributeNameL(_L("TestAttName"));
+ locEntry->SetStringIdL(_L("TestStrId2"));
+ locEntry->SetQmFilenameL(_L("TestQmFilename2"));
+ locEntry->SetRowId(6668);
+ mStorage->AddLocalizationL(*locEntry);
+
+ countLocalization2 = locEntriesCount();
+
+ CleanupStack::PopAndDestroy(locEntry);
+
+ );
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(countLocalization1 , countLocalization2);
+
+ __UHEAP_MARKEND;
+
+}
+//-------------------------------------------------------------------------
+TInt CCAStorageTest::locEntriesCount()
+{
+ TInt count(0);
+ CCaSqlQuery *query = CCaSqlQuery::NewL(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ CleanupStack::PushL(query);
+ query->SetQueryL(KSQLCountFromLocalizationTable);
+ query->PrepareL();
+ query->ExecuteL(count);
+ CleanupStack::PopAndDestroy(query);
+ return count;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestorganize.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,366 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestorganize.cpp
+ *
+ * Created on: 2009-08-14
+ * Author: maciej.walczynski
+ */
+
+#include "castoragetest.h"
+#include "caoperationparams.h"
+#include "castorage.h"
+#include "caarraycleanup.inl"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+#include "cainnerentry.h"
+#include "casqlitestorage.h"
+#include "casqlquery.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testOrganizeRemove()
+{
+ TInt err(KErrNone);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ RArray<TInt> entryIds;
+ CleanupClosePushL(entryIds);
+ entryIds.AppendL(15);
+ entryIds.AppendL(16);
+
+ TCaOperationParams organizeParams;
+ organizeParams.iGroupId = 12;
+ organizeParams.iOperationType = TCaOperationParams::ERemove;
+ mStorage->OrganizeL(entryIds, organizeParams);
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetParentId(12);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ // Check that entries with ids 15 and 16 are not in group 12
+ for (TInt j = 0; j < entryIds.Count(); j++) {
+ for (TInt i = 0; i < resultArray.Count(); i++) {
+ if (resultArray[i]->GetId() == entryIds[j]) {
+ err = KErrWrongData;
+ break;
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ CleanupStack::PopAndDestroy(&entryIds);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testOrganizeAppend()
+{
+ TInt err(KErrNone);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ RArray<TInt> entryIds;
+ CleanupClosePushL(entryIds);
+ entryIds.AppendL(8);
+ entryIds.AppendL(7);
+
+ TCaOperationParams organizeParams;
+ organizeParams.iGroupId = 3;
+ organizeParams.iOperationType = TCaOperationParams::EAppend;
+ mStorage->OrganizeL(entryIds,organizeParams);
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetParentId(3);
+ innerQuery->SetSort(CCaInnerQuery::Default);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ TInt j = resultArray.Count() - 1;
+ for (TInt i = entryIds.Count() - 1; i >= 0; i--, j--) {
+ if (resultArray[j]->GetId() != entryIds[i]) {
+ err = KErrWrongData;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ CleanupStack::PopAndDestroy(&entryIds);
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testOrganizePrepend()
+{
+ TInt err(KErrNone);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ RArray<TInt> entryIds;
+ CleanupClosePushL(entryIds);
+ entryIds.AppendL(8);
+ entryIds.AppendL(7);
+
+ TCaOperationParams organizeParams;
+ organizeParams.iGroupId = 3;
+ organizeParams.iOperationType = TCaOperationParams::EPrepend;
+ mStorage->OrganizeL(entryIds,organizeParams);
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetParentId(3);
+ innerQuery->SetSort(CCaInnerQuery::Default);
+ RPointerArray<CCaInnerEntry> resultArray;
+ CleanupResetAndDestroyPushL(resultArray);
+ mStorage->GetEntriesL(innerQuery, resultArray);
+
+ TInt j = 0;
+ for (TInt i = 0; i < entryIds.Count(); i++, j++) {
+ if (resultArray[j]->GetId() != entryIds[i]) {
+ err = KErrWrongData;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&resultArray);
+ CleanupStack::PopAndDestroy(innerQuery);
+ CleanupStack::PopAndDestroy(&entryIds);
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testOrganizeInsertNewIntoGroup()
+{
+ TInt err(KErrNone);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ //insert somewhere in the middle
+ RArray<TInt> entryIds;
+ CleanupClosePushL(entryIds);
+ TInt newInsertEntryId = 7;
+
+ entryIds.AppendL(newInsertEntryId);
+
+ CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
+ innerQuery->SetParentId(2);
+ innerQuery->SetSort(CCaInnerQuery::Default);
+
+ RPointerArray<CCaInnerEntry> resultArray1;
+ CleanupResetAndDestroyPushL(resultArray1);
+ mStorage->GetEntriesL(innerQuery, resultArray1);
+
+ TInt count = resultArray1.Count();
+ TInt insertPosition = count / 2;
+ TInt beforeId = resultArray1[insertPosition - 1]->GetId();
+
+ TCaOperationParams organizeParams;
+ organizeParams.iGroupId = 2;
+ organizeParams.iBeforeEntryId = beforeId;
+ organizeParams.iOperationType = TCaOperationParams::EInsert;
+ mStorage->OrganizeL(entryIds,organizeParams);
+
+ RPointerArray<CCaInnerEntry> resultArray2;
+ CleanupResetAndDestroyPushL(resultArray2);
+ mStorage->GetEntriesL(innerQuery, resultArray2);
+
+ TInt idNew = resultArray2[ insertPosition - 1 ]->GetId();
+ err = (resultArray2[ insertPosition - 1 ]->GetId() == newInsertEntryId) ? err : KErrWrongData;
+ err = (resultArray2[ insertPosition ]->GetId() == beforeId) ? err : KErrWrongData;
+
+ //insert into 1st position (prepend)
+
+ CCaSqLiteStorage *storage = STATIC_CAST(CCaSqLiteStorage *,mStorage);
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(storage->iSqlDb);
+ query->SetQueryL(KSQLGetUnexistingIdFromGroup);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEIdGroup), KAllCollectionsGroupId);
+ TInt unexistingIdInGroup;
+ query->ExecuteL(unexistingIdInGroup);
+ query->CloseStatement();
+ entryIds.Reset();
+ entryIds.AppendL(unexistingIdInGroup);
+ TInt idFirst = resultArray2[ 0 ]->GetId();
+ organizeParams.iBeforeEntryId = idFirst;
+ mStorage->OrganizeL(entryIds,organizeParams);
+
+ RPointerArray<CCaInnerEntry> resultArray3;
+ CleanupResetAndDestroyPushL(resultArray3);
+ mStorage->GetEntriesL(innerQuery, resultArray3);
+
+ err = (resultArray3[ 0 ]->GetId() == unexistingIdInGroup) ? err : KErrWrongData;
+
+ //insert before unexisting item
+ TInt unexistingIdInGroup1;
+ TInt unexistingIdInGroup2;
+ query->SetQueryL(KSQLGetUnexistingIdFromGroup);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEIdGroup), KAllCollectionsGroupId);
+ query->ExecuteL(unexistingIdInGroup1);
+ unexistingIdInGroup2 = unexistingIdInGroup1 + 1;
+ query->CloseStatement();
+ organizeParams.iBeforeEntryId = unexistingIdInGroup1;
+ entryIds.Reset();
+ entryIds.AppendL(unexistingIdInGroup2);
+
+ TInt unexistingBeforeIdError(KErrNone);
+ TRAP(unexistingBeforeIdError, mStorage->OrganizeL(entryIds,organizeParams));
+ if (KErrNone == unexistingBeforeIdError) {
+ err = KErrBadParams;
+}
+
+CleanupStack::PopAndDestroy(&resultArray3);
+CleanupStack::PopAndDestroy(query);
+CleanupStack::PopAndDestroy(&resultArray2);
+CleanupStack::PopAndDestroy(&resultArray1);
+CleanupStack::PopAndDestroy(innerQuery);
+CleanupStack::PopAndDestroy(&entryIds);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testOrganizeBadParams()
+{
+ TInt err(KErrNone);
+ __UHEAP_MARK;
+ TRAP(err,
+ RArray<TInt> errorArray;
+ CleanupClosePushL(errorArray);
+ RArray<TInt> entryIds;
+ CleanupClosePushL(entryIds);
+ TCaOperationParams organizeParams;
+ CCaSqLiteStorage *storage = STATIC_CAST(CCaSqLiteStorage *,mStorage);
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(storage->iSqlDb);
+
+ query->SetQueryL(KSQLGetUnexistingIdFromGroup);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEIdGroup), KAllCollectionsGroupId);
+ TInt unexistingIdInGroup;
+ query->ExecuteL(unexistingIdInGroup);
+ query->CloseStatement();
+ organizeParams.iOperationType = TCaOperationParams::ERemove;
+ entryIds.Append(unexistingIdInGroup);
+ entryIds.Append(unexistingIdInGroup + 1);
+ TRAP(err, mStorage->OrganizeL(entryIds,organizeParams));
+ errorArray.AppendL(err);
+ err = KErrNone;
+ entryIds.Reset();
+
+ organizeParams.iOperationType = TCaOperationParams::EInsert;
+ organizeParams.iBeforeEntryId = unexistingIdInGroup;
+ entryIds.Append(unexistingIdInGroup + 1);
+ TRAP(err, mStorage->OrganizeL(entryIds,organizeParams));
+ errorArray.AppendL(err);
+ err = KErrNone;
+
+ for (TInt i = 0; i < errorArray.Count(); i++) {
+ if (errorArray[i] == 0) {
+ err = KErrBadParams;
+ break;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(&entryIds);
+ CleanupStack::PopAndDestroy(&errorArray);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testCustomSort()
+{
+ TInt err(KErrNone);
+ __UHEAP_MARK;
+ TRAP(err,
+ const TInt KGroupId = 12;
+
+ RArray<TInt> entryIds;
+ CleanupClosePushL(entryIds);
+ RArray<TInt> entryIdsFromDb;
+ CleanupClosePushL(entryIdsFromDb);
+
+ // array with custom sorted ids
+ entryIds.AppendL(14); // 13
+ entryIds.AppendL(15); // 14
+ entryIds.AppendL(13); // 15
+ entryIds.AppendL(16); // 16
+ entryIds.AppendL(17); // 17
+
+ // test
+ mStorage->CustomSortL(entryIds, KGroupId);
+
+ // check results
+ CCaSqLiteStorage *storage = STATIC_CAST(CCaSqLiteStorage *, mStorage);
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(storage->iSqlDb);
+ query->SetQueryL(KSQLGetEntryIdsFromGroupInPositionOrder);
+ query->PrepareL();
+ query->BindIntL(query->iStatement.ParameterIndex(KSQLGEIdGroup), KGroupId);
+ TInt count = query->ExecuteL(entryIdsFromDb, CCaSqlQuery::EGroupTable);
+ query->CloseStatement();
+
+ for (TInt i=0; i<entryIds.Count(); i++) {
+ if (entryIds[i] != entryIdsFromDb[i]) {
+ err = KErrBadParams;
+ break;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(query);
+ CleanupStack::PopAndDestroy(&entryIdsFromDb);
+ CleanupStack::PopAndDestroy(&entryIds);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestproperties.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestproperties.cpp
+ *
+ * Created on: 2009-08-17
+ * Author: michal.wojcik
+ */
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+#include "cadef.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testPropertyGetDbVersion()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+
+ _LIT(KProperty, "Version");
+ _LIT(KPropertyValue, "00001");
+ _LIT(KPropertyValue2, "00002");
+ TRAP(err,
+ // set db version property - 00001
+ mStorage->SetDBPropertyL(KProperty, KPropertyValue);
+
+ TBuf<20> propertyValue;
+ mStorage->DbPropertyL(KProperty, propertyValue);
+
+ if (!propertyValue.CompareC(KPropertyValue)) {
+ err = KErrNone;
+}
+
+// set db version property - 00002
+mStorage->SetDBPropertyL(KProperty, KPropertyValue2);
+
+TBuf<20> propertyValue2;
+mStorage->DbPropertyL(KProperty, propertyValue2);
+
+// check results
+if (err == KErrNone) {
+ if (!propertyValue2.CompareC(KPropertyValue2)) {
+ err = KErrNone;
+ } else {
+ err = KErrGeneral;
+ }
+ }
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testPropertyGetLanguage()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+
+ _LIT(KProperty, "Language");
+ _LIT(KPropertyValue, "en_GB");
+ _LIT(KPropertyValue2, "pl_PL");
+
+ TRAP(err,
+ // set lanquage property - en_GB
+ mStorage->SetDBPropertyL(KProperty, KPropertyValue);
+
+ TBuf<20> propertyValue;
+ mStorage->DbPropertyL(KProperty, propertyValue);
+
+ if (!propertyValue.CompareC(KPropertyValue)) {
+ err = KErrNone;
+}
+
+// set lanquage property - pl_PL
+mStorage->SetDBPropertyL(KProperty, KPropertyValue2);
+
+TBuf<20> propertyValue2;
+mStorage->DbPropertyL(KProperty, propertyValue2);
+
+// check results
+if (err == KErrNone) {
+ if (!propertyValue2.CompareC(KPropertyValue2)) {
+ err = KErrNone;
+ } else {
+ err = KErrGeneral;
+ }
+ }
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testLoadDBFromROM()
+{
+ TInt err(KErrGeneral);
+
+ delete mStorage;
+ mStorage = NULL;
+
+ //we copy corrupted db
+ QFile corruptedfile("c:/testing/data/t_castorage/corruptedcastoragedb");
+ QFile file("c:/castorage.db");
+ bool ok = corruptedfile.open(QIODevice::ReadOnly);
+ ok = file.open(QIODevice::ReadWrite) && ok;
+ ok = file.remove() && ok;
+ ok = corruptedfile.copy("c:/castorage.db") && ok;
+ QCOMPARE(ok, true);
+
+ corruptedfile.close();
+ file.close();
+
+ TRAP(err,
+ mStorage = CaStorageFactory::NewDatabaseL();
+ );
+
+
+ CCaSqLiteStorage *storage = dynamic_cast<CCaSqLiteStorage *>(mStorage);
+ storage->iPrivatePathZDriveDb.Copy(_L("c:\\testing\\data\\t_castorage\\castorage.db"));
+ TRAP(err,
+ mStorage->LoadDataBaseFromRomL();
+ );
+ QCOMPARE(err, KErrNone);
+ testGetEntriesById();// to check that db is accesible
+}
+
+// not stable to use due to impossibilty to dynamically load db to rom
+/*void CCAStorageTest::testBadDBVersion()
+{
+ TInt err(KErrGeneral);
+
+ delete mStorage;
+ mStorage = NULL;
+
+ //we copy db with bad version db
+ QFile badversionfile("c:/testing/data/t_castorage/versioncastoragedb");
+ QFile file("c:/castorage.db");
+ bool ok = badversionfile.open(QIODevice::ReadOnly);
+ ok = file.open(QIODevice::ReadWrite) && ok;
+ ok = file.remove() && ok;
+ ok = badversionfile.copy("c:/castorage.db") && ok;
+ QCOMPARE(ok, true);
+ badversionfile.close();
+ file.close();
+
+ //we would like to copy good db to rom
+ //but we can only assume that it is already there
+ QFile goodversionfile("c:/testing/data/t_castorage/castorage.db");
+ QFile file2("z:/castorage.db");
+ ok = goodversionfile.open(QIODevice::ReadOnly);
+ ok = file2.open(QIODevice::ReadWrite) && ok;
+ ok = file2.remove() && ok;
+ ok = goodversionfile.copy("z:/castorage.db") && ok;
+ QCOMPARE(ok, true);
+ badversionfile.close();
+ file2.close();
+
+
+ TRAP(err,
+ mStorage = CaStorageFactory::NewDatabaseL();
+ );
+
+ //check id good version was loaded instead
+ CCaSqLiteStorage* castorage = dynamic_cast<CCaSqLiteStorage *>(mStorage);
+ TBuf<KCaMaxAttrNameLen> versionValue;
+ castorage->DbPropertyL(KCaDbPropVersion, versionValue);
+ TInt res = versionValue.CompareC( KCaDbVersion );
+ QVERIFY(res == 0);
+}*/
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetestremove.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetestremove.cpp
+ *
+ * Created on: 2009-08-05
+ * Author: michal.czerwiec
+ */
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testRemoveOneEntryWithIcon()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+// TRAP(err,
+ // Check database before remove
+ CCaSqlQuery *query = CCaSqlQuery::NewL(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ CleanupStack::PushL(query);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesBeforeRemove(0);
+ query->ExecuteL(countEntriesBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ TInt countIconsBeforeRemove(0);
+ query->ExecuteL(countIconsBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // Remove from database
+ RArray<TInt> entriesToRemoveArray;
+ CleanupClosePushL(entriesToRemoveArray);
+ // etry with id = 3 has icon
+ TInt entryId = 3;
+ entriesToRemoveArray.AppendL(entryId);
+ mStorage->RemoveL(entriesToRemoveArray);
+
+
+ // Check result after remove
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesAfterRemove(0);
+ query->ExecuteL(countEntriesAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countEntriesBeforeRemove - countEntriesAfterRemove) == entriesToRemoveArray.Count()) {
+ err = KErrNone;
+ }
+
+query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+query->SetQueryL(KSQLGetIdCountFromIconTable);
+query->PrepareL();
+TInt countIconsAfterRemove(0);
+query->ExecuteL(countIconsAfterRemove);
+CleanupStack::PopAndDestroy(query);
+
+if (!err) {
+ if ((countIconsBeforeRemove - countIconsAfterRemove) == 1) {
+ err = KErrNone;
+ } else {
+ err = KErrGeneral;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&entriesToRemoveArray);
+// );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemoveOneEntryWhenIconIsUseByOtherEntry()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check database before remove
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesBeforeRemove(0);
+ query->ExecuteL(countEntriesBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ TInt countIconsBeforeRemove(0);
+ query->ExecuteL(countIconsBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // Remove from database
+ RArray<TInt> entriesToRemoveArray;
+ CleanupClosePushL(entriesToRemoveArray);
+ // etry with id = 20 has same icon as entry with id = 21
+ entriesToRemoveArray.AppendL(20);
+ mStorage->RemoveL(entriesToRemoveArray);
+
+
+ // Check result after remove
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesAfterRemove(0);
+ query->ExecuteL(countEntriesAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countEntriesBeforeRemove - countEntriesAfterRemove) == entriesToRemoveArray.Count()) {
+ err = KErrNone;
+}
+
+query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+query->SetQueryL(KSQLGetIdCountFromIconTable);
+query->PrepareL();
+TInt countIconsAfterRemove(0);
+query->ExecuteL(countIconsAfterRemove);
+CleanupStack::PopAndDestroy(query);
+
+if (countIconsBeforeRemove == countIconsAfterRemove) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+
+CleanupStack::PopAndDestroy(&entriesToRemoveArray);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemoveTwoEntriesWithSameIcon()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check database before remove
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesBeforeRemove(0);
+ query->ExecuteL(countEntriesBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromIconTable);
+ query->PrepareL();
+ TInt countIconsBeforeRemove(0);
+ query->ExecuteL(countIconsBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // Remove from database
+ RArray<TInt> entriesToRemoveArray;
+ CleanupClosePushL(entriesToRemoveArray);
+ // both entries with same icon
+ entriesToRemoveArray.AppendL(19);
+ entriesToRemoveArray.AppendL(20);
+ mStorage->RemoveL(entriesToRemoveArray);
+
+ // Check result after remove
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesAfterRemove(0);
+ query->ExecuteL(countEntriesAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countEntriesBeforeRemove - countEntriesAfterRemove) == entriesToRemoveArray.Count()) {
+ err = KErrNone;
+}
+
+query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+query->SetQueryL(KSQLGetIdCountFromIconTable);
+query->PrepareL();
+TInt countIconsAfterRemove(0);
+query->ExecuteL(countIconsAfterRemove);
+CleanupStack::PopAndDestroy(query);
+
+if (countIconsBeforeRemove - countIconsAfterRemove == 1) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+
+CleanupStack::PopAndDestroy(&entriesToRemoveArray);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemoveOneEntryWithoutIcon()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check database before remove
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesBeforeRemove(0);
+ query->ExecuteL(countEntriesBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // Remove from database
+ RArray<TInt> entriesToRemoveArray;
+ CleanupClosePushL(entriesToRemoveArray);
+ // id = 12 app without icon
+ TInt entryId = 12;
+ entriesToRemoveArray.AppendL(entryId);
+ mStorage->RemoveL(entriesToRemoveArray);
+
+ // Check result after remove
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesAfterRemove(0);
+ query->ExecuteL(countEntriesAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countEntriesBeforeRemove - countEntriesAfterRemove) == entriesToRemoveArray.Count()) {
+ err = KErrNone;
+}
+
+CleanupStack::PopAndDestroy(&entriesToRemoveArray);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemove5Entries()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+
+ TRAP(err,
+ // Check database before remove
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesBeforeRemove(0);
+ query->ExecuteL(countEntriesBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // Remove from database
+ RArray<TInt> entriesToRemoveArray;
+ CleanupClosePushL(entriesToRemoveArray);
+ // 5 entries
+ entriesToRemoveArray.AppendL(4);
+ entriesToRemoveArray.AppendL(5);
+ entriesToRemoveArray.AppendL(10);
+ entriesToRemoveArray.AppendL(13);
+ entriesToRemoveArray.AppendL(14);
+
+ mStorage->RemoveL(entriesToRemoveArray);
+
+ // Check result after remove
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesAfterRemove(0);
+ query->ExecuteL(countEntriesAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countEntriesBeforeRemove - countEntriesAfterRemove) == entriesToRemoveArray.Count()) {
+ err = KErrNone;
+}
+
+CleanupStack::PopAndDestroy(&entriesToRemoveArray);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemoveEntriesWithIdOutOFBound()
+{
+ TInt err(KErrGeneral);
+ __UHEAP_MARK;
+ TRAP(err,
+ // Check database before remove
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromEntryTable);
+ query->PrepareL();
+ TInt countEntriesBeforeRemove(0);
+ query->ExecuteL(countEntriesBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // Remove from database
+ RArray<TInt> entriesToRemoveArray;
+ CleanupClosePushL(entriesToRemoveArray);
+ // 5 entries
+ entriesToRemoveArray.AppendL(4);
+ entriesToRemoveArray.AppendL(5);
+ entriesToRemoveArray.AppendL(56); // Id out of bound
+ entriesToRemoveArray.AppendL(13);
+ entriesToRemoveArray.AppendL(87); // Id out of bound
+
+ // shold leave with KErrNotFound
+ TRAPD(err2, mStorage->RemoveL(entriesToRemoveArray));
+ if (err2 == KErrNotFound) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+
+
+// Check result after remove
+query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+query->SetQueryL(KSQLGetIdCountFromEntryTable);
+query->PrepareL();
+TInt countEntriesAfterRemove(0);
+query->ExecuteL(countEntriesAfterRemove);
+CleanupStack::PopAndDestroy(query);
+
+if (countEntriesBeforeRemove == countEntriesAfterRemove) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+
+CleanupStack::PopAndDestroy(&entriesToRemoveArray);
+ );
+ __UHEAP_MARKEND;
+ QCOMPARE(err, KErrNone);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/src/castoragetesttouch.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,284 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * castoragetesttouch.cpp
+ *
+ * Created on: 2009-08-17
+ * Author: michal.wojcik
+ */
+
+#include "castoragetest.h"
+#include "castoragefactory.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+#include "casqlquery.h"
+#include "casqlitestorage.h"
+#include "castoragetestsqlcommands.h"
+#include "casqlcommands.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCAStorageTest::testTouch()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // check database before touch
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchBeforeTouch(0);
+ query->ExecuteL(countLaunchBeforeTouch);
+ CleanupStack::PopAndDestroy(query);
+
+ // Id 14 - Clock app
+ mStorage->TouchL(14, ETrue);
+
+ // check database after touch
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchAfterTouch(0);
+ query->ExecuteL(countLaunchAfterTouch);
+ CleanupStack::PopAndDestroy(query);
+
+ // flag should be set to EUsed on 1 Entry
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetUsedFlagCountFromEntryTable);
+ query->PrepareL();
+ query->BindValuesForLaunchL(0,0);
+ TInt countEntriesWithUsedFlag(0);
+ query->ExecuteL(countEntriesWithUsedFlag);
+ CleanupStack::PopAndDestroy(query);
+
+ if (((countLaunchAfterTouch - countLaunchBeforeTouch) == 1) && (countEntriesWithUsedFlag == 1)) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testTouch2Times()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // check database before touch
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchBeforeTouch(0);
+ query->ExecuteL(countLaunchBeforeTouch);
+ CleanupStack::PopAndDestroy(query);
+
+ // Id 14 - Clock app
+ mStorage->TouchL(14, ETrue);//removable application
+ User::After(1000000); // 1 sec
+ mStorage->TouchL(14, ETrue);
+
+ // check database after touch
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchAfterTouch(0);
+ query->ExecuteL(countLaunchAfterTouch);
+ CleanupStack::PopAndDestroy(query);
+
+ // flag should be set to EUsed on 1 Entry
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetUsedFlagCountFromEntryTable);
+ query->PrepareL();
+ query->BindValuesForLaunchL(0,0);
+ TInt countEntriesWithUsedFlag(0);
+ query->ExecuteL(countEntriesWithUsedFlag);
+ CleanupStack::PopAndDestroy(query);
+
+ if (((countLaunchAfterTouch - countLaunchBeforeTouch) == 2) && (countEntriesWithUsedFlag == 1)) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+ );
+
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testTouch5Entries()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+
+ TRAP(err,
+ // check database before touch
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchBeforeTouch(0);
+ query->ExecuteL(countLaunchBeforeTouch);
+ CleanupStack::PopAndDestroy(query);
+ //all apps are not removeable
+ mStorage->TouchL(9, EFalse); // calendar
+ mStorage->TouchL(10, EFalse); // calculator
+ mStorage->TouchL(16, EFalse); // music player
+ mStorage->TouchL(20, EFalse); // photos
+ mStorage->TouchL(21, EFalse); // video center
+
+ // check database after touch
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchAfterTouch(0);
+ query->ExecuteL(countLaunchAfterTouch);
+ CleanupStack::PopAndDestroy(query);
+
+ // flag should be set to EUsed on 5 Entries
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetUsedFlagCountFromEntryTable);
+ query->PrepareL();
+ query->BindValuesForLaunchL(0,0);
+ TInt countEntriesWithUsedFlag(0);
+ query->ExecuteL(countEntriesWithUsedFlag);
+ CleanupStack::PopAndDestroy(query);
+
+ if (((countLaunchAfterTouch - countLaunchBeforeTouch) == 5) && (countEntriesWithUsedFlag == 0)) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemoveOldFromLaunch()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // prepare time older than 30 days
+ TTime presentTime;
+ presentTime.UniversalTime();
+ TTime outOfDateTime = presentTime - (TTimeIntervalDays(30 + 5));
+
+ // prepare item with launch time older than 30 days
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLInsertToLaunch);
+ query->PrepareL();
+ // change launch time for calculator app to older than 30 days
+ query->BindValuesForLaunchL(10, outOfDateTime.Int64());
+ query->ExecuteL();
+ CleanupStack::PopAndDestroy(query);
+ // prepare 2 items with launch time newer than 30 days
+ mStorage->TouchL(20, EFalse); // photos
+ mStorage->TouchL(21, EFalse); // video center
+
+ // check database before remove old launch
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchBeforeRemove(0);
+ query->ExecuteL(countLaunchBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // remove launches older than 30 days
+ ((CCaSqLiteStorage *)mStorage)->RemoveOldEntriesFromLaunchTableL(30);
+
+ // check database after remove old launches
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchAfterRemove(0);
+ query->ExecuteL(countLaunchAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countLaunchBeforeRemove - countLaunchAfterRemove) == 1) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
+
+void CCAStorageTest::testRemoveOldWhen2DifferentLaunchTimes()
+{
+ TInt err(KErrGeneral);
+
+ __UHEAP_MARK;
+ TRAP(err,
+ // prepare time older than 30 days
+ TTime presentTime;
+ presentTime.UniversalTime();
+ TTime outOfDateTime = presentTime - (TTimeIntervalDays(30 + 5));
+
+ // prepare item with launch time older than 30 days
+ CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLInsertToLaunch);
+ query->PrepareL();
+ // change launch time for calculator app to older than 30 days
+ query->BindValuesForLaunchL(10, outOfDateTime.Int64());
+ query->ExecuteL();
+ CleanupStack::PopAndDestroy(query);
+ // prepare 2 items with launch time newer than 30 days
+ mStorage->TouchL(10, EFalse); // launch the same app again - time newer than 30 days
+
+ // check database before remove old launch
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchBeforeRemove(0);
+ query->ExecuteL(countLaunchBeforeRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ // remove launches older than 30 days
+ ((CCaSqLiteStorage *)mStorage)->RemoveOldEntriesFromLaunchTableL(30);
+
+ // check database after remove old launches
+ query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb);
+ query->SetQueryL(KSQLGetIdCountFromLaunchTable);
+ query->PrepareL();
+ TInt countLaunchAfterRemove(0);
+ query->ExecuteL(countLaunchAfterRemove);
+ CleanupStack::PopAndDestroy(query);
+
+ if ((countLaunchBeforeRemove - countLaunchAfterRemove) == 1) {
+ err = KErrNone;
+} else {
+ err = KErrGeneral;
+}
+ );
+ __UHEAP_MARKEND;
+
+ QCOMPARE(err, KErrNone);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/t_castorage.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h ../../inc/*.h
+SOURCES += ./src/*.cpp ../../src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/t_castorage.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,86 @@
+# Copyright (c) 2009 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:
+TEMPLATE = app
+include(../../../../common.pri)
+CONFIG(debug, debug|release):DESTDIR = debug
+else:DESTDIR = release
+CONFIG += debug_and_release \
+ console
+QT += testlib \
+ xml
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+DEPENDPATH += . \
+ ./inc \
+ ./src
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../homescreensrv_plat/contentstorage_api
+INCLUDEPATH += ../../../cautils/inc \
+ ../../inc
+symbian: {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.UID2 = 0x1000008D
+ TARGET.UID3 = 0x20026FAB
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \
+ ../../inc \
+ ../../../cautils/inc \
+ ../../../srvinc \
+ ../../../inc
+ LIBS += -leuser \
+ -lsqldb \
+ -lestor \
+ -lefsrv \
+ -lbafl \
+ -lcautils \
+ -lflogger \
+ -lxqutils
+
+ exportRunScript.sources = ./data/castorage.bat
+ exportRunScript.path = /testing/data/t_castorage/
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = /testing/data/t_castorage/
+
+ exportCorruptedDB.sources = ./data/corruptedcastoragedb
+ exportCorruptedDB.path = /testing/data/t_castorage/
+
+ exportVersionDB.sources = ./data/versioncastoragedb
+ exportVersionDB.path = /testing/data/t_castorage/
+
+
+
+ DEPLOYMENT += \
+ exportRunScript \
+ exportDB \
+ exportCorruptedDB \
+ exportVersionDB
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} c:$${exportDB.path}"
+ BLD_INF_RULES.prj_testexports += "$${exportCorruptedDB.sources} c:$${exportCorruptedDB.path}"
+ BLD_INF_RULES.prj_testexports += "$${exportVersionDB.sources} c:$${exportVersionDB.path}"
+
+}
+include(t_castorage.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+SUBDIRS = t_castorage
+
+CONFIG += ordered
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/misc/cmt/caconf.ini Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,16 @@
+MCCABE_FUNCTION_MAX=20
+V_FUNCTION_MIN=1
+V_FUNCTION_MAX=2000
+V_FILE_MIN=1
+V_FILE_MAX=20000
+LOC_FUNCTION_MIN=1
+LOC_FUNCTION_MAX=100
+LOC_FILE_MIN=1
+LOC_FILE_MAX=2000
+B_FILE_MIN=0
+B_FILE_MAX=10
+COMMENT_RATIO_FILE_MIN=0
+COMMENT_RATIO_FILE_MAX=100
+COMMENT_RATIO_FUNCTION_MIN=0
+COMMENT_RATIO_FUNCTION_MAX=100
+COMMENT_FUNCTION_MIN=0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/misc/cmt/cmtca.cmd Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,19 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call collectcafiles.cmd
+cmt -c caconf.ini -o cacmt.txt < cafiles.txt
+cmt2html -i cacmt.txt
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/misc/cmt/collectcafiles.cmd Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+dir ..\..\caclient\src\*.cpp /s /b >>cafiles.txt
+dir ..\..\caclient\s60\src\*.cpp /s /b >>cafiles.txt
+dir ..\..\castorage\src\*.cpp /s /b >>cafiles.txt
+dir ..\..\engsrc\*.cpp /s /b >>cafiles.txt
+dir ..\..\extsrc\*.cpp /s /b >>cafiles.txt
+dir ..\..\cahandler\app\src\*.cpp /s /b >>cafiles.txt
+dir ..\..\cahandler\url\src\*.cpp /s /b >>cafiles.txt
+dir ..\..\src\*.cpp /s /b >>cafiles.txt
+dir ..\..\srvsrc\*.cpp /s /b >>cafiles.txt
+dir ..\..\cautils\src\*.cpp /s /b >>cafiles.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
\ No newline at end of file
Binary file contentstorage/tsrc/t_casrv/data/castorage.db has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE+../../srvsrc/casrvengutils.cpp" abld build winscw udeb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../../srvsrc/casrvengutils.cpp*\" sbs -j 4 -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_casrv -o c:\\t_casrv.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/inc/casrvtestutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef CA_SRV_TEST_UTILS_H
+#define CA_SRV_TEST_UTILS_H
+//utility class for tests
+//all utility methods should be implemented here
+
+#include "casrvengutils.h"
+#include "casrvplugin.h"
+
+class CCaStorageProxy;
+class CCaInnerEntry;
+class CCaSrvEngUtils;
+
+class CTestUtils: public CBase
+{
+public:
+
+ /**/
+ virtual ~CTestUtils();
+
+ /**/
+ static CTestUtils* NewL();
+
+ /**/
+ static CTestUtils* NewLC();
+
+
+ /**
+ * Copys test Db
+ */
+ TInt CopyDb();
+
+ /**
+ * Checks if app exists in Db
+ private:
+
+ /**
+ * Copys files
+ */
+ TInt Copy( const TDesC& aSource, const TDesC& aDest );
+
+ CTestUtils();
+
+ void ConstructL();
+
+ RFs iFs;
+ CFileMan* iFileManager;
+ /*
+ * own
+ */
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/inc/t_casrvutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* 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:
+*
+*/
+
+
+#ifndef __T_casrvUtils_H__
+#define __T_casrvUtils_H__
+class CTestUtils;
+class CCaStorageProxy;
+class CCaSrvEngUtils;
+class CCaSrvAppScanner;
+#include <QtTest/QtTest>
+#include <e32def.h>
+
+class T_casrvUtils: public QObject
+{
+ Q_OBJECT
+private slots: // New methods
+
+ //setup methods
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ //tests
+ void testNewL();
+ void testGetAppUidL();
+ void testGetApaAppInfoL();
+ void testGetAppInfoL();
+ void testIsNativeL();
+private: // Data
+
+ CTestUtils *iTestUtils;
+
+ CCaStorageProxy *iStorage;
+
+ CCaSrvEngUtils *iSrvEngUtils;
+};
+
+#endif // __T_casrvUtils_H__
+
+// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/inc/testconsts.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * testconsts.h
+ *
+ * Created on: 2009-08-24
+ *
+ */
+
+#ifndef TESTCONSTS_H_
+#define TESTCONSTS_H_
+
+// CONSTANTS
+
+//test utils
+_LIT(KTestDbSource, "C:\\testing\\data\\t_casrv\\castorage.db");
+_LIT(KTestDbDest, "C:\\castorage.db");
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+
+
+//app scanner
+const TInt noteApp = 0xA0000230;
+const TInt notInstalledUid = 0xA0000232;// uid of not installed app
+const TInt installedUid = 0xE6BC1167; // installed app
+//const TInt KSystemApp = 0x10005901;// system app eg. clock
+const TInt KSystemApp = 0x20022EF9;
+
+_LIT( KMmcIdValue, "00000001" );
+
+
+
+#endif /* TESTCONSTS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_casrv_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\sis\rd.cer -key ..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/src/casrvtestutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2009 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 <W32STD.H>
+#include <e32property.h>
+#include <cadef.h>
+#include <badesca.h>
+#include <apgtask.h>
+#include <AknTaskList.h>
+#include <apgcli.h>
+#include <APACMDLN.h>
+#include <EIKENV.h>
+
+
+#include "castorageproxy.h"
+#include "cainnerentry.h"
+#include "cainnerquery.h"
+#include "caarraycleanup.inl"
+
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTRUCTION
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewL()
+ {
+ CTestUtils* self = CTestUtils::NewLC();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+CTestUtils* CTestUtils::NewLC()
+ {
+ CTestUtils* self = new( ELeave ) CTestUtils();
+ CleanupStack::PushL( self );
+
+ self->ConstructL();
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+// ---------------------------------------------------------------------------
+//
+CTestUtils::~CTestUtils()
+ {
+ iFileManager->Delete(KTestDbDest);
+ delete iFileManager; iFileManager = NULL;
+ iFs.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Default constructor
+// ---------------------------------------------------------------------------
+//
+CTestUtils::CTestUtils()
+ {
+
+ }
+
+// ---------------------------------------------------------------------------
+// Second phase construct
+// ---------------------------------------------------------------------------
+//
+void CTestUtils::ConstructL()
+ {
+ User::LeaveIfError( iFs.Connect() );
+ iFileManager = CFileMan::NewL( iFs );
+ }
+
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::Copy( const TDesC& aSource, const TDesC& aDest )
+ {
+ return iFileManager->Copy(aSource, aDest);
+ }
+
+//-----------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------
+TInt CTestUtils::CopyDb()
+ {
+ return Copy(KTestDbSource, KTestDbDest);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/src/t_casrvutils.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,208 @@
+/*
+* 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:
+*
+*/
+
+
+// CLASS HEADER
+#include "T_casrvUtils.h"
+
+// EXTERNAL INCLUDES
+#include <e32property.h>
+#include <e32debug.h>
+
+#include "cadef.h"
+#include "castorageproxy.h"
+#include "castorage.h"
+#include "casrvengutils.h"
+#include "cainnerentry.h"
+
+// INTERNAL INCLUDES
+#include "casrvtestutils.h"
+#include "testconsts.h"
+
+// CONSTANTS
+const TUid KAppScannerPluginUid = {0x20026FAF};
+
+void T_casrvUtils::initTestCase()
+{
+}
+
+void T_casrvUtils::cleanupTestCase()
+{
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void
+T_casrvUtils::init()
+{
+ TRAPD(err,
+ iTestUtils = CTestUtils::NewL();
+ iTestUtils->CopyDb();
+
+ iStorage = CCaStorageProxy::NewL();
+
+ iSrvEngUtils = CCaSrvEngUtils::NewL();
+ );
+ QCOMPARE(err, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void
+T_casrvUtils::cleanup()
+{
+
+ delete iSrvEngUtils;
+ iSrvEngUtils = NULL;
+ delete iStorage;
+ iStorage = NULL;
+ delete iTestUtils;
+ iTestUtils = NULL;
+
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void
+T_casrvUtils::testNewL()
+{
+ CCaSrvEngUtils *obj(0);
+
+ TRAPD(err, obj = CCaSrvEngUtils::NewL());
+ QCOMPARE(err, KErrNone);
+
+ QVERIFY(obj != NULL);
+
+ delete obj;
+}
+
+void
+T_casrvUtils::testGetAppUidL()
+{
+ TInt getAppUidResult(KErrGeneral);
+ TInt getInvalidAppUidResult(KErrNone);
+ TUid actualAppUid = TUid::Uid(0);
+ const TInt32 expectedAppUid = 1;
+
+ TRAPD(err,
+ CCaInnerEntry *const entry = CCaInnerEntry::NewLC();
+
+ entry->SetUid(expectedAppUid);
+
+
+ getAppUidResult =
+ iSrvEngUtils->GetAppUid(*entry, actualAppUid);
+
+ const TInt32 invalidUid = 0;
+ entry->SetUid(invalidUid);
+
+ getInvalidAppUidResult =
+ iSrvEngUtils->GetAppUid(*entry, actualAppUid);
+
+ CleanupStack::PopAndDestroy(entry);
+ );
+
+ QCOMPARE(err, KErrNone);
+ QCOMPARE(getAppUidResult, KErrNone);
+ QCOMPARE(expectedAppUid, actualAppUid.iUid);
+ QCOMPARE(getInvalidAppUidResult, KErrNotFound);
+}
+
+void
+T_casrvUtils::testGetApaAppInfoL()
+{
+ TApaAppInfo referenceInfo;
+
+ RApaLsSession apaLsSession;
+ TInt err(KErrNone);
+ TRAP(err, User::LeaveIfError(apaLsSession.Connect()));
+ QCOMPARE(err, KErrNone);
+
+ QCOMPARE(apaLsSession.GetAppInfo(referenceInfo, TUid::Uid(KSystemApp)), KErrNone);
+
+ TApaAppInfo srvEngUtilsInfo;
+ const TInt result = iSrvEngUtils->GetApaAppInfo(
+ TUid::Uid(KSystemApp), srvEngUtilsInfo);
+ QCOMPARE(result, KErrNone);
+
+ QCOMPARE(srvEngUtilsInfo.iUid.iUid, referenceInfo.iUid.iUid);
+ QVERIFY(srvEngUtilsInfo.iFullName.Compare(referenceInfo.iFullName) == 0);
+ QVERIFY(srvEngUtilsInfo.iCaption.Compare(referenceInfo.iCaption) == 0);
+ QVERIFY(srvEngUtilsInfo.iShortCaption.Compare(referenceInfo.iShortCaption) == 0);
+}
+
+void
+T_casrvUtils::testGetAppInfoL()
+{
+ CCaInnerEntry *entry(0);
+ TRAPD(err,
+ entry = CCaInnerEntry::NewLC();
+ CleanupStack::Pop(entry);
+ );
+ QCOMPARE(err, KErrNone);
+
+ TApaAppInfo info;
+
+ entry->SetUid(KSystemApp);
+
+ TInt result = iSrvEngUtils->GetAppInfo(*entry, info);
+ QCOMPARE(result, KErrNone);
+ QCOMPARE(info.iUid.iUid, static_cast<TInt32>(KSystemApp));
+ QVERIFY(info.iFullName.Compare(_L("Z:\\sys\\bin\\phonebook.exe")) == 0);
+ QVERIFY(info.iCaption.Compare(_L("Contacts")) == 0);
+ QVERIFY(info.iShortCaption.Length()>0);
+
+ const TInt32 invalidUid = 0;
+ entry->SetUid(invalidUid);
+ QCOMPARE(iSrvEngUtils->GetAppInfo(*entry, info), KErrNotFound);
+
+ entry->SetUid(notInstalledUid);
+ QCOMPARE(iSrvEngUtils->GetAppInfo(*entry, info), KErrNotFound);
+
+ delete entry;
+}
+
+void
+T_casrvUtils::testIsNativeL()
+{
+ CCaInnerEntry *entry(0);
+ TRAPD(err,
+ entry = CCaInnerEntry::NewLC();
+ entry->SetEntryTypeNameL(KCaTypeApp);
+ CleanupStack::Pop(entry);
+ );
+ QCOMPARE(err, KErrNone);
+
+
+ entry->SetUid(KSystemApp);
+
+ const TInt32 isNative = iSrvEngUtils->IsNativeL(*entry);
+
+ QVERIFY(isNative != 0);
+
+ delete entry;
+}
+
+QTEST_MAIN(T_casrvUtils)
+
+// END OF FILE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/t_casrv.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+
+SOURCES += ./src/*.cpp \
+ ../../srvsrc/cainstallnotifier.cpp \
+ ../../srvsrc/cainstallstrategy.cpp \
+ ../../srvsrc/casrvengutils.cpp \
+ ../../srvsrc/castorageproxy.cpp \
+ ../../srvsrc/casrvnotifier.cpp \
+ ../../srvsrc/casrv.cpp \
+ ../../srvsrc/casrvmmchistory.cpp \
+ ../../srvsrc/casrvsession.cpp \
+ ../../srvsrc/cabackupnotifier.cpp \
+ ../../cautils/src/*.cpp \
+ ../../castorage/src/*.cpp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/t_casrv.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,105 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+CONFIG += HB
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../homescreensrv_plat/contentstorage_api \
+ ../../srvinc \
+ ../../extinc \
+ ../../cautils/inc \
+ ../../casrv/casrvmgr/inc \
+ ../../castorage/inc \
+ ../../../srvinc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_casrv.pri)
+
+symbian: {
+ ### get rid of localization warnings
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+ ###
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x2002870D
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -lcautils \
+ -lcasathandler \
+ -lefsrv \
+ -lestor \
+ -lapparc \
+ -lCenRepNotifHandler \
+ -lcentralrepository \
+ -lplatformenv \
+ -lsysutil \
+ -leuser \
+ -lapgrfx \
+ -lws32 \
+ -lbafl \
+ -lavkon \
+ -lcone \
+ -lcasrvmanager \
+ -lsisregistryclient \
+ -lecom \
+ -lsqldb \
+ -lflogger \
+ -lscrclient \
+ -lsifnotification
+
+ exportDB.sources = ./data/castorage.db
+ exportDB.path = c:/testing/data/t_casrv/
+
+ BLD_INF_RULES.prj_testexports += "$${exportDB.sources} $${exportDB.path}"
+
+ DEPLOYMENT += exportDB
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_casrv/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_casrv.exe -o c:\t_casrv.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/coverageafter.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,22 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call ctcpost -p profile.txt
+call ctc2html -nsb -i profile.txt -o CTCFUNCTION
+call del profile.txt;
+call ctcpost -fd -p profile.txt;
+call ctc2html -nsb -i profile.txt -o CTCDECISION;
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/decision.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+call cd ../../group
+
+call del mon.sym
+call del mon.dat
+call rmdir /s /q CTCHTML
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call ctcwrap -i fd -C "EXCLUDE=*" -C "NO_EXCLUDE=../extsrc/casat*" abld build winscw udeb
+
+call cd ../tsrc/t_sathandler/
+
+call bldmake bldfiles
+call abld makefile winscw udeb
+call abld reallyclean winscw udeb
+call abld build winscw udeb
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ chdir("../../group");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../extsrc/casat*\" sbs -j 4 -c winscw_udeb");
+
+
+ chdir("../tsrc/t_sathandler");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_sathandler -o c:\\t_sathandler.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../../group");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../tsrc/t_sathandler/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../tsrc/t_sathandler/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/inc/T_casathandler.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_casathandler.h
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+#ifndef T_CASATHANDLER_H
+#define T_CASATHANDLER_H
+
+#include <QtTest/QtTest>
+#include <e32def.h>
+
+class CSatMonitor;
+/**
+ *
+ * Test class.
+ *
+ */
+class T_CaSatHandler: public QObject
+{
+ Q_OBJECT
+private slots:
+
+ //tests
+ void testConstruction();
+ void testGetName();
+ void testCheckVisibility();
+ void testGetIcon();
+
+ void testGetBitmap();
+};
+
+#endif // T_CASATHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,24 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_sathandler_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\sis\rd.cer -key ..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/readme.txt Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,1 @@
+On HW SIM card with SAT application musb be inserted. Device must be in online mode.
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/src/T_casathandler.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+/*
+ * T_casathandler.cpp
+ *
+ * Created on: 2009-09-16
+ * Author:
+ */
+
+
+#include "cadef.h"
+#include "ca2internalCRkeys.h"
+#include "T_casathandler.h"
+#include "casathandler.h"
+#include "e32property.h"
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatHandler::testConstruction()
+{
+ bool constructed(false);
+ TRAPD(err,
+ CCaSatHandler *satHandler = CCaSatHandler::NewL();
+ CleanupStack::PushL(satHandler);
+
+ constructed = satHandler != NULL;
+
+ CleanupStack::PopAndDestroy(satHandler);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(constructed);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatHandler::testGetName()
+{
+ bool nameMatches(false);
+ TRAPD(err,
+ CCaSatHandler *satHandler = CCaSatHandler::NewL();
+ CleanupStack::PushL(satHandler);
+ RBuf satName;
+ satName.CleanupClosePushL();
+ satName.Create(KCenRepBufferSize);
+ RProperty::Get(KCRUidCa, KCaSatUIName, satName);
+ RBuf satHandlerName;
+ satHandlerName.CleanupClosePushL();
+ satHandlerName.Create(KCenRepBufferSize);
+ satHandler->GetName(satHandlerName);
+
+ nameMatches = satHandlerName.Compare(satName) == 0;
+
+ CleanupStack::PopAndDestroy(&satHandlerName);
+ CleanupStack::PopAndDestroy(&satName);
+ CleanupStack::PopAndDestroy(satHandler);
+ );
+ QCOMPARE(err, KErrNone);
+ QVERIFY(nameMatches);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatHandler::testCheckVisibility()
+{
+ ;
+ TInt visibility(KErrNone);
+ RProperty::Get(KCRUidCa, KCaShowSatUI, visibility);
+ TBool visibilityHandler = CCaSatHandler::CheckVisibility();
+ QCOMPARE(visibilityHandler, visibility);
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatHandler::testGetIcon()
+{
+ // preconditions
+ RProperty::Define( KCRUidCa, KCaSatUIIconId, RProperty::EInt );
+
+ bool loadIconResult(false);
+ TInt setSizeResult(KErrNone);
+ TRAPD(err,
+ CCaSatHandler *satHandler = CCaSatHandler::NewL();
+ CleanupStack::PushL(satHandler);
+ TInt iconId(KErrNone);
+ User::LeaveIfError(RProperty::Get(KCRUidCa, KCaSatUIIconId, iconId));
+ if (iconId > 0) {
+ CAknIcon *icon = NULL;
+ icon = satHandler->LoadIconL();
+ CleanupStack::PushL(icon);
+ loadIconResult = (icon != NULL);
+ TSize size(1, 1);
+ //TInt err = AknIconUtils::SetSize( icon->Bitmap(), size ) ;
+ setSizeResult = AknIconUtils::SetSize(icon->Bitmap(), size);
+ CleanupStack::PopAndDestroy(icon);
+ } else {
+ CAknIcon *icon = NULL;
+ icon = satHandler->LoadIconL();
+ loadIconResult = (icon == NULL);
+ }
+ CleanupStack::PopAndDestroy(satHandler);
+ );
+
+ QCOMPARE(err, KErrNone);
+ QVERIFY(loadIconResult);
+ QCOMPARE(setSizeResult, KErrNone);
+}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void T_CaSatHandler::testGetBitmap()
+{
+ CCaSatHandler *satHandler = CCaSatHandler::NewL();
+ CleanupStack::PushL(satHandler);
+ RIconEf iIconEf;
+ CleanupClosePushL(iIconEf);
+ //CFbsBitmap* bitmap = satHandler->GetBitmapL( iIconEf );
+ //EUNIT_ASSERT( !bitmap );
+ CleanupStack::PopAndDestroy(&iIconEf);
+ CleanupStack::PopAndDestroy(satHandler);
+}
+
+QTEST_MAIN(T_CaSatHandler);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/t_sathandler.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h
+
+SOURCES += ./src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/t_sathandler.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,75 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+DEFINES += CONTENT_ARSENAL_STORAGE_UT
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += \
+ ./inc \
+ ../../inc \
+ ../../cautils/inc \
+ ../../extinc \
+ ../../castorage/inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_sathandler.pri)
+
+symbian: {
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20028712
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lecom \
+ -lcasathandler \
+ -laknicon \
+ -lSatClient \
+ -lfbscli \
+ -lbitgdi
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/t_sathandler/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_sathandler.exe -o c:\t_sathandler.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/testutils/inc/t_cainstaller.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2010 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: ?Description
+ *
+ */
+
+#ifndef T_CA_INSTALLER_H
+#define T_CA_INSTALLER_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <usif/sif/sif.h>
+#include <usif/scr/scr.h>
+
+/**
+ * Installer
+ *
+ */
+NONSHARABLE_CLASS(T_CaInstaller): public CActive {
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~T_CaInstaller();
+
+ /**
+ * Two-phased constructor. Leaves on failure.
+ * Allocates memory for and constructs an uninstaller object. After that
+ * starts asynchronous uninnstallation of the requested entry
+ * @param aFileName name of the file to be installed
+ * @param aPriority priority of the active scheduler responsible for handling
+ * asynchronous installation operation
+ * @return The constructed object.
+ */
+ static T_CaInstaller *NewL( TInt aPriority =
+ CActive::EPriorityStandard );
+
+ /**
+ * Starts asynchronous installation operation
+ * @param aFileName name of the file to be installed
+ * @param aComponentId placeholder for component id of the package after
+ * instalation is completed.
+ */
+ void InstallL(const TDesC& aFileName);
+ /**
+ * Uninstall operation
+ * @param aComponentId id of the component to be installed.
+ */
+ void UninstallL( Usif::TComponentId aComponentId );
+
+ /**
+ * Uninstall operation for package(s) based on filename
+ * for native and HS widgets.
+ * @param aFileName the file name installed with the package(s)
+ */
+ void UninstallL( const TDesC& aFileName );
+
+ /**
+ * Uninstall operation for java applications
+ * @param aUid ui
+ */
+ void UninstallL(TUint32 aUid);
+
+ /**
+ * Find component id for a file name
+ * @param aFileName the file name installed with the package(s)
+ * @return componentId for a requested file name
+ */
+ Usif::TComponentId GetComponentIdL( const TDesC& aFileName );
+
+ /**
+ * Find component id for a uid
+ * @param aUid ui
+ * @return componentId for a requested uid
+ */
+ Usif::TComponentId GetComponentIdL( TInt32 aUid );
+
+ /**
+ * Find component id for CWRT app id
+ * @param aAppId CWRT widget app id
+ * @return componentId for a requested uid
+ */
+ Usif::TComponentId GetComponentIdForAppIdL( const TDesC& aAppId);
+private:
+ // construction
+ /**
+ * Constructor.
+ * Starts active scheduler.
+ * @param aPriority priority of the active scheduler responsible for handling
+ * asynchronous installation operation
+ */
+ T_CaInstaller(TInt aPriority);
+
+ /**
+ * Initializes the object and starts asynchronous uninstallation process.
+ */
+ void ConstructL();
+
+
+
+private:
+ // from CActive
+
+ void RunL();
+ void DoCancel();
+ TInt RunError( TInt aError );
+
+private:
+ Usif::COpaqueNamedParams* iArguments;
+ Usif::COpaqueNamedParams* iResults;
+ RFs iFs;
+ Usif::RSoftwareInstall iInstaller;
+ Usif::RSoftwareComponentRegistry iSoftwareRegistry;
+ CActiveSchedulerWait iSchedulerWait;
+};
+
+#endif // T_CA_INSTALLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/testutils/src/t_cainstaller.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2010 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: ?Description
+ *
+ */
+
+#include <usif/usifcommon.h>
+#include <usif/scr/screntries.h>
+
+#include "t_cainstaller.h"
+
+using namespace Usif;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::~T_CaInstaller
+// ---------------------------------------------------------------------------
+//
+T_CaInstaller::~T_CaInstaller()
+ {
+ Cancel();
+ iFs.Close();
+ delete iArguments;
+ delete iResults;
+ iInstaller.Close();
+ iSoftwareRegistry.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::NewL
+// ---------------------------------------------------------------------------
+//
+T_CaInstaller *T_CaInstaller::NewL(TInt aPriority)
+ {
+ T_CaInstaller *self = new (ELeave) T_CaInstaller(
+ aPriority );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::T_CaInstaller
+// ---------------------------------------------------------------------------
+//
+T_CaInstaller::T_CaInstaller( TInt aPriority ) :
+ CActive( aPriority ), iInstaller()
+ {
+ CActiveScheduler::Add( this );
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::ConstructL
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::ConstructL()
+ {
+ User::LeaveIfError( iInstaller.Connect() );
+ User::LeaveIfError( iSoftwareRegistry.Connect() );
+ User::LeaveIfError( iFs.Connect() );
+
+ iArguments = COpaqueNamedParams::NewL();
+ iResults = COpaqueNamedParams::NewL();
+
+ iArguments->AddIntL( KSifInParam_InstallInactive, ETrue );
+ iArguments->AddIntL( KSifInParam_InstallSilently, ETrue );
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstallOperation::ConstructL
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::InstallL( const TDesC& aFileName )
+ {
+ if (IsActive())
+ {
+ User::Leave(KErrInUse);
+ }
+
+ iInstaller.Install( aFileName, *iArguments, *iResults, iStatus );
+
+ SetActive();
+
+ iSchedulerWait.Start();
+
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::UnistallL
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::UninstallL(TComponentId aComponentId)
+ {
+ if (IsActive())
+ {
+ User::Leave( KErrInUse );
+ }
+
+ if (aComponentId >= 1)
+ {
+ iInstaller.Uninstall( aComponentId, *iArguments, *iResults, iStatus );
+
+ SetActive();
+
+ iSchedulerWait.Start();
+ }
+
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::UnistallL
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::UninstallL(const TDesC& aFileName)
+ {
+ UninstallL( GetComponentIdL(aFileName) );
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::UnistallL
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::UninstallL( TUint32 aUid )
+ {
+ UninstallL( GetComponentIdL( aUid ) );
+ }
+
+TComponentId T_CaInstaller::GetComponentIdL( const TDesC& aFileName )
+ {
+ CComponentFilter* const fileNameFilter = CComponentFilter::NewLC();
+ fileNameFilter->SetFileL( aFileName );
+
+ RArray<TComponentId> componentIds;
+ CleanupClosePushL( componentIds );
+ iSoftwareRegistry.GetComponentIdsL( componentIds, fileNameFilter );
+
+ TComponentId componentId( 0 );
+
+ if ( componentIds.Count() == 1 )
+ {
+ componentId = componentIds[0];
+ }
+ else if ( componentIds.Count() >= 2 )
+ {
+ User::Leave( KErrGeneral );
+ }
+
+ CleanupStack::PopAndDestroy( &componentIds );
+ CleanupStack::PopAndDestroy( fileNameFilter );
+
+ return componentId;
+ }
+
+TComponentId T_CaInstaller::GetComponentIdForAppIdL( const TDesC& aAppId )
+ {
+ CComponentFilter* const appIdFilter = CComponentFilter::NewLC();
+ appIdFilter->AddPropertyL( _L("AppId"), aAppId );
+
+ RArray<TComponentId> componentIds;
+ CleanupClosePushL( componentIds );
+ iSoftwareRegistry.GetComponentIdsL( componentIds, appIdFilter );
+
+ TComponentId componentId( 0 );
+
+ if ( componentIds.Count() == 1 )
+ {
+ componentId = componentIds[0];
+ }
+ else if ( componentIds.Count() >= 2 )
+ {
+ User::Leave( KErrGeneral );
+ }
+
+ CleanupStack::PopAndDestroy( &componentIds );
+ CleanupStack::PopAndDestroy( appIdFilter );
+
+ return componentId;
+ }
+
+
+TComponentId T_CaInstaller::GetComponentIdL( TInt32 aUid )
+ {
+ TUid uid;
+ TComponentId componentId = iSoftwareRegistry.GetComponentIdForAppL(
+ uid.Uid( aUid ) );
+
+ if ( componentId <= 0 )
+ {
+ User::Leave( KErrGeneral );
+ }
+ return componentId;
+ }
+// ---------------------------------------------------------------------------
+// T_CaInstaller::RunL
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::RunL()
+ {
+ iSchedulerWait.AsyncStop();
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::DoCancel
+// ---------------------------------------------------------------------------
+//
+void T_CaInstaller::DoCancel()
+ {
+ iInstaller.CancelOperation();
+ iSchedulerWait.AsyncStop();
+ }
+
+// ---------------------------------------------------------------------------
+// T_CaInstaller::RunError
+// ---------------------------------------------------------------------------
+//
+TInt T_CaInstaller::RunError(TInt /* aError */)
+ {
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/testutils/testutils.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+# Copyright (c) 2009 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:
+
+
+symbian: {
+ LIBS += \
+ -lsif \
+ -lscrclient \
+ -lxqutils
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += symbian_tests
+
+
+symbian {
+ CONFIG += symbian_test
+ }
+
+ SUBDIRS += \
+ ../castorage/tsrc/t_castorage \
+ ../casoftwareregistry/tsrc/t_casoftwareregistry \
+ ../casrv/caappscanner/tsrc/t_caappscanner \
+ ../casrv/causifscanner/tsrc/t_causifscanner \
+ ../casrv/caprogresscanner/tsrc/t_caprogresscanner \
+ ../casrv/calocalizerscanner/tsrc/t_calocalizerscanner \
+ ../casrv/carunningappmonitor/tsrc/t_carunningappmonitor \
+ ../casrv/casatmonitor/tsrc/t_satmonitor \
+ ../casrv/cawidgetscanner/tsrc/t_cawidgetscanner \
+ t_casrv \
+ t_sathandler \
+ ../caclient/tsrc/t_caclient \
+ ../../homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api \
+ ../cahandler/app/tsrc/t_caapphandler \
+ ../cahandler/tapp/tsrc/t_catapphandler \
+ ../cahandler/url/tsrc/t_caurlhandler
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+#USAGE:
+# Usage: decision_cov.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+ if (($make eq "instrument") || ($make eq "all")) {
+
+ chdir("../../../../contentstorage/casatinterface/group");
+
+ system("del mon.sym");
+ system("del mon.dat");
+ system("del profile.txt");
+ system("rmdir /s /q CTCFUNCTION");
+ system("rmdir /s /q CTCDECISION");
+
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("ctcwrap -i fd -2comp -C EXCLUDE=* -C \"NO_EXCLUDE=../src/MenuSatInterface.cpp\" sbs -j 4 -c winscw_udeb");
+
+
+ chdir("../../../homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api");
+ system("call qmake -config coverage");
+ system("call sbs clean -c winscw_udeb");
+ system("call sbs clean -c winscw_udeb.test");
+ system("call sbs -c winscw_udeb");
+
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("call \\epoc32\\release\\winscw\\udeb\\t_menu_sat_interface_api -o c:\\t_menu_sat_interface_api.log");
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ chdir("../../../../contentstorage/casatinterface/group");
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../../../homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -fd -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o ../../../homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/CTCDECISION");
+ system("call del profile.txt");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/preparesis.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+set TEMPLATE_FILE=t_menu_sat_interface_api_template.pkg
+set EXT=tmp
+
+perl -i.%EXT% -pe"s/\$\(PLATFORM\)/armv5/gm; s/\$\(TARGET\)/urel/gm; s/\(0x2001E61C\)\, \, \, \, \{\"Qt\"\}//gm" %TEMPLATE_FILE%
+
+createsis create -cert ..\..\..\..\sis\rd.cer -key ..\..\..\..\sis\rd-key.pem %TEMPLATE_FILE%
+
+move %TEMPLATE_FILE%.%EXT% %TEMPLATE_FILE%
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/t_menu_sat_interface_api.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h
+
+SOURCES += ./src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/t_menu_sat_interface_api.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,67 @@
+# Copyright (c) 2009 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:
+
+
+TEMPLATE = app
+
+include(../../../../common.pri)
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+} else {
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release \
+ console
+QT += testlib
+
+coverage:DEFINES += COVERAGE_MEASUREMENT
+
+DEPENDPATH += . \
+ ./inc \
+ ./src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../../contentstorage/inc \
+ $$MW_LAYER_SYSTEMINCLUDE
+
+include(t_menu_sat_interface_api.pri)
+
+symbian: {
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20028713
+ TARGET.CAPABILITY = ALL \
+ -TCB
+ TARGET.EPOCSTACKSIZE = 0x14000 \
+ // \
+ 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 \
+ 0x1000000 \
+ // \
+ 128kB \
+ - \
+ 16MB
+
+ LIBS += \
+ -leuser \
+ -lMenuInterface
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api/test.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+t_menu_sat_interface_api.exe -o c:\t_menu_sat_interface_api.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hsappkeyhandler/tsrc/t_hsappkeyhandler/inc/t_hsappkeyhandler.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2007-2009 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:
+*
+*/
+
+#ifndef T_HSAPPKEYHANDLER_H
+#define T_HSAPPKEYHANDLER_H
+
+#include <w32std.h>
+
+#include <QObject>
+
+#include <hb/hbcore/hbdevicedialogsymbian.h>
+
+class CHsAppKeyPlugin;
+
+class T_HsAppKeyHandler : public QObject, public MHbDeviceDialogObserver
+{
+ Q_OBJECT
+
+public:
+ explicit T_HsAppKeyHandler(QObject *parent = 0);
+
+private slots:
+ void callDataReceived();
+ void testDeviceDialogClosed();
+ void testProvideKeyEvents();
+ void testHandleKeyEventIgnoresKeysOtherThanAppKey();
+ void testHandleKeyEventConsumesEverySecondEventForAppKey();
+ void testShortPressSwitchesBetweenHsAndApplibWhenTsIsNotVisible();
+ void testLongPressShowsTaskSwitcher();
+ void testShortPressDismissesTaskSwitcherShownByLongpress();
+ void testLongpressDoesNothingIfTaskSwitcherIsShownByOtherComponent();
+ void testShortPressDismissesTaskSwitcherShownByOtherComponent();
+
+private slots:
+ void init();
+ void cleanup();
+
+public: // from MHbDeviceDialogObserver
+ void DataReceived(CHbSymbianVariantMap &aData);
+ void DeviceDialogClosed(TInt aCompletionCode);
+
+private: // helper methods
+ bool makeShortPress();
+ bool makeLongPress();
+ bool sendKeyEventTwice(TKeyEvent keyEvent);
+
+ bool isTaskSwitcherVisible();
+
+ bool showTaskSwitcher();
+
+private:
+ CHsAppKeyPlugin *mCHsAppKeyPluginInstance;
+ CHbDeviceDialogSymbian *mDialog;
+};
+
+#endif // T_HSAPPKEYHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hsappkeyhandler/tsrc/t_hsappkeyhandler/src/t_hsappkeyhandler.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,343 @@
+/*
+* Copyright (c) 2007-2009 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_hsappkeyhandler.h"
+
+#include <QtTest/QtTest>
+#include <QScopedPointer>
+
+#include <QValueSpaceSubscriber>
+
+#include <hb/hbcore/hbsymbianvariant.h>
+
+#include <tspropertydefs.h>
+#include <homescreendomainpskeys.h>
+
+#include "hsappkeyplugin.h"
+
+QTM_USE_NAMESPACE
+
+namespace {
+ _LIT(KTsPluginName, "com.nokia.taskswitcher.tsdevicedialogplugin/1.0");
+}
+
+// -----------------------------------------------------------------------------
+// CONSTRUCTOR
+// -----------------------------------------------------------------------------
+//
+T_HsAppKeyHandler::T_HsAppKeyHandler(QObject *parent) :
+ QObject(parent),
+ mCHsAppKeyPluginInstance(0),
+ mDialog(0)
+{
+}
+
+// -----------------------------------------------------------------------------
+// INIT AND CLEANUP
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::init()
+{
+ TRAPD(errNo, mCHsAppKeyPluginInstance = CHsAppKeyPlugin::NewL());
+ QCOMPARE(errNo, KErrNone);
+ QVERIFY(mCHsAppKeyPluginInstance);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::cleanup()
+{
+ delete mCHsAppKeyPluginInstance;
+ mCHsAppKeyPluginInstance = 0;
+
+ delete mDialog;
+ mDialog = 0;
+}
+
+// -----------------------------------------------------------------------------
+// TEST CASES
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::callDataReceived()
+{
+ // just call unused part of HbDeviceDialogMonitor interface
+ CHbSymbianVariantMap *dummy;
+ TRAPD(errNo, dummy = CHbSymbianVariantMap::NewL());
+
+ QCOMPARE(errNo, KErrNone);
+ QVERIFY(dummy);
+
+ mCHsAppKeyPluginInstance->DataReceived(*dummy);
+ delete dummy;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testProvideKeyEvents()
+{
+ RArray<TKeyEvent> keyEventArray;
+ CleanupClosePushL(keyEventArray);
+
+ TRAPD(errNo, mCHsAppKeyPluginInstance->ProvideKeyEventsL(keyEventArray));
+ QCOMPARE(errNo, KErrNone);
+
+ QCOMPARE(keyEventArray.Count(), 2);
+
+ TKeyEvent shortPress = keyEventArray[0];
+ QCOMPARE(shortPress.iCode, static_cast<TUint>(EKeyApplication0));
+ QCOMPARE(shortPress.iScanCode, static_cast<TInt>(EStdKeyApplication0));
+ QCOMPARE(shortPress.iModifiers, static_cast<TUint>(0));
+ QCOMPARE(shortPress.iRepeats, 0);
+
+ TKeyEvent longPress = keyEventArray[0];
+ QCOMPARE(longPress.iCode, static_cast<TUint>(EKeyApplication0));
+ QCOMPARE(longPress.iScanCode, static_cast<TInt>(EStdKeyApplication0));
+ QCOMPARE(longPress.iModifiers, static_cast<TUint>(0));
+ QCOMPARE(longPress.iRepeats, 0);
+
+ CleanupStack::PopAndDestroy(&keyEventArray);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testDeviceDialogClosed()
+{
+ // @todo: verify that calling this method closes task switcher
+ mCHsAppKeyPluginInstance->DeviceDialogClosed(0);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testHandleKeyEventIgnoresKeysOtherThanAppKey()
+{
+ TInt errNo(KErrNone);
+ TKeyResponse keyResponse(EKeyWasNotConsumed);
+
+ TKeyEvent invalidKeyEvent;
+ invalidKeyEvent.iCode = !EKeyApplication0;
+
+ TRAP(errNo, keyResponse = mCHsAppKeyPluginInstance->HandleKeyEventL(invalidKeyEvent, EEventNull));
+ QCOMPARE(errNo, KErrNone);
+ QCOMPARE(keyResponse, EKeyWasNotConsumed);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testHandleKeyEventConsumesEverySecondEventForAppKey()
+{
+ TInt errNo(KErrNone);
+ TKeyResponse keyResponse(EKeyWasNotConsumed);
+
+ // verify that for every supported key we consume every second event and ignore the others
+ RArray<TKeyEvent> keyEventArray;
+ CleanupClosePushL(keyEventArray);
+ TRAP(errNo, mCHsAppKeyPluginInstance->ProvideKeyEventsL(keyEventArray));
+ QCOMPARE(errNo, KErrNone);
+
+ for (TInt i(0); i != keyEventArray.Count(); ++i) {
+ TKeyEvent keyEvent = keyEventArray[i];
+
+ // first event ignored
+ TRAP(errNo, keyResponse = mCHsAppKeyPluginInstance->HandleKeyEventL(keyEvent, EEventNull));
+ QCOMPARE(errNo, KErrNone);
+ QCOMPARE(keyResponse, EKeyWasNotConsumed);
+
+ // second event consumed
+ TRAP(errNo, keyResponse = mCHsAppKeyPluginInstance->HandleKeyEventL(keyEvent, EEventNull));
+ QCOMPARE(errNo, KErrNone);
+ QCOMPARE(keyResponse, EKeyWasConsumed);
+ }
+
+ CleanupStack::PopAndDestroy(&keyEventArray);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testShortPressSwitchesBetweenHsAndApplibWhenTsIsNotVisible()
+{
+ // verify preconditions
+ QCOMPARE(isTaskSwitcherVisible(), false);
+
+ QValueSpaceSubscriber hsStateGetter(QString("%1/%2").arg(HsStatePSKeyPath).arg(HsStatePSKeySubPath));
+ QVERIFY(hsStateGetter.isConnected());
+
+ // make sure we start from homescreen
+ if (hsStateGetter.value().toInt() != EHomeScreenIdleState) {
+ QVERIFY(makeShortPress());
+ }
+
+ QVariant initialState = hsStateGetter.value();
+
+ QVERIFY(makeShortPress());
+ QVERIFY(hsStateGetter.value() != initialState);
+
+ QVERIFY(makeShortPress());
+ QVERIFY(hsStateGetter.value() == initialState);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testLongPressShowsTaskSwitcher()
+{
+ // verify preconditions
+ QCOMPARE(isTaskSwitcherVisible(), false);
+
+ QVERIFY(makeLongPress());
+ QCOMPARE(isTaskSwitcherVisible(), true);
+
+ // second longpress does nothing
+ QVERIFY(makeLongPress());
+ QCOMPARE(isTaskSwitcherVisible(), true);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testShortPressDismissesTaskSwitcherShownByLongpress()
+{
+ // verify preconditions
+ QCOMPARE(isTaskSwitcherVisible(), false);
+
+ QVERIFY(makeLongPress());
+ QCOMPARE(isTaskSwitcherVisible(), true);
+
+ QVERIFY(makeShortPress());
+ QCOMPARE(isTaskSwitcherVisible(), false);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testLongpressDoesNothingIfTaskSwitcherIsShownByOtherComponent()
+{
+ // verify preconditions
+ QCOMPARE(isTaskSwitcherVisible(), false);
+ QVERIFY(!mDialog);
+
+ QVERIFY(showTaskSwitcher());
+ QCOMPARE(isTaskSwitcherVisible(), true);
+
+ QVERIFY(makeLongPress());
+ QCOMPARE(isTaskSwitcherVisible(), true);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::testShortPressDismissesTaskSwitcherShownByOtherComponent()
+{
+ // verify preconditions
+ QCOMPARE(isTaskSwitcherVisible(), false);
+ QVERIFY(!mDialog);
+
+ QVERIFY(showTaskSwitcher());
+ QCOMPARE(isTaskSwitcherVisible(), true);
+
+ // after short press the TaskSwitcher will call DeviceDialogClosed callback
+ // of MHbDeviceDialogObserver, which should delete and clear mDialog member.
+ QVERIFY(makeShortPress());
+ QTest::qWait(1000);
+ QCOMPARE(isTaskSwitcherVisible(), false);
+ QVERIFY(!mDialog);
+}
+
+// -----------------------------------------------------------------------------
+// HELPER MEHTODS
+// -----------------------------------------------------------------------------
+//
+
+bool T_HsAppKeyHandler::makeShortPress()
+{
+ TKeyEvent shortpress = {EKeyApplication0, EStdKeyApplication0, 0, 0};
+ return sendKeyEventTwice(shortpress);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+bool T_HsAppKeyHandler::makeLongPress()
+{
+ TKeyEvent longpress = {EKeyApplication0, EStdKeyApplication0, 0, 1};
+ return sendKeyEventTwice(longpress);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+bool T_HsAppKeyHandler::sendKeyEventTwice(TKeyEvent keyEvent)
+{
+ Q_ASSERT(mCHsAppKeyPluginInstance);
+
+ TKeyResponse keyResponse(EKeyWasNotConsumed);
+ // send key event twice (HandleKeyEventL accepts every second event)
+ TRAPD(errNo,
+ mCHsAppKeyPluginInstance->HandleKeyEventL(keyEvent, EEventNull);
+ keyResponse = mCHsAppKeyPluginInstance->HandleKeyEventL(keyEvent, EEventNull);
+ );
+
+ return (KErrNone == errNo) && (EKeyWasConsumed == keyResponse);
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+bool T_HsAppKeyHandler::isTaskSwitcherVisible()
+{
+ QValueSpaceSubscriber tsVisibilityGetter(QString("%1/%2").arg(TsProperty::KTsPath).arg(TsProperty::KVisibilityPath));
+ Q_ASSERT(tsVisibilityGetter.isConnected());
+
+ QVariant tsVisibility = tsVisibilityGetter.value();
+ Q_ASSERT(tsVisibility.isValid());
+ return tsVisibility.toBool();
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+bool T_HsAppKeyHandler::showTaskSwitcher()
+{
+ mDialog = CHbDeviceDialogSymbian::NewL();
+ QScopedPointer<CHbSymbianVariantMap> params(CHbSymbianVariantMap::NewL());
+ return KErrNone == mDialog->Show(KTsPluginName, *params, this);
+}
+
+// ---------------------------------------------------------------------------
+// MHbDeviceDialogObserver implementation
+// ---------------------------------------------------------------------------
+//
+void T_HsAppKeyHandler::DataReceived(CHbSymbianVariantMap &/*aData*/)
+{
+ //no implementation required
+}
+
+void T_HsAppKeyHandler::DeviceDialogClosed(TInt /*aCompletionCode*/)
+{
+ delete mDialog;
+ mDialog = 0;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+QTEST_MAIN(T_HsAppKeyHandler)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hsappkeyhandler/tsrc/t_hsappkeyhandler/t_hsappkeyhandler.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2010 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:
+#
+
+TEMPLATE = app
+CONFIG += testcase mobility
+
+MOBILITY = publishsubscribe
+
+DEPENDPATH += .\
+ ./src \
+ ./inc \
+ ../../src \
+ ../../inc \
+
+INCLUDEPATH += .\
+ ./inc \
+ ../../inc
+
+symbian: {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.UID2 = 0x100039CE
+ TARGET.CAPABILITY = CAP_APPLICATION AllFiles
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ LIBS += -lcone -lapgrfx -lws32 -lecom -leuser -lhbcore -lapparc -lafactivitylauncher
+
+}
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp \
+
+include(../../../common.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hsappkeyhandler/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2010 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:
+#
+
+TEMPLATE = subdirs
+
+SUBDIRS += t_hsappkeyhandler \
+
+CONFIG += ordered
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/sis/t_hswidgetmodel.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+;
+; Copyright (c) 2009 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:
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"t_hswidgetmodel"},(0x20022F52),1,0,0
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Supports S60 5th Edition
+[0x1028315F], 0, 0, 0, {"S60ProductID"}
+
+; HS widget Model unittest
+"/epoc32/release/armv5/urel/t_hswidgetmodelexe.exe" - "c:/sys/bin/t_hswidgetmodelexe.exe"
+"/epoc32/data/z/private/10003a3f/import/apps/t_hswidgetmodelexe_reg.rsc" - "c:/private/10003a3f/import/apps/t_hswidgetmodelexe_reg.rsc"
+"/epoc32/data/z/resource/apps/t_hswidgetmodelexe.rsc" - "c:/resource/apps/t_hswidgetmodelexe.rsc"
+
+;test providers stubs and manifests
+"/epoc32/release/armv5/urel/testwidgetprovider.dll" - "c:/sys/bin/testwidgetprovider.dll"
+"./../testwidgetprovider/qmakepluginstubs/testwidgetprovider.qtplugin" - "c:/hsresources/testresources/plugins/widgetproviders/testwidgetprovider.qtplugin"
+"./../testwidgetprovider/resource/testwidgetprovider.manifest" - "c:/hsresources/testresources/plugins/widgetproviders/testwidgetprovider.manifest"
+
+"./../t_hswidgetmodelexe/invalidwidget.manifest" - "c:/hsresources/testresources/invalidwidget.manifest"
+"./../t_hswidgetmodelexe/notwellformedwidget.manifest" - "c:/hsresources/testresources/notwellformedwidget.manifest"
+"./../t_hswidgetmodelexe/validwidget2.manifest" - "c:/hsresources/testresources/validwidget2.manifest"
+"./../t_hswidgetmodelexe/validwidget.manifest" - "c:/hsresources/testresources/validwidget.manifest"
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/sis/t_hswidgetmodel_sisx.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+@echo off
+
+if exist t_hswidgetmodel.sisx del t_hswidgetmodel.sisx
+
+makesis t_hswidgetmodel.pkg
+signsis t_hswidgetmodel.sis t_hswidgetmodel.sisx ../../../../bin/sis/rd.cer ../../../../bin/sis/rd-key.pem
+
+if exist t_hswidgetmodel.sisx (
+echo t_hswidgetmodel.sisx creation SUCCEEDED
+del t_hswidgetmodel.sis
+)
+
+if not exist t_hswidgetmodel.sisx (
+echo t_hswidgetmodel.sisx creation FAILED
+)
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/decision_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,72 @@
+#
+# Copyright (c) 2009 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: Script for running branch coverage test
+#
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "";
+my $success = GetOptions ("make=s" => \$make);
+
+sub printUsage()
+{
+ print <<USAGE_EOF;
+ Usage : perl decision.pl [-make=make command]
+
+ -make=nmake || make
+
+USAGE_EOF
+ exit 1;
+
+}
+
+if($make)
+{
+system("del mon.sym");
+system("del mon.dat");
+system("rmdir /s /q CTCHTML");
+
+# build hscomponent model lib first
+chdir("..");
+chdir("..");
+system("qmake -r");
+system("call $make distclean");
+system("call qmake -r");
+system("call $make debug");
+
+# build unit test related projects
+chdir(tsrc);
+
+system("qmake -r");
+system("call $make distclean");
+system("call qmake -r");
+system("call $make debug");
+system("call qmake -r");
+system("call $make install");
+chdir("t_hswidgetmodelexe");
+system("call $make distclean");
+system("call qmake -config coverage");
+system("ctcwrap -i fd -C EXCLUDE=* -C NO_EXCLUDE=./../../src/*.cpp $make debug Makefile");
+chdir("debug");
+system("call t_hswidgetmodelexe.exe");
+chdir("..");
+system("call ctcpost -p profile.txt");
+system("call ctc2html -i profile.txt");
+}
+else
+{
+printUsage();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/function_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,75 @@
+#
+# Copyright (c) 2009 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: Script for running function coverage test
+#
+
+#!/usr/bin/perl
+
+
+# import module
+use Getopt::Long;
+
+# read options
+my $make = "";
+my $success = GetOptions ("make=s" => \$make);
+
+sub printUsage()
+{
+ print <<USAGE_EOF;
+ Usage : perl decision.pl [-make=make command]
+
+ -make=nmake || make
+
+USAGE_EOF
+ exit 1;
+
+}
+
+if($make)
+{
+system("del mon.sym");
+system("del mon.dat");
+system("rmdir /s /q CTCHTML");
+
+# build hscomponent model lib first
+chdir("..");
+chdir("..");
+system("qmake -r");
+system("call $make distclean");
+system("call qmake -r");
+system("call $make debug");
+
+# build unit test related projects
+chdir(tsrc);
+
+system("qmake -r");
+system("call $make distclean");
+system("call qmake -r");
+system("call $make debug");
+system("call qmake -r");
+system("call $make install");
+chdir("t_hswidgetmodelexe");
+system("call $make distclean");
+system("call qmake -config coverage");
+system("ctcwrap -i f -C EXCLUDE=* -C NO_EXCLUDE=./../../src/*.cpp $make debug Makefile");
+chdir("debug");
+system("call t_hswidgetmodelexe.exe");
+chdir("..");
+system("call ctcpost -p profile.txt");
+system("call ctc2html -i profile.txt");
+}
+else
+{
+printUsage();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/inc/testwidgetmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,216 @@
+/*
+* Copyright (c) 2008 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#ifndef HOMESCREEN_TEST_TESTWIDGETMODEL_H
+#define HOMESCREEN_TEST_TESTWIDGETMODEL_H
+
+#include <QtTest/QtTest>
+#include "hswidget.h"
+
+#ifdef Q_OS_SYMBIAN
+#include <QDir>
+#endif
+
+
+
+
+
+class TestWidget : public HsWidget
+{
+ Q_OBJECT
+
+public:
+
+ TestWidget(QGraphicsItem* aParent = 0, Qt::WindowFlags aFlags = 0)
+ : HsWidget(aParent, aFlags) {}
+
+protected:
+
+ StartResult onStart()
+ {
+ return mStartResult;
+ }
+
+ SuspendResult onSuspend()
+ {
+ return mSuspendResult;
+ }
+
+ ResumeResult onResume()
+ {
+ return mResumeResult;
+ }
+
+ StopResult onStop()
+ {
+ return mStopResult;
+ }
+
+public:
+
+ void setFaultingState()
+ {
+ setFaulting();
+ }
+
+ void setFaultedState()
+ {
+ setFaulted();
+ }
+
+ void setFinishedState()
+ {
+ setFinished();
+ }
+
+public:
+
+ StartResult mStartResult;
+ SuspendResult mSuspendResult;
+ ResumeResult mResumeResult;
+ StopResult mStopResult;
+
+};
+
+class TestWidget2 : public HsWidget
+{
+ Q_OBJECT
+
+public:
+
+ TestWidget2(QGraphicsItem* aParent = 0, Qt::WindowFlags aFlags = 0)
+ : HsWidget(aParent, aFlags) {}
+
+protected:
+
+ StartResult onStart()
+ {
+ return StartResultFinished;
+ }
+
+ StopResult onStop()
+ {
+ return StopResultFinished;
+ }
+
+};
+
+class TestWidget3 : public HsWidget
+{
+ Q_OBJECT
+
+public:
+
+ TestWidget3(QGraphicsItem* aParent = 0, Qt::WindowFlags aFlags = 0)
+ : HsWidget(aParent, aFlags) {}
+
+protected:
+
+ StartResult onStart()
+ {
+ return mStartResult;
+ }
+
+ StopResult onStop()
+ {
+ return mStopResult;
+ }
+
+public:
+
+ void setFaultingState()
+ {
+ setFaulting();
+ }
+
+ void setFaultedState()
+ {
+ setFaulted();
+ }
+
+ void setFinishedState()
+ {
+ setFinished();
+ }
+
+public:
+
+ StartResult mStartResult;
+ StopResult mStopResult;
+
+};
+
+
+/**
+ * @test Test class for hswidgetmodel library.
+ */
+class TestWidgetModel : public QObject
+{
+ Q_OBJECT
+
+private slots:
+
+ /**
+ * Sets dir for component model's test resources
+ */
+ void initTestCase()
+ {
+#ifdef Q_OS_SYMBIAN
+ QDir::setCurrent("C:/hsresources/testresources/");
+#endif
+ }
+
+
+ /**
+ * hswidget.h
+ */
+ void testWidgetInterface();
+ void testWidgetConstructor();
+ void testWidgetPreferenceService();
+ void testWidgetStart_data();
+ void testWidgetStart();
+ void testWidgetSuspend_data();
+ void testWidgetSuspend();
+ void testWidgetResume_data();
+ void testWidgetResume();
+ void testWidgetStop_data();
+ void testWidgetStop();
+ void testWidgetSetFinished_data();
+ void testWidgetSetFinished();
+ void testWidgetSetFaulted_data();
+ void testWidgetSetFaulted();
+ void testWidgetSetFaulting_data();
+ void testWidgetSetFaulting();
+
+ /**
+ * testwidgetfactory.cpp
+ */
+
+ void testCreateWidget();
+
+ /**
+ * testwidgetprovidermanifest.cpp
+ */
+ void testWidgetProviderManifest();
+ void testWidgetManifests();
+
+
+};
+
+
+#endif // HOMESCREEN_TEST_TESTWIDGETMODEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/installs_win32.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 2009 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:
+#
+
+testfiles.path = ../../../../bin/hstests/
+testfiles.files = ./debug/t_hswidgetmodelexe.exe \
+ ./*.manifest \
+ ../../../../bin/debug/hsruntimeservices.dll \
+ ../../../../bin/debug/hswidgetmodel.dll
+
+runtimeservicesdllrelease.path = ./release/
+runtimeservicesdllrelease.files = ../../../../bin/release/hsruntimeservices.dll \
+ ../../../../bin/release/hswidgetmodel.dll \
+ ./*.manifest
+
+runtimeservicesdlldebug.path = ./debug/
+runtimeservicesdlldebug.files = ../../../../bin/debug/hsruntimeservices.dll \
+ ../../../../bin/debug/hswidgetmodel.dll \
+ ./*.manifest
+
+INSTALLS += testfiles runtimeservicesdllrelease runtimeservicesdlldebug
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/invalidwidget.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<notwidgetprovider>
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget"
+ title="TestWidget"
+ iconuri="test.png"/>
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget2"
+ title="TestWidget2"
+ iconuri="test.png"/>
+</notwidgetprovider>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/notwellformedwidget.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widgetprovider>
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget"
+ title="TestWidget"
+ iconuri="test.png>
+</widgetprovider>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/src/testwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,865 @@
+/*
+* Copyright (c) 2008 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: Tests for WidgetBase class.
+*
+*/
+
+
+#include "testwidgetmodel.h"
+#include "hswidget.h"
+#include "hswidget_p.h"
+#include "ihswidgetpreferenceservice.h"
+
+
+
+
+
+
+void TestWidgetModel::testWidgetInterface()
+{
+ QGraphicsWidget parent;
+
+ TestWidget3 *w = new TestWidget3(&parent);
+ w->mStartResult = HsWidget::StartResultRunning;
+ w->mStopResult = HsWidget::StopResultFinished;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ w->start();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+
+ w->suspend();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+
+ w->resume();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+
+ w->stop();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 1);
+ QCOMPARE(faultedSpy.count(), 0);
+ stoppedSpy.clear();
+
+ w->start();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+
+ w->setFinishedState();
+
+ QCOMPARE(succeededSpy.count(), 1);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+ succeededSpy.clear();
+
+ w->start();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+
+ w->setFaultingState();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 0);
+
+ w->setFaultedState();
+
+ QCOMPARE(succeededSpy.count(), 0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(faultedSpy.count(), 1);
+
+ faultedSpy.clear();
+}
+
+
+void TestWidgetModel::testWidgetConstructor()
+{
+ {
+ TestWidget w(0);
+ QVERIFY(!w.widgetPreferenceService());
+ }
+
+ {
+ HsWidget *parent = new TestWidget(0);
+ QVERIFY(parent);
+ HsWidget *child = new TestWidget(parent);
+ QVERIFY(child);
+ QVERIFY(child->parentItem() == parent);
+ delete parent;
+ }
+}
+
+
+void TestWidgetModel::testWidgetPreferenceService()
+{
+ QGraphicsWidget parent;
+
+ HsWidget *w = new TestWidget(&parent);
+ QObject invalid;
+ w->setProperty("http://homescreen.nokia.com/runtimeservices/widgetpreferenceservice", qVariantFromValue(&invalid));
+ QVERIFY(!w->widgetPreferenceService());
+
+}
+
+
+void TestWidgetModel::testWidgetStart_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("startResult");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Constructed -> Running")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidget::StartResultRunning
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Running")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidget::StartResultRunning
+ << 0
+ << 0
+ << 0;
+
+ // ---
+
+ QTest::newRow("Constructed -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StartResultFinished
+ << 1
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StartResultFinished
+ << 1
+ << 0
+ << 0;
+
+ // ---
+
+ QTest::newRow("Constructed -> Faulted")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StartResultFaulted
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Finished -> Faulted")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StartResultFaulted
+ << 0
+ << 0
+ << 1;
+
+ // ---
+
+ QTest::newRow("Running -> Running")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidget::StartResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Faulting -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::StartResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finishing -> Finishing")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidget::StartResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Suspended -> Suspended")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidget::StartResultFaulted
+ << 0
+ << 0
+ << 0;
+}
+
+
+void TestWidgetModel::testWidgetStart()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, startResult);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+ w->mStartResult = (HsWidget::StartResult)startResult;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->start();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
+
+void TestWidgetModel::testWidgetSuspend_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("suspendResult");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Running -> Suspended")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidget::SuspendResultSuspended
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Running -> Faulted")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::SuspendResultFaulted
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Running -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::SuspendResultFaulting
+ << 0
+ << 0
+ << 0;
+
+ // ---
+
+ QTest::newRow("Constructed -> Constructed")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidget::SuspendResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::SuspendResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Faulting -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::SuspendResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finishing -> Finishing")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidget::SuspendResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Suspended -> Suspended")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidget::SuspendResultFaulted
+ << 0
+ << 0
+ << 0;
+}
+
+
+void TestWidgetModel::testWidgetSuspend()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, suspendResult);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+ w->mSuspendResult = (HsWidget::SuspendResult)suspendResult;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->suspend();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
+
+void TestWidgetModel::testWidgetResume_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("resumeResult");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Suspended -> Running")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidget::ResumeResultRunning
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Suspended -> Faulted")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::ResumeResultFaulted
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Suspended -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::ResumeResultFaulting
+ << 0
+ << 0
+ << 0;
+
+ // ---
+
+ QTest::newRow("Constructed -> Constructed")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidget::ResumeResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Running -> Running")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidget::ResumeResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::ResumeResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Faulting -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::ResumeResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finishing -> Finishing")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidget::ResumeResultFaulted
+ << 0
+ << 0
+ << 0;
+}
+
+
+void TestWidgetModel::testWidgetResume()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, resumeResult);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+ w->mResumeResult = (HsWidget::ResumeResult)resumeResult;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->resume();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
+
+void TestWidgetModel::testWidgetStop_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("stopResult");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Running -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StopResultFinished
+ << 0
+ << 1
+ << 0;
+
+ QTest::newRow("Running -> Finishing")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidget::StopResultFinishing
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Running -> Faulted")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StopResultFaulted
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Running -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::StopResultFaulting
+ << 0
+ << 0
+ << 0;
+
+ // ---
+
+ QTest::newRow("Suspended -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StopResultFinished
+ << 0
+ << 1
+ << 0;
+
+ QTest::newRow("Suspended -> Finishing")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidget::StopResultFinishing
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Suspended -> Faulted")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StopResultFaulted
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Suspended -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::StopResultFaulting
+ << 0
+ << 0
+ << 0;
+
+ // ---
+
+ QTest::newRow("Constructed -> Constructed")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidget::StopResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidget::StopResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Faulting -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidget::StopResultFaulted
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finishing -> Finishing")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidget::StopResultFaulted
+ << 0
+ << 0
+ << 0;
+}
+
+
+void TestWidgetModel::testWidgetStop()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, stopResult);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+ w->mStopResult = (HsWidget::StopResult)stopResult;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->stop();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
+
+void TestWidgetModel::testWidgetSetFinished_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Constructed -> Constructed")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Running -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 1
+ << 0
+ << 0;
+
+ QTest::newRow("Suspended -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 1
+ << 0
+ << 0;
+
+ QTest::newRow("Finishing -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 1
+ << 0;
+
+ QTest::newRow("Faulting -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 1;
+}
+
+
+void TestWidgetModel::testWidgetSetFinished()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->setFinished();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
+
+void TestWidgetModel::testWidgetSetFaulted_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Constructed -> Constructed")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Running -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Suspended -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Finishing -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 1;
+
+ QTest::newRow("Faulting -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 1;
+}
+
+
+void TestWidgetModel::testWidgetSetFaulted()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->setFaulted();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
+
+void TestWidgetModel::testWidgetSetFaulting_data()
+{
+ QTest::addColumn<int>("fromState");
+ QTest::addColumn<int>("toState");
+ QTest::addColumn<int>("succeededEmitCount");
+ QTest::addColumn<int>("stoppedEmitCount");
+ QTest::addColumn<int>("faultedEmitCount");
+
+ // ---
+
+ QTest::newRow("Constructed -> Constructed")
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << (int)HsWidgetPrivate::WidgetStateConstructed
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finished -> Finished")
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << (int)HsWidgetPrivate::WidgetStateFinished
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Faulting -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Running -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateRunning
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Suspended -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateSuspended
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << 0
+ << 0
+ << 0;
+
+ QTest::newRow("Finishing -> Faulting")
+ << (int)HsWidgetPrivate::WidgetStateFinishing
+ << (int)HsWidgetPrivate::WidgetStateFaulting
+ << 0
+ << 0
+ << 0;
+}
+
+
+void TestWidgetModel::testWidgetSetFaulting()
+{
+ QFETCH(int, fromState);
+ QFETCH(int, toState);
+ QFETCH(int, succeededEmitCount);
+ QFETCH(int, stoppedEmitCount);
+ QFETCH(int, faultedEmitCount);
+
+ TestWidget* w = new TestWidget();
+ HsWidgetPrivate *wp = new HsWidgetPrivate(w);
+
+ wp->mState = (HsWidgetPrivate::WidgetState)fromState;
+
+ QSignalSpy succeededSpy(w, SIGNAL(succeeded()));
+ QSignalSpy stoppedSpy(w, SIGNAL(stopped()));
+ QSignalSpy faultedSpy(w, SIGNAL(faulted()));
+
+ wp->setFaulting();
+
+ QVERIFY(wp->mState == toState);
+ QCOMPARE(succeededSpy.count(), succeededEmitCount);
+ QCOMPARE(stoppedSpy.count(), stoppedEmitCount);
+ QCOMPARE(faultedSpy.count(), faultedEmitCount);
+
+ delete w;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/src/testwidgetfactory.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2008 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: Tests for Exception class.
+*
+*/
+
+
+#include "testwidgetmodel.h"
+#include "hswidgetfactory.h"
+#include "hsiwidgetprovider.h"
+#include "hswidget.h"
+
+#include <qglobal.h>
+
+
+
+
+
+
+void TestWidgetModel::testCreateWidget()
+{
+
+ HsWidget* widget = 0;
+
+ HsWidgetFactory factory;
+
+ HsWidgetToken token;
+#ifdef Q_OS_SYMBIAN
+ token.mLibrary = "C:/hsresources/testresources/plugins/widgetproviders/testwidgetprovider.dll";
+#else
+ token.mLibrary = "plugins/widgetproviders/testwidgetprovider.dll";
+#endif
+ token.mUri = "homescreen.nokia.com/widget/testwidget";
+
+ widget = factory.createWidget(token);
+ QVERIFY(widget);
+ delete widget;
+
+ token.mUri = "homescreen.nokia.com/widget/notfound";
+ widget = factory.createWidget(token);
+ QVERIFY(!widget);
+ delete widget;
+
+ token.mLibrary = "notfound";
+ widget = factory.createWidget(token);
+ QVERIFY(!widget);
+ delete widget;
+
+ HsPluginUnloader loader(0);
+ QCoreApplication::processEvents(); // for code coverage to catch deleteLater
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/src/testwidgetmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 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: Main test class for hspluginmodel library.
+*
+*/
+
+
+#include "testwidgetmodel.h"
+#include <QGraphicsScene>
+#include <QGraphicsView>
+
+
+
+
+QTEST_MAIN(TestWidgetModel)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/src/testwidgetprovidermanifest.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2008 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: Tests for WidgetBase class.
+*
+*/
+
+
+#include "testwidgetmodel.h"
+#include "hswidgetprovidermanifest.h"
+#include "hsiwidgetprovider.h"
+
+
+
+
+
+
+void TestWidgetModel::testWidgetProviderManifest()
+{
+
+ HsWidgetProviderManifest manifest1;
+ manifest1.loadFromXml("notfound.manifest");
+ QVERIFY(manifest1.widgets().count() == 0);
+
+ HsWidgetProviderManifest manifest2;
+ manifest2.loadFromXml("notwellformedwidget.manifest");
+ QVERIFY(manifest2.widgets().count() == 0);
+
+ HsWidgetProviderManifest manifest3;
+ manifest3.loadFromXml("invalidwidget.manifest");
+ QVERIFY(manifest3.widgets().count() == 0);
+
+ HsWidgetProviderManifest manifest4;
+ manifest4.loadFromXml("validwidget.manifest");
+
+ QVERIFY(manifest4.loadOnQuery() == false);
+ QVERIFY(manifest4.widgets().count() > 0);
+ QList<HsWidgetToken> widgets = manifest4.widgets();
+ QCOMPARE(widgets.at(0).mLibrary, widgets.at(1).mLibrary);
+ QVERIFY(widgets.at(0).mUri == "homescreen.nokia.com/widget/testwidget");
+
+ HsWidgetProviderManifest manifest5;
+ manifest5.loadFromXml("validwidget2.manifest");
+ QVERIFY(manifest5.loadOnQuery() == true);
+ QVERIFY(manifest5.widgets().count() > 0);
+ QList<HsWidgetToken> widgets5 = manifest5.widgets();
+ QVERIFY(widgets5.at(0).mLibrary == "testwidgetprovider.dll");
+ QVERIFY(widgets5.at(0).mUri == "homescreen.nokia.com/widget/testwidget");
+
+}
+
+void TestWidgetModel::testWidgetManifests()
+{
+ HsWidgetProviderManifest manifest;
+ manifest.loadFromXml("validwidget.manifest");
+ QList<HsWidgetToken> widgets = manifest.widgets();
+ QVERIFY(widgets.count() == 2);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/t_hswidgetmodel.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 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:
+#
+
+HEADERS += ./inc/*.h \
+ ../../inc/*.h \
+ ../../../homescreensrv_plat/hswidgetmodel_api/*.h
+
+SOURCES += ./src/*.cpp \
+ ../../src/*.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/t_hswidgetmodelexe.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,79 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+CONFIG(debug, debug|release) {
+ DESTDIR = debug
+}
+else {
+ DESTDIR = release
+}
+
+CONFIG(debug, debug|release):DESTDIR = debug
+else:DESTDIR = release
+
+CONFIG += debug_and_release \
+ console
+
+CONFIG += hb
+
+CONFIG += qtestlib
+
+QT += xml testlib
+
+
+DEFINES += HOMESCREEN_TEST \
+ HSWIDGETMODEL_TEST
+
+DEPENDPATH += . \
+ ./inc \
+ ./src \
+ ../../inc \
+ ../../src
+
+INCLUDEPATH += . \
+ ./inc \
+ ../../inc \
+ ../../../homescreensrv_plat/hswidgetmodel_api \
+ ../../../inc \
+ ../../../hscontentmodel/inc \
+ ../../../hsutils/inc/
+
+include(t_hswidgetmodel.pri)
+
+symbian: {
+ CONFIG += symbian_test
+ CONFIG -= hb
+ load(hb.prf)
+ CONFIG -= symbian_i18n
+
+ TARGET.UID3 = 0x20022F52
+ TARGET.CAPABILITY = CAP_APPLICATION AllFiles
+
+ export.sources = *.manifest
+ export.path = /hsresources/testresources/
+
+ exportBinaries.sources = testwidgetprovider.dll \
+
+ testplugin.pkg_postrules = "\"../testwidgetprovider/qmakepluginstubs/testwidgetprovider.qtplugin"\"" - ""\"!:\hsresources\testresources\plugins\widgetproviders\testwidgetprovider.qtplugin"\"
+ testplugin.pkg_postrules += "\"../testwidgetprovider/resource/testwidgetprovider.manifest"\"" - ""\"!:\hsresources\testresources\plugins\widgetproviders\testwidgetprovider.manifest"\"
+
+ DEPLOYMENT += export exportBinaries testplugin
+
+}
+
+win32:include(installs_win32.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/validwidget.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widgetprovider>
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget"
+ title="TestWidget"
+ iconuri="test.png"/>
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget2"
+ title="TestWidget2"
+ iconuri="test.png"/>
+</widgetprovider>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/t_hswidgetmodelexe/validwidget2.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widgetprovider loadonquery="true">
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget"
+ title="TestWidget"
+ iconuri="test.png"/>
+</widgetprovider>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/testwidgetprovider/inc/testwidgetprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef HOMESCREEN_TEST_TESTWIDGETPROVIDER_H
+#define HOMESCREEN_TEST_TESTWIDGETPROVIDER_H
+
+#include "hsiwidgetprovider.h"
+#include "hswidget.h"
+
+
+
+
+
+
+class TestWidget : public HsWidget
+{
+ Q_OBJECT
+
+public:
+
+ TestWidget(QGraphicsItem* aParent = 0, Qt::WindowFlags aFlags = 0)
+ : HsWidget(aParent, aFlags) {}
+
+protected:
+
+ StartResult onStart()
+ {
+ return StartResultFinished;
+ }
+
+ StopResult onStop()
+ {
+ return StopResultFinished;
+ }
+
+};
+
+
+class TestWidgetProvider : public QObject, public IHsWidgetProvider
+{
+
+ Q_OBJECT
+ Q_INTERFACES(IHsWidgetProvider)
+
+public:
+
+ TestWidgetProvider();
+ virtual ~TestWidgetProvider();
+
+public:
+
+ QList<HsWidgetToken> widgets();
+ HsWidget* createWidget(const HsWidgetToken& aToken);
+
+private:
+
+ HsWidgetToken mTestWidgetToken;
+
+};
+
+
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/testwidgetprovider/resource/testwidgetprovider.manifest Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widgetprovider>
+ <widget library="testwidgetprovider.dll"
+ uri="homescreen.nokia.com/widget/testwidget"
+ title="TestWidget"
+ iconuri="test.png"/>
+</widgetprovider>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/testwidgetprovider/src/testwidgetprovider.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 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 "testwidgetprovider.h"
+
+
+
+
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+TestWidgetProvider::TestWidgetProvider()
+{
+ mTestWidgetToken.mLibrary = QString("testwidgetprovider.dll");
+ mTestWidgetToken.mUri = QString("homescreen.nokia.com/widget/testwidget");
+ mTestWidgetToken.mTitle = QString("TestWidget");
+ mTestWidgetToken.mIconUri = QString("test.png");
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+TestWidgetProvider::~TestWidgetProvider()
+{
+
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+QList<HsWidgetToken> TestWidgetProvider::widgets()
+{
+ return QList<HsWidgetToken>() << mTestWidgetToken;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+HsWidget* TestWidgetProvider::createWidget(const HsWidgetToken& aToken)
+{
+ HsWidget* widget = 0;
+
+ if(aToken.mUri == mTestWidgetToken.mUri)
+ {
+ widget = new TestWidget();
+ }
+
+ return widget;
+}
+
+
+Q_EXPORT_PLUGIN2(testwidgetprovider, TestWidgetProvider)
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/testwidgetprovider/testwidgetprovider.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2009 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:
+#
+
+
+HEADERS += ./inc/*.h
+
+
+
+SOURCES += ./src/*.cpp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/testwidgetprovider/testwidgetprovider.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = lib
+CONFIG(debug, debug|release) {
+ LIBS += -L../../../../bin/debug -lhswidgetmodel
+ DESTDIR = debug
+}
+else {
+ LIBS += -L../../../../bin/release -lhswidgetmodel
+ DESTDIR = release
+}
+
+CONFIG += debug_and_release plugin
+
+CONFIG += hb
+
+DEPENDPATH += ./inc \
+ ./src
+INCLUDEPATH += ./inc \
+ ../../inc \
+ ../../../homescreensrv_plat/hswidgetmodel_api \
+ ../t_hswidgetmodelexe/inc \
+ ../../../../misc
+
+
+symbian: {
+
+CONFIG += symbian_test
+
+TARGET.UID3 = 0x20022F53
+TARGET.EPOCALLOWDLLDATA=1
+TARGET.CAPABILITY = ALL -TCB
+
+export.sources = resource/*.manifest
+export.path = /hsresources/testresources/plugins/widgetproviders
+pluginstub.sources = testwidgetprovider.dll
+pluginstub.path = /hsresources/testresources/plugins/widgetproviders
+DEPLOYMENT += export pluginstub
+}
+
+include(testwidgetprovider.pri)
+
+win32:include(testwidgetprovider_installs_win32.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/testwidgetprovider/testwidgetprovider_installs_win32.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2009 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:
+#
+#
+# Release
+#
+
+r01.path = ../t_hswidgetmodelexe/release/plugins/widgetproviders
+r01.files = ./release/*.dll
+
+r02.path = ../t_hswidgetmodelexe/release/plugins/widgetproviders
+r02.files = ./resource/*.manifest
+
+testfiles.path = ../../../../bin/hstests/plugins/widgetproviders
+testfiles.files = ./debug/*.dll \
+ ./resource/*.manifest
+
+INSTALLS += r01 r02 testfiles
+
+#
+# Debug
+#
+
+d01.path = ../t_hswidgetmodelexe/debug/plugins/widgetproviders
+d01.files = ./debug/*.dll
+
+d02.path = ../t_hswidgetmodelexe/debug/plugins/widgetproviders
+d02.files = ./resource/*.manifest
+
+INSTALLS += d01 d02
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hswidgetmodel/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+SUBDIRS = testwidgetprovider \
+ t_hswidgetmodelexe
+
+CONFIG += ordered
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/backstepping.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+symbian {
+ BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"group/bld.inf\""
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/bwins/tsbacksteppingu.def Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+ ??1CTsBacksteppingActivation@@UAE@XZ @ 1 NONAME ; CTsBacksteppingActivation::~CTsBacksteppingActivation(void)
+ ?NewL@CTsBacksteppingActivation@@SAPAV1@AAVMTsWindowGroupsMonitor@@@Z @ 2 NONAME ; class CTsBacksteppingActivation * CTsBacksteppingActivation::NewL(class MTsWindowGroupsMonitor &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/eabi/tsbacksteppingu.def Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+ _ZN25CTsBacksteppingActivation4NewLER22MTsWindowGroupsMonitor @ 1 NONAME
+ _ZN25CTsBacksteppingActivationD0Ev @ 2 NONAME
+ _ZN25CTsBacksteppingActivationD1Ev @ 3 NONAME
+ _ZN25CTsBacksteppingActivationD2Ev @ 4 NONAME
+ _ZTI25CTsBacksteppingActivation @ 5 NONAME
+ _ZTV25CTsBacksteppingActivation @ 6 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/group/bld.inf Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+tsbackstepping.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/group/tsbackstepping.mmp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+TARGET tsbackstepping.dll
+TARGETTYPE dll
+UID 0x1000008d 0x200267AD
+SECUREID 0x200267AD
+CAPABILITY ALL -TCB
+
+EPOCHEAPSIZE 0x100000 0x600000 // 1MB - 6MB
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../../inc
+
+SOURCEPATH ../src
+SOURCE tsbackstepping.cpp
+SOURCE tsbacksteppingfilter.cpp
+SOURCE tsbacksteppingactivation.cpp
+
+LIBRARY euser.lib
+LIBRARY ws32.lib // for RWsSession
+LIBRARY apgrfx.lib // for TApaTask / TApaTasksList
+LIBRARY tsutils.lib
+LIBRARY afactivitylauncher.lib
+
+DEBUGLIBRARY flogger.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/inc/tsbackstepping.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef __CBACKSTEPPING_H
+#define __CBACKSTEPPING_H
+
+#include <w32std.h>
+#include <tswindowgroupsobserver.h>
+
+class CTsBacksteppingFilter;
+
+NONSHARABLE_CLASS(CTsBackstepping) : public CTsWindowGroupsObserver
+{
+public:
+ static CTsBackstepping* NewL(MTsWindowGroupsMonitor &);
+ static CTsBackstepping* NewLC(MTsWindowGroupsMonitor &);
+ virtual ~CTsBackstepping();
+
+private:
+ CTsBackstepping(MTsWindowGroupsMonitor &);
+ void ConstructL();
+
+ void HandleWindowGroupChanged(MTsResourceManager &,
+ const TArray<RWsSession::TWindowGroupChainInfo> &);
+
+ void HandleWindowGroupChangedL(MTsResourceManager &,
+ const TArray<RWsSession::TWindowGroupChainInfo> &);
+ TInt homescreenOffsetL(MTsResourceManager &,
+ const TArray<RWsSession::TWindowGroupChainInfo> &) const;
+
+ TInt parentOffsetL(TInt, const TArray<RWsSession::TWindowGroupChainInfo> &) const;
+
+ inline TBool isEmbededApp(const RWsSession::TWindowGroupChainInfo&) const;
+
+ TUid getUidFromWindowGroupL(MTsResourceManager &resources, TInt windowGroupId) const;
+
+private:
+ CTsBacksteppingFilter *mFilter;
+};
+
+#endif // __CBACKSTEPPING_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/inc/tsbacksteppingactivation.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef CTSBACKSTEPPINGWAITINGDLE_H
+#define CTSBACKSTEPPINGWAITINGDLE_H
+
+#include <e32base.h>
+#include <e32property.h>
+
+class MTsWindowGroupsMonitor;
+
+
+class CTsBacksteppingActivation : public CActive
+ {
+public:
+ /**
+ * Two-phased constructor.
+ * @param aPriority priority for the timer.
+ * @return new instance of CTeleWaitingIdle.
+ */
+ IMPORT_C static CTsBacksteppingActivation* NewL(MTsWindowGroupsMonitor &monitor);
+ /**
+ * destructor
+ */
+ IMPORT_C virtual ~CTsBacksteppingActivation();
+
+protected:
+ /**
+ * @see CActive.
+ */
+ void RunL();
+
+ /**
+ * @see CActive::RunError(TInt)
+ */
+ TInt RunError(TInt);
+
+ /**
+ * @see CActive.
+ */
+ void DoCancel();
+
+private:
+ /**
+ * constructor.
+ * @return new instance of CTeleWaitingIdle.
+ */
+ CTsBacksteppingActivation(MTsWindowGroupsMonitor &monitor);
+
+ void ConstructL();
+
+ void Subscribe();
+
+private:
+ MTsWindowGroupsMonitor &mMonitor;
+
+ // Central Repository.
+ RProperty mProperty;
+
+ // Backstepping engine. Own
+ CBase* mEngine;
+ };
+
+#endif /* CTSBACKSTEPPINGWAITINGDLE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/inc/tsbacksteppingfilter.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef TSBACKSTEPPINGFILTER_H
+#define TSBACKSTEPPINGFILTER_H
+
+#include <w32std.h>
+#include <tswindowgroupsobserver.h>
+
+
+NONSHARABLE_CLASS(CTsBacksteppingFilter) : public CBase
+{
+public:
+ static CTsBacksteppingFilter* NewL();
+ ~CTsBacksteppingFilter();
+
+ TBool isBlocked(TUid applicationUid) const;
+
+private:
+ CTsBacksteppingFilter();
+ void ConstructL();
+
+private:
+ RArray<TUid> mBlockedApps;
+
+};
+
+#endif // TSBACKSTEPPINGFILTER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/src/tsbackstepping.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,196 @@
+/*
+* Copyright (c) 2009 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 "tsbackstepping.h"
+
+#include <w32std.h>// key event
+#include <apgwgnam.h>// for CApaWindowGroupName
+#include <apgtask.h>
+#include <coedef.h>
+#include <e32property.h>
+
+#include <homescreendomainpskeys.h>
+#include <afactivitylauncher.h>
+
+#include "tsbacksteppingfilter.h"
+
+_LIT(KHsActivactionUri, "appto://20022F35?activityname=HsIdleView&activityinbackground=true");
+
+/**
+ * CTsBackstepping::NewL
+ * two phase constructor
+ */
+CTsBackstepping* CTsBackstepping::NewL(MTsWindowGroupsMonitor &monitor)
+ {
+ CTsBackstepping* self = CTsBackstepping::NewLC(monitor);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+ * CTsBackstepping::NewLC
+ * two phase constructor
+ */
+CTsBackstepping* CTsBackstepping::NewLC(MTsWindowGroupsMonitor &monitor)
+{
+ CTsBackstepping* self = new (ELeave) CTsBackstepping(monitor);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+/**
+ * CTsBackstepping::CTsBackstepping
+ * constructor
+ */
+CTsBackstepping::CTsBackstepping(MTsWindowGroupsMonitor &monitor)
+:
+CTsWindowGroupsObserver(monitor)
+{
+}
+
+/**
+ * CTsBackstepping::~CTsBackstepping
+ * deconstructor
+ */
+CTsBackstepping::~CTsBackstepping()
+{
+ delete mFilter;
+}
+
+/**
+ * CTsBackstepping::ConstructL
+ * two phase constructor
+ */
+void CTsBackstepping::ConstructL ()
+{
+ BaseConstructL();
+ mFilter = CTsBacksteppingFilter::NewL();
+}
+
+/**
+ * CTsBackstepping::AnalyseWindowStackL
+ * Analyzes window stack and move homescreen to proper position
+ */
+void CTsBackstepping::HandleWindowGroupChanged(MTsResourceManager &resource, const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups)
+{
+ TRAP_IGNORE(HandleWindowGroupChangedL(resource, windowGroups));
+}
+
+/**
+ * CTsBackstepping::AnalyseWindowStackL
+ * Analyzes window stack and move homescreen to proper position
+ */
+void CTsBackstepping::HandleWindowGroupChangedL(MTsResourceManager &resource,
+ const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups)
+{
+ // calculate the desired position of Homescreen
+ const TInt currentHsOffset(homescreenOffsetL(resource, windowGroups));
+ TInt optimalOffset(1);
+ TInt targetHsOffset(currentHsOffset);
+ for (TInt offset(0); offset < currentHsOffset; ++offset) {
+ TUid uid = getUidFromWindowGroupL(resource, windowGroups[offset].iId);
+ if (TUid::Null() != uid) {
+ if (isEmbededApp(windowGroups[offset])) {
+ targetHsOffset = parentOffsetL(offset, windowGroups) + 1;
+ } else if (!mFilter->isBlocked(uid)) {
+ if(offset + 1 < currentHsOffset &&
+ getUidFromWindowGroupL(resource, windowGroups[offset+1].iId) == TUid::Null()) {
+ ++optimalOffset;
+ }
+ targetHsOffset = optimalOffset;
+ }
+ break;
+ } else {
+ ++optimalOffset;
+ }
+ }
+
+ // change windows order if necessary
+ if (targetHsOffset != currentHsOffset) {
+ const TInt hsWindowGroup(windowGroups[currentHsOffset].iId);
+ resource.WsSession().SetWindowGroupOrdinalPosition(hsWindowGroup, targetHsOffset);
+ }
+
+ // switch Homescreen to Idle state if Homescreen is not in foreground and is in different state
+ if (targetHsOffset != 0) {
+ TInt hsState(EHomeScreenIdleState);
+ User::LeaveIfError(RProperty::Get(KHsCategoryUid, KHsCategoryStateKey, hsState));
+ if (hsState != EHomeScreenIdleState) {
+ CAfActivityLauncher *activityEnabler =
+ CAfActivityLauncher::NewLC(resource.ApaSession(),
+ resource.WsSession());
+ activityEnabler->launchActivityL(KHsActivactionUri);
+ CleanupStack::PopAndDestroy(activityEnabler);
+ }
+ }
+}
+
+/**
+ * CTsBackstepping::homescreenOffsetL
+ */
+TInt CTsBackstepping::homescreenOffsetL(MTsResourceManager &resource,
+ const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups) const
+{
+ TInt offset(KErrNotFound);
+ for (TInt iter(0);KErrNotFound == offset && iter < windowGroups.Count(); ++iter) {
+ if (KHsCategoryUid == getUidFromWindowGroupL(resource, windowGroups[iter].iId)) {
+ offset = iter;
+ }
+ }
+ User::LeaveIfError(offset);
+ return offset;
+}
+
+/**
+ * CTsBackstepping::homescreenOffsetL
+ */
+TInt CTsBackstepping::parentOffsetL(TInt offset,
+ const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups) const
+{
+ for(TInt iter(offset + 1); iter < windowGroups.Count(); ++iter) {
+ if(windowGroups[iter].iId == windowGroups[offset].iParentId) {
+ return isEmbededApp(windowGroups[iter]) ?
+ parentOffsetL(iter, windowGroups) : iter;
+ }
+ }
+ User::Leave(KErrNotFound);
+ return KErrNotFound;
+}
+
+/**
+ * CTsBackstepping::isEmbededApp
+ */
+TBool CTsBackstepping::isEmbededApp(const RWsSession::TWindowGroupChainInfo &windowGroupInfo) const
+{
+ return 0 < windowGroupInfo.iParentId;
+}
+
+/**
+ * CTsBackstepping::getUidFromWindowGroupL
+ */
+TUid CTsBackstepping::getUidFromWindowGroupL(MTsResourceManager &resource, TInt windowGroupId) const
+{
+ TUid retVal(TUid::Null());
+ CApaWindowGroupName *windowGroupName = CApaWindowGroupName::NewLC(resource.WsSession());
+ windowGroupName->ConstructFromWgIdL(windowGroupId);
+ retVal = windowGroupName->AppUid();
+ CleanupStack::PopAndDestroy(windowGroupName);
+ return retVal;
+}
+
+// end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/src/tsbacksteppingactivation.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2009 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 <startupdomainpskeys.h>
+#include <flogger.h>
+#include <w32std.h>
+
+#include "tsbacksteppingactivation.h"
+#include "tsbackstepping.h"
+
+ // ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CBacksteppingActivation::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTsBacksteppingActivation* CTsBacksteppingActivation::NewL(MTsWindowGroupsMonitor &monitor)
+{
+ CTsBacksteppingActivation* self = new( ELeave ) CTsBacksteppingActivation(monitor);
+ self->ConstructL();
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+// CTsBacksteppingActivation::CTsBacksteppingActivation
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTsBacksteppingActivation::CTsBacksteppingActivation(MTsWindowGroupsMonitor &monitor)
+:
+ CActive(EPriorityLow),
+ mMonitor(monitor)
+{
+ CActiveScheduler::Add(this);
+}
+
+// -----------------------------------------------------------------------------
+// CTsBacksteppingActivation::ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CTsBacksteppingActivation::ConstructL()
+{
+ User::LeaveIfError(mProperty.Attach(KPSUidStartup, KPSIdlePhase1Ok));
+ iStatus = KRequestPending;
+ SetActive();
+ TRequestStatus* status(&iStatus);
+ User::RequestComplete(status, KErrNone);
+}
+
+// -----------------------------------------------------------------------------
+// CTsBacksteppingActivation::~CTsBacksteppingActivation
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTsBacksteppingActivation::~CTsBacksteppingActivation()
+{
+ Cancel();
+ delete mEngine;
+ mProperty.Close();
+}
+
+// -----------------------------------------------------------------------------
+// CBacksteppingActivation::DoCancel
+//
+// -----------------------------------------------------------------------------
+//
+void CTsBacksteppingActivation::DoCancel()
+{
+ if ( IsActive() && mProperty.Handle() ) {
+ mProperty.Cancel();
+ }
+}
+
+// -----------------------------------------------------------------------------
+// CBacksteppingActivation::RunL
+//
+// -----------------------------------------------------------------------------
+//
+void CTsBacksteppingActivation::RunL()
+{
+ User::LeaveIfError(iStatus.Int());
+
+ TInt state(~EIdlePhase1Ok);
+ User::LeaveIfError(mProperty.Get(state));
+
+ if (EIdlePhase1Ok == state) {
+ if (0 == mEngine) {
+ mEngine = CTsBackstepping::NewL(mMonitor);
+ }
+ } else {
+ delete mEngine;
+ mEngine = 0;
+ }
+ Subscribe();
+}
+
+// -----------------------------------------------------------------------------
+// CBacksteppingActivation::RunError
+//
+// -----------------------------------------------------------------------------
+//
+TInt CTsBacksteppingActivation::RunError(TInt error)
+{
+ if (KErrCancel != error) {
+ Subscribe();
+ }
+ return KErrNone;
+}
+
+// -----------------------------------------------------------------------------
+// CBacksteppingActivation::Subscribe
+//
+// -----------------------------------------------------------------------------
+//
+void CTsBacksteppingActivation::Subscribe()
+{
+ mProperty.Subscribe(iStatus);
+ SetActive();
+}
+// end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/src/tsbacksteppingfilter.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 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 "tsbacksteppingfilter.h"
+
+const TInt KBlockedApps [] = {0x100058b3/* <-- phoneui.exe */};
+
+/**
+ * CTsBacksteppingFilter::NewL
+ */
+CTsBacksteppingFilter* CTsBacksteppingFilter::NewL()
+{
+ CTsBacksteppingFilter *self = new(ELeave)CTsBacksteppingFilter();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+/**
+ * CTsBacksteppingFilter::~CTsBacksteppingFilter
+ */
+CTsBacksteppingFilter::~CTsBacksteppingFilter()
+{
+ mBlockedApps.Close();
+}
+
+/**
+ * CTsBacksteppingFilter::isBlocked
+ */
+TBool CTsBacksteppingFilter::isBlocked(TUid applicationUid) const
+{
+ return KErrNotFound != mBlockedApps.Find(applicationUid);
+}
+
+/**
+ * CTsBacksteppingFilter::CTsBacksteppingFilter
+ */
+CTsBacksteppingFilter::CTsBacksteppingFilter()
+{
+}
+
+/**
+ * CTsBacksteppingFilter::ConstructL
+ */
+void CTsBacksteppingFilter::ConstructL()
+{
+ const TInt count(sizeof(KBlockedApps) / sizeof(TInt));
+ for(TInt offset(0);offset < count; ++offset) {
+ mBlockedApps.AppendL(TUid::Uid(KBlockedApps[offset]));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/tsrc/t_tsbackstepping/t_tsbackstepping.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,109 @@
+/** Copyright (c) 2009 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 <QtTest/QtTest>
+#include <QPixmap>
+#include <e32std.h>
+#include <AknDef.h>
+#include <QString>
+#include <qdebug>
+#include <apgcli.h>
+#include <apacmdln.h>
+#include <apgtask.h>
+#include <eikenv.h>
+#include <s32strm.h>
+#include <S32MEM.H>
+#include <APGWGNAM.H>
+#include <FBS.H>
+#include "t_tsbackstepping.h"
+#include "tsbackstepping.h"
+#include <tsresourcemanager.h>
+#include <tswindowgroupsobserver.h>
+
+#include "tstestutils.h"
+
+const TUid KIconApplicationUid = {0xEd0b4e47};
+const TUid KNoIconApplicationUid = {0xE453fc1b};
+const TUid KHsApplicationUid = {0x20022F35};
+
+namespace {
+ const char KIconApplicationName[] = "appwithicon";
+ const char KNoIconApplicationName[] = "appwithouticon";
+}
+
+// -----------------------------------------------------------------------------
+// init and cleanup methods
+// -----------------------------------------------------------------------------
+//
+void TestBackStepping::initTestCase()
+{
+ mResources = CTsResourceManager::NewL();
+ mMonitor = CTsWindowGroupsMonitor::NewL(*mResources);
+}
+
+void TestBackStepping::cleanupTestCase()
+{
+ delete mMonitor;
+ delete mResources;
+}
+
+// -----------------------------------------------------------------------------
+// test cases
+// -----------------------------------------------------------------------------
+//
+void TestBackStepping::testBacksteppingMovesHomescreenToSecondPosition()
+{
+ // start test applicationss
+ quint64 iconAppId;
+ quint64 noIconAppId;
+ QVERIFY(TsTestUtils::startApplication(KIconApplicationName, iconAppId));
+ QVERIFY(TsTestUtils::startApplication(KNoIconApplicationName, noIconAppId));
+
+ // get window group list that will be passed to backstepping algorithm
+ RArray<RWsSession::TWindowGroupChainInfo> windowGroupList;
+ QCOMPARE(mResources->WsSession().WindowGroupList(0, &windowGroupList), KErrNone);
+
+ // we don't test window server events monitor. manually force backstepping algorithm
+ CTsBackstepping *backstepping = CTsBackstepping::NewL(*mMonitor);
+ static_cast<MTsWindowGroupsObserver*>(backstepping)->HandleWindowGroupChanged(*mResources, windowGroupList.Array());
+
+ // read window group list list after backstepping
+ QCOMPARE(mResources->WsSession().WindowGroupList(0, &windowGroupList), KErrNone);
+
+ QCOMPARE(getUidForWgId(windowGroupList[0].iId), KNoIconApplicationUid);
+ QCOMPARE(getUidForWgId(windowGroupList[1].iId), KHsApplicationUid);
+ QCOMPARE(getUidForWgId(windowGroupList[2].iId), KIconApplicationUid);
+
+ delete backstepping;
+ windowGroupList.Close();
+
+ // close test applications
+ QVERIFY(TsTestUtils::closeApplication(noIconAppId));
+ QVERIFY(TsTestUtils::closeApplication(iconAppId));
+}
+
+// -----------------------------------------------------------------------------
+// helper method
+// -----------------------------------------------------------------------------
+//
+TUid TestBackStepping::getUidForWgId(int wgId) const
+{
+ CApaWindowGroupName *windowName = CApaWindowGroupName::NewLC(mResources->WsSession(), wgId);
+ TUid appUid = windowName->AppUid();
+ CleanupStack::PopAndDestroy(windowName);
+ return appUid;
+}
+
+QTEST_MAIN(TestBackStepping)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/tsrc/t_tsbackstepping/t_tsbackstepping.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+#include <w32std.h>
+
+class CTsResourceManager;
+class CTsWindowGroupsMonitor;
+
+class TestBackStepping : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void testBacksteppingMovesHomescreenToSecondPosition();
+
+private:
+ TUid getUidForWgId(int wgId) const;
+
+public:
+ CTsResourceManager *mResources;
+ CTsWindowGroupsMonitor *mMonitor;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/tsrc/t_tsbackstepping/t_tsbackstepping.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console
+
+INCLUDEPATH += ../../../../inc
+
+HEADERS += t_tsbackstepping.h
+SOURCES += t_tsbackstepping.cpp
+
+HEADERS += ../../inc/tsbackstepping.h \
+ ../../inc/tsbacksteppingfilter.h \
+
+SOURCES += ../../src/tsbackstepping.cpp \
+ ../../src/tsbacksteppingfilter.cpp \
+
+LIBS += -lestor.dll
+LIBS += -lapparc.dll
+LIBS += -lfbscli.dll
+LIBS += -lbitgdi.dll
+LIBS += -laknicon.dll
+
+LIBS += -leuser.dll
+LIBS += -lws32.dll #// for RWsSession
+LIBS += -lapgrfx.dll #// for TApaTask / TApaTasksList
+LIBS += -ltsutils.dll
+LIBS += -lafactivitylauncher
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
+
+symbian {
+CONFIG += symbian_test
+coverage: CONFIG -= symbian_test
+TARGET.CAPABILITY = ALL -TCB
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/backstepping/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS += ../../../internal/tsapps/testapp
+SUBDIRS += t_tsbackstepping
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/bwins/tstaskmonitorclientu.def Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+EXPORTS
+ ?taskListChanged@TsTaskMonitor@@IAEXXZ @ 1 NONAME ; void TsTaskMonitor::taskListChanged(void)
+ ?close@TsTask@@QAEXXZ @ 2 NONAME ; void TsTask::close(void)
+ ?SetVisibility@CTsScreenshotClient@@QAEHHW4Visibility@@@Z @ 3 NONAME ; int CTsScreenshotClient::SetVisibility(int, enum Visibility)
+ ?tr@TsTaskMonitor@@SA?AVQString@@PBD0@Z @ 4 NONAME ; class QString TsTaskMonitor::tr(char const *, char const *)
+ ?oldOffset@TsTaskChangeInfo@@QBEHXZ @ 5 NONAME ; int TsTaskChangeInfo::oldOffset(void) const
+ ?name@TsTask@@QBE?AVQString@@XZ @ 6 NONAME ; class QString TsTask::name(void) const
+ ?isClosable@TsTask@@QBE_NXZ @ 7 NONAME ; bool TsTask::isClosable(void) const
+ ?changeType@TsTaskChangeInfo@@QBE?AW4ChangeType@1@XZ @ 8 NONAME ; enum TsTaskChangeInfo::ChangeType TsTaskChangeInfo::changeType(void) const
+ ??0TsTaskMonitor@@QAE@PAVQObject@@@Z @ 9 NONAME ; TsTaskMonitor::TsTaskMonitor(class QObject *)
+ ?qt_metacall@TsTaskMonitor@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 10 NONAME ; int TsTaskMonitor::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?trUtf8@TsTaskMonitor@@SA?AVQString@@PBD0@Z @ 11 NONAME ; class QString TsTaskMonitor::trUtf8(char const *, char const *)
+ ?staticMetaObject@TsTaskMonitor@@2UQMetaObject@@B @ 12 NONAME ; struct QMetaObject const TsTaskMonitor::staticMetaObject
+ ?RegisterScreenshot@CTsScreenshotClient@@QAEHPAVCFbsBitmap@@HW4UpdatePriority@@@Z @ 13 NONAME ; int CTsScreenshotClient::RegisterScreenshot(class CFbsBitmap *, int, enum UpdatePriority)
+ ?UnregisterScreenshot@CTsScreenshotClient@@QAEHH@Z @ 14 NONAME ; int CTsScreenshotClient::UnregisterScreenshot(int)
+ ?changeList@TsTaskMonitor@@QAE?AV?$QList@U?$QPair@VTsTaskChangeInfo@@V?$QSharedPointer@VTsTask@@@@@@@@_N@Z @ 15 NONAME ; class QList<struct QPair<class TsTaskChangeInfo, class QSharedPointer<class TsTask> > > TsTaskMonitor::changeList(bool)
+ ??1CTsScreenshotClient@@UAE@XZ @ 16 NONAME ; CTsScreenshotClient::~CTsScreenshotClient(void)
+ ?NewLC@CTsScreenshotClient@@SAPAV1@XZ @ 17 NONAME ; class CTsScreenshotClient * CTsScreenshotClient::NewLC(void)
+ ??_ETsTaskMonitor@@UAE@I@Z @ 18 NONAME ; TsTaskMonitor::~TsTaskMonitor(unsigned int)
+ ?getStaticMetaObject@TsTaskMonitor@@SAABUQMetaObject@@XZ @ 19 NONAME ; struct QMetaObject const & TsTaskMonitor::getStaticMetaObject(void)
+ ?metaObject@TsTaskMonitor@@UBEPBUQMetaObject@@XZ @ 20 NONAME ; struct QMetaObject const * TsTaskMonitor::metaObject(void) const
+ ?registerScreenshot@TsTaskSettings@@QAE_NABVQPixmap@@@Z @ 21 NONAME ; bool TsTaskSettings::registerScreenshot(class QPixmap const &)
+ ?NewL@CTsScreenshotClient@@SAPAV1@XZ @ 22 NONAME ; class CTsScreenshotClient * CTsScreenshotClient::NewL(void)
+ ??1TsTaskSettings@@QAE@XZ @ 23 NONAME ; TsTaskSettings::~TsTaskSettings(void)
+ ?qt_metacast@TsTaskMonitor@@UAEPAXPBD@Z @ 24 NONAME ; void * TsTaskMonitor::qt_metacast(char const *)
+ ?open@TsTask@@QAEXXZ @ 25 NONAME ; void TsTask::open(void)
+ ?trUtf8@TsTaskMonitor@@SA?AVQString@@PBD0H@Z @ 26 NONAME ; class QString TsTaskMonitor::trUtf8(char const *, char const *, int)
+ ??1TsTaskMonitor@@UAE@XZ @ 27 NONAME ; TsTaskMonitor::~TsTaskMonitor(void)
+ ??0TsTaskChangeInfo@@QAE@HH@Z @ 28 NONAME ; TsTaskChangeInfo::TsTaskChangeInfo(int, int)
+ ??0TsTaskSettings@@QAE@XZ @ 29 NONAME ; TsTaskSettings::TsTaskSettings(void)
+ ?screenshot@TsTask@@QBE?AVQPixmap@@XZ @ 30 NONAME ; class QPixmap TsTask::screenshot(void) const
+ ?newOffset@TsTaskChangeInfo@@QBEHXZ @ 31 NONAME ; int TsTaskChangeInfo::newOffset(void) const
+ ?unregisterScreenshot@TsTaskSettings@@QAE_NXZ @ 32 NONAME ; bool TsTaskSettings::unregisterScreenshot(void)
+ ?isActive@TsTask@@QBE_NXZ @ 33 NONAME ; bool TsTask::isActive(void) const
+ ??1TsTask@@QAE@XZ @ 34 NONAME ; TsTask::~TsTask(void)
+ ?setVisibility@TsTaskSettings@@QAE_N_N@Z @ 35 NONAME ; bool TsTaskSettings::setVisibility(bool)
+ ?tr@TsTaskMonitor@@SA?AVQString@@PBD0H@Z @ 36 NONAME ; class QString TsTaskMonitor::tr(char const *, char const *, int)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/client.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,78 @@
+#
+# Copyright (c) 2009 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:
+#
+
+INCLUDEPATH += $$PWD/inc
+
+HEADERS += $$PWD/inc/tstaskmonitor.h \
+ $$PWD/inc/tstask.h \
+ $$PWD/inc/tstasklauncher.h \
+ $$PWD/inc/tstaskcontent.h \
+ $$PWD/inc/tstaskchangeinfo.h
+
+SOURCES += $$PWD/src/tstaskmonitor.cpp \
+ $$PWD/src/tstask.cpp \
+ $$PWD/src/tstaskchangeinfo.cpp \
+
+symbian {
+ INCLUDEPATH += $$PWD/s60/inc \
+ $$PWD/../inc \
+ $$PWD/../utils/inc \
+ $$PWD/../../inc \
+
+ HEADERS += $$PWD/s60/inc/tstaskmonitorobserver.h \
+ $$PWD/s60/inc/tstaskmonitorclient.h \
+ $$PWD/s60/inc/tstaskmonitorclientimpl.h \
+ $$PWD/s60/inc/tssession.h \
+ $$PWD/../utils/inc/tsentry.h \
+ $$PWD/../utils/inc/tsentrykey.h \
+ $$PWD/../utils/inc/tsutils.h \
+ $$PWD/../utils/inc/tsscreenshotmsg.h \
+ $$PWD/../utils/inc/tsunregscreenshotmsg.h \
+ $$PWD/../utils/inc/tsvisibilitymsg.h \
+ $$PWD/s60/inc/tstaskmonitor_p.h \
+ $$PWD/s60/inc/tsscreenshotclient.h \
+ $$PWD/s60/inc/tsscreenshotclientimpl.h \
+ $$PWD/s60/inc/tstasksettings_p.h \
+ $$PWD/../../homescreensrv_plat/taskswitcher_api/tstasksettings.h \
+
+ SOURCES += $$PWD/s60/src/tstaskmonitorclient.cpp \
+ $$PWD/s60/src/tstaskmonitorclientimpl.cpp \
+ $$PWD/s60/src/tssession.cpp \
+ $$PWD/../utils/src/tsentry.cpp \
+ $$PWD/../utils/src/tsentrykey.cpp \
+ $$PWD/../utils/src/tsscreenshotmsg.cpp \
+ $$PWD/../utils/src/tsunregscreenshotmsg.cpp \
+ $$PWD/../utils/src/tsvisibilitymsg.cpp \
+ $$PWD/s60/src/tstaskmonitor_p.cpp \
+ $$PWD/s60/src/tsscreenshotclient.cpp \
+ $$PWD/s60/src/tsscreenshotclientimpl.cpp \
+ $$PWD/src/tstasksettings.cpp \
+ $$PWD/s60/src/tstasksettings_p.cpp \
+
+ LIBS += -lxqutils \
+ -lestor \
+ -lfbscli
+
+} else {
+ INCLUDEPATH += $$PWD/stub/inc \
+
+ HEADERS += $$PWD/stub/inc/tstaskmonitor_p.h \
+ $$PWD/stub/inc/tstasksettings_p.h \
+
+ SOURCES += $$PWD/stub/src/tstaskmonitor_p.cpp \
+ $$PWD/stub/src/tstasksettings_p.cpp \
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/client.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = lib
+TARGET = tstaskmonitorclient
+
+CONFIG += dll
+
+DEFINES += TSTASKMONITOR_LIB
+
+symbian {
+ dll.sources = tstaskmonitorclient.dll
+ dll.path = $$SHARED_LIB_DIR
+ DEPLOYMENT += dll
+ LIBS += -ltsutils -lws32 -lapgrfx -lcone
+
+ BLD_INF_RULES.prj_exports += "inc/tstaskmonitor.h |../../inc/tstaskmonitor.h" \
+ "inc/tstask.h |../../inc/tstask.h" \
+ "inc/tstaskchangeinfo.h |../../inc/tstaskchangeinfo.h" \
+
+ TARGET.UID3 = 0x200267AF
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA = 1
+
+}
+
+include(client.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/eabi/tstaskmonitorclientu.def Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+EXPORTS
+ _ZN13TsTaskMonitor10changeListEb @ 1 NONAME
+ _ZN13TsTaskMonitor11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME
+ _ZN13TsTaskMonitor11qt_metacastEPKc @ 3 NONAME
+ _ZN13TsTaskMonitor15taskListChangedEv @ 4 NONAME
+ _ZN13TsTaskMonitor16staticMetaObjectE @ 5 NONAME DATA 16
+ _ZN13TsTaskMonitor19getStaticMetaObjectEv @ 6 NONAME
+ _ZN13TsTaskMonitorC1EP7QObject @ 7 NONAME
+ _ZN13TsTaskMonitorC2EP7QObject @ 8 NONAME
+ _ZN13TsTaskMonitorD0Ev @ 9 NONAME
+ _ZN13TsTaskMonitorD1Ev @ 10 NONAME
+ _ZN13TsTaskMonitorD2Ev @ 11 NONAME
+ _ZN14TsTaskSettings13setVisibilityEb @ 12 NONAME
+ _ZN14TsTaskSettings18registerScreenshotERK7QPixmap @ 13 NONAME
+ _ZN14TsTaskSettings20unregisterScreenshotEv @ 14 NONAME
+ _ZN14TsTaskSettingsC1Ev @ 15 NONAME
+ _ZN14TsTaskSettingsC2Ev @ 16 NONAME
+ _ZN14TsTaskSettingsD1Ev @ 17 NONAME
+ _ZN14TsTaskSettingsD2Ev @ 18 NONAME
+ _ZN16TsTaskChangeInfoC1Eii @ 19 NONAME
+ _ZN16TsTaskChangeInfoC2Eii @ 20 NONAME
+ _ZN19CTsScreenshotClient13SetVisibilityEi10Visibility @ 21 NONAME
+ _ZN19CTsScreenshotClient18RegisterScreenshotEP10CFbsBitmapi14UpdatePriority @ 22 NONAME
+ _ZN19CTsScreenshotClient20UnregisterScreenshotEi @ 23 NONAME
+ _ZN19CTsScreenshotClient4NewLEv @ 24 NONAME
+ _ZN19CTsScreenshotClient5NewLCEv @ 25 NONAME
+ _ZN19CTsScreenshotClientD0Ev @ 26 NONAME
+ _ZN19CTsScreenshotClientD1Ev @ 27 NONAME
+ _ZN19CTsScreenshotClientD2Ev @ 28 NONAME
+ _ZN6TsTask4openEv @ 29 NONAME
+ _ZN6TsTask5closeEv @ 30 NONAME
+ _ZN6TsTaskD1Ev @ 31 NONAME
+ _ZN6TsTaskD2Ev @ 32 NONAME
+ _ZNK13TsTaskMonitor10metaObjectEv @ 33 NONAME
+ _ZNK16TsTaskChangeInfo10changeTypeEv @ 34 NONAME
+ _ZNK16TsTaskChangeInfo9newOffsetEv @ 35 NONAME
+ _ZNK16TsTaskChangeInfo9oldOffsetEv @ 36 NONAME
+ _ZNK6TsTask10isClosableEv @ 37 NONAME
+ _ZNK6TsTask10screenshotEv @ 38 NONAME
+ _ZNK6TsTask4nameEv @ 39 NONAME
+ _ZNK6TsTask8isActiveEv @ 40 NONAME
+ _ZTI13TsTaskMonitor @ 41 NONAME
+ _ZTV13TsTaskMonitor @ 42 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/inc/tstask.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASK_H
+#define TSTASK_H
+
+#include <QPixmap>
+#include <QString>
+
+#include "tstaskmonitor_global.h"
+
+class TsTaskContent;
+class TsTaskLauncher;
+
+class TsTask
+{
+
+public:
+ TsTask(TsTaskContent *content, TsTaskLauncher &launcher);
+ TSTASKMONITOR_EXPORT ~TsTask();
+
+ TSTASKMONITOR_EXPORT void open();
+ TSTASKMONITOR_EXPORT void close();
+
+ TSTASKMONITOR_EXPORT bool isClosable() const;
+ TSTASKMONITOR_EXPORT bool isActive() const;
+ TSTASKMONITOR_EXPORT QPixmap screenshot() const;
+ TSTASKMONITOR_EXPORT QString name() const;
+
+private:
+ const TsTaskContent *const mContent;
+ TsTaskLauncher &mLauncher;
+
+};
+
+#endif //TSTASK_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/inc/tstaskchangeinfo.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKCHANGEINFO_H
+#define TSTASKCHANGEINFO_H
+
+#include "tstaskmonitor_global.h"
+
+class TSTASKMONITOR_EXPORT TsTaskChangeInfo
+{
+public:
+ enum ChangeType{
+ EChangeInsert,
+ EChangeDelete,
+ EChangeMove,
+ EChangeUpdate,
+ EChangeCancel
+ };
+ static const int KInvalidOffset = -2;
+
+ TsTaskChangeInfo(int newOffset = KInvalidOffset, int oldOffset = KInvalidOffset);
+
+ int newOffset() const;
+ int oldOffset() const;
+ ChangeType changeType() const;
+
+private:
+ int mNewOffset;
+ int mOldOffset;
+
+};
+
+#endif /* TSTASKCHANGEINFO_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/inc/tstaskcontent.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKCONTENT_H
+#define TSTASKCONTENT_H
+
+class TsTaskContent
+{
+
+public:
+ bool mClosable;
+ bool mActive;
+ QPixmap mScreenshot;
+ QString mName;
+ QByteArray mKey;
+
+};
+
+#endif //TSTASKCONTENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/inc/tstasklauncher.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKLAUNCHER_H
+#define TSTASKLAUNCHER_H
+
+class QByteArray;
+
+class TsTaskLauncher {
+
+public:
+ virtual void openTask(const QByteArray &key) = 0;
+ virtual void closeTask(const QByteArray &key) = 0;
+};
+
+#endif //TSTASKLAUNCHER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/inc/tstaskmonitor.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKMONITOR_H
+#define TSTASKMONITOR_H
+
+#include <QObject>
+#include <QSharedPointer>
+#include <QPair>
+
+#include "tstaskmonitor_global.h"
+#include "tstask.h"
+
+class TsTaskMonitorPrivate;
+class TsTaskChangeInfo;
+
+typedef QPair<TsTaskChangeInfo, QSharedPointer <TsTask> > TsTaskChange;
+
+class TSTASKMONITOR_EXPORT TsTaskMonitor : public QObject
+{
+ Q_OBJECT
+
+public:
+ TsTaskMonitor(QObject *parent = 0);
+ ~TsTaskMonitor();
+ QList<TsTaskChange> changeList(bool fullList = false); //TODO merge these functions with bool
+
+signals:
+ void taskListChanged();
+
+private:
+ TsTaskMonitorPrivate *d_ptr;
+ friend class TsTaskMonitorPrivate;
+};
+
+#endif //TSTASKMONITOR_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tsscreenshotclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSCREENSHOTCLIENT_H
+#define TSSCREENSHOTCLIENT_H
+
+#include <e32base.h>
+
+#include "tstaskmonitorglobals.h"
+
+class CFbsBitmap;
+class CTsScreenshotClientImpl;
+
+NONSHARABLE_CLASS( CTsScreenshotClient ) : public CBase
+{
+public:
+ IMPORT_C static CTsScreenshotClient* NewL();
+ IMPORT_C static CTsScreenshotClient* NewLC();
+ IMPORT_C ~CTsScreenshotClient();
+
+public:
+ IMPORT_C TInt RegisterScreenshot(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority = Normal);
+ IMPORT_C TInt UnregisterScreenshot(TInt wgId);
+ IMPORT_C TInt SetVisibility(TInt wgId, Visibility value);
+
+private:
+ CTsScreenshotClient();
+ void ConstructL();
+
+private:
+ CTsScreenshotClientImpl* iImpl;
+};
+
+#endif // TSSCREENSHOTCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tsscreenshotclientimpl.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSCREENSHOTCLIENTIMPL_H
+#define TSSCREENSHOTCLIENTIMPL_H
+
+#include <e32base.h>
+
+#include "tstaskmonitorglobals.h"
+#include "tssession.h"
+
+class CFbsBitmap;
+
+NONSHARABLE_CLASS( CTsScreenshotClientImpl ) : public CBase
+{
+public:
+ static CTsScreenshotClientImpl* NewL();
+ static CTsScreenshotClientImpl* NewLC();
+ ~CTsScreenshotClientImpl();
+
+public:
+ TInt RegisterScreenshot(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority);
+ TInt UnregisterScreenshot(TInt wgId);
+ TInt SetVisibility(TInt wgId, Visibility value);
+
+private:
+ CTsScreenshotClientImpl();
+ void ConstructL();
+
+ RTsSession iSession;
+};
+
+#endif // TSSCREENSHOTCLIENTIMPL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tssession.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSESSION_H
+#define TSSESSION_H
+
+#include <e32base.h>
+
+#include "tstaskmonitorglobals.h"
+
+class CFbsBitmap;
+
+NONSHARABLE_CLASS( RTsSession ) : public RSessionBase
+{
+public:
+ TInt Connect();
+
+public: // task monitor API
+ HBufC8* TasksContentLC();
+ void Subscribe(TRequestStatus& aStatus);
+ void CancelSubscribe();
+ void OpenTask(const TDesC8 &key);
+ void CloseTask(const TDesC8 &key);
+
+public: // screenshots API
+ TInt RegisterScreenshot(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority);
+ TInt UnregisterScreenshot(TInt wgId);
+ TInt SetVisibility(TInt wgId, Visibility value);
+
+private:
+ void RegisterScreenshotL(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority);
+ void UnregisterScreenshotL(TInt wgId);
+ void SetVisibilityL(TInt wgId, Visibility value);
+
+private:
+ TInt StartServer();
+};
+
+#endif // TSSESSION_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tstaskmonitor_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKMONITOR_P_H
+#define TSTASKMONITOR_P_H
+
+
+#include <w32std.h>
+
+#include <QList>
+#include <QSharedPointer>
+#include <QPair>
+
+#include "tstaskmonitorobserver.h"
+#include "tstasklauncher.h"
+#include "tstaskmonitor.h"
+
+class RDesReadStream;
+class TsTask;
+class TsTaskContent;
+class CTsTaskMonitorClient;
+
+class TsTaskMonitorPrivate : public MTsTaskMonitorObserver, public TsTaskLauncher
+{
+public:
+ TsTaskMonitorPrivate(TsTaskMonitor *q);
+ virtual ~TsTaskMonitorPrivate();
+
+public:
+ QList<TsTaskChange> changeList();
+
+public: // from MTsTaskMonitorObserver
+ virtual void HandleRunningAppChange();
+
+public: // from TsTaskLauncher
+ virtual void openTask(const QByteArray &key);
+ virtual void closeTask(const QByteArray &key);
+
+private: // helper methods
+ void internalizeContentL(RDesReadStream &dataStream, QScopedPointer<TsTaskContent> &content);
+
+private:
+ TsTaskMonitor *q_ptr;
+ CTsTaskMonitorClient *mClient;
+ RWsSession &mWsSession;
+};
+
+#endif //TSTASKMONITOR_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tstaskmonitorclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKMONITORCLIENT_H
+#define TSTASKMONITORCLIENT_H
+
+#include <e32base.h>
+
+class MTsTaskMonitorObserver;
+class CTsTaskMonitorClientImpl;
+
+NONSHARABLE_CLASS( CTsTaskMonitorClient ) : public CBase
+{
+public:
+ static CTsTaskMonitorClient* NewL();
+ static CTsTaskMonitorClient* NewLC();
+ ~CTsTaskMonitorClient();
+
+public:
+ HBufC8* TasksContentLC();
+ void Subscribe(MTsTaskMonitorObserver& aObserver);
+ void CancelSubscribe();
+ void OpenTask(const TDesC8 &key);
+ void CloseTask(const TDesC8 &key);
+
+private:
+ CTsTaskMonitorClient();
+ void ConstructL();
+
+private:
+ CTsTaskMonitorClientImpl* iImpl;
+};
+
+#endif // TSTASKMONITORCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tstaskmonitorclientimpl.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKMONITORCLIENTIMPL_H
+#define TSTASKMONITORCLIENTIMPL_H
+
+#include <e32base.h>
+
+#include "tssession.h"
+
+class MTsTaskMonitorObserver;
+
+NONSHARABLE_CLASS( CTsTaskMonitorClientImpl ) : public CActive
+{
+public:
+ static CTsTaskMonitorClientImpl* NewL();
+ static CTsTaskMonitorClientImpl* NewLC();
+ ~CTsTaskMonitorClientImpl();
+
+public:
+ HBufC8* TasksContentLC();
+ void Subscribe(MTsTaskMonitorObserver& aObserver);
+ void CancelSubscribe();
+ void OpenTask(const TDesC8 &key);
+ void CloseTask(const TDesC8 &key);
+
+private:
+ void RunL();
+ void DoCancel();
+
+private:
+ CTsTaskMonitorClientImpl();
+ void ConstructL();
+
+ RTsSession iSession;
+ MTsTaskMonitorObserver* iObserver; // not owned
+};
+
+#endif // TSTASKMONITORCLIENTIMPL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tstaskmonitorobserver.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2008 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: Client API
+ *
+*/
+
+#ifndef TSTASKMONITOROBSERVER_H
+#define TSTASKMONITOROBSERVER_H
+
+#include <e32base.h>
+
+/**
+ * Observer interface for getting notifications about fast swap content changes.
+ */
+class MTsTaskMonitorObserver
+ {
+public:
+ /**
+ * Called when there is a change in the fast swap content.
+ * The data can be queried via CTsTaskMonitorClient::TaskListL
+ */
+ virtual void HandleRunningAppChange() = 0;
+ };
+
+#endif //TSTASKMONITOROBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/inc/tstasksettings_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKSETTINGS_P_H
+#define TSTASKSETTINGS_P_H
+
+#include <QPixmap>
+
+class CTsScreenshotClient;
+
+class TsTaskSettingsPrivate
+{
+public:
+ TsTaskSettingsPrivate();
+ ~TsTaskSettingsPrivate();
+
+public:
+ bool registerScreenshot(const QPixmap &screenshot);
+ bool unregisterScreenshot();
+ bool setVisibility(bool visibility);
+
+private:
+ int wgId();
+
+private:
+ CTsScreenshotClient *mClient;
+
+};
+
+#endif //TSTASKSETTINGS_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tsscreenshotclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 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 <s32mem.h>
+
+#include "tsscreenshotclient.h"
+#include "tsscreenshotclientimpl.h"
+
+EXPORT_C CTsScreenshotClient *CTsScreenshotClient::NewL()
+{
+ CTsScreenshotClient* self = NewLC();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+EXPORT_C CTsScreenshotClient *CTsScreenshotClient::NewLC()
+{
+ CTsScreenshotClient* self = new (ELeave) CTsScreenshotClient;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+void CTsScreenshotClient::ConstructL()
+{
+ iImpl = CTsScreenshotClientImpl::NewL();
+}
+
+CTsScreenshotClient::CTsScreenshotClient()
+{
+}
+
+EXPORT_C CTsScreenshotClient::~CTsScreenshotClient()
+{
+ delete iImpl;
+}
+
+EXPORT_C TInt CTsScreenshotClient::RegisterScreenshot(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority)
+{
+ return iImpl->RegisterScreenshot(screenshot, wgId, priority);
+}
+
+EXPORT_C TInt CTsScreenshotClient::UnregisterScreenshot(TInt wgId)
+{
+ return iImpl->UnregisterScreenshot(wgId);
+}
+
+EXPORT_C TInt CTsScreenshotClient::SetVisibility(TInt wgId, Visibility value)
+{
+ return iImpl->SetVisibility(wgId, value);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tsscreenshotclientimpl.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+ /*
+* Copyright (c) 2009 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 <e32base.h>
+
+#include "tsscreenshotclientimpl.h"
+
+CTsScreenshotClientImpl* CTsScreenshotClientImpl::NewL()
+{
+ CTsScreenshotClientImpl* self = NewLC();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+CTsScreenshotClientImpl* CTsScreenshotClientImpl::NewLC()
+{
+ CTsScreenshotClientImpl* self = new (ELeave) CTsScreenshotClientImpl;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+CTsScreenshotClientImpl::CTsScreenshotClientImpl()
+{
+}
+
+CTsScreenshotClientImpl::~CTsScreenshotClientImpl()
+{
+ iSession.Close();
+}
+
+void CTsScreenshotClientImpl::ConstructL()
+{
+ User::LeaveIfError(iSession.Connect());
+}
+
+TInt CTsScreenshotClientImpl::RegisterScreenshot(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority)
+{
+ return iSession.RegisterScreenshot(screenshot, wgId, priority);
+}
+
+TInt CTsScreenshotClientImpl::UnregisterScreenshot(TInt wgId)
+{
+ return iSession.UnregisterScreenshot(wgId);
+}
+
+TInt CTsScreenshotClientImpl::SetVisibility(TInt wgId, Visibility value)
+{
+ return iSession.SetVisibility(wgId, value);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tssession.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2009 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 <s32mem.h>
+#include <fbs.h>
+
+#include "tssession.h"
+#include "tsscreenshotmsg.h"
+#include "tsunregscreenshotmsg.h"
+#include "tsvisibilitymsg.h"
+
+TInt RTsSession::Connect()
+{
+ TInt retry = 4;
+ TInt error(KErrNone);
+ do {
+ error = CreateSession(KRunningAppServerName, TVersion(0, 0, 0));
+ if (KErrNotFound == error || KErrServerTerminated == error) {
+ error = StartServer();
+ if (KErrNone == error || KErrAlreadyExists == error) {
+ retry = 0;
+ error = CreateSession(KRunningAppServerName, TVersion(0, 0, 0));
+ }
+ } else {
+ retry = 0;
+ }
+ } while (--retry > 0);
+ return error;
+}
+
+TInt RTsSession::StartServer()
+{
+ TInt error;
+
+ RSemaphore semaphore;
+ error = semaphore.CreateGlobal(KTsServerReadySemaphore, 0);
+
+ if (KErrNone == error || KErrAlreadyExists == error) {
+ RProcess server;
+ error = server.Create(KRunningAppServerName, KNullDesC, TUidType(KNullUid, KNullUid, KRunningAppServerUid));
+ if (KErrNone == error) {
+ TRequestStatus status;
+ server.Rendezvous(status);
+
+ if (status != KRequestPending) {
+ server.Kill(0);
+ User::WaitForRequest(status);
+ } else {
+ server.Resume();
+ User::WaitForRequest(status);
+
+ // wait for server
+ semaphore.Wait();
+ }
+
+ if (KErrCancel == status.Int()) {
+ error = KErrNone;
+ } else {
+ error = (EExitPanic == server.ExitType()) ? KErrGeneral : status.Int();
+ }
+ }
+ server.Close();
+ }
+ semaphore.Close();
+
+ return error;
+}
+
+
+HBufC8* RTsSession::TasksContentLC()
+{
+ for (;;) {
+ TPckgBuf<TInt> dataSize;
+ User::LeaveIfError(SendReceive(GetRunningAppInfo, TIpcArgs(&dataSize)));
+ HBufC8* data = HBufC8::NewLC(dataSize());
+ TPtr8 dataPointer(data->Des());
+ TInt err = SendReceive(FlushData, TIpcArgs(&dataPointer, dataSize()));
+ if (err == KErrNone) {
+ return data;
+ } else if (err != KErrCorrupt) {
+ User::Leave(err);
+ }
+ CleanupStack::PopAndDestroy(data);
+ // If result was KErrCorrupt then the size received from GetRunningAppInfo is
+ // not valid anymore so restart the whole procedure.
+ }
+}
+
+void RTsSession::Subscribe(TRequestStatus& aStatus)
+{
+ SendReceive(SubscribeRunningAppChanges, aStatus);
+}
+
+void RTsSession::CancelSubscribe()
+{
+ SendReceive(CancelSubscribeRunningAppChanges);
+}
+
+void RTsSession::OpenTask(const TDesC8 &key)
+{
+ SendReceive(OpenTaskMessage, TIpcArgs(&key));
+}
+
+void RTsSession::CloseTask(const TDesC8 &key)
+{
+ SendReceive(CloseTaskMessage, TIpcArgs(&key));
+}
+
+TInt RTsSession::RegisterScreenshot(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority)
+{
+ TRAPD(errNo, RegisterScreenshotL(screenshot, wgId, priority));
+ return errNo;
+}
+
+TInt RTsSession::UnregisterScreenshot(TInt wgId)
+{
+ TRAPD(errNo, UnregisterScreenshotL(wgId));
+ return errNo;
+}
+
+TInt RTsSession::SetVisibility(TInt wgId, Visibility value)
+{
+ TRAPD(errNo, SetVisibilityL(wgId, value));
+ return errNo;
+}
+
+void RTsSession::RegisterScreenshotL(CFbsBitmap *screenshot, TInt wgId, UpdatePriority priority)
+{
+ CTsScreenshotMsg *message = CTsScreenshotMsg::NewLC(wgId, *screenshot, priority);
+ HBufC8* serializedData = message->ExternalizeLC();
+ TIpcArgs arguments(serializedData);
+ User::LeaveIfError(SendReceive(RegisterScreenshotMessage, arguments));
+ CleanupStack::PopAndDestroy(serializedData);
+ CleanupStack::PopAndDestroy(message);
+}
+
+void RTsSession::UnregisterScreenshotL(TInt wgId)
+{
+ CTsUnregisterScreenshotMsg *message = CTsUnregisterScreenshotMsg::NewLC(wgId);
+ HBufC8* serializedData = message->ExternalizeLC();
+ TIpcArgs arguments(serializedData);
+ User::LeaveIfError(SendReceive(UnregisterScreenshotMessage, arguments));
+ CleanupStack::PopAndDestroy(serializedData);
+ CleanupStack::PopAndDestroy(message);
+}
+
+void RTsSession::SetVisibilityL(TInt wgId, Visibility value)
+{
+ CTsVisibilitMsg *message = CTsVisibilitMsg::NewLC(wgId, value);
+ HBufC8* serializedData = message->ExternalizeLC();
+ TIpcArgs arguments(serializedData);
+ User::LeaveIfError(SendReceive(VisibilityChange, arguments));
+ CleanupStack::PopAndDestroy(serializedData);
+ CleanupStack::PopAndDestroy(message);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tstaskmonitor_p.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2009 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 "tstaskmonitor_p.h"
+#include "tstaskmonitor.h"
+
+#include <eikenv.h>
+#include <fbs.h>
+#include <s32mem.h>
+
+#include <XQConversions>
+
+#include "tstaskmonitorclient.h"
+#include "tstask.h"
+#include "tstaskcontent.h"
+#include "tstaskchangeinfo.h"
+#include "tsutils.h"
+using TaskSwitcher::CleanupResetAndDestroyPushL;
+
+TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q) : q_ptr(q), mClient(0), mWsSession(CEikonEnv::Static()->WsSession())
+{
+ QT_TRAP_THROWING(mClient = CTsTaskMonitorClient::NewL());
+ mClient->Subscribe(*this);
+}
+
+TsTaskMonitorPrivate::~TsTaskMonitorPrivate()
+{
+ mClient->CancelSubscribe();
+ delete mClient;
+}
+
+
+QList<TsTaskChange> TsTaskMonitorPrivate::changeList()
+{
+ QList<TsTaskChange> changes;
+ TsTaskChangeInfo qtChangeItem(-2,-2);
+
+ QT_TRAP_THROWING (
+
+ HBufC8 *data = mClient->TasksContentLC();
+ if (data->Size() == 0) {
+ CleanupStack::PopAndDestroy(data);
+ return changes;
+ }
+ TPtr8 dataPointer(data->Des());
+ RDesReadStream dataStream(dataPointer);
+ CleanupClosePushL(dataStream);
+
+ int count = dataStream.ReadInt32L();
+ QT_TRYCATCH_LEAVING(
+ changes.append( TsTaskChange( qtChangeItem, QSharedPointer<TsTask>()));
+ for (int iter(0); iter < count; iter++) {
+ qtChangeItem = TsTaskChangeInfo(iter, TsTaskChangeInfo::KInvalidOffset);
+ QScopedPointer<TsTaskContent> content(new TsTaskContent);
+ internalizeContentL(dataStream, content);
+ changes.append( TsTaskChange( qtChangeItem, QSharedPointer<TsTask>(new TsTask(content.take(), *this))));
+ }
+ )//QT_TRYCATCH_LEAVING
+ CleanupStack::PopAndDestroy(&dataStream);
+ CleanupStack::PopAndDestroy(data);
+ );//QT_TRAP_THROWING
+
+ return changes;
+}
+
+void TsTaskMonitorPrivate::internalizeContentL(RDesReadStream & dataStream, QScopedPointer<TsTaskContent> &content)
+{
+ // get name
+ TInt nameLength(dataStream.ReadInt32L());
+ if (0 < nameLength) {
+ HBufC* name = HBufC::NewLC(dataStream, nameLength);
+ content->mName = XQConversions::s60DescToQString(*name);
+ CleanupStack::PopAndDestroy(name);
+ }
+
+ // get screenshot
+ TInt screenshotHandle = dataStream.ReadInt32L();
+ CFbsBitmap *screenshot = new (ELeave) CFbsBitmap;
+ CleanupStack::PushL(screenshot);
+ if (KErrNone == screenshot->Duplicate(screenshotHandle)) {
+ content->mScreenshot = QPixmap::fromSymbianCFbsBitmap(screenshot);
+ }
+ CleanupStack::PopAndDestroy(screenshot);
+
+ // get key
+ TInt keyLength(dataStream.ReadInt32L());
+ if (0 < keyLength) {
+ HBufC8* key = HBufC8::NewLC(keyLength);
+ TPtr8 des(key->Des());
+ dataStream.ReadL(des, keyLength);
+ content->mKey = XQConversions::s60Desc8ToQByteArray(*key);
+ CleanupStack::PopAndDestroy(key);
+ }
+
+ // get other values
+ content->mActive = dataStream.ReadInt32L();
+ content->mClosable = dataStream.ReadInt32L();
+}
+
+void TsTaskMonitorPrivate::HandleRunningAppChange()
+{
+ emit q_ptr->taskListChanged();
+}
+
+void TsTaskMonitorPrivate::openTask(const QByteArray &key)
+{
+ TPtrC8 desC(reinterpret_cast<const TUint8*>(key.constData()), key.length());
+ mClient->OpenTask(desC);
+
+}
+
+void TsTaskMonitorPrivate::closeTask(const QByteArray &key)
+{
+ TPtrC8 desC(reinterpret_cast<const TUint8*>(key.constData()), key.length());
+ mClient->CloseTask(desC);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tstaskmonitorclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 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 <s32mem.h>
+
+#include "tstaskmonitorclient.h"
+#include "tstaskmonitorclientimpl.h"
+
+CTsTaskMonitorClient *CTsTaskMonitorClient::NewL()
+{
+ CTsTaskMonitorClient* self = NewLC();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+CTsTaskMonitorClient *CTsTaskMonitorClient::NewLC()
+{
+ CTsTaskMonitorClient* self = new (ELeave) CTsTaskMonitorClient;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+void CTsTaskMonitorClient::ConstructL()
+{
+ iImpl = CTsTaskMonitorClientImpl::NewL();
+}
+
+CTsTaskMonitorClient::CTsTaskMonitorClient()
+{
+}
+
+CTsTaskMonitorClient::~CTsTaskMonitorClient()
+{
+ delete iImpl;
+}
+
+HBufC8* CTsTaskMonitorClient::TasksContentLC()
+{
+ return iImpl->TasksContentLC();
+}
+
+void CTsTaskMonitorClient::Subscribe(MTsTaskMonitorObserver& aObserver)
+{
+ iImpl->Subscribe(aObserver);
+}
+
+void CTsTaskMonitorClient::CancelSubscribe()
+{
+ iImpl->CancelSubscribe();
+}
+
+void CTsTaskMonitorClient::OpenTask(const TDesC8 &key)
+{
+ iImpl->OpenTask(key);
+}
+
+void CTsTaskMonitorClient::CloseTask(const TDesC8 &key)
+{
+ iImpl->CloseTask(key);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tstaskmonitorclientimpl.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2009 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 <e32base.h>
+
+#include "tstaskmonitorclientimpl.h"
+#include "tstaskmonitorobserver.h"
+
+CTsTaskMonitorClientImpl* CTsTaskMonitorClientImpl::NewL()
+{
+ CTsTaskMonitorClientImpl* self = NewLC();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+CTsTaskMonitorClientImpl* CTsTaskMonitorClientImpl::NewLC()
+{
+ CTsTaskMonitorClientImpl* self = new (ELeave) CTsTaskMonitorClientImpl;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+CTsTaskMonitorClientImpl::CTsTaskMonitorClientImpl() : CActive(CActive::EPriorityStandard)
+{
+ CActiveScheduler::Add(this);
+}
+
+CTsTaskMonitorClientImpl::~CTsTaskMonitorClientImpl()
+{
+ Cancel();
+ iSession.Close();
+}
+
+void CTsTaskMonitorClientImpl::ConstructL()
+{
+ User::LeaveIfError(iSession.Connect());
+}
+
+
+HBufC8* CTsTaskMonitorClientImpl::TasksContentLC()
+{
+ return iSession.TasksContentLC();
+}
+
+void CTsTaskMonitorClientImpl::Subscribe(MTsTaskMonitorObserver& aObserver)
+{
+ Cancel();
+ iObserver = &aObserver;
+ iSession.Subscribe(iStatus);
+ SetActive();
+}
+
+void CTsTaskMonitorClientImpl::CancelSubscribe()
+{
+ Cancel();
+}
+
+void CTsTaskMonitorClientImpl::OpenTask(const TDesC8 &key)
+{
+ iSession.OpenTask(key);
+}
+
+void CTsTaskMonitorClientImpl::CloseTask(const TDesC8 &key)
+{
+ iSession.CloseTask(key);
+}
+
+void CTsTaskMonitorClientImpl::RunL()
+{
+ if (iStatus == KErrNone && iObserver) {
+ iSession.Subscribe(iStatus);
+ SetActive();
+ iObserver->HandleRunningAppChange();
+ }
+}
+
+void CTsTaskMonitorClientImpl::DoCancel()
+{
+ iSession.CancelSubscribe();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/s60/src/tstasksettings_p.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 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 "tstasksettings_p.h"
+
+#include <fbs.h>
+#include <coecntrl.h>
+#include <QScopedPointer>
+#include <QApplication>
+#include <QDesktopWidget>
+
+#include "tsscreenshotclient.h"
+#include "tstaskmonitorglobals.h"
+
+TsTaskSettingsPrivate::TsTaskSettingsPrivate() : mClient(0)
+{
+ QT_TRAP_THROWING(mClient = CTsScreenshotClient::NewL());
+}
+
+TsTaskSettingsPrivate::~TsTaskSettingsPrivate()
+{
+ delete mClient;
+}
+
+bool TsTaskSettingsPrivate::registerScreenshot(const QPixmap &screenshot)
+{
+ QScopedPointer<CFbsBitmap> bitmap(screenshot.toSymbianCFbsBitmap());
+ if (bitmap.isNull())
+ return false;
+
+ return KErrNone == mClient->RegisterScreenshot(bitmap.data(), wgId());
+}
+
+bool TsTaskSettingsPrivate::unregisterScreenshot()
+{
+ return KErrNone == mClient->UnregisterScreenshot(wgId());
+}
+
+bool TsTaskSettingsPrivate::setVisibility(bool visibility)
+{
+ return (KErrNone == mClient->SetVisibility(wgId(), visibility ? Visible : Invisible));
+}
+
+int TsTaskSettingsPrivate::wgId()
+{
+ return QApplication::desktop()->winId()->ControlEnv()->RootWin().WindowGroupId();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/src/tstask.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2009 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 "tstask.h"
+
+#include "tstaskcontent.h"
+#include "tstasklauncher.h"
+
+/*!
+ @class TsTask
+ @ingroup publicApi
+ @brief TsTask object represents a single task.
+
+ This class represents one running task. It can be queried for task content
+ like screenshot or task name, or used to start or close task.
+*/
+
+/*!
+ @internal
+ Constructor.
+*/
+TsTask::TsTask(TsTaskContent *content, TsTaskLauncher &launcher) : mContent(content), mLauncher(launcher)
+{
+}
+
+/*!
+ Destructor.
+*/
+TsTask::~TsTask()
+{
+ delete mContent;
+}
+
+/*!
+ @return True if it's possible to close the task, false otherwise.
+*/
+bool TsTask::isClosable() const
+{
+ return mContent->mClosable;
+}
+
+/*!
+ @return True if the task is running, false otherwise.
+*/
+bool TsTask::isActive() const
+{
+ return mContent->mActive;
+}
+
+/*!
+ @return Screenshot of the task.
+*/
+QPixmap TsTask::screenshot() const
+{
+ return mContent->mScreenshot;
+}
+
+/*!
+ @return Name of the task.
+*/
+QString TsTask::name() const
+{
+ return mContent->mName;
+}
+
+/*!
+ Start or bring the task to foreground.
+*/
+void TsTask::open()
+{
+ mLauncher.openTask(mContent->mKey);
+}
+
+/*!
+ Close the task.
+*/
+void TsTask::close()
+{
+ mLauncher.closeTask(mContent->mKey);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/src/tstaskchangeinfo.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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 "tstaskchangeinfo.h"
+
+TsTaskChangeInfo::TsTaskChangeInfo(int newOffset, int oldOffset) :
+ mNewOffset(newOffset), mOldOffset(oldOffset)
+{
+}
+
+int TsTaskChangeInfo::newOffset() const
+{
+ return mNewOffset;
+}
+
+int TsTaskChangeInfo::oldOffset() const
+{
+ return mOldOffset;
+}
+
+TsTaskChangeInfo::ChangeType TsTaskChangeInfo::changeType() const
+{
+ ChangeType retVal(EChangeInsert);
+ if (KInvalidOffset == mNewOffset) {
+ if (KInvalidOffset == mOldOffset) {
+ retVal = EChangeCancel;
+ } else {
+ retVal = EChangeDelete;
+ }
+ } else if (mOldOffset == mNewOffset) {
+ retVal = EChangeUpdate;
+ } else if(KInvalidOffset != mOldOffset) {
+ retVal = EChangeMove;
+ }
+ return retVal;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/src/tstaskmonitor.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 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 "tstaskmonitor.h"
+#include "tstaskmonitor_p.h"
+
+#include "tstask.h"
+
+/*!
+ @class TsTaskMonitor
+ @ingroup publicApi
+ @brief TsTaskMonitor gives access to list of running tasks.
+
+ This class is one of the Qt interfaces for Task Monitor server. It can be
+ used to retrieve list of running tasks and receive notifications about the
+ changes of this list.
+*/
+
+/*!
+ Constructor.
+*/
+TsTaskMonitor::TsTaskMonitor(QObject *parent) : QObject(parent), d_ptr(0)
+{
+ d_ptr = new TsTaskMonitorPrivate(this);
+}
+
+/*!
+ Destructor.
+*/
+TsTaskMonitor::~TsTaskMonitor()
+{
+ delete d_ptr;
+}
+
+/*!
+ \return Current list of tasks from Task Monitor server.
+
+ \sa TsTask, taskListChanged()
+*/
+QList<TsTaskChange> TsTaskMonitor::changeList(bool /*fullList*/)
+{
+ return d_ptr->changeList();
+}
+
+/*!
+ @fn TsTaskMonitor::taskListChanged()
+
+ This signal is emitted when task list changes in any way:
+ - the new task is started
+ - running task is terminated
+ - parameters of one task change (for example image representing the task is updated)
+
+ No data is passed within this signal, user should retrieve task list
+ using taskList().
+
+ \sa taskList()
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/src/tstasksettings.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2009 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 "tstasksettings.h"
+#include "tstasksettings_p.h"
+
+/*!
+ @class TsTaskSettings
+ @ingroup publicApi
+ @brief TsTaskSettings allows application to alter the way it will be
+ handled by TsTaskMonitor.
+
+ This class is one of the Qt interfaces for Task Monitor server. It can be
+ used to set custom screenshot of the task, or to change the task visibility.
+*/
+
+/*!
+ Constructor.
+*/
+TsTaskSettings::TsTaskSettings() : d_ptr(new TsTaskSettingsPrivate())
+{
+}
+
+/*!
+ Destructor.
+*/
+TsTaskSettings::~TsTaskSettings()
+{
+ delete d_ptr;
+}
+
+/*!
+ Overwrites default screenshot of task with \a screenshot. If \a
+ screenshot is null, this method will return false.
+ @return True if the screenshot is successfully saved, false otherwise.
+*/
+bool TsTaskSettings::registerScreenshot(const QPixmap &screenshot)
+{
+ return d_ptr->registerScreenshot(screenshot);
+}
+
+/*!
+ Removes custom screenshot saved with registerScreenshot(). If there was no
+ saved screenshot, this method will return false.
+ @return True if the screenshot is successfully removed, false otherwise.
+*/
+bool TsTaskSettings::unregisterScreenshot()
+{
+ return d_ptr->unregisterScreenshot();
+}
+
+/*!
+ Changes the \a visibilty of task. Hidden tasks are not present on the task
+ list returned by TsTaskMonitor::taskList().
+ @return True if the visibility is changed successfully, false otherwise.
+*/
+bool TsTaskSettings::setVisibility(bool visibility)
+{
+ return d_ptr->setVisibility(visibility);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/stub/inc/tstaskmonitor_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKMONITOR_P_H
+#define TSTASKMONITOR_P_H
+
+#include <QList>
+#include <QSharedPointer>
+
+#include "tstask.h"
+
+class TsTaskMonitor;
+
+class TsTaskMonitorPrivate
+{
+public:
+ TsTaskMonitorPrivate(TsTaskMonitor *q);
+
+public:
+ QList< QSharedPointer<TsTask> > taskList();
+
+};
+
+#endif //TSTASKMONITOR_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/stub/inc/tstasksettings_p.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTASKSETTINGS_P_H
+#define TSTASKSETTINGS_P_H
+
+#include <QPixmap>
+
+class TsTaskSettingsPrivate
+{
+public:
+ bool registerScreenshot(const QPixmap &screenshot);
+ bool unregisterScreenshot();
+};
+
+#endif //TSTASKSETTINGS_P_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/stub/src/tstaskmonitor_p.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 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 "tstaskmonitor_p.h"
+
+TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q)
+{
+ Q_UNUSED(q);
+}
+
+QList< QSharedPointer<TsTask> > TsTaskMonitorPrivate::taskList()
+{
+ return QList< QSharedPointer<TsTask> >();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/stub/src/tstasksettings_p.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 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 "tstasksettings_p.h"
+
+bool TsTaskSettingsPrivate::registerScreenshot(const QPixmap &screenshot)
+{
+ Q_UNUSED(screenshot);
+ return true;
+}
+
+bool TsTaskSettingsPrivate::unregisterScreenshot()
+{
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/t_tstaskmonitorclient/t_tstaskmonitorclient.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2009 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_tstaskmonitorclient.h"
+
+#include <QtTest/QtTest>
+
+#include "tstestutils.h"
+
+#include "tstaskchangeinfo.h"
+#include "tstask.h"
+
+namespace {
+ const char KUnitTestTaskName[] = "t_tstaskmonitorclient";
+ const char KTestApplicationName[] = "appwithouticon";
+}
+
+void T_TsTaskMonitorClient::initTestCase()
+{
+ QCOMPARE(mWsSession.Connect(), KErrNone);
+}
+
+void T_TsTaskMonitorClient::cleanupTestCase()
+{
+ mWsSession.Close();
+}
+
+void T_TsTaskMonitorClient::testTaskClose()
+{
+ int firstCount = mTaskMonitor.changeList(true).count();
+
+ // start test application and wait for notification
+ quint64 testApplicationId;
+ QVERIFY(TsTestUtils::startApplication(KTestApplicationName, testApplicationId));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ // find test application task
+ QSharedPointer<TsTask> testAppTask = findTask(KTestApplicationName);
+ QVERIFY(!testAppTask.isNull());
+
+ int secondCount = mTaskMonitor.changeList(true).count();
+ QCOMPARE(secondCount, firstCount + 1);
+
+ // call close and wait for task list change signal
+ testAppTask->close();
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QTest::qWait(3000); // wait until the process fully closes
+
+ // we closed the test application, so the count should be equal to the first one
+ int thirdCount = mTaskMonitor.changeList(true).count();
+ QCOMPARE(thirdCount, firstCount);
+}
+
+void T_TsTaskMonitorClient::testTaskListChangeSignal()
+{
+ QSignalSpy spy(&mTaskMonitor, SIGNAL(taskListChanged()));
+ QVERIFY(spy.isValid());
+
+ // start app
+ quint64 testApplicationId;
+ QVERIFY(TsTestUtils::startApplication(KTestApplicationName, testApplicationId));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QCOMPARE(spy.count(), 1);
+
+ // find unit test task
+ QSharedPointer<TsTask> unitTestTask = findTask(KUnitTestTaskName);
+ QVERIFY(!unitTestTask.isNull());
+
+ // signal is emitted after order of tasks is changed
+ unitTestTask->open();
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QCOMPARE(spy.count(), 2);
+
+ // close test app
+ QVERIFY(TsTestUtils::closeApplication(testApplicationId));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+}
+
+void T_TsTaskMonitorClient::testTaskList()
+{
+ // get task list, it should contain at least one application - this unit test
+ int firstCount = mTaskMonitor.changeList(true).count();
+ QVERIFY(firstCount);
+
+ // start test application, and get task list.
+ // It should contain one more item than during first check
+
+ {
+ quint64 testApplicationId;
+ QVERIFY(TsTestUtils::startApplication(KTestApplicationName, testApplicationId));
+ // wait for signals after application start and backstepping
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ int secondCount = mTaskMonitor.changeList(true).count();
+ QCOMPARE(secondCount, firstCount + 1);
+
+ QVERIFY(TsTestUtils::closeApplication(testApplicationId));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ }
+ QTest::qWait(3000); // wait until the process fully closes
+
+ // close test application and get task list
+ // It should contain the same number of items as during first check
+ QCOMPARE(mTaskMonitor.changeList(true).count(), firstCount);
+}
+
+void T_TsTaskMonitorClient::testTaskChangeInfoGetters()
+{
+ const int KNewOffset(1500);
+ const int KOldOffset(2900);
+
+ TsTaskChangeInfo changeInfo(KNewOffset, KOldOffset);
+ QCOMPARE(changeInfo.newOffset(), KNewOffset);
+ QCOMPARE(changeInfo.oldOffset(), KOldOffset);
+}
+
+void T_TsTaskMonitorClient::testCreatingInsertTaskChangeInfo()
+{
+ TsTaskChangeInfo changeInfo(0, TsTaskChangeInfo::KInvalidOffset);
+ QCOMPARE(changeInfo.changeType(), TsTaskChangeInfo::EChangeInsert);
+}
+
+void T_TsTaskMonitorClient::testCreatingDeleteTaskChangeInfo()
+{
+ TsTaskChangeInfo changeInfo(TsTaskChangeInfo::KInvalidOffset, 0);
+ QCOMPARE(changeInfo.changeType(), TsTaskChangeInfo::EChangeDelete);
+}
+
+void T_TsTaskMonitorClient::testCreatingMoveTaskChangeInfo()
+{
+ TsTaskChangeInfo changeInfo(0, 1);
+ QCOMPARE(changeInfo.changeType(), TsTaskChangeInfo::EChangeMove);
+}
+
+void T_TsTaskMonitorClient::testCreatingUpdateTaskChangeInfo()
+{
+ TsTaskChangeInfo changeInfo(0, 0);
+ QCOMPARE(changeInfo.changeType(), TsTaskChangeInfo::EChangeUpdate);
+}
+
+void T_TsTaskMonitorClient::testCreatingCancelTaskChangeInfo()
+{
+ TsTaskChangeInfo changeInfo(TsTaskChangeInfo::KInvalidOffset, TsTaskChangeInfo::KInvalidOffset);
+ QCOMPARE(changeInfo.changeType(), TsTaskChangeInfo::EChangeCancel);
+}
+
+QSharedPointer<TsTask> T_TsTaskMonitorClient::findTask(const QString &taskName)
+{
+ // find unit test task
+ QSharedPointer<TsTask> myTask;
+ foreach(TsTaskChange taskChange, mTaskMonitor.changeList(true)) {
+ if (!taskChange.second.isNull()) {
+ if (taskChange.second->name().contains(taskName)) {
+ myTask = taskChange.second;
+ break;
+ }
+ }
+ }
+ return myTask;
+}
+
+QTEST_MAIN(T_TsTaskMonitorClient)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/t_tstaskmonitorclient/t_tstaskmonitorclient.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSTASKMONITORCLIENT_H
+#define T_TSTASKMONITORCLIENT_H
+
+#include <QObject>
+#include <W32STD.H>
+#include "tstaskmonitor.h"
+
+/**
+* @test Test class for TsTaskMonitorClient
+*/
+class T_TsTaskMonitorClient : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void testTaskListChangeSignal();
+ void testTaskList();
+ void testTaskClose();
+
+private slots:
+ void testTaskChangeInfoGetters();
+ void testCreatingInsertTaskChangeInfo();
+ void testCreatingDeleteTaskChangeInfo();
+ void testCreatingMoveTaskChangeInfo();
+ void testCreatingUpdateTaskChangeInfo();
+ void testCreatingCancelTaskChangeInfo();
+
+private: // helper methods
+ QSharedPointer<TsTask> findTask(const QString &taskName);
+
+private:
+ TsTaskMonitor mTaskMonitor;
+ RWsSession mWsSession;
+
+};
+
+#endif //T_TSTASKMONITORCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/t_tstaskmonitorclient/t_tstaskmonitorclient.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+QT *= testlib
+CONFIG += console
+
+INCLUDEPATH += . \
+
+HEADERS += t_tstaskmonitorclient.h \
+
+SOURCES += t_tstaskmonitorclient.cpp \
+
+DEFINES += TSTASKMONITOR_TEST
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA=1
+
+ LIBS += -lcone \
+ -lapgrfx \ # for RApaLsSession
+ -lws32 \ # for RWsSession
+
+}
+
+LIBS += -ltsutils.dll
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
+
+coverage {
+ DEFINES += COVERAGE_MEASUREMENT
+ DEFINES += QT_NO_DEBUG # omit ASSERTS in coverage measurements
+}
+
+include(../../client.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/t_tstasksettings/t_tstasksettings.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2009 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_tstasksettings.h"
+
+#include <s32mem.h>
+
+#include <QtTest/QtTest>
+#include <QDesktopWidget>
+#include <QPainter>
+
+#include <QDebug>
+#include <XQConversions>
+
+#if defined (Q_OS_SYMBIAN)
+#include <coecntrl.h>
+#include "tstaskmonitorclient.h"
+#include "tsscreenshotclient.h"
+#include "tsutils.h"
+using TaskSwitcher::CleanupResetAndDestroyPushL;
+#endif
+
+#include "tstask.h"
+#include "tstaskchangeinfo.h"
+#include "tstestutils.h"
+
+void T_TsTaskSettings::initTestCase()
+{
+ while (!unitTestTask().data())
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+}
+
+void T_TsTaskSettings::testRegisteringScreenshotTriggersTaskListChangeSignal()
+{
+ QVERIFY(mTaskSettings.registerScreenshot(imageWithCircle()));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+}
+
+void T_TsTaskSettings::testUnregisteringScreenshotTriggersTaskListChangeSignal()
+{
+ QVERIFY(mTaskSettings.registerScreenshot(imageWithCircle()));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ QVERIFY(mTaskSettings.unregisterScreenshot());
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+}
+
+void T_TsTaskSettings::testIconIsReturnedAfterUnregisteringScreenshot()
+{
+ // get icon
+ QSharedPointer<TsTask> taskBefore = unitTestTask();
+ QVERIFY(taskBefore.data());
+ QPixmap icon = taskBefore->screenshot();
+ QVERIFY(!icon.isNull());
+
+ // register and unregister screenshot
+ QVERIFY(mTaskSettings.registerScreenshot(imageWithCircle()));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QVERIFY(mTaskSettings.unregisterScreenshot());
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ // compare pixmap returned after register/unregister with icon
+ QSharedPointer<TsTask> taskAfter = unitTestTask();
+ QVERIFY(taskAfter.data());
+ QVERIFY(taskAfter->screenshot().toImage() == icon.toImage());
+}
+
+void T_TsTaskSettings::testRegisteringEmptyPixmapReturnsFalse()
+{
+ QVERIFY(!mTaskSettings.registerScreenshot(QPixmap()));
+}
+
+void T_TsTaskSettings::testRegisteringTheSameScreenshotTwiceTriggersTaskListChangeSignal()
+{
+ QPixmap image = imageWithCircle();
+
+ QVERIFY(mTaskSettings.registerScreenshot(image));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QVERIFY(mTaskSettings.registerScreenshot(image));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+}
+
+void T_TsTaskSettings::testRegisteringOverwritesOldScreenshot()
+{
+ QPixmap previousScreenshot;
+ {
+ QSharedPointer<TsTask> myTask = unitTestTask();
+ QVERIFY(myTask.data());
+ previousScreenshot = myTask->screenshot();
+ }
+
+ QVERIFY(mTaskSettings.registerScreenshot(imageWithCircle()));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ QPixmap screenshotAfterFirstRegistration;
+ {
+ QSharedPointer<TsTask> myTask = unitTestTask();
+ QVERIFY(myTask.data());
+ screenshotAfterFirstRegistration = myTask->screenshot();
+ }
+
+ QVERIFY(previousScreenshot.toImage() != screenshotAfterFirstRegistration.toImage());
+
+ QVERIFY(mTaskSettings.registerScreenshot(imageWithCircle()));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ QPixmap screenshotAfterSecondRegistration;
+ {
+ QSharedPointer<TsTask> myTask = unitTestTask();
+ QVERIFY(myTask.data());
+ screenshotAfterSecondRegistration = myTask->screenshot();
+ }
+
+ QVERIFY(screenshotAfterSecondRegistration.toImage() != screenshotAfterFirstRegistration.toImage());
+}
+
+void T_TsTaskSettings::testRegisteringFailsIfHigherPriorityScreenshotIsRegistered()
+{
+ QPixmap highPriorityScreenshot = imageWithCircle();
+ registerHighPriorityScreenshot(highPriorityScreenshot);
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+
+ QVERIFY(!mTaskSettings.registerScreenshot(imageWithCircle()));
+
+ // clean up and verify the screenshots can be registered
+ QVERIFY(mTaskSettings.unregisterScreenshot());
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ QVERIFY(mTaskSettings.registerScreenshot(imageWithCircle()));
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+}
+
+void T_TsTaskSettings::testChangingVisibilityOfApplication()
+{
+ {
+ QSharedPointer<TsTask> myTask = unitTestTask();
+ QVERIFY(myTask.data());
+ }
+
+ // hide unit test task
+ mTaskSettings.setVisibility(false);
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ {
+ QSharedPointer<TsTask> myTask = unitTestTask();
+ QVERIFY(!myTask.data());
+ }
+
+ // show unit test task
+ mTaskSettings.setVisibility(true);
+ QVERIFY(TsTestUtils::waitForSignal(&mTaskMonitor, SIGNAL(taskListChanged())));
+ {
+ QSharedPointer<TsTask> myTask = unitTestTask();
+ QVERIFY(myTask.data());
+ }
+}
+
+QSharedPointer<TsTask> T_TsTaskSettings::unitTestTask()
+{
+ // find unit test task
+ QSharedPointer<TsTask> myTask;
+ foreach(TsTaskChange taskChange, mTaskMonitor.changeList(true)) {
+ if (!taskChange.second.isNull()) {
+ if (taskChange.second->name() == "t_tstasksettings") {
+ myTask = taskChange.second;
+ break;
+ }
+ }
+ }
+ return myTask;
+}
+
+bool T_TsTaskSettings::registerHighPriorityScreenshot(const QPixmap &screenshot)
+{
+#if defined (Q_OS_SYMBIAN)
+ int wgId = QApplication::desktop()->winId()->ControlEnv()->RootWin().WindowGroupId();
+
+ QScopedPointer<CFbsBitmap> bitmap(screenshot.toSymbianCFbsBitmap());
+ if (bitmap.isNull())
+ return false;
+
+ int error(KErrGeneral);
+
+ QT_TRAP_THROWING (
+ CTsScreenshotClient* screenshotClient = CTsScreenshotClient::NewLC();
+ error = screenshotClient->RegisterScreenshot(bitmap.data(), wgId, High);
+ CleanupStack::PopAndDestroy(screenshotClient);
+ );
+
+ return error == KErrNone;
+#else
+ return false;
+#endif
+}
+
+QPixmap T_TsTaskSettings::imageWithCircle()
+{
+ static int hue = 0;
+ QPixmap screenshot(10, 10);
+
+ {
+ QPainter painter(&screenshot);
+ painter.setBrush(Qt::black);
+ painter.drawRect(screenshot.rect());
+ painter.setBrush(QColor::fromHsv(hue, 255, 255));
+ painter.drawEllipse(screenshot.rect());
+ }
+
+ hue += 17;
+ return screenshot;
+}
+
+QTEST_MAIN(T_TsTaskSettings)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/t_tstasksettings/t_tstasksettings.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSTASKSETTINGS_H
+#define T_TSTASKSETTINGS_H
+
+#include <QObject>
+
+#include "tstaskmonitor.h"
+#include "tstasksettings.h"
+
+/**
+* @test Test class for TsTaskSettings
+*/
+class T_TsTaskSettings : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void testRegisteringScreenshotTriggersTaskListChangeSignal();
+ void testUnregisteringScreenshotTriggersTaskListChangeSignal();
+ void testIconIsReturnedAfterUnregisteringScreenshot();
+ void testRegisteringEmptyPixmapReturnsFalse();
+ void testRegisteringTheSameScreenshotTwiceTriggersTaskListChangeSignal();
+ void testRegisteringOverwritesOldScreenshot();
+ void testRegisteringFailsIfHigherPriorityScreenshotIsRegistered();
+
+ void testChangingVisibilityOfApplication();
+
+private:
+ QSharedPointer<TsTask> unitTestTask();
+ QPixmap imageWithCircle();
+ bool registerHighPriorityScreenshot(const QPixmap &screenshot);
+
+private:
+ TsTaskSettings mTaskSettings;
+ TsTaskMonitor mTaskMonitor;
+
+};
+
+#endif //T_TSTASKSETTINGS_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/t_tstasksettings/t_tstasksettings.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+QT *= testlib
+CONFIG += console
+
+INCLUDEPATH += . \
+
+HEADERS += t_tstasksettings.h \
+
+SOURCES += t_tstasksettings.cpp \
+
+DEFINES += TSTASKMONITOR_TEST
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA=1
+
+ LIBS += -lcone \
+ -lapgrfx \ # for RApaLsSession
+ -lws32 \ # for RWsSession
+
+}
+
+LIBS += -ltsutils.dll
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
+
+coverage {
+ DEFINES += COVERAGE_MEASUREMENT
+ DEFINES += QT_NO_DEBUG # omit ASSERTS in coverage measurements
+}
+
+include(../../client.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/client/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+# dependencies
+SUBDIRS += ../../../internal/tstestutils \
+ ../../../internal/tsapps/testapp \
+
+# test cases
+SUBDIRS += t_tstaskmonitorclient \
+ t_tstasksettings \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/inc/tstaskmonitorglobals.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef RUNNINGAPPGLOBALS_H
+#define RUNNINGAPPGLOBALS_H
+
+#include <e32base.h>
+
+_LIT(KRunningAppServerName, "hsrunningappmonitor");
+_LIT(KTsServerReadySemaphore, "TaskSwitcherReadySemaphore");
+const TUid KRunningAppServerUid = {0x200267B0};
+const TInt KRequestDataSizeOffset(0);
+const TInt KRequestDataBufferOffset(0);
+
+enum RunningAppCmd {
+ GetRunningAppInfo =0,
+ SubscribeRunningAppChanges,
+ UpdateScreenshot,
+ FlushData,
+ CancelSubscribeRunningAppChanges,
+ RegisterScreenshotMessage,
+ UnregisterScreenshotMessage,
+ VisibilityChange,
+ OpenTaskMessage,
+ CloseTaskMessage,
+};
+
+enum UpdatePriority {
+ Low = 0,
+ Normal,
+ High
+};
+
+enum Visibility {
+ Invisible =0,
+ Visible
+};
+
+enum ScreenshotMessageOffsets {
+ ScreenshotHandle = 0,
+ WindowsGroup,
+ AdditionalParameters,
+ Priority
+};
+
+#endif //RUNNINGAPPGLOBALS_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/rom.pri Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>"
+BLD_INF_RULES.prj_exports += "rom/tstaskmonitor_core.iby CORE_APP_LAYER_IBY_EXPORT_PATH(tstaskmonitor_core.iby)"
+BLD_INF_RULES.prj_exports += "./sis/stubs/taskmonitor_stub.sis /epoc32/release/winscw/udeb/z/system/install/taskmonitor_stub.sis"
+BLD_INF_RULES.prj_exports += "./sis/stubs/taskmonitor_stub.sis /epoc32/data/z/system/install/taskmonitor_stub.sis"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/rom/tstaskmonitor_core.iby Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef __TSTASKMONITOR_CORE_IBY__
+#define __TSTASKMONITOR_CORE_IBY__
+
+file=ABI_DIR\BUILD_DIR\tstaskmonitorclient.dll SHARED_LIB_DIR\tstaskmonitorclient.dll
+file=ABI_DIR\BUILD_DIR\hsrunningappmonitor.exe PROGRAMS_DIR\hsrunningappmonitor.exe
+data=\epoc32\data\z\resource\apps\hsrunningappmonitor.rsc resource\apps\hsrunningappmonitor.rsc
+data=ZPRIVATE\10003a3f\import\apps\hsrunningappmonitor_reg.rsc private\10003a3f\import\apps\hsrunningappmonitor_reg.rsc
+
+
+file=ABI_DIR\BUILD_DIR\tsbackstepping.dll SHARED_LIB_DIR\tsbackstepping.dll
+
+
+ECOM_PLUGIN( tsscreenshotplugin.dll, tsscreenshotplugin.rsc )
+
+// stub sis
+data=ZSYSTEM/install/taskmonitor_stub.sis system/install/taskmonitor_stub.sis
+
+#endif //__TSTASKMONITOR_CORE_IBY__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/group/bld.inf Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+tsscreenshotplugin.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/group/tsscreenshotplugin.mmp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+TARGET tsscreenshotplugin.dll
+TARGETTYPE PLUGIN
+UID 0x10009D8D 0x200267AE
+CAPABILITY CAP_ECOM_PLUGIN
+VENDORID VID_DEFAULT
+
+OPTION_REPLACE ARMCC --arm -O3 --cpu 6
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../utils/inc
+USERINCLUDE ../../inc
+
+SOURCEPATH ../src
+SOURCE tsscreenshotmain.cpp
+SOURCE tsscreenshotplugin.cpp
+SOURCE ../../utils/src/tsscreenshotmsg.cpp
+
+RESOURCE tsscreenshotplugin.rss
+
+LIBRARY ecom.lib
+LIBRARY euser.lib
+LIBRARY wsgraphicdrawer.lib
+LIBRARY fbscli.lib
+LIBRARY estor.lib
+LIBRARY gdi.lib
+LIBRARY tstaskmonitorclient.lib
+DEBUGLIBRARY flogger.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/inc/tsscreenshotplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2008 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:
+*
+*/
+#ifndef TSSCREENSHOTPLUGIN_H
+#define TSSCREENSHOTPLUGIN_H
+
+#include <w32std.h>
+#include <graphics/wsgraphicdrawerinterface.h>
+#include <graphics/wsgraphicdrawer.h>
+
+class CTsScreenshotPlugin: public CWsGraphicDrawer,
+ public MWsEventHandler
+{
+public:
+ /**
+ * Two phase constructor
+ */
+
+ static CTsScreenshotPlugin* NewL();
+
+ /**
+ * Destructor
+ */
+ ~CTsScreenshotPlugin();
+
+private:
+ /**
+ * From CWsGraphicDrawer.
+ * @see CWsGraphicDrawer::DoDraw(MWsGc&, const TRect&, const TDesC8&) const
+ */
+ void DoDraw(MWsGc&, const TRect&, const TDesC8&) const;
+
+ /**
+ * From CWsGraphicDrawer
+ * @see CWsGraphicDrawer::HandleMessage(const TDesC8&)
+ */
+ void HandleMessage(const TDesC8&);
+
+ void HandleMessageL(const TDesC8&);
+
+ /**
+ * From CWsGraphicDrawer
+ * @see CWsGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment&, const TGraphicDrawerId& , MWsClient&, const TDesC8&)
+ */
+ void ConstructL(MWsGraphicDrawerEnvironment& env,
+ const TGraphicDrawerId& id,
+ MWsClient& owner,
+ const TDesC8& data);
+
+ /**
+ * From MWsEventHandler.
+ *
+ * @see MWsEventHandler::DoHandleEvent(const TWservCrEvent&)
+ */
+ void DoHandleEvent(const TWservCrEvent& event);
+
+ /**
+ * Function take screenshot od current display
+ * @param screenshot identyfier
+ */
+ void TakeScreenshot(TInt);
+
+ /**
+ * Function take screenshot od current display
+ * @param screenshot identyfier
+ */
+ void TakeScreenshotL(TInt);
+
+private:
+ RPointerArray<CFbsBitmap> mCache;
+ TInt mWindowGroupId;
+};
+
+#endif //TSSCREENSHOTPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/screenshotplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"group/bld.inf\""
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/src/tsscreenshotmain.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2008 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 <ecom/implementationproxy.h>
+#include "tsscreenshotplugin.h"
+
+const TInt KImpId( 0x200267AE );
+
+// --------------------------------------------------------------------------
+// KImplementationTable
+// --------------------------------------------------------------------------
+//
+LOCAL_C const TImplementationProxy KImplementationTable[] =
+{
+ IMPLEMENTATION_PROXY_ENTRY(KImpId, CTsScreenshotPlugin::NewL)
+};
+
+// --------------------------------------------------------------------------
+// ImplementationGroupProxy
+// --------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+ aTableCount = (sizeof(KImplementationTable) / sizeof(TImplementationProxy));
+ return KImplementationTable;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/src/tsscreenshotplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,178 @@
+/*
+* Copyright (c) 2008 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 <graphics/wsscreendevice.h>
+#include <s32mem.h>
+
+#include <tstaskmonitorglobals.h>
+
+#include "tsscreenshotplugin.h"
+#include "tsscreenshotmsg.h"
+
+const TInt KInvalidGroupId(~0);
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CTsScreenshotPlugin* CTsScreenshotPlugin::NewL()
+{
+ //no second step construction is required here
+ //window server will initialize plugin later
+ return new(ELeave)CTsScreenshotPlugin();
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::ConstructL(MWsGraphicDrawerEnvironment& env,
+ const TGraphicDrawerId& id,
+ MWsClient& owner,
+ const TDesC8& /*data*/ )
+{
+ BaseConstructL(env, id, owner);
+ env.RegisterEventHandler(this,
+ this,
+ TWservCrEvent::EWindowGroupChanged |
+ TWservCrEvent::EDeviceOrientationChanged);
+ mWindowGroupId = KInvalidGroupId;
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CTsScreenshotPlugin::~CTsScreenshotPlugin()
+{
+ Env().UnregisterEventHandler(this);
+ mCache.ResetAndDestroy();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::DoDraw(MWsGc&, const TRect&, const TDesC8&) const
+{
+ //plugin is not a real drawer
+ //no implementation required
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::HandleMessage(const TDesC8& msg)
+{
+ TRAP_IGNORE(HandleMessageL(msg));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::HandleMessageL(const TDesC8& msg)
+{
+ RDesReadStream msgStream(msg);
+ CleanupClosePushL(msgStream);
+ TInt function = msgStream.ReadInt32L();
+ if (RegisterScreenshotMessage == function) {
+ CTsScreenshotMsg *screenshotMsg = CTsScreenshotMsg::NewLC(msgStream);
+ for(TInt iter(0); iter < mCache.Count(); ++iter) {
+ if (mCache[iter]->Handle() == screenshotMsg->screenshot().Handle()) {
+ //bitmap is not needed no more
+ delete mCache[iter];
+ mCache.Remove(iter);
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy(screenshotMsg);
+ }
+ CleanupStack::PopAndDestroy(&msgStream);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::DoHandleEvent(const TWservCrEvent& event)
+{
+ switch (event.Type()) {
+ case TWservCrEvent::EWindowGroupChanged:
+ if (KInvalidGroupId != mWindowGroupId) {
+ TakeScreenshot(mWindowGroupId);
+ }
+ mWindowGroupId = event.WindowGroupIdentifier();
+ break;
+ case TWservCrEvent::EDeviceOrientationChanged:
+ TakeScreenshot(mWindowGroupId);
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::TakeScreenshot(TInt id)
+{
+ TRAP_IGNORE(TakeScreenshotL(id);)
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotPlugin::TakeScreenshotL(TInt id)
+{
+ if(0 >= Env().ScreenCount()) {
+ User::Leave(KErrCorrupt);
+ }
+ const TInt screenId(0); //use local variable in case of changing screen selection policy
+ const MWsScreenConfig* const screenConfig =
+ Env().Screen(screenId)->ObjectInterface<MWsScreenConfig>();
+ const MWsScreenDevice* const screenDevice =
+ static_cast<MWsScreenDevice*>(Env().Screen(screenId)->ResolveObjectInterface(MWsScreenDevice::EWsObjectInterfaceId));
+
+ User::LeaveIfNull(screenConfig);
+ User::LeaveIfNull(screenDevice);
+
+ //prepare destination bitmap
+ CFbsBitmap *bitmap = new (ELeave) CFbsBitmap();
+ CleanupStack::PushL(bitmap);
+
+
+ User::LeaveIfError(bitmap->Create(screenConfig->SizeInPixels(),
+ screenConfig->DisplayMode()));
+
+ screenDevice->CopyScreenToBitmapL(bitmap,
+ screenConfig->SizeInPixels());
+
+
+ //prepare and send message
+ RBuf8 message;
+ CleanupClosePushL(message);
+ message.CreateL(CTsScreenshotMsg::size() + sizeof(TInt));
+ RDesWriteStream stream(message);
+ CleanupClosePushL(stream);
+ stream.WriteInt32L(RegisterScreenshotMessage);
+ CTsScreenshotMsg * screenshotMsg = CTsScreenshotMsg::NewLC(id, *bitmap, Low);
+ stream << (*screenshotMsg);
+ CleanupStack::PopAndDestroy(screenshotMsg);
+ CleanupStack::PopAndDestroy(&stream);
+ User::LeaveIfError(SendMessage(message));
+ CleanupStack::PopAndDestroy(&message);
+ mCache.AppendL(bitmap);
+ CleanupStack::Pop(bitmap);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/src/tsscreenshotplugin.rss Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2008 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: ECOM registration file
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = 0x200267AE;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = 0x10281924;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x200267AE;
+ version_no = 1;
+ display_name = "tsscreenshotplugin";
+ default_data = "";
+ opaque_data = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/tsrc/t_screenshotplugin/t_screenshotplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include <w32std.h>
+#include <s32mem.h>
+#include <apgtask.h>
+#include <qdesktopwidget.h>
+#include <qsignalspy.h>
+#include <coecntrl.h>
+
+#include "t_screenshotplugin.h"
+#include "tstaskmonitorglobals.h"
+#include "tsscreenshotmsg.h"
+
+
+const int testTimeout(10000);
+const int homescreenUID(0x20022F35);
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+class CScreenshotPluginClient: public CWsGraphic
+{
+public:
+ static CScreenshotPluginClient* NewLC(MScreenshotObserver& observer)
+ {
+ CScreenshotPluginClient* self = new (ELeave)CScreenshotPluginClient(observer);
+ CleanupStack::PushL(self);
+ self->BaseConstructL(TUid::Uid(0x200267AE), KNullDesC8);
+ return self;
+ }
+
+private:
+ CScreenshotPluginClient(MScreenshotObserver& observer)
+ :mObserver(observer)
+ {}
+
+ void HandleMessage(const TDesC8& data)
+ {TRAP_IGNORE(HandleMessageL(data));}
+
+ void HandleMessageL(const TDesC8& data)
+ {
+ RDesReadStream msgStream(data);
+ CleanupClosePushL(msgStream);
+ if(RegisterScreenshotMessage != msgStream.ReadInt32L()) {
+ User::Leave(KErrNotSupported);
+ }
+
+ //parse msg to ACK provider ASAP and be sure that bitmap still exists
+ CTsScreenshotMsg* screenshotMsg = CTsScreenshotMsg::NewLC(msgStream);
+ SendMessage(data);
+
+ //reset stream
+ msgStream.Close();
+ msgStream.Open(data);
+
+ //forward stream to storage
+ mObserver.ScreenshotTaken(screenshotMsg->windowGroupId(),
+ screenshotMsg->screenshot().Handle(),
+ 0,
+ screenshotMsg->priority());
+
+ CleanupStack::PopAndDestroy(screenshotMsg);
+ CleanupStack::PopAndDestroy(&msgStream);
+ }
+
+ void OnReplace()
+ {}
+
+private:
+ MScreenshotObserver &mObserver;
+};
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+
+T_Screenshotplugin::T_Screenshotplugin() : testUi("test")
+{
+ testUi.show();
+}
+
+void T_Screenshotplugin::testPlugin()
+{
+ const bool appMovingOperations [] = {false, true, false};
+ QEventLoop loop;
+ connect(this,
+ SIGNAL(screenshotTaken(int, int, int, int)),
+ &loop,
+ SLOT(quit()));
+
+ CScreenshotPluginClient::NewLC(*this);//create plugin client. test doesnt need pointer
+
+ //just move tested app to foreground
+ QTimer::singleShot(testTimeout, &loop, SLOT(quit()));
+ moveApp(homescreenUID, true);
+ loop.exec();
+
+ //!!!!Tested application should be in foreground!!!!!!
+ //Move tested app foreground/background and wait for screenshot/timeout
+ for (int iter(0), count(sizeof(appMovingOperations)/sizeof(bool)); iter < count; ++iter) {
+ QSignalSpy spy(this, SIGNAL(screenshotTaken(int, int, int, int)));
+ QTimer::singleShot(testTimeout, &loop, SLOT(quit()));
+ moveApp(homescreenUID, appMovingOperations[iter]);
+ loop.exec();
+ QTest::qWait(4000);
+ QCOMPARE(spy.count(), 1);
+
+ }
+ //!!!!Tested application should be in background!!!!!!
+ QSignalSpy spy(this, SIGNAL(screenshotTaken(int, int, int, int)));
+ QTimer::singleShot(testTimeout, &loop, SLOT(quit()));
+ moveApp(homescreenUID, false);
+ loop.exec();
+ QCOMPARE(spy.count(), 0);
+
+ CleanupStack::PopAndDestroy();//destroy client
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void T_Screenshotplugin::ScreenshotTaken(int a, int b, int c, int d)
+{
+ emit screenshotTaken(a, b, c, d);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void T_Screenshotplugin::moveApp(int uid, bool foreground)
+{
+ TApaTaskList taskList(QApplication::desktop()->winId()->ControlEnv()->WsSession());
+ TApaTask task(taskList.FindApp(TUid::Uid(uid)));
+ if ( task.Exists() )
+ {
+ foreground ? task.BringToForeground() : task.SendToBackground();
+ }
+}
+
+QTEST_MAIN(T_Screenshotplugin)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/tsrc/t_screenshotplugin/t_screenshotplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_SCREENSHOTPLUGIN_H
+#define T_SCREENSHOTPLUGIN_H
+
+#include <QObject>
+#include <QLabel>
+class MScreenshotObserver
+{
+public:
+ virtual void ScreenshotTaken(int, int, int, int) =0;
+};
+/**
+* @test Test class for Screenshotplugin
+*/
+class T_Screenshotplugin : public QObject,
+ public MScreenshotObserver
+{
+ Q_OBJECT
+
+public:
+ T_Screenshotplugin();
+
+private slots:
+ void testPlugin();
+
+signals:
+ void screenshotTaken(int, int, int, int);
+
+private:
+ void ScreenshotTaken(int, int, int, int);
+ void moveApp(int, bool =false);
+ QLabel testUi;
+
+};
+
+#endif //T_SCREENSHOTPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/tsrc/t_screenshotplugin/t_screenshotplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+QT += testlib
+CONFIG += console
+
+INCLUDEPATH += . \
+ ../../../inc \
+
+HEADERS += t_screenshotplugin.h \
+ ../../../utils/inc/tsscreenshotmsg.h
+
+SOURCES += t_screenshotplugin.cpp \
+ ../../../utils/src/tsscreenshotmsg.cpp
+
+
+symbian {
+ LIBS += -lws32 \
+ -lfbscli \
+ -lestor \
+ -lapgrfx \
+
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA=1
+}
+
+coverage {
+ DEFINES += COVERAGE_MEASUREMENT
+ DEFINES += QT_NO_DEBUG # omit ASSERTS in coverage measurements
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/screenshotplugin/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS += ../../screenshotplugin \
+ t_screenshotplugin
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/hsdataobservertask.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef DATAOBSERVERTASK_H
+#define DATAOBSERVERTASK_H
+#include "tsdataobserver.h"
+#include <e32base.h>
+class CHsDataObserverTask: public CTsDataObserver
+{
+public:
+ ~CHsDataObserverTask();
+ static void ExecuteLD(MTsDataObserverStorage& storage,const RMessage2& msg);
+
+private:
+ CHsDataObserverTask(MTsDataObserverStorage& storage, const RMessage2& msg);
+ void DataChanged();
+ void Cancel(const RMessage2& reason);
+ TBool IsParent(const CSession2*session);
+
+private:
+ MTsDataObserverStorage& mStorage;
+ const RMessage2 mMsg;
+ TBool mDataChanged;
+};
+#endif //DATAOBSERVERTASK_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/hsdataprovidertask.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef DATAPROVIDERTASK_H
+#define DATAPROVIDERTASK_H
+
+#include "tsdataprovider.h"
+
+class HsDataProviderTask {
+public:
+ static void ExecuteL(const MTsDataProvider& provider, const RMessage2& msg);
+};
+
+#endif //DATAPROVIDER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/hsrunningappserver.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef RUNNINGAPPSERVER_H
+#define RUNNINGAPPSERVER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <w32std.h>
+#include "tsdataobserver.h"
+
+class CTsResourceManager;
+class CTsWindowGroupsMonitor;
+class MTsModel;
+class CTsRunningAppModel;
+class CTsStorage;
+class CTsSerializedDataProvider;
+class CTsServiceProvider;
+
+/**
+ * CRunningAppServer
+ *
+ */
+class CRunningAppServer : public CServer2,
+ public MTsDataObserver,
+ public MTsDataObserverStorage
+{
+public:
+ /**
+ * Destructor.
+ */
+ ~CRunningAppServer();
+
+ /**
+ * Two-phased constructor.
+ */
+ static CRunningAppServer* NewLC();
+
+public: //MHsDataObserver
+ void DataChanged();
+
+public: //MHsDataObserverStorage
+ void PushL(CTsDataObserver*);
+ void Pop(CTsDataObserver*);
+ void Cancel(const RMessage2&);
+ void Invalidate(const CSession2* session);
+
+private:
+ /**
+ * Constructor for performing 1st stage construction
+ */
+ CRunningAppServer();
+
+ /**
+ * Default constructor for performing 2nd stage construction
+ */
+ void ConstructL();
+
+ /**
+ * Interface implementation
+ * @see CServer2::NewSessionL(const TVersion&, const RMessage2&)
+ */
+ CSession2* NewSessionL(const TVersion& version, const RMessage2& message) const;
+
+ void addProviders(RPointerArray<MTsModel> &dst, const CTsServiceProvider& serviceProvider);
+
+private:
+ RPointerArray<CTsDataObserver> mObservers;
+ RWsSession mWsSession;
+ CTsResourceManager* mResources;
+ CTsWindowGroupsMonitor* mMonitor;
+ CTsSerializedDataProvider* mSerializer;
+ CTsStorage* mStorage;
+ CTsServiceProvider* mServiceProvider;
+ CTsRunningAppModel* mAppsModel;
+ CBase *mBacksteppingEngine;
+};
+
+#endif // RUNNINGAPPSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/hsrunningappsession.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef RUNNINGAPPSESSION_H
+#define RUNNINGAPPSESSION_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include "tsdataobserver.h"
+#include "tsdataprovider.h"
+#include "tsdatastorage.h"
+/**
+ * CActivitySession
+ *
+ */
+class CRunningAppSession : public CSession2
+{
+public:
+ // Constructors and destructor
+
+ /**
+ * Destructor.
+ */
+ ~CRunningAppSession();
+
+ /**
+ * Two-phased constructor.
+ * @param fileSession - initialized file system session
+ * @param taskStorage - global observers storage
+ * @param storage - data storage
+ */
+ static CRunningAppSession* NewL(MTsDataObserverStorage& observerStorage,
+ const MTsDataProvider& dataProvider,
+ const TArray<MTsDataStorage*> &dataStorages);
+
+private:
+
+ /**
+ * Constructor for performing 1st stage construction
+ */
+ CRunningAppSession(MTsDataObserverStorage& observerStorage,
+ const MTsDataProvider& dataProvider);
+
+ /**
+ * EPOC default constructor for performing 2nd stage construction
+ */
+ void ConstructL(const TArray<MTsDataStorage*> &dataStorages);
+
+private:
+ /**
+ * Implements interface
+ * @see void CSession2::ServiceL(const RMessage2&)
+ */
+ void ServiceL(const RMessage2& message);
+
+private:
+ MTsDataObserverStorage& mObserverStorage;
+ const MTsDataProvider& mDataProvider;
+ RPointerArray<MTsDataStorage> mDataStorages;
+};
+
+#endif // RUNNINGAPPSESSION_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsdatalist.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2008 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: Non-closeable app list class
+ *
+*/
+
+
+#ifndef TSDATALIST_H
+#define TSDATALIST_H
+
+#include <e32base.h>
+#include <tswindowgroupsobserver.h>
+#include "tsentry.h"
+#include "tsdatastorage.h"
+#include "tsdataobserver.h"
+#include <HbIcon>
+
+class CApaWindowGroupName;
+class CFbsBitmap;
+
+NONSHARABLE_CLASS( CTsDataList ) : public CTsWindowGroupsObserver,
+ public MTsDataStorage
+ {
+public:
+ static CTsDataList* NewL(MTsResourceManager& resources,
+ MTsWindowGroupsMonitor &monitor,
+ MTsDataObserver& observer);
+
+ ~CTsDataList();
+
+private:
+ CTsDataList(MTsResourceManager& resources,
+ MTsWindowGroupsMonitor &monitor,
+ MTsDataObserver& observer);
+
+ void ConstructL();
+
+public:
+ const RTsFswArray& Data() const;
+
+ void HandleWindowGroupChanged(MTsResourceManager &,
+ const TArray<RWsSession::TWindowGroupChainInfo> &);
+
+ TBool IsHiddenUid( TUid uid );
+
+ TBool isSupported(TInt function) const;
+ void handleDataL(TInt function,RReadStream& dataStream);
+
+private:
+ void registerScreenshotL(RReadStream& dataStream);
+ void unregisterScreenshotL(RReadStream& dataStream);
+ void changeVisibilityL(RReadStream& dataStream);
+ void CollectAppsL(RTsFswArray& appsList,
+ const TArray<RWsSession::TWindowGroupChainInfo> &wgList);
+
+ void AddEntryL(const TTsEntryKey& key,
+ const TUid& appUid,
+ CApaWindowGroupName* wgName,
+ RTsFswArray& newList );
+
+ TBool ConsiderOldDataL( const TTsEntryKey& key );
+
+ HBufC* FindAppNameLC(CApaWindowGroupName* windowName,
+ const TUid& appUid,
+ TInt wgId );
+
+ void FitDataToList( RTsFswArray& listToFit);
+
+ TBool CheckIfExists(const CTsEntry& entry,
+ const RTsFswArray& newList) const;
+
+ CFbsBitmap* GetAppIconL(const TUid& aAppUid);
+
+ TInt FindEntry(const RTsFswArray& list, const TTsEntryKey& key ) const;
+
+ TBool EstablishOrder(const RArray<TTsEntryKey>& keyList);
+
+ TTsEntryKey GenerateKeyL(TInt);
+
+ void HideEntryIfNotAllowed(CTsEntry* entry);
+
+ TBool UpdateEntryData(const RTsFswArray& list);
+
+ void RebuildVisibleDataListL();
+
+ CFbsBitmap* HbIcon2CFbsBitmapL(const HbIcon& icon);
+private:
+ /**
+ * Resource manager. Not own
+ */
+ MTsResourceManager& mResources;
+
+ MTsDataObserver &mObserver;
+
+ RTsFswArray mData; // current fsw content, i.e. the task list
+ RTsFswArray mVisibleData;
+
+ // list of hidden uids
+ RArray<TUid> mHiddenUids;
+
+ // default icon
+ CFbsBitmap* mDefaultIcon;
+ };
+
+#endif //TSDATALIST_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsdataprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef DATAPROVIDER_H
+#define DATAPROVIDER_H
+
+#include <e32base.h>
+class MTsDataProvider {
+public:
+ virtual const TDesC8& Data() const = 0;
+};
+
+#endif //DATAPROVIDR_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsdatastorage.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef DATASTORAGE_H
+#define DATASTORAGE_H
+
+#include <e32base.h>
+#include "tstaskmonitorglobals.h"
+class CFbsBitmap;
+class MTsDataStorage {
+public:
+ virtual TBool isSupported(TInt function) const =0;
+ virtual void handleDataL(TInt function, RReadStream& dataStream) =0;
+};
+
+#endif //DATASTORAGE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsdatatask.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSDATATASK_H
+#define TSDATATASK_H
+#include "tstaskmonitorglobals.h"
+#include "tsdatastorage.h"
+class TsDataTask
+{
+public:
+ static void ExecuteL(const TArray<MTsDataStorage*> &dataStorages,
+ const RMessage2& msg);
+};
+
+#endif //TSDATATASK_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSMODEL_H
+#define TSMODEL_H
+
+#include <e32base.h>
+#include "tsmodelitem.h"
+
+class MTsModelObserver;
+class MTsModel
+{
+public:
+ virtual TInt count() const = 0;
+ TTsModelItem itemL(TInt offset) const;
+ virtual void setObserver(MTsModelObserver *observer) = 0;
+
+protected: //data access. should be used by TModelItem
+ virtual const TDesC& displayNameL(TInt offset) const = 0;
+ virtual TInt iconHandleL(TInt offset) const = 0;
+ virtual TTime timestampL(TInt offset) const = 0;
+ virtual TTsModelItemKey keyL(TInt offset) const = 0;
+ virtual TBool isActiveL(TInt offset) const = 0;
+ virtual TBool isClosableL(TInt offset) const = 0;
+
+protected: //operations execution
+ virtual TBool closeL(TTsModelItemKey key) const = 0;
+ virtual TBool launchL(TTsModelItemKey key) const = 0;
+
+ friend class TTsModelItem;
+};
+
+#endif //TSMODEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsmodelitem.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSMODELITEM_H
+#define TSMODELITEM_H
+
+#include <e32base.h>
+
+
+#include "tsmodelitemkey.h"
+
+class MTsModel;
+
+class TTsModelItem {
+public:
+ TTsModelItem(const MTsModel& model, TInt offset);
+ TTsModelItem(const TTsModelItem& item);
+ const TDesC& displayNameL() const;
+ TInt iconHandleL() const;
+ TTime timestampL() const;
+ TTsModelItemKey keyL() const;
+ TBool isActiveL() const;
+ TBool isClosableL() const;
+ TBool closeL() const;
+ TBool launchL() const;
+
+public:
+ void ExternalizeL(RWriteStream& stream) const;
+
+private:
+ void validateL() const;
+
+private:
+ const MTsModel& mModel;
+ const TInt mIndex;
+};
+
+#endif //TSMODELITEM_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsmodelitemkey.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSMODELITEMKEY_H
+#define TSMODELITEMKEY_H
+
+#include <e32base.h>
+#include <s32strm.h>
+
+typedef TInt TTsKey;
+
+class TTsModelItemKey
+{
+public:
+ static TInt size();
+ TTsModelItemKey();
+ TTsModelItemKey(TTsKey key, TInt root);
+ TTsModelItemKey(const TTsModelItemKey &key);
+ TTsModelItemKey& operator =(const TTsModelItemKey& key);
+ TBool operator == (const TTsModelItemKey key) const;
+ TInt key() const;
+ void ExternalizeL(RWriteStream& stream) const;
+ void InternalizeL(RReadStream& stream);
+
+private:
+ TTsKey mKey;
+ TInt mRoot;
+};
+
+#endif //TSMODELITEMKEY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsmodelitemkeymsg.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+
+#ifndef TSMODELITEMKEYMSG_H
+#define TSMODELITEMKEYMSG_H
+#include <e32base.h>
+#include <s32strm.h>
+#include "tsmodelitemkey.h"
+
+class CTsModelItemKeyMsg: public CBase
+{
+public:
+ static CTsModelItemKeyMsg* NewLC(RReadStream& stream);
+ static TInt size();
+ ~CTsModelItemKeyMsg();
+ TTsModelItemKey key() const;
+ void InternalizeL(RReadStream &stream);
+
+private:
+ CTsModelItemKeyMsg();
+ void ConstructL(RReadStream &stream);
+
+private:
+ TTsModelItemKey mKey;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsmodelobserver.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSMODELOBSERVER_H
+#define TSMODELOBSERVER_H
+
+#include <e32base.h>
+
+class MTsModel;
+class TTsModelItem;
+
+class MTsModelObserver {
+public:
+ virtual void dataChanged(MTsModel &model) = 0;
+ virtual void dataChanged(const TTsModelItem &item) = 0;
+};
+
+#endif //TSMODELOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsrunningappmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSRUNNINGAPPMODEL_H
+#define TSRUNNINGAPPMODEL_H
+
+#include "tsmodel.h"
+#include "tsdatastorage.h"
+#include "tsdataobserver.h"
+
+#include <tswindowgroupsobserver.h>
+
+class CTsDataList;
+class CTsScreenshotProvider;
+
+NONSHARABLE_CLASS(CTsRunningAppModel) : public CBase, public MTsModel, public MTsDataStorage, public MTsDataObserver
+{
+
+public:
+ static CTsRunningAppModel *NewL(MTsResourceManager &resources, MTsWindowGroupsMonitor &monitor);
+ static CTsRunningAppModel *NewLC(MTsResourceManager &resources, MTsWindowGroupsMonitor &monitor);
+
+ ~CTsRunningAppModel();
+
+private:
+ CTsRunningAppModel(MTsResourceManager &resources);
+ void ConstructL(MTsResourceManager &resources, MTsWindowGroupsMonitor &monitor);
+
+// MHsDataObserver interface implementation
+public:
+ virtual void DataChanged();
+
+// MTsDataStorage interface implementation
+public:
+ TBool isSupported(TInt function) const;
+ void handleDataL(TInt function, RReadStream& dataStream);
+
+public:
+ virtual TInt count() const;
+ virtual void setObserver(MTsModelObserver *observer);
+
+public:
+ virtual const TDesC& displayNameL(TInt offset) const;
+ virtual TInt iconHandleL(TInt offset) const;
+ virtual TTime timestampL(TInt offset) const;
+ virtual TTsModelItemKey keyL(TInt offset) const;
+ virtual TBool isActiveL(TInt offset) const;
+ virtual TBool isClosableL(TInt offset) const;
+
+public:
+ virtual TBool closeL(TTsModelItemKey key) const;
+ virtual TBool launchL(TTsModelItemKey key) const;
+
+private: // owned
+ CTsDataList *mDataList;
+
+private: // not owned
+ MTsModelObserver *mObserver;
+ CTsScreenshotProvider *mScreenshotProvider;
+ MTsResourceManager &mResources;
+
+};
+
+#endif //TSRUNNINGAPPMODEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsscreenshotprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSCREENSHOTPROVIDER_H
+#define TSSCREENSHOTPROVIDER_H
+#include "tsdatastorage.h"
+#include <w32std.h>
+
+class CTsScreenshotProvider: public CWsGraphic
+{
+public:
+ static CTsScreenshotProvider* NewL(MTsDataStorage&);
+private:
+ CTsScreenshotProvider(MTsDataStorage&);
+ void HandleMessage(const TDesC8&);
+ void HandleMessageL(const TDesC8&);
+ void OnReplace();
+private:
+ MTsDataStorage& mStorage;
+};
+
+#endif //TSSCREENSHOTTASK_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsserializeddataprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef SERIALIZEDDATAPROVIDER_H
+#define SERIALIZEDDATAPROVIDER_H
+
+#include "tsdataobserver.h"
+#include "tsdataprovider.h"
+#include "tsmodelobserver.h"
+
+class RWriteStream;
+
+class CTsSerializedDataProvider: public CBase,
+ public MTsModelObserver,
+ public MTsDataProvider
+{
+public:
+ static CTsSerializedDataProvider* NewL(MTsDataObserver &observer);
+ ~CTsSerializedDataProvider();
+ const TDesC8& Data() const;
+ void dataChanged(MTsModel &model);
+ void dataChanged(const TTsModelItem &item);
+
+private:
+ CTsSerializedDataProvider(MTsDataObserver& observer);
+ void serializeModel(const MTsModel &src);
+ void serializeModelL(const MTsModel &src);
+ void serializeModelL(RWriteStream& dst, const MTsModel &src);
+
+private:
+ MTsDataObserver& mObserver;
+ RBuf8 mData;
+
+};
+
+#endif //SERIALIZEDDATAPROVIDER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsservice.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSERVICE_H
+#define TSSERVICE_H
+
+#include <e32base.h>
+
+#include "tsmodel.h"
+#include "tsdataobserver.h"
+
+class QObject;
+class TsAbstractModel;
+
+class CTsService: public CBase,
+ public MTsModel,
+ public MTsDataObserver
+{
+public:
+ static CTsService* NewLC(QObject* model);
+ ~CTsService();
+
+public: //from MTsDataObserver
+ void DataChanged();
+
+public: //from MTsModel
+ TInt count() const;
+ void setObserver(MTsModelObserver *observer);
+
+protected: //from MTsModel
+ const TDesC& displayNameL(TInt offset) const;
+ TInt iconHandleL(TInt offset) const;
+ TTime timestampL(TInt offset) const;
+ TTsModelItemKey keyL(TInt offset) const;
+ TBool isActiveL(TInt offset) const;
+ TBool isClosableL(TInt offset) const;
+ TBool closeL(TTsModelItemKey key) const;
+ TBool launchL(TTsModelItemKey key) const;
+
+private:
+ CTsService();
+ void ConstructL(QObject* model);
+ TInt intValueL(TInt offset, const char *key) const;
+ TTime timeValueL(TInt offset, const char *key) const;
+ const TDesC& stringValueL(TInt offset, const char *key) const;
+private:
+ QObject *mModel;
+ QObject *mServiceObserver;
+ MTsModelObserver *mModelObserver;
+ HBufC *mBuffer;
+};
+#endif //TSSERVICE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsserviceobserver.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSERVICEOBSERVER_H
+#define TSSERVICEOBSERVER_H
+#include <QObject>
+
+#include "tsdataobserver.h"
+class TsServiceObserver: public QObject
+{
+ Q_OBJECT
+
+public:
+ TsServiceObserver(MTsDataObserver& observer);
+
+public slots:
+ void dataChanged();
+
+private:
+ MTsDataObserver &mObserver;
+};
+#endif //TSSERVICEOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsservicesprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSERVICESPROVIDER_H
+#define TSSERVICESPROVIDER_H
+
+#include "tsmodel.h"
+#include "tsservicesproviderconfig.h"
+
+class CTsService;
+
+class CTsServiceProvider: public CBase
+{
+public:
+ static CTsServiceProvider* NewL(const CTsServiceProviderConfig& config);
+ ~CTsServiceProvider();
+ MTsModel& operator[](TInt offset) const;
+ TInt count() const;
+
+private:
+ CTsServiceProvider();
+ void Construct(const CTsServiceProviderConfig& config);
+
+private:
+ RPointerArray<CTsService> mServices;
+};
+#endif //TSSERVICESPROVIDER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsservicesproviderconfig.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSERVICESPROVIDERCONFIG_H
+#define TSSERVICESPROVIDERCONFIG_H
+
+#include <e32base.h>
+class QObject;
+class CTsServiceProviderConfig: public CBase
+{
+public:
+ static CTsServiceProviderConfig* NewLC();
+ ~CTsServiceProviderConfig();
+
+ TInt count() const;
+ QObject* loadL(TInt offset)const;
+private:
+ CTsServiceProviderConfig();
+ void ConstructL();
+
+private:
+ RPointerArray<TAny> mServices;
+};
+
+#endif //TSSERVICESPROVIDERCONFIG_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/inc/tsstorage.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSTORAGE_H
+#define TSSTORAGE_H
+#include <e32base.h>
+
+#include "tsmodel.h"
+#include "tsmodelobserver.h"
+#include "tsdataobserver.h"
+#include "tsdatastorage.h"
+
+class CTsStorage: public CBase,
+ public MTsModel,
+ public MTsModelObserver,
+ public MTsDataObserver,
+ public MTsDataStorage
+{
+public:
+ static CTsStorage* NewL(const TArray<MTsModel*> &dataProviders);
+ ~CTsStorage();
+
+private:
+ CTsStorage();
+ void ConstructL(const TArray<MTsModel*> &dataProviders);
+ TInt resetModel();
+ void resetModelL();
+ void pullDataL(const MTsModel& src);
+ void reorderDataL();
+
+public://from MTsModelObserver
+ void dataChanged(MTsModel &model);
+ void dataChanged(const TTsModelItem &item);
+
+public://from MTsModel
+ TInt count() const;
+ void setObserver(MTsModelObserver *observer);
+
+private://from MTsModel
+ const TDesC& displayNameL(TInt offset) const;
+ TInt iconHandleL(TInt offset) const;
+ TTime timestampL(TInt offset) const;
+ TTsModelItemKey keyL(TInt offset) const;
+ TBool isActiveL(TInt offset) const;
+ TBool isClosableL(TInt offset) const;
+ TBool closeL(TTsModelItemKey key) const;
+ TBool launchL(TTsModelItemKey key) const;
+ TTsModelItem findL(TTsModelItemKey key) const;
+
+public://from MTsDataObserver
+ void DataChanged();
+
+public://from MTsDataStorage
+ TBool isSupported(TInt function) const;
+ void handleDataL(TInt function, RReadStream& dataStream);
+
+private:
+ RPointerArray<MTsModel> mDataProviders;
+ RArray<TTsModelItem> mData;
+ MTsModelObserver* mDataObserver;
+
+};
+
+#endif //TSSTORAGE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/server.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,107 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = hsrunningappmonitor
+CONFIG += hb mobility
+MOBILITY = serviceframework
+
+myrssrules = \
+"hidden = KAppIsHidden;"
+RSS_RULES += myrssrules
+
+INCLUDEPATH += inc \
+ ../inc \
+ ../../inc \
+ ../utils/inc \
+ ../backstepping/inc \
+
+SOURCES += src/hsdataobservertask.cpp \
+ src/hsdataprovidertask.cpp \
+ src/hsrunningappserver.cpp \
+ src/hsrunningappsession.cpp \
+ src/main.cpp \
+ src/tsdatalist.cpp \
+ src/tsdatatask.cpp \
+ src/tsscreenshotprovider.cpp \
+ src/tsmodelitemkey.cpp \
+ src/tsmodelitem.cpp \
+ src/tsmodel.cpp \
+ src/tsrunningappmodel.cpp \
+ src/tsstorage.cpp \
+ src/tsserializeddataprovider.cpp \
+ src/tsservice.cpp \
+ src/tsservicesprovider.cpp \
+ src/tsservicesproviderconfig.cpp \
+ src/tsserviceobserver.cpp \
+ src/tsmodelitemkeymsg.cpp \
+ ../utils/src/tsentrykey.cpp \
+ ../utils/src/tsentrykeygenerator.cpp \
+ ../utils/src/tsentry.cpp \
+ ../utils/src/tsscreenshotmsg.cpp \
+ ../utils/src/tsunregscreenshotmsg.cpp \
+ ../utils/src/tsvisibilitymsg.cpp
+
+
+HEADERS += inc/hsdataobservertask.h \
+ inc/tsdataprovider.h \
+ inc/hsdataprovidertask.h \
+ inc/hsrunningappserver.h \
+ inc/hsrunningappsession.h \
+ inc/tsdatalist.h \
+ inc/tsdatastorage.h \
+ inc/tsdatatask.h \
+ inc/tsscreenshotprovider.h \
+ inc/tsmodelobserver.h \
+ inc/tsmodelitemkey.h \
+ inc/tsmodelitem.h \
+ inc/tsmodel.h \
+ inc/tsrunningappmodel.h \
+ inc/tsstorage.h \
+ inc/tsserializeddataprovider.h \
+ inc/tsservice.h \
+ inc/tsservicesprovider.h \
+ inc/tsservicesproviderconfig.h \
+ inc/tsserviceobserver.h \
+ inc/tsmodelitemkeymsg.h \
+ ../utils/inc/tsdataobserver.h \
+ ../utils/inc/tsentry.h \
+ ../utils/inc/tsentrykey.h \
+ ../utils/inc/tsentrykeygenerator.h \
+ ../utils/inc/tsutils.h \
+ ../utils/inc/tsscreenshotmsg.h \
+ ../utils/inc/tsunregscreenshotmsg.h \
+ ../utils/inc/tsvisibilitymsg.h
+
+
+LIBS += -lxqutils \
+ -ltsutils \
+ -ltsbackstepping \
+ -laknicon \
+ -lfbscli \ #for CFbsBitmap
+ -lestor \ #for RDesReadStream
+ -lxqutils \
+ -lapgrfx \ #for CApaWindowGroupName
+ -lws32 \ #for CWsGraphic
+ -lapparc \ #for TApaAppInfo
+ -lcaclient \ #for getApplicationIcon
+ -lcone
+
+symbian {
+ TARGET.UID3 = 0x200267B0
+ TARGET.CAPABILITY = All -TCB
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/hsdataobservertask.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 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 "hsdataobservertask.h"
+#include "tstaskmonitorglobals.h"
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CHsDataObserverTask::CHsDataObserverTask(MTsDataObserverStorage& storage,
+ const RMessage2& msg)
+:
+ mStorage(storage),
+ mMsg(msg)
+{
+ // No implementation required
+}
+
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CHsDataObserverTask::~CHsDataObserverTask()
+{
+ if (EFalse == mMsg.IsNull()) {
+ mMsg.Complete(mDataChanged ? KErrNone : KErrCancel);
+ }
+}
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CHsDataObserverTask::ExecuteLD(MTsDataObserverStorage& storage,const RMessage2& msg)
+{
+ CTsDataObserver *self = new (ELeave)CHsDataObserverTask(storage, msg);
+ CleanupStack::PushL(self);
+ storage.PushL(self);
+ CleanupStack::Pop(self);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CHsDataObserverTask::DataChanged()
+{
+ mDataChanged = ETrue;
+ mStorage.Pop(this);
+ delete this;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CHsDataObserverTask::Cancel(const RMessage2& reason)
+{
+ if (CancelSubscribeRunningAppChanges == reason.Function() &&
+ mMsg.Session() == reason.Session()) {
+ mStorage.Pop(this);
+ delete this;
+ }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TBool CHsDataObserverTask::IsParent(const CSession2* session)
+{
+ return mMsg.Session() == session;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/hsdataprovidertask.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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 "hsdataprovidertask.h"
+#include "tstaskmonitorglobals.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void HsDataProviderTask::ExecuteL(const MTsDataProvider& provider, const RMessage2& msg)
+{
+ switch (msg.Function()) {
+ case GetRunningAppInfo:
+ msg.WriteL(KRequestDataSizeOffset, TPckgBuf<TInt>(provider.Data().Length()));
+ msg.Complete(KErrNone);
+ break;
+
+ case FlushData:
+ if (provider.Data().Length() > msg.GetDesMaxLengthL(KRequestDataBufferOffset)) {
+ User::Leave(KErrCorrupt);
+ }
+ msg.WriteL(KRequestDataBufferOffset, provider.Data());
+ msg.Complete(KErrNone);
+ break;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/hsrunningappserver.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,187 @@
+/*
+* Copyright (c) 2009 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 <tswindowgroupsobserver.h>
+#include "tstaskmonitorglobals.h"
+#include "hsrunningappserver.h"
+#include "hsrunningappsession.h"
+#include "tsbacksteppingactivation.h"
+
+#include "tsmodel.h"
+#include "tsstorage.h"
+#include "tsservicesprovider.h"
+#include "tsserializeddataprovider.h"
+#include "tsrunningappmodel.h"
+
+_LIT(KErrObserverExists, "Observer already exists");
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CRunningAppServer::CRunningAppServer()
+:
+CServer2(EPriorityStandard)
+{
+ // No implementation required
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CRunningAppServer::~CRunningAppServer()
+{
+ delete mBacksteppingEngine;
+ delete mStorage;
+ delete mAppsModel;
+ delete mServiceProvider;
+ delete mSerializer;
+ delete mMonitor;
+ mObservers.ResetAndDestroy();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CRunningAppServer* CRunningAppServer::NewLC()
+{
+ CRunningAppServer* self = new (ELeave) CRunningAppServer();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppServer::ConstructL()
+{
+ StartL(KRunningAppServerName);
+ User::LeaveIfError(mWsSession.Connect());
+ mResources = CTsResourceManager::NewL();
+ mMonitor = CTsWindowGroupsMonitor::NewL(*mResources);
+
+ mSerializer = CTsSerializedDataProvider::NewL(*this);
+
+ RPointerArray<MTsModel> providers;
+ CleanupClosePushL(providers);
+
+ mAppsModel = CTsRunningAppModel::NewL(*mResources, *mMonitor);
+ providers.AppendL(mAppsModel);
+
+ CTsServiceProviderConfig *cfg = CTsServiceProviderConfig::NewLC();
+ mServiceProvider = CTsServiceProvider::NewL(*cfg);
+ CleanupStack::PopAndDestroy(cfg);
+ addProviders(providers, *mServiceProvider);
+
+ mStorage = CTsStorage::NewL(providers.Array());
+ mStorage->setObserver(mSerializer);
+ CleanupStack::PopAndDestroy(&providers);
+
+ // load initial data
+ mStorage->DataChanged();
+
+ TRAP_IGNORE(mBacksteppingEngine = CTsBacksteppingActivation::NewL(*mMonitor);)
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CSession2* CRunningAppServer::NewSessionL(const TVersion &, const RMessage2&) const
+{
+ RPointerArray<MTsDataStorage> dataStorages;
+ CleanupClosePushL(dataStorages);
+ dataStorages.AppendL(const_cast<CRunningAppServer *>(this)->mAppsModel);
+ dataStorages.AppendL(const_cast<CRunningAppServer *>(this)->mStorage);
+ CSession2* retVal = CRunningAppSession::NewL(*const_cast<CRunningAppServer *>(this),
+ *const_cast<CRunningAppServer *>(this)->mSerializer,
+ dataStorages.Array());
+ CleanupStack::PopAndDestroy(&dataStorages);
+ return retVal;
+
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppServer::DataChanged()
+{
+ while (0 < mObservers.Count()) {
+ mObservers[0]->DataChanged();
+ }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppServer::PushL(CTsDataObserver* observer)
+{
+ ( 0 <= mObservers.Find(observer)) ?
+ User::Panic(KErrObserverExists, KErrAlreadyExists) :
+ mObservers.AppendL(observer);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppServer::Pop(CTsDataObserver* observer)
+{
+ const TInt offset(mObservers.Find(observer));
+ if(0 <= offset) {
+ mObservers.Remove(offset);
+ }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppServer::Cancel(const RMessage2& reason)
+{
+ for (TInt iter(mObservers.Count() - 1); 0 <= iter; --iter) {
+ mObservers[iter]->Cancel(reason);
+ }
+ reason.Complete(KErrNone);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppServer::Invalidate(const CSession2* session)
+{
+ for (TInt iter(mObservers.Count() - 1); 0 <= iter; --iter) {
+ if(mObservers[iter]->IsParent(session)) {
+ delete mObservers[iter];
+ mObservers.Remove(iter);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void CRunningAppServer::addProviders(RPointerArray<MTsModel> &dst,
+ const CTsServiceProvider& serviceProvider)
+{
+ for (TInt offset(0); offset < serviceProvider.count(); ++offset) {
+ dst.Append(&serviceProvider[offset]);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/hsrunningappsession.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2009 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 "hsrunningappsession.h"
+#include "tstaskmonitorglobals.h"
+
+#include "hsdataobservertask.h"
+#include "hsdataprovidertask.h"
+#include "tsdatatask.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CRunningAppSession::CRunningAppSession(MTsDataObserverStorage& observerStorage,
+ const MTsDataProvider& dataProvider)
+:
+ mObserverStorage(observerStorage),
+ mDataProvider(dataProvider)
+{
+ // No implementation required
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CRunningAppSession::~CRunningAppSession()
+{
+ mObserverStorage.Invalidate(this);
+ mDataStorages.Close();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CRunningAppSession* CRunningAppSession::NewL(MTsDataObserverStorage& observerStorage,
+ const MTsDataProvider& dataProvider,
+ const TArray<MTsDataStorage*> &dataStorages)
+{
+ CRunningAppSession* self = new (ELeave) CRunningAppSession(observerStorage,
+ dataProvider);
+ CleanupStack::PushL(self);
+ self->ConstructL(dataStorages);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppSession::ConstructL(const TArray<MTsDataStorage*> &dataStorages)
+{
+ for (TInt iter(0); iter < dataStorages.Count(); ++iter) {
+ mDataStorages.AppendL(dataStorages[iter]);
+ }
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CRunningAppSession::ServiceL(const RMessage2& message)
+{
+ switch (message.Function()) {
+ case SubscribeRunningAppChanges:
+ CHsDataObserverTask::ExecuteLD(mObserverStorage, message);
+ break;
+
+ case CancelSubscribeRunningAppChanges:
+ mObserverStorage.Cancel(message);
+ break;
+
+ case GetRunningAppInfo:
+ case FlushData:
+ HsDataProviderTask::ExecuteL(mDataProvider, message);
+ break;
+
+ case RegisterScreenshotMessage:
+ case UnregisterScreenshotMessage:
+ case VisibilityChange:
+ case OpenTaskMessage:
+ case CloseTaskMessage:
+ TsDataTask::ExecuteL(mDataStorages.Array(), message);
+ break;
+
+ default:
+ message.Complete(CServer2::EBadMessageNumber);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 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 <QApplication>
+
+#include "hsrunningappserver.h"
+#include "tstaskmonitorglobals.h"
+#include <apgwgnam.h>
+#include <eikenv.h>
+
+#include <caservice.h>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ // hide server from TaskSwitcher
+ CEikonEnv * env = CEikonEnv::Static();
+ if(env) {
+ env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
+
+ CApaWindowGroupName *wgName = CApaWindowGroupName::NewLC(env->WsSession());
+ wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
+ wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down
+ wgName->SetCaptionL(KRunningAppServerName);
+ wgName->SetWindowGroupName(env->RootWin());
+ CleanupStack::PopAndDestroy(wgName);
+ }
+
+ // maintain instance of caservice (needed for getting application icons)
+ QSharedPointer<CaService> service = CaService::instance();
+
+ CServer2* serverObject = CRunningAppServer::NewLC();
+ CleanupStack::Pop(serverObject);
+
+ RSemaphore semaphore;
+ if (KErrNone == semaphore.OpenGlobal(KTsServerReadySemaphore)) {
+ semaphore.Signal();
+ }
+ semaphore.Close();
+
+ int result = app.exec();
+
+ delete serverObject;
+ return result;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsdatalist.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,565 @@
+/*
+ * Copyright (c) 2008 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: File containing application list classes
+ *
+ */
+
+//INCLUDES:
+#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL
+#include <apgwgnam.h>
+#include <bitstd.h>
+#include <AknIconUtils.h> // avkon
+#include <apgicnfl.h> // fbsbitmap
+#include <AknIconSrvClient.h>
+#include <fbs.h>
+#include <apgwgnam.h>
+#include <QSizeF>
+#include <camenuiconutility.h>
+
+#include "tsdatalist.h"
+#include "tsentrykeygenerator.h"
+#include "tsscreenshotmsg.h"
+#include "tsunregscreenshotmsg.h"
+#include "tsvisibilitymsg.h"
+
+// size for the created app icons
+const TInt KAppIconWidth = 128;
+const TInt KAppIconHeight = 128;
+
+//uids to be hidden
+const TUid KHsApplicationUid = { 0x20022F35 };
+
+// ================= MEMBER FUNCTIONS =======================
+
+// --------------------------------------------------------------------------
+/**
+ * Two-phased constructor.
+ */
+CTsDataList* CTsDataList::NewL(MTsResourceManager& resources,
+ MTsWindowGroupsMonitor &monitor,
+ MTsDataObserver& observer)
+{
+ CTsDataList* self = new (ELeave) CTsDataList(resources, monitor, observer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Constructor.
+ */
+CTsDataList::CTsDataList(MTsResourceManager& resources,
+ MTsWindowGroupsMonitor &monitor,
+ MTsDataObserver& observer)
+:
+ CTsWindowGroupsObserver(monitor),
+ mResources(resources),
+ mObserver(observer)
+{
+}
+
+// --------------------------------------------------------------------------
+/*
+ * Destructor
+ */
+CTsDataList::~CTsDataList()
+{
+ mData.ResetAndDestroy();
+ mVisibleData.Close();
+ mHiddenUids.Close();
+ RFbsSession::Disconnect();
+ RAknIconSrvClient::Disconnect();
+ delete mDefaultIcon;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Performs 2nd phase construction.
+ */
+void CTsDataList::ConstructL()
+{
+ BaseConstructL();
+ mHiddenUids.AppendL(KHsApplicationUid);
+ User::LeaveIfError(RFbsSession::Connect());
+ RAknIconSrvClient::Connect();
+ mDefaultIcon = HbIcon2CFbsBitmapL(HbIcon("qtg_large_application"));
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Returns a reference to the current content.
+ * Also performs sanity checks, e.g. associates application icons
+ * when no screenshot has been received.
+ * @return ref to content array
+ */
+const RTsFswArray& CTsDataList::Data() const
+{
+ return mVisibleData;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsWindowGroupsObserver HandleWindowGroupChanged
+ */
+void CTsDataList::HandleWindowGroupChanged(MTsResourceManager &,
+ const TArray<RWsSession::TWindowGroupChainInfo> &wgList)
+{
+ TRAP_IGNORE(RTsFswArray newAppsList;
+ CleanupResetAndDestroyPushL(newAppsList);
+ CollectAppsL(newAppsList, wgList);
+ FitDataToList(newAppsList);
+ CleanupStack::PopAndDestroy(&newAppsList);
+ );
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Adds running apps to the list.
+ * @param appsList array to add to
+ */
+void CTsDataList::CollectAppsL(RTsFswArray& appsList,
+ const TArray<RWsSession::TWindowGroupChainInfo> &wgList)
+{
+ for (TInt i = 0; i < wgList.Count(); ++i) {
+ TTsEntryKey key;
+ TInt err = TsEntryKeyGeneraror::Generate(key, wgList[i].iId, wgList);
+
+ //skip this entry if it is already on list or generate key failed
+ if (err!=KErrNone || FindEntry(appsList, key) >= 0) {
+ continue;
+ }
+
+ // get window group name
+ CApaWindowGroupName* windowName = CApaWindowGroupName::NewLC(mResources.WsSession(), key.WindowGroupId());
+ TUid appUid = windowName->AppUid();
+
+ // get screen number (-1=console, 0=main screen, 1=cover ui)
+ TInt appScreen = 0;
+ TInt scrNumErr = mResources.ApaSession().GetDefaultScreenNumber( appScreen, appUid );
+
+ if (appUid.iUid && !windowName->Hidden() && (appScreen == 0 || appScreen == -1) && scrNumErr == KErrNone ) {
+ AddEntryL(key, appUid, windowName, appsList);
+ }
+
+ CleanupStack::PopAndDestroy(windowName);
+ }
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Called from CollectTasksL for each entry in the task list.
+ * @param key entry key
+ * @param appUid application uid
+ * @param wgName window group name or NULL
+ * @param newList list to add to
+ */
+void CTsDataList::AddEntryL(const TTsEntryKey& key, const TUid& appUid,
+ CApaWindowGroupName* wgName, RTsFswArray& newList)
+{
+ CTsEntry* entry = CTsEntry::NewLC(key, mObserver);
+
+ // check if present in old list and if yes then take some of the old data
+ TBool found = ConsiderOldDataL(key);
+
+ // if not present previously then find out app name
+ // and check if screenshot is already available
+ if (!found) {
+ entry->SetAppUid(appUid);
+
+ HBufC* name = FindAppNameLC(wgName, appUid, key.WindowGroupId());
+ if (name) {
+ entry->SetAppNameL(*name);
+ }
+ CleanupStack::PopAndDestroy(name);
+
+ CFbsBitmap* iconBitmap = GetAppIconL(appUid);
+ //transfer ownership to entry
+ entry->SetAppIcon(iconBitmap);
+ }
+
+ if (wgName) {
+ entry->SetCloseableApp(!wgName->IsSystem());
+ }
+
+ // add to new list, ownership is transferred
+ newList.AppendL(entry);
+ CleanupStack::Pop(entry);
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Checks if there is an entry for same app in the content list.
+ * If yes then it takes some of the data for the entry that
+ * will correspond to the same app in the refreshed content list.
+ * @param key new key in content list
+ * @return ETrue if app was found
+ */
+TBool CTsDataList::ConsiderOldDataL(const TTsEntryKey& key)
+{
+ for (TInt entryIdx = 0, oldCount = mData.Count(); entryIdx < oldCount; ++entryIdx) {
+ if (mData[entryIdx]->Key() == key) {
+ return ETrue;
+ }
+ }
+ return EFalse;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Finds out the application name.
+ * @param windowName window group name or NULL
+ * @param appUId application uid
+ * @param wgId window group id
+ * @return application name, ownership transferred to caller
+ */
+HBufC* CTsDataList::FindAppNameLC(CApaWindowGroupName* windowName, const TUid& appUid, TInt wgId)
+{
+ //Retrieve the app name
+ TApaAppInfo info;
+ mResources.ApaSession().GetAppInfo(info, appUid);
+ TPtrC caption = info.iShortCaption;
+
+ HBufC* tempName = 0;
+ if (!caption.Length() && windowName) // if not set - use thread name instead
+ {
+ if (windowName->Caption().Length()) {
+ tempName = windowName->Caption().AllocL();
+ //put on cleanupstack after the if
+ }
+ else {
+ TThreadId threadId;
+ TInt err = mResources.WsSession().GetWindowGroupClientThreadId(wgId, threadId);
+ if (err == KErrNone) {
+ RThread thread;
+ CleanupClosePushL(thread);
+ err = thread.Open(threadId);
+ if (err == KErrNone) {
+ tempName = thread.Name().AllocL(); // codescanner::forgottoputptroncleanupstack
+ // tempName put on cleanupstack after the if
+ }
+ CleanupStack::PopAndDestroy(&thread);
+ }
+ }
+ }
+ else {
+ tempName = caption.AllocL();
+ //put on cleanupstack after the if
+ }
+ CleanupStack::PushL(tempName);
+ return tempName;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Fit existing class contained data list into give one.
+ * Data is being changed with application type consideration that is based
+ * on aConsiderWidgets param.
+ * Function removes or add entries into data depend on given list.
+ * @param listToFit list with actual data
+ */
+void CTsDataList::FitDataToList(RTsFswArray& listToFit)
+{
+ TBool changed = EFalse;
+ TInt listCount = listToFit.Count();
+ TInt dataCount = mData.Count();
+
+ //remove items that dont't exists in newly collected list
+ for (TInt i = dataCount - 1; i >= 0; --i) {
+ if (!CheckIfExists(*mData[i], listToFit)) {
+ delete mData[i];
+ mData.Remove(i);
+ changed = ETrue;
+ }
+ }
+ RArray<TTsEntryKey> allKeys;
+
+ //add new items at start
+ for (TInt i = listToFit.Count() - 1; i >= 0; --i) {
+ allKeys.Insert(listToFit[i]->Key(), 0);
+ if (!CheckIfExists(*listToFit[i], mData)) {
+ HideEntryIfNotAllowed(listToFit[i]);
+ mData.Insert(listToFit[i], 0);
+
+ TTime currentTimestamp;
+ currentTimestamp.UniversalTime();
+ mData[0]->SetTimestamp(currentTimestamp);
+
+ listToFit[i] = 0;
+ changed = ETrue;
+ }
+ }
+ //establish order
+ TBool orderChanged = EstablishOrder(allKeys);
+
+ //update entries data
+ TBool dataChanged = UpdateEntryData(listToFit);
+ RebuildVisibleDataListL();
+ if (changed || orderChanged || dataChanged) {
+ mObserver.DataChanged();
+ }
+ allKeys.Close();
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Checks if there is an entry for same app in the given list.
+ * @param entry entry
+ * @param newList ref to list
+ * @return ETrue if app was found
+ */
+
+TBool CTsDataList::CheckIfExists(const CTsEntry& entry, const RTsFswArray& list) const
+{
+ TBool exists(EFalse);
+ TInt pos = FindEntry(list, entry.Key());
+ if (pos >= 0) {
+ exists = ETrue;
+ }
+ return exists;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Retrieves the bitmap for the icon of the given app.
+ * @param appUid application uid
+ * @return app CFbsBitmap
+ */
+CFbsBitmap* CTsDataList::GetAppIconL(const TUid& aAppUid)
+{
+ HbIcon icon = CaMenuIconUtility::getApplicationIcon(aAppUid.iUid, QSizeF(KAppIconWidth, KAppIconHeight));
+ CFbsBitmap* iconBitmap = HbIcon2CFbsBitmapL(icon);
+ if (!iconBitmap) {
+ iconBitmap = new(ELeave) CFbsBitmap;
+ TInt err = KErrNotFound;
+ if(mDefaultIcon) {
+ err = iconBitmap->Duplicate(mDefaultIcon->Handle());
+ }
+ if (KErrNone!=err) {
+ delete iconBitmap;
+ iconBitmap = NULL;
+ }
+ }
+ return iconBitmap;
+ }
+
+// --------------------------------------------------------------------------
+/**
+ * Converts HbIcon to CFbsBitmap
+ * @param icon icon to be coverted
+ * @return CFbsBitmap
+ */
+CFbsBitmap* CTsDataList::HbIcon2CFbsBitmapL(const HbIcon& icon)
+{
+ QIcon qicon = icon.qicon();
+ QPixmap pixmap = qicon.pixmap(QSize(KAppIconWidth, KAppIconHeight));
+ CFbsBitmap* retValue = NULL;
+ if (!pixmap.isNull()) {
+ retValue = pixmap.toSymbianCFbsBitmap();
+ }
+ return retValue;
+}
+// --------------------------------------------------------------------------
+TBool CTsDataList::isSupported(TInt function) const
+{
+ return (RegisterScreenshotMessage == function ||
+ UnregisterScreenshotMessage == function ||
+ VisibilityChange == function);
+}
+
+// --------------------------------------------------------------------------
+void CTsDataList::handleDataL(TInt function,RReadStream& dataStream)
+{
+ switch(function){
+ case RegisterScreenshotMessage:
+ registerScreenshotL(dataStream);
+ break;
+ case UnregisterScreenshotMessage:
+ unregisterScreenshotL(dataStream);
+ break;
+ case VisibilityChange:
+ changeVisibilityL(dataStream);
+ break;
+ }
+}
+
+// --------------------------------------------------------------------------
+void CTsDataList::registerScreenshotL(RReadStream& dataStream)
+{
+ CTsScreenshotMsg* msg = CTsScreenshotMsg::NewLC(dataStream);
+ const TInt pos = FindEntry(mData, GenerateKeyL(msg->windowGroupId()));
+ User::LeaveIfError(pos);
+ mData[pos]->SetScreenshotL(msg->screenshot(), msg->priority());
+ CleanupStack::PopAndDestroy(msg);
+}
+// --------------------------------------------------------------------------
+void CTsDataList::unregisterScreenshotL(RReadStream& dataStream)
+{
+
+ CTsUnregisterScreenshotMsg* msg = CTsUnregisterScreenshotMsg::NewLC(dataStream);
+ const TInt pos = FindEntry(mData, GenerateKeyL(msg->windowGroupId()));
+ User::LeaveIfError(pos);
+ mData[pos]->RemoveScreenshotL();
+ CleanupStack::PopAndDestroy(msg);
+}
+// --------------------------------------------------------------------------
+void CTsDataList::changeVisibilityL(RReadStream& dataStream)
+{
+ CTsVisibilitMsg* msg = CTsVisibilitMsg::NewLC(dataStream);
+ const TInt pos = FindEntry(mData, GenerateKeyL(msg->windowGroupId()));
+ User::LeaveIfError(pos);
+ msg->visibility() == mData[pos]->GetVisibility() ? User::Leave(KErrInUse) :
+ mData[pos]->SetVisibility(msg->visibility());
+ CleanupStack::PopAndDestroy(msg);
+ RebuildVisibleDataListL();
+ mObserver.DataChanged();
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Checks if given uid is on hidden list
+ * @param aUid uid to be checked
+ * @return ETrue if uid is on hidden list
+ */
+TBool CTsDataList::IsHiddenUid(TUid uid)
+{
+ return mHiddenUids.Find(uid) >= 0 ? ETrue : EFalse;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Finds entry in array
+ * @param list list to find
+ * @param key finding key
+ * @return position or KErrNotFound
+ */
+TInt CTsDataList::FindEntry(const RTsFswArray& list, const TTsEntryKey& key) const
+{
+ TInt pos(KErrNotFound);
+ for (TInt entryIdx = 0; entryIdx < list.Count(); ++entryIdx) {
+ if (list[entryIdx]->Key() == key) {
+ pos = entryIdx;
+ break;
+ }
+ }
+ return pos;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Establish entry order accridung to aKeyList, all keys MUST be in iData
+ * @param keyList reference key list
+ * @return ETrue if changes occured
+ */
+TBool CTsDataList::EstablishOrder(const RArray<TTsEntryKey>& keyList)
+{
+ TBool changed(EFalse);
+ TInt lastChangedItem(KErrNotFound);
+ __ASSERT_ALWAYS(mData.Count() == keyList.Count(), User::Panic(_L("EstablishOrder 1"), KErrBadHandle) );
+ for (TInt i = 0; i < keyList.Count(); i++) {
+ const TTsEntryKey& currentdataKey = mData[i]->Key();
+ const TTsEntryKey& referenceKey = keyList[i];
+ if (!(currentdataKey == referenceKey)) {
+ TInt foundPos = FindEntry(mData, referenceKey);
+ __ASSERT_ALWAYS(foundPos>=0, User::Panic(_L("EstablishOrder 2"), KErrBadHandle) );
+ CTsEntry* entry = mData[foundPos];
+ mData.Remove(foundPos);
+ mData.Insert(entry, i);
+ changed = ETrue;
+ lastChangedItem = i;
+ }
+ }
+
+ TTime currentTimestamp;
+ currentTimestamp.UniversalTime();
+ for (TInt i = lastChangedItem; i >= 0; --i) {
+ mData[i]->SetTimestamp(currentTimestamp);
+ }
+
+ return changed;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Updates entry data on mData according to list
+ * @param list reference entires list
+ * @return ETrue if changes occured
+ */
+TBool CTsDataList::UpdateEntryData(const RTsFswArray& list)
+{
+ __ASSERT_ALWAYS(mData.Count() == list.Count(), User::Panic(_L("UpdateEntryData 1"), KErrBadHandle) );
+ TBool changed(EFalse);
+ for (TInt i=0; i<list.Count(); i++) {
+ if(list[i]) {
+ __ASSERT_ALWAYS(mData[i]->Key() == list[i]->Key(), User::Panic(_L("UpdateEntryData 12"), KErrBadHandle) );
+ if(mData[i]->CloseableApp() != list[i]->CloseableApp()) {
+ mData[i]->SetCloseableApp(list[i]->CloseableApp());
+ changed = ETrue;
+ }
+ }
+ }
+ return changed;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Function generate task key using window group id
+ * @param wgId - window group id of running application
+ * @param entry key
+ */
+TTsEntryKey CTsDataList::GenerateKeyL(TInt wgId)
+{
+ RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
+ CleanupClosePushL(allWgIds);
+ User::LeaveIfError(mResources.WsSession().WindowGroupList(0, &allWgIds));
+ TTsEntryKey key;
+ User::LeaveIfError(TsEntryKeyGeneraror::Generate(key, wgId, allWgIds.Array()));
+ CleanupStack::PopAndDestroy(&allWgIds);
+ return key;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Hides entrie if exist on mHiddenUids
+ * @param entry
+ */
+void CTsDataList::HideEntryIfNotAllowed(CTsEntry* entry)
+{
+ TUid uid = entry->AppUid();
+ if(mHiddenUids.Find(uid) >= 0) {
+ entry->SetVisibility(Invisible);
+ }
+
+}
+
+void CTsDataList::RebuildVisibleDataListL()
+{
+ mVisibleData.Reset();
+
+ RArray<TInt> visibleItems(mData.Count() ? mData.Count() : 1);
+ CleanupClosePushL(visibleItems);
+ for (TInt iter = 0; iter < mData.Count(); ++iter) {
+ if (Visible == mData[iter]->GetVisibility()) {
+ visibleItems.AppendL(iter);
+ }
+ }
+
+ for (TInt iter = 0; iter < visibleItems.Count(); ++iter) {
+ mVisibleData.AppendL(mData[visibleItems[iter]]);
+ }
+ CleanupStack::PopAndDestroy(&visibleItems);
+}
+// end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsdatatask.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 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 "tsdatatask.h"
+#include <s32mem.h>
+// -----------------------------------------------------------------------------
+void TsDataTask::ExecuteL(const TArray<MTsDataStorage*>& dataStorages, const RMessage2& msg)
+{
+ TInt responseCode(KErrNotSupported);
+ for (TInt iter(0); iter < dataStorages.Count() && KErrNone != responseCode; ++iter) {
+ if (dataStorages[iter]->isSupported(msg.Function())) {
+ HBufC8 *data = HBufC8::NewLC(msg.GetDesLength(0));
+ TPtr8 des(data->Des());
+ msg.ReadL(0, des);
+ RDesReadStream dataStream(*data);
+ CleanupClosePushL(dataStream);
+ dataStorages[iter]->handleDataL(msg.Function(), dataStream);
+ CleanupStack::PopAndDestroy(&dataStream);
+ CleanupStack::PopAndDestroy(data);
+
+ responseCode = KErrNone;
+ }
+ }
+ User::LeaveIfError(responseCode);
+ msg.Complete(responseCode);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 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 "tsmodel.h"
+
+// -----------------------------------------------------------------------------
+/**
+ * Create shallow copy of model item
+ * @param offset - index of requested item
+ * @return reference to item
+ */
+TTsModelItem MTsModel::itemL(TInt offset) const
+{
+ if(count() <= offset) {
+ User::Leave(KErrOverflow);
+ }
+ return TTsModelItem(*this, offset);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsmodelitem.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2009 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 "tsmodel.h"
+// -----------------------------------------------------------------------------
+/**
+ * Constructor
+ * @param model - data owner
+ * @param offset - data index
+ */
+TTsModelItem::TTsModelItem(const MTsModel& model, TInt offset)
+:
+mModel(model),
+mIndex(offset)
+{}
+
+// -----------------------------------------------------------------------------
+/**
+ * Copy constructor
+ * @param item - template item
+ */
+TTsModelItem::TTsModelItem(const TTsModelItem& item)
+:
+mModel(item.mModel),
+mIndex(item.mIndex)
+{}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and retrieve display name data
+ * @return item display name
+ */
+const TDesC& TTsModelItem::displayNameL() const
+{
+ validateL();
+ return mModel.displayNameL(mIndex);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and retrieve icon handle ( CFbsBitmap handle )
+ * @return item icon handle
+ */
+TInt TTsModelItem::iconHandleL() const
+{
+ validateL();
+ return mModel.iconHandleL(mIndex);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and retrieve entry key
+ * @return item key
+ */
+TTsModelItemKey TTsModelItem::keyL() const
+{
+ validateL();
+ return mModel.keyL(mIndex);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and retrieve entry timestamp
+ * @return item timestamp
+ */
+TTime TTsModelItem::timestampL() const
+{
+ validateL();
+ return mModel.timestampL(mIndex);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and retrieve activity status
+ * @return activity status
+ */
+TBool TTsModelItem::isActiveL() const
+{
+ validateL();
+ return mModel.isActiveL(mIndex);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and retrieve closable status
+ * @return closable status
+ */
+TBool TTsModelItem::isClosableL() const
+{
+ validateL();
+ return mModel.isClosableL(mIndex);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and forward close request to its owner
+ * @return EFalse on failure
+ */
+TBool TTsModelItem::closeL() const
+{
+ validateL();
+ return mModel.closeL(keyL());
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance and forward launch request to its owner
+ * @return EFalse on failure
+ */
+TBool TTsModelItem::launchL() const
+{
+ validateL();
+ return mModel.launchL(keyL());
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Validate item instance
+ */
+void TTsModelItem::validateL() const
+{
+ if (mModel.count() <= mIndex) {
+ User::Leave(KErrOverflow);
+ }
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Serialize item into destination stream
+ * @param stream - output stream
+ */
+
+void TTsModelItem::ExternalizeL(RWriteStream& stream) const
+{
+ stream.WriteInt32L(displayNameL().Length());
+ if (0 < displayNameL().Length()) {
+ stream << displayNameL();
+ }
+ stream.WriteInt32L(iconHandleL());
+ stream.WriteInt32L(TTsModelItemKey::size());
+ stream << keyL();
+ stream.WriteInt32L(isActiveL());
+ stream.WriteInt32L(isClosableL());
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsmodelitemkey.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 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 "tsmodelitemkey.h"
+// -----------------------------------------------------------------------------
+TInt TTsModelItemKey::size()
+{
+ return sizeof(TInt) * 2;
+}
+// -----------------------------------------------------------------------------
+TTsModelItemKey::TTsModelItemKey()
+:
+ mKey(0),
+ mRoot(0)
+{}
+
+// -----------------------------------------------------------------------------
+TTsModelItemKey::TTsModelItemKey(TTsKey key, TInt root)
+:
+ mKey(key),
+ mRoot(root)
+{}
+
+// -----------------------------------------------------------------------------
+TTsModelItemKey::TTsModelItemKey(const TTsModelItemKey &key)
+:
+ mKey(key.mKey),
+ mRoot(key.mRoot)
+{}
+
+// -----------------------------------------------------------------------------
+TTsModelItemKey& TTsModelItemKey::operator =(const TTsModelItemKey& key)
+{
+ mKey = key.mKey;
+ mRoot = key.mRoot;
+ return (*this);
+}
+
+// -----------------------------------------------------------------------------
+TBool TTsModelItemKey::operator == (const TTsModelItemKey key) const
+{
+ return ( mKey == key.mKey && mRoot == key.mRoot);
+}
+
+// -----------------------------------------------------------------------------
+TInt TTsModelItemKey::key() const
+{
+ return mKey;
+}
+
+// -----------------------------------------------------------------------------
+void TTsModelItemKey::ExternalizeL(RWriteStream& stream) const
+{
+ stream.WriteInt32L(mKey);
+ stream.WriteInt32L(mRoot);
+}
+
+// -----------------------------------------------------------------------------
+void TTsModelItemKey::InternalizeL(RReadStream& stream)
+{
+ mKey = stream.ReadInt32L();
+ mRoot = stream.ReadInt32L();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsmodelitemkeymsg.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+#include <s32mem.h>
+#include "tsmodelitemkeymsg.h"
+
+// -----------------------------------------------------------------------------
+CTsModelItemKeyMsg* CTsModelItemKeyMsg::NewLC(RReadStream& stream)
+{
+ CTsModelItemKeyMsg* self = new (ELeave)CTsModelItemKeyMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(stream);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsModelItemKeyMsg::~CTsModelItemKeyMsg()
+{}
+
+// -----------------------------------------------------------------------------
+TTsModelItemKey CTsModelItemKeyMsg::key() const
+{
+ return mKey;
+}
+
+// -----------------------------------------------------------------------------
+void CTsModelItemKeyMsg::InternalizeL(RReadStream &stream)
+{
+ stream >> mKey;
+}
+
+// -----------------------------------------------------------------------------
+CTsModelItemKeyMsg::CTsModelItemKeyMsg()
+{
+ //no implementation required
+}
+
+// -----------------------------------------------------------------------------
+void CTsModelItemKeyMsg::ConstructL(RReadStream &stream)
+{
+ stream >> (*this);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsrunningappmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2009 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 "tsrunningappmodel.h"
+
+#include <AknDef.h>
+#include <apgwgnam.h>
+#include <apgtask.h>
+
+#include "tsdatalist.h"
+#include "tsmodelobserver.h"
+#include "tsscreenshotprovider.h"
+
+CTsRunningAppModel *CTsRunningAppModel::NewL(MTsResourceManager &resources, MTsWindowGroupsMonitor &monitor)
+{
+ CTsRunningAppModel *self = CTsRunningAppModel::NewLC(resources, monitor);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+CTsRunningAppModel *CTsRunningAppModel::NewLC(MTsResourceManager &resources, MTsWindowGroupsMonitor &monitor)
+{
+ CTsRunningAppModel *self = new (ELeave) CTsRunningAppModel(resources);
+ CleanupStack::PushL(self);
+ self->ConstructL(resources, monitor);
+ return self;
+}
+
+CTsRunningAppModel::~CTsRunningAppModel()
+{
+ delete mDataList;
+ delete mScreenshotProvider;
+}
+
+CTsRunningAppModel::CTsRunningAppModel(MTsResourceManager &resources) : mResources(resources)
+{
+}
+
+void CTsRunningAppModel::ConstructL(MTsResourceManager &resources, MTsWindowGroupsMonitor &monitor)
+{
+ mDataList = CTsDataList::NewL(resources, monitor, *this);
+ mScreenshotProvider = CTsScreenshotProvider::NewL(*mDataList);
+
+ RArray<RWsSession::TWindowGroupChainInfo> wgList;
+ CleanupClosePushL(wgList);
+ User::LeaveIfError(resources.WsSession().WindowGroupList(0, &wgList));
+ mDataList->HandleWindowGroupChanged(resources, wgList.Array());
+ CleanupStack::PopAndDestroy(&wgList);
+}
+
+// --------------------------------------------------------------------------
+// MHsDataObserver interface implementation
+// --------------------------------------------------------------------------
+//
+void CTsRunningAppModel::DataChanged()
+{
+ if (mObserver) {
+ mObserver->dataChanged(*this);
+ }
+}
+
+// --------------------------------------------------------------------------
+// MTsTaskSettings interface implementation
+// --------------------------------------------------------------------------
+//
+TBool CTsRunningAppModel::isSupported(TInt function) const
+{
+ return mDataList->isSupported(function);
+}
+
+void CTsRunningAppModel::handleDataL(TInt function,RReadStream& dataStream)
+{
+ mDataList->handleDataL(function, dataStream);
+}
+
+// --------------------------------------------------------------------------
+// MTsModel interface implementation
+// --------------------------------------------------------------------------
+//
+TInt CTsRunningAppModel::count() const
+{
+ return mDataList->Data().Count();
+}
+
+void CTsRunningAppModel::setObserver(MTsModelObserver *observer)
+{
+ mObserver = observer;
+}
+
+const TDesC& CTsRunningAppModel::displayNameL(TInt offset) const
+{
+ return mDataList->Data()[offset]->AppName();
+}
+
+TInt CTsRunningAppModel::iconHandleL(TInt offset) const
+{
+ CFbsBitmap *bitmap = mDataList->Data()[offset]->Screenshot();
+ if (!bitmap) {
+ bitmap = mDataList->Data()[offset]->AppIconBitmap();
+ }
+
+ if (bitmap) {
+ return bitmap->Handle();
+ } else {
+ return KErrNotFound;
+ }
+}
+
+TTime CTsRunningAppModel::timestampL(TInt offset) const
+{
+ return mDataList->Data()[offset]->Timestamp();
+}
+
+TTsModelItemKey CTsRunningAppModel::keyL(TInt offset) const
+{
+ return TTsModelItemKey(mDataList->Data()[offset]->Key().WindowGroupId(),
+ reinterpret_cast<TInt>(this));
+}
+
+TBool CTsRunningAppModel::isActiveL(TInt /*offset*/) const
+{
+ return ETrue;
+}
+
+TBool CTsRunningAppModel::isClosableL(TInt offset) const
+{
+ return mDataList->Data()[offset]->CloseableApp();
+}
+
+TBool CTsRunningAppModel::closeL(TTsModelItemKey key) const
+{
+ TApaTask task(mResources.WsSession());
+ task.SetWgId(key.key());
+ task.EndTask();
+ return ETrue;
+}
+
+TBool CTsRunningAppModel::launchL(TTsModelItemKey key) const
+{
+ // find uid by wgid from key
+ CApaWindowGroupName *windowGroupName =
+ CApaWindowGroupName::NewLC(mResources.WsSession(), key.key());
+ TUid uid = windowGroupName->AppUid();
+ CleanupStack::PopAndDestroy(windowGroupName);
+
+ TApaTask task = TApaTaskList(mResources.WsSession()).FindApp(uid);
+ task.BringToForeground();
+ return task.Exists();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsscreenshotprovider.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2009 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 <s32mem.h>
+
+#include "tsscreenshotprovider.h"
+#include "tstaskmonitorglobals.h"
+#include "tsscreenshotmsg.h"
+
+
+const TUid KPluginUID = {0x200267AE};
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CTsScreenshotProvider* CTsScreenshotProvider::NewL(MTsDataStorage& storage)
+{
+ CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider(storage);
+ CleanupStack::PushL(self);
+ self->BaseConstructL(KPluginUID, KNullDesC8);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CTsScreenshotProvider::CTsScreenshotProvider(MTsDataStorage& storage)
+:
+mStorage(storage)
+{}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotProvider::HandleMessage(const TDesC8& msg)
+{
+ TRAP_IGNORE(HandleMessageL(msg));
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotProvider::HandleMessageL(const TDesC8& msg)
+{
+ RDesReadStream msgStream(msg);
+ CleanupClosePushL(msgStream);
+ if(RegisterScreenshotMessage != msgStream.ReadInt32L()) {
+ User::Leave(KErrNotSupported);
+ }
+
+ //parse msg to ACK provider ASAP and be sure that bitmap still exists
+ CTsScreenshotMsg* screenshotMsg = CTsScreenshotMsg::NewLC(msgStream);
+ SendMessage(msg);
+
+ //reset stream
+ msgStream.Close();
+ msgStream.Open(msg);
+
+ //forward stream to storage
+ mStorage.handleDataL(msgStream.ReadInt32L(), msgStream);
+
+ CleanupStack::PopAndDestroy(screenshotMsg);//
+ CleanupStack::PopAndDestroy(&msgStream);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CTsScreenshotProvider::OnReplace()
+{
+ //no implementation required
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsserializeddataprovider.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2009 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 <s32mem.h>
+#include "tsserializeddataprovider.h"
+#include "tsmodel.h"
+// -----------------------------------------------------------------------------
+/**
+ * Leaving constructor.
+ * @param observer - data observer
+ */
+CTsSerializedDataProvider* CTsSerializedDataProvider::NewL(MTsDataObserver &observer)
+{
+ return new (ELeave) CTsSerializedDataProvider(observer);
+
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Constructor
+ * @param observer - data observer
+ */
+CTsSerializedDataProvider::CTsSerializedDataProvider(MTsDataObserver& observer)
+:
+ mObserver(observer)
+{}
+
+// -----------------------------------------------------------------------------
+/**
+ * Destructor
+ */
+CTsSerializedDataProvider::~CTsSerializedDataProvider()
+{
+ mData.Close();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation.
+ * @see MTsDataProvider::Data()
+ */
+const TDesC8& CTsSerializedDataProvider::Data() const
+{
+ return mData;
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation.
+ * @see MTsModelObserver::dataChanged(MTsModel &)
+ */
+void CTsSerializedDataProvider::dataChanged(MTsModel &model)
+{
+ serializeModel(model);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation.
+ * @see MTsModelObserver::dataChanged(TTsModelItem &)
+ */
+void CTsSerializedDataProvider::dataChanged(const TTsModelItem &/*item*/)
+{
+ //No implementation required now.
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Serialize source model into internal data storage
+ * @param src - model
+ */
+void CTsSerializedDataProvider::serializeModel(const MTsModel &src)
+{
+ TRAPD(errNo, serializeModelL(src));
+ if(KErrNone == errNo ) {
+ mObserver.DataChanged();
+ }
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Serialize source model into internal data storage. Function can leave.
+ * @param src - source model
+ */
+void CTsSerializedDataProvider::serializeModelL(const MTsModel &src)
+{
+ const TInt KExpandSize = 256;
+ CBufFlat* buf = CBufFlat::NewL(KExpandSize);
+ CleanupStack::PushL(buf);
+ RBufWriteStream stream(*buf);
+ CleanupClosePushL(stream);
+
+ serializeModelL(stream, src);
+
+ CleanupStack::PopAndDestroy(&stream);
+ mData.Close();
+ mData.CreateL(buf->Size());
+ buf->Read(0, mData, buf->Size());
+ CleanupStack::PopAndDestroy(buf);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Serialize source model into destination stream. Function can leave.
+ * @param dst - destination stream
+ * @param src - source model
+ */
+void CTsSerializedDataProvider::serializeModelL(RWriteStream& dst, const MTsModel &src)
+{
+ dst.WriteInt32L(src.count());
+ for (TInt iter(0); iter < src.count(); ++iter) {
+ dst << src.itemL(iter);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsservice.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+#include <QDateTime>
+#include <QVariantHash>
+
+#include <xqconversions.h>
+
+#include "tsservice.h"
+#include "tsmodelobserver.h"
+#include "tsserviceobserver.h"
+
+// -----------------------------------------------------------------------------
+LOCAL_C QVariantHash valueL(QObject *model, TInt offset)
+{
+ QList<QVariantHash> items;
+ QMetaObject::invokeMethod(model, "taskList", Q_RETURN_ARG(QList<QVariantHash>, items));
+
+ if (offset >= items.count()) {
+ User::Leave(KErrCorrupt);
+ }
+
+ return items.at(offset);
+}
+
+// -----------------------------------------------------------------------------
+CTsService* CTsService::NewLC(QObject* model)
+{
+ CTsService *self = new (ELeave)CTsService();
+ CleanupStack::PushL(self);
+ self->ConstructL(model);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsService::CTsService()
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+void CTsService::ConstructL(QObject* model)
+{
+ mModel = model;
+ User::LeaveIfNull(mModel);
+ // @todo: add checking for all necessary methods
+
+ mServiceObserver = new TsServiceObserver(*this);
+ User::LeaveIfNull(mServiceObserver);
+ QObject::connect(mModel,
+ SIGNAL(dataChanged()),
+ mServiceObserver,
+ SLOT(dataChanged()));
+}
+
+// -----------------------------------------------------------------------------
+CTsService::~CTsService()
+{
+ delete mModel;
+ delete mServiceObserver;
+ delete mBuffer;
+}
+
+// -----------------------------------------------------------------------------
+void CTsService::DataChanged()
+{
+ if (0 != mModelObserver) {
+ mModelObserver->dataChanged(*this);
+ }
+}
+// -----------------------------------------------------------------------------
+TInt CTsService::count() const
+{
+ QList<QVariantHash> items;
+ QMetaObject::invokeMethod(mModel, "taskList", Q_RETURN_ARG(QList<QVariantHash>, items));
+ return items.count();
+}
+
+// -----------------------------------------------------------------------------
+void CTsService::setObserver(MTsModelObserver *observer)
+{
+ mModelObserver = observer;
+}
+
+// -----------------------------------------------------------------------------
+const TDesC& CTsService::displayNameL(TInt offset) const
+{
+ return stringValueL(offset, "TaskName");
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsService::iconHandleL(TInt offset) const
+{
+ return intValueL(offset, "TaskScreenshot");
+}
+
+// -----------------------------------------------------------------------------
+TTime CTsService::timestampL(TInt offset) const
+{
+ return timeValueL(offset, "TaskTimestamp");
+}
+
+// -----------------------------------------------------------------------------
+TTsModelItemKey CTsService::keyL(TInt offset) const
+{
+ return TTsModelItemKey(intValueL(offset, "TaskId"), reinterpret_cast<TInt>(this));
+}
+
+// -----------------------------------------------------------------------------
+TBool CTsService::isActiveL(TInt offset) const
+{
+ return intValueL(offset, "TaskIsRunning");
+}
+
+// -----------------------------------------------------------------------------
+TBool CTsService::isClosableL(TInt offset) const
+{
+ return intValueL(offset, "TaskCanBeClosed");
+}
+
+// -----------------------------------------------------------------------------
+TBool CTsService::closeL(TTsModelItemKey key) const
+{
+ bool result(false);
+ QMetaObject::invokeMethod(mModel, "closeTask", Q_RETURN_ARG(bool, result), Q_ARG(QVariant, key.key()));
+ return result;
+}
+
+// -----------------------------------------------------------------------------
+TBool CTsService::launchL(TTsModelItemKey key) const
+{
+ bool result(false);
+ QMetaObject::invokeMethod(mModel, "openTask", Q_RETURN_ARG(bool, result), Q_ARG(QVariant, key.key()));
+ return result;
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsService::intValueL(TInt offset, const char *key) const
+{
+ return valueL(mModel, offset).value(key).toInt();
+}
+
+// -----------------------------------------------------------------------------
+TTime CTsService::timeValueL(TInt offset, const char *key) const
+{
+ // Conversion between TTime which counts from year 0, and QDateTime which uses unix epoch (1st Jan 1970)
+ return TTime(_L("19700000:")) + TTimeIntervalSeconds(valueL(mModel, offset).value(key).toDateTime().toTime_t());
+}
+
+// -----------------------------------------------------------------------------
+const TDesC& CTsService::stringValueL(TInt offset, const char *key) const
+{
+ delete mBuffer;
+ const_cast<CTsService *>(this)->mBuffer = 0;
+
+ const QVariantHash item(valueL(mModel, offset));
+ QT_TRYCATCH_LEAVING(
+ const_cast<CTsService *>(this)->mBuffer =
+ XQConversions::qStringToS60Desc(item.value(key).toString()));
+ return *mBuffer;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsserviceobserver.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 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 "tsserviceobserver.h"
+// -----------------------------------------------------------------------------
+TsServiceObserver::TsServiceObserver(MTsDataObserver& observer)
+:
+ mObserver(observer)
+{}
+
+// -----------------------------------------------------------------------------
+void TsServiceObserver::dataChanged()
+{
+ mObserver.DataChanged();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsservicesprovider.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2009 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 "tsservicesprovider.h"
+#include "tsservice.h"
+// -----------------------------------------------------------------------------
+CTsServiceProvider* CTsServiceProvider::NewL(const CTsServiceProviderConfig& config)
+{
+ CTsServiceProvider* self = new (ELeave)CTsServiceProvider();
+ self->Construct(config);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProvider::CTsServiceProvider()
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+void CTsServiceProvider::Construct(const CTsServiceProviderConfig& config)
+{
+ CTsService* srvPtr(0);
+ for (TInt iter(0); iter < config.count(); ++iter) {
+ TRAP_IGNORE(
+ srvPtr = CTsService::NewLC(config.loadL(iter));
+ mServices.AppendL(srvPtr);
+ CleanupStack::Pop(srvPtr);
+ );
+ }
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProvider::~CTsServiceProvider()
+{
+ mServices.ResetAndDestroy();
+}
+
+// -----------------------------------------------------------------------------
+MTsModel& CTsServiceProvider::operator[](TInt offset) const
+{
+ return *(mServices[offset]);
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsServiceProvider::count() const
+{
+ return mServices.Count();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsservicesproviderconfig.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2009 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 <xqconversions.h>
+#include <qservicemanager.h>
+#include "tsservicesproviderconfig.h"
+
+const char ServicesInterface [] = "com.nokia.qt.taskswitcher.dataprovider";
+// -----------------------------------------------------------------------------
+CTsServiceProviderConfig* CTsServiceProviderConfig::NewLC()
+{
+ CTsServiceProviderConfig *self = new (ELeave)CTsServiceProviderConfig();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProviderConfig::CTsServiceProviderConfig()
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+void CTsServiceProviderConfig::ConstructL()
+{
+ QTM_NAMESPACE::QServiceInterfaceDescriptor *ptr(0);
+ //QT_TRYCATCH_LEAVING(
+ QTM_NAMESPACE::QServiceManager serviceManager;
+ const QList<QTM_NAMESPACE::QServiceInterfaceDescriptor> serivces(serviceManager.findInterfaces(QTM_NAMESPACE::QServiceFilter(ServicesInterface)));
+ foreach(QTM_NAMESPACE::QServiceInterfaceDescriptor serviceImplementation, serivces) {
+ ptr = new QTM_NAMESPACE::QServiceInterfaceDescriptor(serviceImplementation);
+ if(0 != ptr) {
+ if(KErrNone != mServices.Append(ptr)) {
+ delete ptr;
+ }
+ }
+ }
+ //)
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProviderConfig::~CTsServiceProviderConfig()
+{
+ for(TInt iter(0); iter < mServices.Count(); ++iter){
+ delete static_cast<QTM_NAMESPACE::QServiceInterfaceDescriptor *>(mServices[iter]);
+ }
+ mServices.Close();
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsServiceProviderConfig::count() const
+{
+ return mServices.Count();
+}
+
+// -----------------------------------------------------------------------------
+QObject* CTsServiceProviderConfig::loadL(TInt offset)const
+{
+ const QTM_NAMESPACE::QServiceInterfaceDescriptor *service
+ = static_cast<QTM_NAMESPACE::QServiceInterfaceDescriptor *>(mServices[offset]);
+ QObject *retVal(0);
+ QT_TRYCATCH_LEAVING(
+ QTM_NAMESPACE::QServiceManager serviceManager;
+ retVal = serviceManager.loadInterface(*service);
+ );
+ User::LeaveIfNull(retVal);
+ return retVal;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsstorage.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,285 @@
+/*
+* Copyright (c) 2009 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 <tstaskmonitorglobals.h>
+#include "tsstorage.h"
+#include "tsmodelitemkeymsg.h"
+// -----------------------------------------------------------------------------
+/**
+ * Two phase construction. Create and initialize storage instance.
+ * @param dataProviders - list of data providers
+ * @return storage instane
+ */
+CTsStorage* CTsStorage::NewL(const TArray<MTsModel*> &dataProviders)
+{
+ CTsStorage* self = new(ELeave) CTsStorage();
+ CleanupStack::PushL(self);
+ self->ConstructL(dataProviders);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Destructor. Function cancel subscribtion for data change notyfications
+ */
+CTsStorage::~CTsStorage()
+{
+ for (TInt iter(0); iter < mDataProviders.Count(); ++iter) {
+ mDataProviders[iter]->setObserver(0);
+ }
+ mData.Close();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * First phase construction.
+ */
+CTsStorage::CTsStorage()
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Second phase construction. Function make subscribtion for data changes notifications
+ * @param dataProviders - list of data providers
+ */
+void CTsStorage::ConstructL(const TArray<MTsModel*> &dataProviders)
+{
+ for (TInt iter(0); iter < dataProviders.Count(); ++iter) {
+ mDataProviders.AppendL(dataProviders[iter]);
+ dataProviders[iter]->setObserver(this);
+ }
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsDataObserver::DataChanged()
+ */
+void CTsStorage::DataChanged()
+{
+ resetModel();
+}
+
+// -----------------------------------------------------------------------------
+TBool CTsStorage::isSupported(TInt function) const
+{
+ return (OpenTaskMessage == function || CloseTaskMessage == function);
+}
+// -----------------------------------------------------------------------------
+void CTsStorage::handleDataL(TInt function, RReadStream& dataStream)
+{
+ if(!isSupported(function)) {
+ User::Leave(KErrCorrupt);
+ }
+ CTsModelItemKeyMsg* msg = CTsModelItemKeyMsg::NewLC(dataStream);
+ OpenTaskMessage == function ? launchL(msg->key()) : closeL(msg->key());
+ CleanupStack::PopAndDestroy(msg);
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModelObserver::dataChanged(MTsModel &)
+ */
+void CTsStorage::dataChanged(MTsModel &/*model*/)
+{
+ resetModel();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModelObserver::dataChanged(const TTsModelItem &)
+ */
+void CTsStorage::dataChanged(const TTsModelItem &/*item*/)
+{
+ resetModel();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::count()
+ */
+TInt CTsStorage::count() const
+{
+ return mData.Count();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::setObserver(MTsModelObserver *)
+ */
+void CTsStorage::setObserver(MTsModelObserver *observer)
+{
+ mDataObserver = observer;
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::displayNameL(TInt)
+ */
+const TDesC& CTsStorage::displayNameL(TInt offset) const
+{
+ return mData[offset].displayNameL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::iconHandleL(TInt)
+ */
+TInt CTsStorage::iconHandleL(TInt offset) const
+{
+ return mData[offset].iconHandleL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::timestampL(TInt)
+ */
+TTime CTsStorage::timestampL(TInt offset) const
+{
+ return mData[offset].timestampL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::keyL(TInt)
+ */
+TTsModelItemKey CTsStorage::keyL(TInt offset) const
+{
+ return mData[offset].keyL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::isActiveL(TInt)
+ */
+TBool CTsStorage::isActiveL(TInt offset) const
+{
+ return mData[offset].isActiveL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::isClosableL(TInt)
+ */
+TBool CTsStorage::isClosableL(TInt offset) const
+{
+ return mData[offset].isClosableL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::closeL(TTsModelItemKey)
+ */
+TBool CTsStorage::closeL(TTsModelItemKey key) const
+{
+ return findL(key).closeL();
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Interface implementation
+ * @see MTsModel::launchL(TTsModelItemKey)
+ */
+TBool CTsStorage::launchL(TTsModelItemKey key) const
+{
+ return findL(key).launchL();
+}
+
+
+// -----------------------------------------------------------------------------
+TTsModelItem CTsStorage::findL(TTsModelItemKey key) const
+{
+ for(TInt offset(0); offset < mData.Count(); ++offset) {
+ if(mData[offset].keyL() == key){
+ return mData[offset];
+ }
+ }
+ User::Leave(KErrNotFound);
+ return itemL(0);//just avoid compilation warnings
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Retrieve shallow copy of data from known data providers and sort entries
+ */
+TInt CTsStorage::resetModel()
+{
+ TRAPD(errNo, resetModelL());
+ return errNo;
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Retrieve shallow copy of data from known data providers and sort entries
+ */
+void CTsStorage::resetModelL()
+{
+ mData.Reset();
+ for (TInt iter(0); iter < mDataProviders.Count(); ++iter) {
+ pullDataL(*(mDataProviders[iter]));
+ }
+ reorderDataL();
+ if (0 != mDataObserver) {
+ mDataObserver->dataChanged(*this);
+ }
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Retrieve shallow copy of data from source model
+ * @param src - source model
+ */
+void CTsStorage::pullDataL(const MTsModel& src)
+{
+ for (TInt iter(0); iter < src.count(); ++iter) {
+ mData.AppendL(src.itemL(iter));
+ }
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Sort internal data model
+ */
+void CTsStorage::reorderDataL()
+{
+ for (TInt prev(0); prev < mData.Count(); ++prev) {
+ for(TInt next(prev + 1); next < mData.Count(); ++next) {
+ const TTsModelItem prevItem(mData[prev]), nextItem(mData[next]);
+ if(prevItem.timestampL() < nextItem.timestampL()) {
+ mData.Remove(prev);
+ mData.InsertL(nextItem, prev);
+
+ mData.Remove(next);
+ mData.InsertL(prevItem, next);
+ }
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsmodelitem/t_tsmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2009 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_tsmodel.h"
+
+_LIT(KDisplayName, "TestName" );
+
+TBool T_TsModel::expectedBoolValue()
+{
+ return ETrue;
+}
+
+const TDesC& T_TsModel::expectedDesCValue()
+{
+ return KDisplayName();
+}
+
+TInt T_TsModel::expectedIntValue()
+{
+ return 0;
+}
+
+TInt T_TsModel::count() const
+{
+ return 1;
+}
+
+TTime T_TsModel::expectedTimeValue()
+{
+ return TTime(0);
+}
+
+
+void T_TsModel::setObserver(MTsModelObserver */*observer*/)
+{
+}
+
+const TDesC& T_TsModel::displayNameL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedDesCValue();
+}
+
+TInt T_TsModel::iconHandleL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedIntValue();
+}
+
+TTime T_TsModel::timestampL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedTimeValue();
+}
+
+TTsModelItemKey T_TsModel::keyL(TInt /*offset*/) const
+{
+ return TTsModelItemKey(T_TsModel::expectedIntValue(), reinterpret_cast<TInt>(this));
+}
+
+TBool T_TsModel::isActiveL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
+
+TBool T_TsModel::isClosableL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
+
+TBool T_TsModel::closeL(TTsModelItemKey /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
+
+TBool T_TsModel::launchL(TTsModelItemKey /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsmodelitem/t_tsmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 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 "tsmodel.h"
+class T_TsModel: public MTsModel
+{
+public:
+ static TBool expectedBoolValue();
+ static const TDesC& expectedDesCValue();
+ static TInt expectedIntValue();
+ static TTime expectedTimeValue();
+
+ TInt count() const;
+ void setObserver(MTsModelObserver *observer);
+
+protected:
+ const TDesC& displayNameL(TInt offset) const;
+ TInt iconHandleL(TInt offset) const;
+ TTime timestampL(TInt offset) const;
+ TTsModelItemKey keyL(TInt offset) const;
+ TBool isActiveL(TInt offset) const;
+ TBool isClosableL(TInt offset) const;
+ TBool closeL(TTsModelItemKey key) const;
+ TBool launchL(TTsModelItemKey key) const;
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsmodelitem/t_tsmodelitem.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+
+#include "t_tsmodelitem.h"
+#include "t_tsmodel.h"
+
+void T_TsModelItem::testItem()
+{
+ T_TsModel model;
+ int errNo(KErrNone);
+ const int invalidOffset(model.count());
+ const int validOffset(model.count() - 1);
+ QVERIFY(0 <= validOffset);
+
+ TRAP(errNo, model.itemL(invalidOffset).displayNameL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).displayNameL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(0 == T_TsModel::expectedDesCValue().Compare(model.itemL(validOffset).displayNameL()));
+
+ TRAP(errNo, model.itemL(invalidOffset).iconHandleL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).iconHandleL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedIntValue() == model.itemL(validOffset).iconHandleL());
+
+ TRAP(errNo, model.itemL(invalidOffset).timestampL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).timestampL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedTimeValue() == model.itemL(validOffset).timestampL());
+
+ TRAP(errNo, model.itemL(invalidOffset).keyL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).keyL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedIntValue() == model.itemL(validOffset).keyL().key());
+
+ TRAP(errNo, model.itemL(invalidOffset).isActiveL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).isActiveL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).isActiveL());
+
+ TRAP(errNo, model.itemL(invalidOffset).isClosableL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).isClosableL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).isClosableL());
+
+ TRAP(errNo, model.itemL(invalidOffset).closeL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).closeL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).closeL());
+
+ TRAP(errNo, model.itemL(invalidOffset).launchL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(validOffset).launchL());
+ QVERIFY(KErrNone == errNo);
+ QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).launchL());
+
+}
+
+QTEST_MAIN(T_TsModelItem)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsmodelitem/t_tsmodelitem.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+
+class T_TsModelItem : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testItem();
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsmodelitem/t_tsmodelitem.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console
+
+
+SOURCES += t_tsmodelitem.cpp \
+ t_tsmodel.cpp
+
+HEADERS += t_tsmodelitem.h \
+ t_tsmodel.h
+
+
+SOURCES += ../../src/tsmodelitemkey.cpp \
+ ../../src/tsmodelitem.cpp \
+ ../../src/tsmodel.cpp
+
+HEADERS += ../../inc/tsmodelitemkey.h \
+ ../../inc/tsmodelitem.h \
+ ../../inc/tsmodel.h
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.CAPABILITY = ALL -TCB
+
+ LIBS += -lestor \ # for RWriteStream
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsserializeddataprovider/t_tsmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2009 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_tsmodel.h"
+
+_LIT(KDisplayName, "TestName" );
+
+TBool T_TsModel::expectedBoolValue()
+{
+ return ETrue;
+}
+
+const TDesC& T_TsModel::expectedDesCValue()
+{
+ return KDisplayName();
+}
+
+TInt T_TsModel::expectedIntValue()
+{
+ return 0;
+}
+
+T_TsModel::T_TsModel(int itemsCount)
+:
+mItemsCount(itemsCount)
+{}
+
+TInt T_TsModel::count() const
+{
+ return mItemsCount;
+}
+
+TTime T_TsModel::expectedTimeValue()
+{
+ return TTime(0);
+}
+
+
+void T_TsModel::setObserver(MTsModelObserver */*observer*/)
+{
+}
+
+const TDesC& T_TsModel::displayNameL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedDesCValue();
+}
+
+TInt T_TsModel::iconHandleL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedIntValue();
+}
+
+TTime T_TsModel::timestampL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedTimeValue();
+}
+
+TTsModelItemKey T_TsModel::keyL(TInt /*offset*/) const
+{
+ return TTsModelItemKey(T_TsModel::expectedIntValue(), reinterpret_cast<TInt>(this));
+}
+
+TBool T_TsModel::isActiveL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
+
+TBool T_TsModel::isClosableL(TInt /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
+
+TBool T_TsModel::closeL(TTsModelItemKey /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
+
+TBool T_TsModel::launchL(TTsModelItemKey /*offset*/) const
+{
+ return T_TsModel::expectedBoolValue();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsserializeddataprovider/t_tsmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 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 "tsmodel.h"
+class T_TsModel: public MTsModel
+{
+public:
+ static TBool expectedBoolValue();
+ static const TDesC& expectedDesCValue();
+ static TInt expectedIntValue();
+ static TTime expectedTimeValue();
+
+ TInt count() const;
+ void setObserver(MTsModelObserver *observer);
+ T_TsModel(int itemsCount =0);
+protected:
+ const TDesC& displayNameL(TInt offset) const;
+ TInt iconHandleL(TInt offset) const;
+ TTime timestampL(TInt offset) const;
+ TTsModelItemKey keyL(TInt offset) const;
+ TBool isActiveL(TInt offset) const;
+ TBool isClosableL(TInt offset) const;
+ TBool closeL(TTsModelItemKey key) const;
+ TBool launchL(TTsModelItemKey key) const;
+
+private:
+ int mItemsCount;
+
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsserializeddataprovider/t_tsserializeddataprovider.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include "tsserializeddataprovider.h"
+#include "t_tsmodel.h"
+#include "t_tsserializeddataprovider.h"
+
+void T_TsSerializedDataProvider::testModelDataChanged()
+{
+ CTsSerializedDataProvider* provider(0);
+
+ mNotifications = 0;
+ provider = CTsSerializedDataProvider::NewL(*this);
+ T_TsModel emptyModel(0);
+ QVERIFY(0 == provider->Data().Length());
+ provider->dataChanged(emptyModel);
+ QVERIFY(1 == mNotifications);
+ QVERIFY(0 < provider->Data().Length());
+ delete provider;
+
+ mNotifications = 0;
+ provider = CTsSerializedDataProvider::NewL(*this);
+ T_TsModel model(2);
+ QVERIFY(0 == provider->Data().Length());
+ provider->dataChanged(model);
+ QVERIFY(1 == mNotifications);
+ QVERIFY(0 < provider->Data().Length());
+ delete provider;
+}
+
+void T_TsSerializedDataProvider::testItemDataChanged()
+{
+ CTsSerializedDataProvider* provider(0);
+
+ mNotifications = 0;
+ provider = CTsSerializedDataProvider::NewL(*this);
+ T_TsModel model(1);
+ QVERIFY(0 == provider->Data().Length());
+ provider->dataChanged(model.itemL(0));
+ QVERIFY(0 == mNotifications);
+ QVERIFY(0 == provider->Data().Length());
+ delete provider;
+}
+
+void T_TsSerializedDataProvider::DataChanged()
+{
+ ++mNotifications;
+}
+
+QTEST_MAIN(T_TsSerializedDataProvider)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsserializeddataprovider/t_tsserializeddataprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+#include "tsdataobserver.h"
+class T_TsSerializedDataProvider : public QObject,
+ public MTsDataObserver
+{
+ Q_OBJECT
+
+ void DataChanged();
+private slots:
+ void testModelDataChanged();
+ void testItemDataChanged();
+private:
+ int mNotifications;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsserializeddataprovider/t_tsserializeddataprovider.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console
+
+
+SOURCES += t_tsserializeddataprovider.cpp \
+ t_tsmodel.cpp
+
+HEADERS += t_tsserializeddataprovider.h \
+ t_tsmodel.h
+
+
+SOURCES += ../../src/tsmodelitemkey.cpp \
+ ../../src/tsmodelitem.cpp \
+ ../../src/tsmodel.cpp \
+ ../../src/tsserializeddataprovider.cpp
+
+HEADERS += ../../inc/tsmodelitemkey.h \
+ ../../inc/tsmodelitem.h \
+ ../../inc/tsmodel.h \
+ ../../inc/tsserializeddataprovider.h \
+ ../../../utils/inc/tsdataobserver.h
+
+symbian {
+LIBS += -lestor
+CONFIG += symbian_test
+coverage: CONFIG -= symbian_test
+TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/t_tsservicesprovider.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include "t_tsservicesprovider.h"
+#include "tsservicesproviderconfig.h"
+#include "tsservice.h"
+#include "tsservicesprovider.h"
+#include "tsserviceobserver.h"
+
+
+class QtModel: public QObject
+{
+ QList<QVariantHash> taskList() const
+ {
+ return QList<QVariantHash>();
+ }
+
+ QList<QVariantHash> taskList(int limit) const
+ {
+ Q_UNUSED(limit);
+ return QList<QVariantHash>();
+ }
+
+ bool openTask(const QVariant &/*id*/){return true;};
+ bool closeTask(const QVariant &/*id*/){return true;};
+};
+
+void T_TsServiceProvider::testProvider()
+{
+ CTsServiceProvider *provider(0);
+ CTsServiceProviderConfig* config(0);
+ //test provider with different amount of data
+ int errNo;
+ const int maxDataCount(4);
+
+
+ for(TInt dataCount(0); dataCount < maxDataCount; ++dataCount) {
+ config = CTsServiceProviderConfig::NewLC(dataCount);
+ provider = CTsServiceProvider::NewL(*config);
+ CleanupStack::PopAndDestroy(config);
+ QVERIFY(dataCount == provider->count());
+ for(TInt dataProviderIter(0); dataProviderIter < provider->count(); ++dataProviderIter) {
+ MTsModel& model((*provider)[dataProviderIter]);
+
+ //we dont verify data. just try to retrieve it. model can leave but shouldn't panic
+ for (TInt dataIter(0); dataIter < model.count(); ++dataIter) {
+ TRAP_IGNORE(model.itemL(dataIter).keyL());
+ TRAP_IGNORE(model.itemL(dataIter).displayNameL());
+ TRAP_IGNORE(model.itemL(dataIter).iconHandleL());
+ TRAP_IGNORE(model.itemL(dataIter).isActiveL());
+ TRAP_IGNORE(model.itemL(dataIter).isClosableL());
+ TRAP_IGNORE(model.itemL(dataIter).timestampL());
+ TRAP_IGNORE(model.itemL(dataIter).launchL());
+ TRAP_IGNORE(model.itemL(dataIter).closeL());
+ }
+ TRAP(errNo, model.itemL(model.count()).keyL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).displayNameL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).iconHandleL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).isActiveL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).isClosableL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).timestampL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).launchL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count()).closeL());
+ QVERIFY(KErrNone != errNo);
+
+ TRAP(errNo, model.itemL(model.count() + 1).keyL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).displayNameL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).iconHandleL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).isActiveL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).isClosableL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).timestampL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).launchL());
+ QVERIFY(KErrNone != errNo);
+ TRAP(errNo, model.itemL(model.count() + 1).closeL());
+ QVERIFY(KErrNone != errNo);
+ }
+ delete provider;
+ }
+}
+
+void T_TsServiceProvider::testService()
+{
+ int errNo, maxNotifications(20);
+ CTsService* service;
+ mNotyfications = 0;
+
+ TRAP(errNo, service = CTsService::NewLC(0));
+ QVERIFY(KErrNone != errNo);
+
+ TRAP(errNo,
+ service = CTsService::NewLC(new QtModel());
+ service->setObserver(0);
+ service->DataChanged();
+ if(0 != mNotyfications){
+ User::Leave(KErrCorrupt);
+ }
+ service->setObserver(this);
+ for(int iter(0); iter < maxNotifications; ++iter) {
+ service->DataChanged();
+ if(iter + 1 != mNotyfications){
+ User::Leave(KErrCorrupt);
+ }
+ }
+ CleanupStack::PopAndDestroy(service);
+ );//TRAP
+ QVERIFY(KErrNone == errNo);
+}
+
+void T_TsServiceProvider::testServiceObserver()
+{
+ TsServiceObserver observer(*this);
+ QObject::connect(this,
+ SIGNAL(someSignal()),
+ &observer,
+ SLOT(dataChanged()));
+ QTimer::singleShot(5000, &mLoop, SLOT(quit()));
+ mNotyfications = 0;
+ emit someSignal();
+ if(0 == mNotyfications && !mLoop.isRunning()) {
+ mLoop.exec();
+ }
+ QVERIFY(1 == mNotyfications);
+}
+
+void T_TsServiceProvider::dataChanged(MTsModel &/*model*/)
+{
+ ++mNotyfications;
+}
+
+void T_TsServiceProvider::dataChanged(const TTsModelItem &/*item*/)
+{
+}
+
+void T_TsServiceProvider::DataChanged()
+{
+ ++mNotyfications;
+ if(mLoop.isRunning()) {
+ mLoop.quit();
+ }
+}
+
+QTEST_MAIN(T_TsServiceProvider)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/t_tsservicesprovider.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSSERVICESPROVIDER_H
+#define T_TSSERVICESPROVIDER_H
+
+#include <QObject>
+#include <QEventLoop>
+#include <tsmodelobserver.h>
+#include "tsdataobserver.h"
+class CTsServiceProviderConfig;
+class T_TsServiceProvider : public QObject,
+ public MTsModelObserver,
+ public MTsDataObserver
+{
+ Q_OBJECT
+public:
+ void dataChanged(MTsModel &model);
+ void dataChanged(const TTsModelItem &item);
+ void DataChanged();
+
+private slots:
+ void testProvider();
+ void testService();
+ void testServiceObserver();
+
+signals:
+ void someSignal();
+private:
+ int mNotyfications;
+ QEventLoop mLoop;
+};
+#endif //T_TSSERVICESPROVIDER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/t_tsservicesprovider.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console mobility
+MOBILITY = serviceframework
+
+SOURCES += t_tsservicesprovider.cpp \
+ tstestmodel.cpp \
+ tsservicesproviderconfig.cpp \
+
+
+HEADERS += t_tsservicesprovider.h \
+ tstestmodel.h \
+ tsservicesproviderconfig.h
+
+
+SOURCES += ../../src/tsservicesprovider.cpp \
+ ../../src/tsservice.cpp \
+ ../../src/tsmodelitemkey.cpp \
+ ../../src/tsmodelitem.cpp \
+ ../../src/tsmodel.cpp \
+ ../../src/tsserviceobserver.cpp
+
+HEADERS += ../../inc/tsservicesprovider.h \
+ ../../inc/tsservice.h \
+ ../../inc/tsmodelitemkey.h \
+ ../../inc/tsmodelitem.h \
+ ../../inc/tsserviceobserver.h \
+
+INCLUDEPATH += ../../../utils/inc
+
+
+LIBS += -lxqutils \
+ -lestor
+
+symbian {
+CONFIG += symbian_test
+coverage: CONFIG -= symbian_test
+TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/tsservicesproviderconfig.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 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 "tsservicesproviderconfig.h"
+#include "tstestmodel.h"
+// -----------------------------------------------------------------------------
+CTsServiceProviderConfig* CTsServiceProviderConfig::NewLC(TInt count)
+{
+ CTsServiceProviderConfig *self = new (ELeave)CTsServiceProviderConfig(count);
+ CleanupStack::PushL(self);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProviderConfig::CTsServiceProviderConfig(TInt count)
+:
+ mCount(count)
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProviderConfig::~CTsServiceProviderConfig()
+{
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsServiceProviderConfig::count() const
+{
+ return mCount;
+}
+
+// -----------------------------------------------------------------------------
+QObject* CTsServiceProviderConfig::loadL(TInt /*offset*/)const
+{
+ return new TsTestModel();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/tsservicesproviderconfig.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSSERVICESPROVIDERCONFIG_H
+#define TSSERVICESPROVIDERCONFIG_H
+
+#include <e32base.h>
+class QObject;
+class CTsServiceProviderConfig: public CBase
+{
+public:
+ static CTsServiceProviderConfig* NewLC(TInt count);
+ ~CTsServiceProviderConfig();
+
+ TInt count() const;
+ QObject* loadL(TInt offset)const;
+private:
+ CTsServiceProviderConfig(TInt count);
+
+private:
+ const TInt mCount;
+};
+
+#endif //TSSERVICESPROVIDERCONFIG_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/tstestmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 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 <QDateTime>
+#include <QStringList>
+
+#include "tstestmodel.h"
+
+const int dataIterations(3);
+
+TsTestModel::TsTestModel()
+{
+ mData = data(-1);
+}
+QList<QVariantHash> TsTestModel::taskList() const
+{
+ return mData;
+}
+
+QList<QVariantHash> TsTestModel::taskList(int limit) const
+{
+ return data(limit);
+}
+
+bool TsTestModel::openTask(const QVariant &/*id*/)
+{
+ return true;
+}
+bool TsTestModel::closeTask(const QVariant &/*id*/)
+{
+ return true;
+}
+
+QList<QVariantHash> TsTestModel::data(int limit) const
+{
+ QStringList allKeys;
+ allKeys << "TaskId" << "TaskName" << "TaskScreenshot" << "TaskTimestamp" << "TaskIsRunning" << "TaskCanBeClosed" << "TaskUid";
+
+ int offset(0);
+ QList<QVariantHash> retVal;
+ for( int iter(0); iter < dataIterations; ++iter) {
+
+ if(-1 != limit && ++offset >limit) {
+ break;
+ }
+ retVal.append(data());
+
+ foreach (const QString &key, allKeys) {
+ if(-1 != limit && ++offset >limit) {
+ break;
+ }
+ QVariantHash dataSet(data());
+ dataSet.remove(key);
+ retVal.append(dataSet);
+ }
+ }
+ return retVal;
+}
+
+QVariantHash TsTestModel::data()const
+{
+ QVariantHash data;
+ data.insert("TaskId", 0);
+ data.insert("TaskName", "Fake test name");
+ data.insert("TaskScreenshot", 0);
+ data.insert("TaskTimestamp", QDateTime());
+ data.insert("TaskIsRunning", 0);
+ data.insert("TaskCanBeClosed", 0);
+ data.insert("TaskUid", 0 );
+ return data;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesprovider/tstestmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef TSTESTMODEL_H
+#define TSTESTMODEL_H
+
+#include <QObject>
+#include <QVariantHash>
+
+class TsTestModel : public QObject
+{
+ Q_OBJECT
+public:
+ TsTestModel();
+public slots:
+ QList<QVariantHash> taskList() const;
+ QList<QVariantHash> taskList(int limit) const;
+
+ bool openTask(const QVariant &id);
+ bool closeTask(const QVariant &id) ;
+
+private:
+ QList<QVariantHash> data(int limit) const;
+ QVariantHash data()const;
+private:
+ QList<QVariantHash> mData;
+
+};
+#endif // TSTESTMODEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesproviderconfig/t_tsservicesproviderconfig.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include <qservicemanager.h>
+#include "t_tsservicesproviderconfig.h"
+#include "tsservicesproviderconfig.h"
+
+const char serviceFile [] = ":/t_tsservicesproviderconfig.xml";
+const char serviceName [] = "TsTestModelPlugin";
+void T_TsServiceProviderConfig::testConfig()
+{
+ CTsServiceProviderConfig *cfg(0);
+
+ //test doesnt install any plugin. number of services can be equal 0
+ cfg = CTsServiceProviderConfig::NewLC();
+ QVERIFY(0 <= cfg->count());
+ QVERIFY(checkInterfaces(*cfg));
+ CleanupStack::PopAndDestroy(cfg);
+
+ //test install test plugin. number of services has to be bigger then 0
+ QTM_NAMESPACE::QServiceManager manager;
+ manager.addService(serviceFile);
+ cfg = CTsServiceProviderConfig::NewLC();
+ QVERIFY(0 < cfg->count());
+ QVERIFY(checkInterfaces(*cfg));
+ CleanupStack::PopAndDestroy(cfg);
+ manager.removeService(serviceName);
+}
+
+bool T_TsServiceProviderConfig::checkInterfaces(const CTsServiceProviderConfig & cfg)
+{
+ bool retVal(true);
+ for(int iter(0); iter < cfg.count() && retVal; ++iter) {
+ QObject* ptr = cfg.loadL(iter);
+ retVal = (0 != ptr);
+ delete ptr;
+ }
+ return retVal;
+}
+
+QTEST_MAIN(T_TsServiceProviderConfig)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesproviderconfig/t_tsservicesproviderconfig.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSSERVICESPROVIDERCONFIG_H
+#define T_TSSERVICESPROVIDERCONFIG_H
+
+#include <QObject>
+class CTsServiceProviderConfig;
+class T_TsServiceProviderConfig : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testConfig();
+private:
+ bool checkInterfaces(const CTsServiceProviderConfig &);
+};
+#endif //T_TSSERVICESPROVIDERCONFIG_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesproviderconfig/t_tsservicesproviderconfig.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console mobility
+MOBILITY = serviceframework
+
+SOURCES += t_tsservicesproviderconfig.cpp
+
+HEADERS += t_tsservicesproviderconfig.h
+
+
+SOURCES += ../../src/tsservicesproviderconfig.cpp
+
+HEADERS += ../../inc/tsservicesproviderconfig.h
+
+LIBS += -lxqutils
+
+RESOURCES += t_tsservicesproviderconfig.qrc
+
+symbian {
+CONFIG += symbian_test
+coverage: CONFIG -= symbian_test
+TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsservicesproviderconfig/t_tsservicesproviderconfig.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/" >
+ <file alias="t_tsservicesproviderconfig.xml">../../internal/modelpluginexample/plugin/data/tstestmodelplugin.xml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsstorage/t_tsmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2009 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_tsmodel.h"
+
+_LIT(KDisplayName, "TestName" );
+
+T_TsModel::T_TsModel(int items)
+{
+ mItemsCount = items;
+}
+
+TInt T_TsModel::count() const
+{
+ return mItemsCount;
+}
+
+void T_TsModel::setObserver(MTsModelObserver *observer)
+{
+ mObserver = observer;
+}
+
+const TDesC& T_TsModel::displayNameL(TInt /*offset*/) const
+{
+ return KDisplayName();
+}
+
+TInt T_TsModel::iconHandleL(TInt /*offset*/) const
+{
+ return 0;
+}
+
+TTime T_TsModel::timestampL(TInt offset) const
+{
+ if (0 == (offset %2)) {
+ offset = 0;
+ }else if(0 == (offset % 5)) {
+ offset = 1;
+ }
+ return TTime(offset);
+}
+
+TTsModelItemKey T_TsModel::keyL(TInt offset) const
+{
+ return TTsModelItemKey(offset, reinterpret_cast<TInt>(this));
+}
+
+TBool T_TsModel::isActiveL(TInt /*offset*/) const
+{
+ return ETrue;
+}
+
+TBool T_TsModel::isClosableL(TInt /*offset*/) const
+{
+ return ETrue;
+}
+
+TBool T_TsModel::closeL(TTsModelItemKey) const
+{
+ return ETrue;
+}
+
+TBool T_TsModel::launchL(TTsModelItemKey ) const
+{
+ return ETrue;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsstorage/t_tsmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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 "tsmodel.h"
+class T_TsModel: public MTsModel
+{
+public:
+ T_TsModel(int items);
+ TInt count() const;
+ void setObserver(MTsModelObserver *observer);
+
+protected:
+ const TDesC& displayNameL(TInt offset) const;
+ TInt iconHandleL(TInt offset) const;
+ TTime timestampL(TInt offset) const;
+ TTsModelItemKey keyL(TInt offset) const;
+ TBool isActiveL(TInt offset) const;
+ TBool isClosableL(TInt offset) const;
+ TBool closeL(TTsModelItemKey key) const;
+ TBool launchL(TTsModelItemKey key) const;
+
+private:
+ TInt mItemsCount;
+ MTsModelObserver* mObserver;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsstorage/t_tsstorage.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+#include "tsstorage.h"
+#include "t_tsstorage.h"
+#include "t_tsmodel.h"
+
+const int KBigSet(100);
+
+void T_TsStorage::testItemDataChanged()
+{
+ CTsStorage* storage(0);
+ T_TsModel emptyProvider(0),
+ bigSetProvider(KBigSet);
+ RPointerArray<MTsModel>providers;
+ CleanupClosePushL(providers);
+
+ //storage has no data providers
+ mNotifications = 0;
+ storage = CTsStorage::NewL(providers.Array());
+ storage->dataChanged(bigSetProvider.itemL(0));
+ QVERIFY(0 == mNotifications);//storage has no observers
+ verifyProviders(*storage, providers.Array());
+ storage->setObserver(this);
+ storage->dataChanged(bigSetProvider.itemL(0));
+ QVERIFY(1 == mNotifications);//storage has observers
+ verifyProviders(*storage, providers.Array());
+ delete storage;
+
+ providers.Append(&emptyProvider);
+ providers.Append(&bigSetProvider);
+
+ //storage has some
+ mNotifications = 0;
+ storage = CTsStorage::NewL(providers.Array());
+ storage->dataChanged(bigSetProvider.itemL(0));
+ QVERIFY(0 == mNotifications);//storage has no observers
+ verifyProviders(*storage, providers.Array());
+ storage->setObserver(this);
+ storage->dataChanged(bigSetProvider.itemL(0));
+ QVERIFY(1 == mNotifications);//storage has observers
+ verifyProviders(*storage, providers.Array());
+ delete storage;
+ CleanupStack::PopAndDestroy(&providers);
+}
+
+void T_TsStorage::testModelDataChanged()
+{
+ CTsStorage* storage(0);
+ T_TsModel emptyProvider(0),
+ bigSetProvider(KBigSet);
+ RPointerArray<MTsModel>providers;
+ CleanupClosePushL(providers);
+
+ //storage has no data providers
+ mNotifications = 0;
+ storage = CTsStorage::NewL(providers.Array());
+ storage->dataChanged(emptyProvider);
+ QVERIFY(0 == mNotifications);//storage has no observers
+ verifyProviders(*storage, providers.Array());
+ storage->setObserver(this);
+ storage->dataChanged(emptyProvider);
+ QVERIFY(1 == mNotifications);//storage has observers
+ verifyProviders(*storage, providers.Array());
+ delete storage;
+
+ providers.Append(&emptyProvider);
+ providers.Append(&bigSetProvider);
+
+ //storage has some
+ mNotifications = 0;
+ storage = CTsStorage::NewL(providers.Array());
+ storage->dataChanged(emptyProvider);
+ QVERIFY(0 == mNotifications);//storage has no observers
+ verifyProviders(*storage, providers.Array());
+ storage->setObserver(this);
+ storage->dataChanged(emptyProvider);
+ QVERIFY(1 == mNotifications);//storage has observers
+ verifyProviders(*storage, providers.Array());
+ delete storage;
+ CleanupStack::PopAndDestroy(&providers);
+}
+
+void T_TsStorage::verifyProviders(const MTsModel &set, const TArray<MTsModel*>& providers)
+{
+ int sum(0);
+ for (int iter(0); iter < providers.Count(); ++iter) {
+ sum += (providers[iter])->count();
+ QVERIFY(set.count() >= (providers[iter])->count());
+ QVERIFY(EFalse != isSubset(set, *(providers[iter])));
+ }
+ QVERIFY(set.count() == sum);
+}
+
+TBool T_TsStorage::isSubset(const MTsModel &set, const MTsModel& subset) const
+{
+ bool isOk = true;
+ for (int i(0); i < subset.count() && isOk; ++i) {
+ isOk = false;
+ for(int k(0); k < set.count() && !isOk; ++k){
+ set.itemL(k).launchL();
+ set.itemL(k).closeL();
+ isOk = (subset.itemL(i).keyL() == set.itemL(k).keyL()) &&
+ (subset.itemL(i).timestampL() == set.itemL(k).timestampL()) &&
+ (subset.itemL(i).iconHandleL() == set.itemL(k).iconHandleL()) &&
+ (subset.itemL(i).isActiveL() == set.itemL(k).isActiveL()) &&
+ (subset.itemL(i).isClosableL() == set.itemL(k).isClosableL()) &&
+ (0 == subset.itemL(i).displayNameL().Compare(set.itemL(k).displayNameL()));
+ }
+ }
+ return isOk ? ETrue : EFalse;
+}
+
+QTEST_MAIN(T_TsStorage)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsstorage/t_tsstorage.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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 <QObject>
+
+#include "tsmodelobserver.h"
+
+class MTsModel;
+class TTsModelItem;
+
+class T_TsStorage : public QObject,
+ public MTsModelObserver
+{
+ Q_OBJECT
+
+private slots:
+ void testItemDataChanged();
+ void testModelDataChanged();
+
+private:
+ void dataChanged(MTsModel &/*model*/){++mNotifications;}
+ void dataChanged(const TTsModelItem &/*item*/){++mNotifications;}
+
+ void verifyProviders(const MTsModel &set, const TArray<MTsModel*>& providers);
+ TBool isSubset(const MTsModel &set, const MTsModel& subset) const;
+
+private:
+ int mNotifications;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/t_tsstorage/t_tsstorage.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2009 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:
+#
+
+CONFIG += qtestlib console
+
+
+SOURCES += t_tsstorage.cpp \
+ t_tsmodel.cpp
+
+HEADERS += t_tsstorage.h \
+ t_tsmodel.h
+
+INCLUDEPATH += ../../../utils/inc \
+ ../../../inc \
+
+SOURCES += ../../src/tsmodelitemkey.cpp \
+ ../../src/tsmodelitem.cpp \
+ ../../src/tsmodel.cpp \
+ ../../src/tsstorage.cpp \
+ ../../src/tsmodelitemkeymsg.cpp
+
+HEADERS += ../../inc/tsmodelobserver.h \
+ ../../inc/tsmodelitemkey.h \
+ ../../inc/tsmodelitem.h \
+ ../../inc/tsmodel.h \
+ ../../inc/tsstorage.h \
+ ../../inc/tsmodelitemkeymsg.h
+
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.CAPABILITY = ALL -TCB
+
+ LIBS += -lestor \ # for RWriteStream
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS += ../internal/modelpluginexample/plugin \
+ t_tsmodelitem \
+ t_tsstorage \
+ t_tsserializeddataprovider \
+ t_tsservicesproviderconfig \
+ t_tsservicesprovider \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/sis/stubs/createstubs.bat Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,17 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description:
+@rem
+
+for %%f in (*.pkg) do makesis -s %%f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/sis/stubs/taskmonitor_stub.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+;
+; Copyright (c) 2009 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:
+;
+; ------------------------------------------------------------------------------
+; Taskswitcher stub SIS package file.
+; Used to enable Taskswitcher to be updated from ROM with a SIS package.
+; When you add new files into this stub, please remember to update
+; SIS stub with "makesis -s" command.
+; ------------------------------------------------------------------------------
+;
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"taskmonitor"},(0x200267B0),1,0,0,TYPE=SA
+
+;Localized Vendor Name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+"" - "Z:\sys\bin\tstaskmonitorclient.dll"
+"" - "Z:\sys\bin\hsrunningappmonitor.exe"
+"" - "Z:\sys\bin\tsscreenshotplugin.dll"
+"" - "Z:\resource\plugins\tsscreenshotplugin.rsc"
+"" - "Z:\sys\bin\tsbackstepping.dll"
\ No newline at end of file
Binary file taskswitcher/sis/stubs/taskmonitor_stub.sis has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/sis/taskmonitor.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+;
+; Copyright (c) 2009 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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"taskmonitor"},(0x200267B0),1,0,0,TYPE=SA, RU
+
+;Localized Vendor Name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+
+"/epoc32/release/armv5/urel/hsrunningappmonitor.exe" - "!:\sys\bin\hsrunningappmonitor.exe"
+"/epoc32/release/armv5/urel/tstaskmonitorclient.dll"-"!:\sys\bin\tstaskmonitorclient.dll"
+"/epoc32/release/armv5/urel/tsscreenshotplugin.dll"-"!:\sys\bin\tsscreenshotplugin.dll"
+"/epoc32/data/z/resource/plugins/tsscreenshotplugin.rsc"-"!:\resource\plugins\tsscreenshotplugin.rsc"
+"/epoc32/release/armv5/urel/tsbackstepping.dll"-"!:\sys\bin\tsbackstepping.dll"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/taskswitcher.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += client
+symbian {
+ SUBDIRS += backstepping \
+ server \
+ screenshotplugin
+
+ BLD_INF_RULES.prj_exports += "inc/tstaskmonitorglobals.h |../inc/tstaskmonitorglobals.h"
+
+}
+
+symbian:include(rom.pri)
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/appiconstarter/appiconstarter.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = appiconstarter
+
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+SOURCES += main.cpp\
+starterwidget.cpp\
+viewmanager.cpp
+
+
+HEADERS += starterwidget.h\
+viewmanager.h
+
+LIBS += -lefsrv.dll \
+ -leuser.dll \
+ -lbafl.dll \
+ -lapgrfx.dll \
+ -leikcore.dll
+
+
+symbian {
+ TARGET.CAPABILITY += AllFiles
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/appiconstarter/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "viewmanager.h"
+
+int main(int argc, char **argv)
+{
+ HbApplication app( argc, argv );
+
+ viewmanager mainWindow;
+ mainWindow.show();
+ mainWindow.activateWindow();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/appiconstarter/starterwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2009 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 <EIKENV.H>
+#include "starterwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QFont>
+#include <QFile>
+#include <QTimer>
+#include <hbmainwindow.h>
+#include <hbinstance.h>
+
+
+
+starterwidget::starterwidget( QGraphicsItem* parent )
+ : HbWidget( parent )
+ {
+ mStart1 = new HbPushButton( "Start Search" );
+ mStart2 = new HbPushButton( "Start FileBrowser" );
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem( mStart1, 1, 0, 1, 1 );
+ mGridLayout->addItem( mStart2, 2, 0, 1, 1 );
+ mGridLayout->setRowStretchFactor ( 0, 1 );
+ mGridLayout->setRowStretchFactor ( 1, 1 );
+ mGridLayout->setRowStretchFactor ( 2, 1 );
+ setLayout(mGridLayout);
+
+ mTimer1 = new QTimer( this );
+ mTimer2 = new QTimer( this );
+ connect( mStart1, SIGNAL(released()), this, SLOT(startopen1() ) );
+ connect( mTimer1, SIGNAL(timeout()), this, SLOT(acivate1() ) );
+ connect( mStart2, SIGNAL(released()), this, SLOT(startopen2() ) );
+ connect( mTimer2, SIGNAL(timeout()), this, SLOT(acivate2() ) );
+ }
+
+starterwidget::~starterwidget()
+ {
+
+ }
+
+void starterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ HbWidget::paint(painter, option, widget);
+
+ if ( mMessage.isEmpty() || mMessage == "" )
+ {
+ return;
+ }
+ QFont font;
+ font.setPointSize(30);
+ painter->setFont(font);
+ painter->drawText(10, 100, mMessage );
+ }
+
+void starterwidget::startopen1()
+ {
+ mTimer1->start( 5000 );
+ }
+
+void starterwidget::startopen2()
+ {
+ mTimer2->start( 5000 );
+ }
+
+void starterwidget::acivate1()
+ {
+ bool ok = QProcess::startDetached("Searchapplication");
+ if ( !ok )
+ {
+ mMessage = "Not Found 1";
+ }
+
+ update();
+ mTimer1->stop();
+ }
+
+void starterwidget::acivate2()
+ {
+ bool ok = QProcess::startDetached("FileBrowser");
+ if ( !ok )
+ {
+ mMessage = "Not Found 2";
+ }
+
+ update();
+ mTimer2->stop();
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/appiconstarter/starterwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef STARTERWIDGET_H_
+#define STARTERWIDGET_H_
+
+#include <QProcess>
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <APGTASK.H>
+class QTimer;
+
+class starterwidget: public HbWidget
+ {
+ Q_OBJECT
+public:
+ starterwidget( QGraphicsItem* parent = 0 );
+ ~starterwidget();
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ QGraphicsGridLayout* mGridLayout;
+
+ HbPushButton* mStart1;
+ HbPushButton* mStart2;
+
+
+
+private slots:
+ void startopen1();
+ void acivate1();
+ void startopen2();
+ void acivate2();
+
+
+
+private:
+
+ QString mMessage;
+ QTimer* mTimer1;
+ QTimer* mTimer2;
+ };
+
+#endif /* STARTERWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/appiconstarter/viewmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 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 <QStringList>
+#include <hbapplication.h>
+#include "viewmanager.h"
+#include "starterwidget.h"
+
+
+ viewmanager::viewmanager():
+ HbMainWindow()
+ {
+ mSw = new starterwidget();
+ mSView = addView(mSw);
+ mSView->setTitle("Starter");
+
+ }
+
+ viewmanager::~viewmanager()
+ {
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/appiconstarter/viewmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef VIEWMANAGER_H_
+#define VIEWMANAGER_H_
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+class starterwidget;
+
+class viewmanager : public HbMainWindow
+{
+ Q_OBJECT
+public:
+ viewmanager();
+ virtual ~viewmanager();
+ void initialize();
+
+private:
+ starterwidget* mSw;
+ HbView* mSView;
+
+};
+
+#endif /* VIEWMANAGER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/gfx/qgn_menu_helloworldbasic.svg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 87.999">
+<g>
+<g>
+<g>
+<g>
+<rect fill="none" width="88" height="87.999"/>
+</g>
+</g>
+<g>
+<linearGradient id="XMLID_7_" gradientUnits="userSpaceOnUse" x1="12.3042" y1="18.3799" x2="63.4113" y2="79.287">
+<stop offset="0" style="stop-color:#B3DDFF"/>
+<stop offset="0.8146" style="stop-color:#084296"/>
+<stop offset="1" style="stop-color:#084296"/>
+</linearGradient>
+<path fill="url(#XMLID_7_)" d="M32.135,7.415L14.363,17.432v23.167c0,0,8.926,15.351,10.468,18.001 c-2.386,1.704-15.44,11.03-15.44,11.03l21.613,12.652c0,0,12.907-9.85,14.71-11.226c1.979,1.109,16.231,9.101,16.231,9.101 l16.664-15.132c0,0-14.066-6.929-16.888-8.318c1.467-3.01,10.531-21.604,10.531-21.604l-22.298-9.59 c0,0-1.486,3.173-2.093,4.467c-2.046-0.88-6.573-2.826-6.573-2.826s-3.713,2.463-5.696,3.778 c-0.327-0.744-0.542-1.233-0.657-1.495c0.007-0.824,0.213-23.72,0.213-23.72L32.135,7.415z"/>
+<linearGradient id="XMLID_8_" gradientUnits="userSpaceOnUse" x1="40.8276" y1="52.1914" x2="16.1997" y2="21.1353">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_8_)" points="59.051,57.621 69.536,36.111 50.944,28.115 48.852,32.581 41.493,29.418 34.719,33.911 32.932,29.849 33.117,9.157 16.363,18.601 16.363,40.06 27.476,59.169 13.064,69.463 30.856,79.879 45.546,68.669 61.667,77.708 75.089,65.521 "/>
+<linearGradient id="XMLID_9_" gradientUnits="userSpaceOnUse" x1="60.585" y1="31.876" x2="53.8582" y2="45.1125">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_9_)" points="41.26,48.783 50.944,28.115 69.536,36.111 59.051,57.621 "/>
+<polygon fill="#0046B7" points="16.363,40.06 27.476,59.169 41.26,48.783 32.932,29.849 "/>
+<polygon fill="#3366CC" points="16.363,40.06 16.363,18.601 33.117,9.157 32.932,29.849 "/>
+<polygon fill="#CFECFF" points="26.696,39.23 41.493,29.418 59.523,37.168 45.546,47.954 "/>
+<path fill="#5AA7E0" d="M41.954,55.286"/>
+<polygon fill="#3366CC" points="26.696,39.23 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#5AA7E0" points="13.064,69.463 27.476,59.169 45.546,68.669 30.856,79.879 "/>
+<linearGradient id="XMLID_10_" gradientUnits="userSpaceOnUse" x1="29.2085" y1="63.6836" x2="48.7102" y2="56.1976">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.0056" style="stop-color:#5AA7E0"/>
+<stop offset="0.85" style="stop-color:#3366CC"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_10_)" points="43.423,46.971 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#0046B7" points="45.546,47.954 45.546,68.669 59.051,57.621 59.523,37.168 "/>
+<linearGradient id="XMLID_11_" gradientUnits="userSpaceOnUse" x1="45.3936" y1="59.5186" x2="59.0508" y2="59.5186">
+<stop offset="0" style="stop-color:#0046B7"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_11_)" points="45.394,50.368 45.546,68.669 59.051,57.621 "/>
+<linearGradient id="XMLID_12_" gradientUnits="userSpaceOnUse" x1="60.8945" y1="68.6807" x2="57.2953" y2="58.792">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.4101" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_12_)" points="61.667,77.708 45.546,68.669 59.051,57.621 75.089,65.521 "/>
+</g>
+</g>
+</g>
+</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasic.hrh Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* ==============================================================================
+* Name : helloworldbasic.hrh
+* Part of : Helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2005-2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef __HELLOWORLDBASIC_HRH__
+#define __HELLOWORLDBASIC_HRH__
+
+// HelloWorldBasic enumerate command codes
+enum THelloWorldBasicIds
+ {
+ EHelloWorldBasicCommand1 = 0x6001, // start value must not be 0
+ EHelloWorldBasicCommand2,
+ EHelloWorldBasicCommand3
+ };
+
+#endif // __HELLOWORLDBASIC_HRH__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasic.pan Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* ==============================================================================
+* Name : helloworldbasic.pan
+* Part of : Helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2005-2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef __HELLOWORLDBASIC_PAN__
+#define __HELLOWORLDBASIC_PAN__
+
+/** HelloWorldBasic application panic codes */
+enum THelloWorldBasicPanics
+ {
+ EHelloWorldBasicUi = 1
+ // add further panics here
+ };
+
+inline void Panic(THelloWorldBasicPanics aReason)
+ {
+ _LIT(applicationName,"HelloWorldBasic");
+ User::Panic(applicationName, aReason);
+ }
+
+#endif // __HELLOWORLDBASIC_PAN__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasicapplication.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* ==============================================================================
+* Name : helloworldbasicapplication.h
+* Part of : Helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2005-2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef __HELLOWORLDBASICAPPLICATION_H__
+#define __HELLOWORLDBASICAPPLICATION_H__
+
+// INCLUDES
+#include <aknapp.h>
+
+// CLASS DECLARATION
+
+/**
+* CHelloWorldBasicApplication application class.
+* Provides factory to create concrete document object.
+* An instance of CHelloWorldBasicApplication is the application part of the
+* AVKON application framework for the HelloWorldBasic example application.
+*/
+class CHelloWorldBasicApplication : public CAknApplication
+ {
+ public: // Functions from base classes
+
+ /**
+ * From CApaApplication, AppDllUid.
+ * @return Application's UID (KUidHelloWorldBasicApp).
+ */
+ TUid AppDllUid() const;
+
+ protected: // Functions from base classes
+
+ /**
+ * From CApaApplication, CreateDocumentL.
+ * Creates CHelloWorldBasicDocument document object. The returned
+ * pointer in not owned by the CHelloWorldBasicApplication object.
+ * @return A pointer to the created document object.
+ */
+ CApaDocument* CreateDocumentL();
+ };
+
+#endif // __HELLOWORLDBASICAPPLICATION_H__
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasicappui.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* ==============================================================================
+* Name : helloworldbasicappui.h
+* Part of : Helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2005-2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef __HELLOWORLDBASICAPPUI_H__
+#define __HELLOWORLDBASICAPPUI_H__
+
+// INCLUDES
+#include <aknappui.h>
+
+// FORWARD DECLARATIONS
+class CHelloWorldBasicAppView;
+
+
+// CLASS DECLARATION
+/**
+* CHelloWorldBasicAppUi application UI class.
+* Interacts with the user through the UI and request message processing
+* from the handler class
+*/
+class CHelloWorldBasicAppUi : public CAknAppUi
+ {
+ public: // Constructors and destructor
+
+ /**
+ * ConstructL.
+ * 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * CHelloWorldBasicAppUi.
+ * C++ default constructor. This needs to be public due to
+ * the way the framework constructs the AppUi
+ */
+ CHelloWorldBasicAppUi();
+
+ /**
+ * ~CHelloWorldBasicAppUi.
+ * Virtual Destructor.
+ */
+ virtual ~CHelloWorldBasicAppUi();
+
+ private: // Functions from base classes
+
+ /**
+ * From CEikAppUi, HandleCommandL.
+ * Takes care of command handling.
+ * @param aCommand Command to be handled.
+ */
+ void HandleCommandL( TInt aCommand );
+
+ /**
+ * HandleResourceChangeL()
+ * Called by framework when layout is changed.
+ * @param aType the type of resources that have changed
+ */
+ void HandleResourceChangeL( TInt aType );
+
+ private: // Data
+
+ /**
+ * The application view
+ * Owned by CHelloWorldBasicAppUi
+ */
+ CHelloWorldBasicAppView* iAppView;
+
+ };
+
+#endif // __HELLOWORLDBASICAPPUI_H__
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasicappview.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,109 @@
+/*
+* ==============================================================================
+* Name : helloworldbasicappview.h
+* Part of : Helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2005-2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef __HELLOWORLDBASICAPPVIEW_H__
+#define __HELLOWORLDBASICAPPVIEW_H__
+
+// INCLUDES
+#include <coecntrl.h>
+
+// CLASS DECLARATION
+class CHelloWorldBasicAppView : public CCoeControl
+ {
+ public: // New methods
+
+ /**
+ * NewL.
+ * Two-phased constructor.
+ * Create a CHelloWorldBasicAppView object, which will draw itself to aRect.
+ * @param aRect The rectangle this view will be drawn to.
+ * @return a pointer to the created instance of CHelloWorldBasicAppView.
+ */
+ static CHelloWorldBasicAppView* NewL( const TRect& aRect );
+
+ /**
+ * NewLC.
+ * Two-phased constructor.
+ * Create a CHelloWorldBasicAppView object, which will draw itself
+ * to aRect.
+ * @param aRect Rectangle this view will be drawn to.
+ * @return A pointer to the created instance of CHelloWorldBasicAppView.
+ */
+ static CHelloWorldBasicAppView* NewLC( const TRect& aRect );
+
+ /**
+ * ~CHelloWorldBasicAppView
+ * Virtual Destructor.
+ */
+ virtual ~CHelloWorldBasicAppView();
+
+ /**
+ * GetText
+ * @return modifiable reference to the descriptor, which stores
+ * user-given text
+ */
+ TDes& GetText();
+
+ public: // Functions from base classes
+
+ /**
+ * From CCoeControl, Draw
+ * Draw this CHelloWorldBasicAppView to the screen.
+ * If the user has given a text, it is also printed to the center of
+ * the screen.
+ * @param aRect the rectangle of this view that needs updating
+ */
+ void Draw( const TRect& aRect ) const;
+
+ /**
+ * From CoeControl, SizeChanged.
+ * Called by framework when the view size is changed.
+ */
+ virtual void SizeChanged();
+
+ private: // Constructors
+
+ /**
+ * ConstructL
+ * 2nd phase constructor.
+ * Perform the second phase construction of a
+ * CHelloWorldBasicAppView object.
+ * @param aRect The rectangle this view will be drawn to.
+ */
+ void ConstructL(const TRect& aRect);
+
+ /**
+ * CHelloWorldBasicAppView.
+ * C++ default constructor.
+ */
+ CHelloWorldBasicAppView();
+
+ private:
+
+ /**
+ * font used, when printing user-given text to the screen
+ */
+ const CFont* iFont;
+
+ /**
+ * descriptor storing the user-given text
+ */
+ TBuf<24> iText;
+ };
+
+#endif // __HELLOWORLDBASICAPPVIEW_H__
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasicdocument.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* ==============================================================================
+* Name : helloworldbasicdocument.h
+* Part of : Helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2005-2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef __HELLOWORLDBASICDOCUMENT_H__
+#define __HELLOWORLDBASICDOCUMENT_H__
+
+// INCLUDES
+#include <akndoc.h>
+
+// FORWARD DECLARATIONS
+class CHelloWorldBasicAppUi;
+class CEikApplication;
+
+
+// CLASS DECLARATION
+
+/**
+* CHelloWorldBasicDocument application class.
+* An instance of class CHelloWorldBasicDocument is the Document part of the
+* AVKON application framework for the HelloWorldBasic example application.
+*/
+class CHelloWorldBasicDocument : public CAknDocument
+ {
+ public: // Constructors and destructor
+
+ /**
+ * NewL.
+ * Two-phased constructor.
+ * Construct a CHelloWorldBasicDocument for the AVKON application aApp
+ * using two phase construction, and return a pointer
+ * to the created object.
+ * @param aApp Application creating this document.
+ * @return A pointer to the created instance of CHelloWorldBasicDocument.
+ */
+ static CHelloWorldBasicDocument* NewL( CEikApplication& aApp );
+
+ /**
+ * NewLC.
+ * Two-phased constructor.
+ * Construct a CHelloWorldBasicDocument for the AVKON application aApp
+ * using two phase construction, and return a pointer
+ * to the created object.
+ * @param aApp Application creating this document.
+ * @return A pointer to the created instance of CHelloWorldBasicDocument.
+ */
+ static CHelloWorldBasicDocument* NewLC( CEikApplication& aApp );
+
+ /**
+ * ~CHelloWorldBasicDocument
+ * Virtual Destructor.
+ */
+ virtual ~CHelloWorldBasicDocument();
+
+ public: // Functions from base classes
+
+ /**
+ * CreateAppUiL
+ * From CEikDocument, CreateAppUiL.
+ * Create a CHelloWorldBasicAppUi object and return a pointer to it.
+ * The object returned is owned by the Uikon framework.
+ * @return Pointer to created instance of AppUi.
+ */
+ CEikAppUi* CreateAppUiL();
+
+ private: // Constructors
+
+ /**
+ * ConstructL
+ * 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * CHelloWorldBasicDocument.
+ * C++ default constructor.
+ * @param aApp Application creating this document.
+ */
+ CHelloWorldBasicDocument( CEikApplication& aApp );
+
+ };
+
+#endif // __HELLOWORLDBASICDOCUMENT_H__
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/inc/helloworldbasicquerydialog.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* ==============================================================================
+* Name : helloworldbasicquerydialog.h
+* Part of : helloworldbasic
+* Interface :
+* Description :
+* Version :
+*
+* Copyright (c) 2006 Nokia Corporation.
+* This material, including documentation and any related
+* computer programs, is protected by copyright controlled by
+* Nokia Corporation.
+* ==============================================================================
+*/
+
+#ifndef HELLOWORLDQUERYDIALOG_H
+#define HELLOWORLDQUERYDIALOG_H
+
+
+// INCLUDES
+#include <aknquerydialog.h>
+
+// CLASS DECLARATION
+
+/**
+* CHelloWorldQueryDialog class.
+* This class is used to query the user for text information
+*/
+class CHelloWorldQueryDialog : public CAknTextQueryDialog
+ {
+ public: // Constructors and destructor
+
+ /**
+ * C++ default constructor.
+ * @param aBuf buffer to store the input
+ * @param aDefInput default input for the dialog
+ */
+ CHelloWorldQueryDialog( TDes& aBuf, HBufC *aDefInput );
+
+ /**
+ * Destructor.
+ */
+ virtual ~CHelloWorldQueryDialog() {};
+
+ private: // from CEikDialog
+
+ /**
+ * sets the default value to the dialog.
+ */
+ void PreLayoutDynInitL();
+
+ private: // Data
+
+ /**
+ * the default input for the dialog
+ */
+ HBufC& iDefInput;
+ };
+
+#endif // HELLOWORLDQUERYDIALOG_H
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/src/helloworldbasic.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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 FILES
+#include <eikstart.h>
+#include "HelloWorldBasicApplication.h"
+
+/**
+ * factory function to create the Hello World Basic application class
+ */
+LOCAL_C CApaApplication* NewApplication()
+ {
+ return new CHelloWorldBasicApplication;
+ }
+
+/**
+ * A normal Symbian OS executable provides an E32Main() function which is
+ * called by the operating system to start the program.
+ */
+GLDEF_C TInt E32Main()
+ {
+ return EikStart::RunApplication( NewApplication );
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/src/helloworldbasicappview.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2009 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 FILES
+#include <coemain.h>
+#include <aknutils.h>
+#include "HelloWorldBasicAppView.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewL( const TRect& aRect )
+ {
+ CHelloWorldBasicAppView* self = CHelloWorldBasicAppView::NewLC( aRect );
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewLC( const TRect& aRect )
+ {
+ CHelloWorldBasicAppView* self = new ( ELeave ) CHelloWorldBasicAppView;
+ CleanupStack::PushL( self );
+ self->ConstructL( aRect );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicAppView::ConstructL( const TRect& aRect )
+ {
+ // Create a window for this application view
+ CreateWindowL();
+
+ // set the font
+ iFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont);
+
+ iText.Zero();
+
+ // Set the windows size
+ SetRect( aRect );
+
+ // Activate the window, which makes it ready to be drawn
+ ActivateL();
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::CHelloWorldBasicAppView()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicAppView::CHelloWorldBasicAppView()
+ {
+ // No implementation required
+ }
+
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::~CHelloWorldBasicAppView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicAppView::~CHelloWorldBasicAppView()
+ {
+ // No implementation required
+ }
+
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::Draw()
+// Draws the display.
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicAppView::Draw( const TRect& /*aRect*/ ) const
+ {
+ // note that the whole screen is drawn everytime, so aRect-parameter
+ // is ignored
+
+ // Get the standard graphics context
+ CWindowGc& gc = SystemGc();
+ gc.SetPenStyle( CGraphicsContext::ENullPen );
+ gc.SetBrushColor( KRgbWhite);
+ gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+
+ // Gets the control's extent
+ TRect rect( Rect());
+
+ // draw also text, if user has given it via dialog
+ if (iText.Length() > 0)
+ {
+ gc.UseFont(iFont);
+ gc.DrawText(iText, rect, Rect().Height()/3, CGraphicsContext::ECenter );
+ gc.DiscardFont();
+ }
+ else
+ {
+ gc.Clear( rect );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::SizeChanged()
+// Called by framework when the view size is changed.
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicAppView::SizeChanged()
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppView::GetText()
+// Called by AppUi to either set the text (via dialog) or zero the contents.
+// -----------------------------------------------------------------------------
+//
+TDes & CHelloWorldBasicAppView::GetText()
+ {
+ return iText;
+ }
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/src/helloworldbasicdocument.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2009 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 FILES
+#include "HelloWorldBasicAppUi.h"
+#include "HelloWorldBasicDocument.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicDocument::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicDocument* CHelloWorldBasicDocument::NewL( CEikApplication&
+ aApp )
+ {
+ CHelloWorldBasicDocument* self = NewLC( aApp );
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicDocument::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicDocument* CHelloWorldBasicDocument::NewLC( CEikApplication&
+ aApp )
+ {
+ CHelloWorldBasicDocument* self =
+ new ( ELeave ) CHelloWorldBasicDocument( aApp );
+
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicDocument::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicDocument::ConstructL()
+ {
+ // No implementation required
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicDocument::CHelloWorldBasicDocument()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicDocument::CHelloWorldBasicDocument( CEikApplication& aApp )
+ : CAknDocument( aApp )
+ {
+ // No implementation required
+ }
+
+// ---------------------------------------------------------------------------
+// CHelloWorldBasicDocument::~CHelloWorldBasicDocument()
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CHelloWorldBasicDocument::~CHelloWorldBasicDocument()
+ {
+ // No implementation required
+ }
+
+// ---------------------------------------------------------------------------
+// CHelloWorldBasicDocument::CreateAppUiL()
+// Constructs CreateAppUi.
+// ---------------------------------------------------------------------------
+//
+CEikAppUi* CHelloWorldBasicDocument::CreateAppUiL()
+ {
+ // Create the application user interface, and return a pointer to it;
+ // the framework takes ownership of this object
+ return ( static_cast <CEikAppUi*> ( new ( ELeave )
+ CHelloWorldBasicAppUi ) );
+ }
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/common/src/helloworldbasicquerydialog.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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 FILES
+
+#include <avkon.hrh>
+#include "HelloWorldBasicQueryDialog.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CHelloWorldQueryDialog::CHelloWorldQueryDialog( TDes& aBuf, HBufC *aDefInput )
+ : CAknTextQueryDialog( aBuf )
+ , iDefInput(*aDefInput)
+ {
+ }
+
+// ---------------------------------------------------------
+// CHelloWorldQueryDialog::PreLayoutDynInitL
+// ---------------------------------------------------------
+//
+void CHelloWorldQueryDialog::PreLayoutDynInitL()
+ {
+ // first we have to execute PreLayoutDynInitL() of the base-class
+ CAknTextQueryDialog::PreLayoutDynInitL();
+
+ // acquire pointer to editor-control and set the default input.
+ CAknQueryControl* control = QueryControl();
+ control->SetTextL(iDefInput);
+
+ // enable OK-button, so that default text can be accepted as it is
+ // without modifying the text
+ MakeLeftSoftkeyVisible( ETrue );
+ }
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/devide_sis.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,110 @@
+use strict;
+
+my $pkgbase = ";Language - standard language definitions
+\&EN,FI,ZH,JA
+
+; standard SIS file header
+\#{\"HelloWorldBasicREPLACE1\", \"HelloWorldBasicREPLACE1\", \"HelloWorldBasicREPLACE1\", \"HelloWorldBasicREPLACE1\"},(REPLACEUID),1,0,0
+
+;Localised Vendor name
+\%{\"Vendor-EN\", \"Vendor-FI\", \"Vendor-ZH\", \"Vendor-JA\"}
+
+;Unique Vendor name
+:\"Vendor\"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {\"S60ProductID\", \"S60ProductID\", \"S60ProductID\", \"S60ProductID\"}
+
+";
+
+my $pkgfiles = ";Files
+\"\\epoc32\\release\\armv5\\urel\\HelloWorldBasicREPLACE2.exe\" -\"!:\\sys\\bin\\HelloWorldBasicREPLACE2.exe\"
+
+\"\\epoc32\\data\\z\\resource\\apps\\HelloWorldBasicREPLACE2.rsc\" -\"!:\\resource\\apps\\HelloWorldBasicREPLACE2.rsc\"
+\"\\epoc32\\data\\z\\resource\\apps\\HelloWorldBasicREPLACE2.r09\" -\"!:\\resource\\apps\\HelloWorldBasicREPLACE2.r09\"
+\"\\epoc32\\data\\z\\resource\\apps\\HelloWorldBasicREPLACE2.r31\" -\"!:\\resource\\apps\\HelloWorldBasicREPLACE2.r31\"
+\"\\epoc32\\data\\z\\resource\\apps\\HelloWorldBasicREPLACE2.r32\" -\"!:\\resource\\apps\\HelloWorldBasicREPLACE2.r32\"
+
+\"\\epoc32\\data\\z\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.rsc\" -\"!:\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.rsc\"
+\"\\epoc32\\data\\z\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.r09\" -\"!:\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.r09\"
+\"\\epoc32\\data\\z\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.r31\" -\"!:\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.r31\"
+\"\\epoc32\\data\\z\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.r32\" -\"!:\\private\\10003a3f\\import\\apps\\HelloWorldBasicREPLACE2_reg.r32\"
+\"\\epoc32\\data\\z\\resource\\apps\\helloworldbasicREPLACE2_aif.mif\" -\"!:\\resource\\apps\\helloworldbasicREPLACE2_aif.mif\"
+;end
+";
+
+my $appnum = shift;
+my $baseuid = 0xA000018A;
+my $defaultappforpkg = 5;
+my $filenum = $appnum/$defaultappforpkg;
+if ($appnum%$defaultappforpkg > 0)
+ {
+ $filenum++;
+ }
+
+generate();
+
+sub generate()
+ {
+ my $i = 0;
+ for ( $i=1; $i<=$filenum; $i++ )
+ {
+ my $filepart =".\\sis\\helloworldbasicPart".$i."\.pkg";
+ open FW, ">$filepart" or die "Couldn't open $filepart to write";
+ binmode FW;
+ print FW replaceheader($i);
+ my $fb = filesbegin($i);
+ my $fe = filesend($i);
+ for(my $f=$fb; $f<=$fe; $f++)
+ {
+ print FW replacefiles($f);
+ }
+ close FW;
+ }
+ }
+
+sub filesend()
+ {
+ my $fileiter = shift;
+ my $fend = $fileiter*$defaultappforpkg;
+ if($fend>$appnum)
+ {
+ $fend = $appnum;
+ }
+ return $fend;
+ }
+
+sub filesbegin()
+ {
+ my $fileiter = shift;
+ my $fbegin = ($fileiter-1)*$defaultappforpkg+1;
+ return $fbegin;
+ }
+
+sub replaceheader()
+ {
+ my $it = shift;
+ my $tempbuf = $pkgbase;
+ $tempbuf =~ s/REPLACE1/$it/sg;
+ $it = ($it-1)*$defaultappforpkg + 1;
+ my $tempuid = uid($it);
+ $tempbuf =~ s/REPLACEUID/$tempuid/sg;
+ return $tempbuf;
+ }
+
+sub replacefiles()
+ {
+ my $it = shift;
+ my $tempbuf = $pkgfiles;
+ $tempbuf =~ s/REPLACE2/$it/sg;
+ return $tempbuf;
+ }
+
+sub uid
+ {
+ my $iter = shift;
+ my $uuid = $baseuid + $iter -1;
+ my $hu = sprintf '%#X', $uuid;
+ $hu =~s/X/x/;
+ return $hu;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/generate.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,162 @@
+use strict;
+use File::Find;
+
+my $appnum = shift;
+my $baseuid = 0xA000018A;
+my $baseuidstr = uid( 1 );
+my $base = `cd`;
+$base =~s/(\s+)$//; #remove linefeed from end
+my $patternbase = $base."\\pattern";
+my $globaliter = 0;
+
+generate();
+
+sub generate()
+ {
+ my $i = 0;
+ for ( $i=1; $i<=$appnum; $i++ )
+ {
+ $globaliter = $i;
+ createappdir($globaliter);
+ find( \&reader, $patternbase );
+ }
+ createpkg();
+ creategroup();
+ system "perl devide_sis.pl $appnum";
+ }
+
+sub uid
+ {
+ my $iter = shift;
+ my $uuid = $baseuid + $iter -1;
+ my $hu = sprintf '%#X', $uuid;
+ $hu =~s/X/x/;
+ return $hu;
+ }
+
+sub reader()
+ {
+ my $file=$_;
+ my $winpath=$File::Find::name;
+ $winpath=~s/\//\\/g;
+ my $nefilepath = "";
+ if ( -f $file && not($winpath =~/svn/) )
+ {
+ $nefilepath = newpath( $winpath, $globaliter );
+ my $appuid = uid( $globaliter );
+ rewritefile( $winpath, $nefilepath, $globaliter, $appuid );
+ }
+ }
+
+sub newpath()
+{
+ my $patternpath = shift;
+ my $iter = shift;
+ my $appdir = "helloworldbasic".$iter;
+ my $appbasicfilepath = "basic".$iter;
+ my $appBasicfilepath = "Basic".$iter;
+ $patternpath =~ s/basic1/$appbasicfilepath/;
+ $patternpath =~ s/Basic1/$appBasicfilepath/;
+ $patternpath =~ s/pattern/$appdir/;
+ return $patternpath;
+}
+
+sub createappdir()
+{
+ my $iter = shift;
+ my $appdir = "helloworldbasic".$iter;
+ my $src = $appdir."\\src";
+ my $inc = $appdir."\\inc";
+ my $data = $appdir."\\data";
+ my $sis = $appdir."\\sis";
+ my $group = $appdir."\\group";
+ system "mkdir $appdir";
+ system "mkdir $src";
+ system "mkdir $inc";
+ system "mkdir $data";
+ system "mkdir $sis";
+ system "mkdir $group";
+}
+
+sub rewritefile()
+{
+ my $input = shift;
+ my $output = shift;
+ my $iter = shift;
+ my $uid = shift;
+ my $basic = "basic".$iter;
+ my $Basic = "Basic".$iter;
+ my $World = "World".$iter;
+
+ open FRI, $input or die "Couldn't open $input to read";
+ binmode FRI;
+ open FWO, ">$output" or die "Couldn't open $output to write";
+ binmode FWO;
+ while( <FRI> )
+ {
+ my $line = $_;
+ $line =~ s/basic1/$basic/g;
+ $line =~ s/Basic1/$Basic/g;
+ $line =~ s/World1/$World/g;
+ $line =~ s/$baseuidstr/$uid/gi;
+ print FWO $line;
+ }
+ close FRI;
+ close FWO;
+}
+
+sub createpkg()
+{
+ system "mkdir sis";
+ open FRS, ".\\pattern\\sis\\helloworldbasic_armv5.pkg" or die "Couldn't open pkg file to read";
+ binmode FRS;
+ open FWS, ">sis\\helloworldbasic_armv5.pkg" or die "Couldn't open pkg file to write";
+ binmode FWS;
+ my @exports;
+ my $begin = 0;
+
+ while ( <FRS> )
+ {
+ my $line = $_;
+ print FWS $line;
+ if ($line =~ /;Files/)
+ {
+ $begin = 1;
+ }
+ if ($begin == 1)
+ {
+ push(@exports, $line);
+ }
+ }
+ close FRS;
+
+ for (my $i=2; $i<=$globaliter; $i++)
+ {
+ my $basic = "basic".$i;
+ my $Basic = "Basic".$i;
+ my $it = 0;
+ while (defined($exports[$it]))
+ {
+ my $line = $exports[$it];
+ $line =~ s/basic1/$basic/g;
+ $line =~ s/Basic1/$Basic/g;
+ print FWS $line;
+ $it++;
+ }
+ print FWS "\r\n\r\n";
+ }
+ close FWS;
+}
+
+sub creategroup()
+ {
+ system "mkdir group";
+ open FWG, ">group\\bld.inf" or die "Couldn't open bld.inf file to write";
+ binmode FWG;
+ for (my $i=1; $i<=$globaliter; $i++)
+ {
+ my $path = "../helloworldbasic".$i."/group/bld.inf";
+ print FWG "\#include \"$path\"\r\n";
+ }
+ }
+ close FWG;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/HelloWorldBasic1_reg.rss Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 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 "Helloworldbasic1.rls"
+#include <appinfo.rh>
+#include <Helloworldbasic1.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0xA000018A
+
+RESOURCE APP_REGISTRATION_INFO
+ {
+ app_file="HelloWorldBasic1";
+ localisable_resource_file = STRING_r_helloworldbasic_loc_resource_file_1;
+ localisable_resource_id = R_HELLOWORLDBASIC_LOCALISABLE_APP_INFO;
+
+ embeddability=KAppNotEmbeddable;
+ newfile=KAppDoesNotSupportNewFile;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/helloworldbasic1.rls Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+// LOCALISATION STRINGS
+
+#ifdef LANGUAGE_SC
+#include "helloworldbasic1_01.rls" // default U.K. English
+#elif defined LANGUAGE_01
+#include "helloworldbasic1_01.rls" // U.K. English
+#elif defined LANGUAGE_09
+#include "helloworldbasic1_09.rls" // Finnish
+#elif defined LANGUAGE_31
+#include "helloworldbasic1_31.rls" // PRC Chinese
+#elif defined LANGUAGE_32
+#include "helloworldbasic1_32.rls" // Japanese
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/helloworldbasic1.rss Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+// RESOURCE IDENTIFIER
+NAME HEWB // 4 letter ID
+
+
+// INCLUDES
+#include <eikon.rh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <appinfo.rh>
+#include "HelloWorldBasic.hrh"
+#include "HelloWorldBasic1.rls"
+
+// RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+// Define the resource file signature
+// This resource should be empty.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// Default Document Name
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_default_document_name
+ {
+ buf="HEWB";
+ }
+
+// -----------------------------------------------------------------------------
+//
+// Define default menu and CBA key.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE EIK_APP_INFO
+ {
+ menubar = r_helloworldbasic_menubar;
+ cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+ }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_helloworldbasic_menubar
+// Menubar for HelloWorldBasic example
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_helloworldbasic_menubar
+ {
+ titles =
+ {
+ MENU_TITLE { menu_pane = r_helloworldbasic_menu; }
+ };
+ }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_helloworldbasic_menu
+// Menu for "Options"
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_helloworldbasic_menu
+ {
+ items =
+ {
+ // added the new Options menu command here
+ MENU_ITEM
+ {
+ command = EHelloWorldBasicCommand1;
+ txt = STRING_r_hewb_command1;
+ },
+ MENU_ITEM
+ {
+ command = EHelloWorldBasicCommand2;
+ txt = STRING_r_hewb_command2;
+ },
+ MENU_ITEM
+ {
+ command = EHelloWorldBasicCommand3;
+ txt = STRING_r_hewb_command3;
+ },
+ MENU_ITEM
+ {
+ command = EAknSoftkeyExit;
+ txt = STRING_r_hewb_exit;
+ }
+ };
+ }
+
+// -----------------------------------------------------------------------------
+//
+// Resources for messages.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF32 r_hewb_command1_text { buf=STRING_r_hewb_command1_text; }
+RESOURCE TBUF32 r_hewb_file_text { buf=STRING_r_hewb_file_text; }
+RESOURCE TBUF32 r_hewb_caption_string { buf=STRING_r_hewb_caption_string; }
+
+// ----------------------------------------------------------------------------
+//
+// r_helloworldbasic_localisable_app_info
+//
+// ----------------------------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_helloworldbasic_localisable_app_info
+ {
+ short_caption = STRING_r_hewb_caption_string;
+ caption_and_icon =
+ CAPTION_AND_ICON_INFO
+ {
+ caption = STRING_r_hewb_caption_string;
+
+ number_of_icons = 1;
+ icon_file = "\\resource\\apps\\Helloworldbasic1_aif.mif";
+ };
+ }
+
+// ----------------------------------------------------------------------------
+//
+// r_dialog_text_edit_query
+//
+// ----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_dialog_text_edit_query
+ {
+ flags = EGeneralQueryFlags;
+ buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+ items =
+ {
+ DLG_LINE
+ {
+ type = EAknCtQuery;
+ id = EGeneralQuery;
+ control = AVKON_DATA_QUERY
+ {
+ layout = EDataLayout;
+ label = "";
+ control = EDWIN
+ {
+ width = 32;
+ maxlength = 32;
+ lines = 1;
+ };
+ };
+ }
+ };
+ }
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/helloworldbasic1_01.rls Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+// LOCALISATION STRINGS
+
+//d:Caption string for app.
+rls_string STRING_r_hewb_caption_string "HelloWorld1"
+
+//d:Short caption string for app.
+rls_string STRING_r_hewb_short_caption_string "HW"
+
+//d:First item in "Options" menu pane, "hello" event.
+rls_string STRING_r_hewb_command1 "Hello"
+
+//d:Second item in "Options" menu pane, "read from file" event.
+rls_string STRING_r_hewb_command2 "Hello from file"
+
+//d:Third item in "Options" menu pane, "hello from edit" event.
+rls_string STRING_r_hewb_command3 "Hello from edit"
+
+//d:Fourth item in "Options" menu pane, "exit" event.
+rls_string STRING_r_hewb_exit "Exit"
+
+//d:When user requests EHelloWorldBasicCommand1 event, text below is shown.
+rls_string STRING_r_hewb_command1_text "Hello!"
+
+//d:When user requests EHelloWorldBasicCommand2 event, text below is shown.
+rls_string STRING_r_hewb_file_text "Hello World!"
+
+rls_string STRING_r_helloworldbasic_loc_resource_file_1 "\\resource\\apps\\HelloWorldBasic1"
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/helloworldbasic1_09.rls Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+// LOCALISATION STRINGS
+
+//d:Caption string for app.
+rls_string STRING_r_hewb_caption_string "Terve Maailma"
+
+//d:Short caption string for app.
+rls_string STRING_r_hewb_short_caption_string "TM"
+
+//d:First item in "Options" menu pane, "hello" event.
+rls_string STRING_r_hewb_command1 "Tervehdys"
+
+//d:Second item in "Options" menu pane, "exit" event.
+rls_string STRING_r_hewb_command2 "Tervehdys tiedostosta"
+
+//d:Third item in "Options" menu pane, "hello from edit" event.
+rls_string STRING_r_hewb_command3 "Kirjoita tervehdys"
+
+//d:Fourth item in "Options" menu pane, "exit" event.
+rls_string STRING_r_hewb_exit "Sulje"
+
+//d:When user requests EHelloWorldBasicCommand1 event, text below is shown.
+rls_string STRING_r_hewb_command1_text "Terve!"
+
+//d:When user requests EHelloWorldBasicCommand2 event, text below is shown.
+rls_string STRING_r_hewb_file_text "Terve Maailma!"
+
+
+rls_string STRING_r_helloworldbasic_loc_resource_file_1 "\\resource\\apps\\HelloWorldBasic1"
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/helloworldbasic1_31.rls Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+CHARACTER_SET UTF8
+
+// LOCALISATION STRINGS
+
+//d:Caption string for app.
+rls_string STRING_r_hewb_caption_string "世界 ä½ å¥½"
+
+//d:Short caption string for app.
+rls_string STRING_r_hewb_short_caption_string "HW"
+
+//d:First item in "Options" menu pane, "hello" event.
+rls_string STRING_r_hewb_command1 "ä½ å¥½"
+
+//d:Second item in "Options" menu pane, "exit" event.
+rls_string STRING_r_hewb_command2 "文件输出"
+
+//d:Third item in "Options" menu pane, "hello from edit" event.
+rls_string STRING_r_hewb_command3 "输入文å—"
+
+//d:Fourth item in "Options" menu pane, "exit" event.
+rls_string STRING_r_hewb_exit "退出"
+
+//d:When user requests EHelloWorldBasicCommand1 event, text below is shown.
+rls_string STRING_r_hewb_command1_text "ä½ å¥½ !"
+
+//d:When user requests EHelloWorldBasicCommand2 event, text below is shown.
+rls_string STRING_r_hewb_file_text "世界 ä½ å¥½ !"
+
+rls_string STRING_r_helloworldbasic_loc_resource_file_1 "\\resource\\apps\\HelloWorldBasic1"
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/data/helloworldbasic1_32.rls Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+CHARACTER_SET UTF8
+
+// LOCALISATION STRINGS
+
+//d:Caption string for app.
+rls_string STRING_r_hewb_caption_string "ãƒãƒãƒ¼ãƒ¯ãƒ¼ãƒ«ãƒ‰"
+
+//d:Short caption string for app.
+rls_string STRING_r_hewb_short_caption_string "HW"
+
+//d:First item in "Options" menu pane, "hello" event.
+rls_string STRING_r_hewb_command1 "ãƒãƒãƒ¼"
+
+//d:Second item in "Options" menu pane, "hello from file" event.
+rls_string STRING_r_hewb_command2 "フィイルをèªã‚€"
+
+//d:Third item in "Options" menu pane, "hello from edit" event.
+rls_string STRING_r_hewb_command3 "編集ã™ã‚‹"
+
+//d:Fourth item in "Options" menu pane, "exit" event.
+rls_string STRING_r_hewb_exit "終了"
+
+//d:When user requests EHelloWorldBasicCommand1 event, text below is shown.
+rls_string STRING_r_hewb_command1_text "ãƒãƒãƒ¼ !"
+
+//d:When user requests EHelloWorldBasicCommand2 event, text below is shown.
+rls_string STRING_r_hewb_file_text "ãƒãƒãƒ¼ãƒ¯ãƒ¼ãƒ«ãƒ‰ !"
+
+rls_string STRING_r_helloworldbasic_loc_resource_file_1 "\\resource\\apps\\HelloWorldBasic1"
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/group/Icons_scalable_dc.mk Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2009 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:
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=$(EPOCROOT)epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\helloworldbasic1_aif.mif
+
+ICONDIR=..\..\common\gfx
+
+do_nothing :
+ @rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE :
+ mifconv $(ICONTARGETFILENAME) \
+ /c32 $(ICONDIR)\qgn_menu_helloworldbasic.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+ @echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/group/bld.inf Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+gnumakefile icons_scalable_dc.mk
+
+HelloWorldBasic.mmp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/group/helloworldbasic.mmp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+TARGET HelloWorldBasic1.exe
+TARGETTYPE exe
+UID 0x100039CE 0xA000018A
+
+
+EPOCSTACKSIZE 0x5000
+
+SOURCEPATH ../src
+SOURCE HelloWorldBasicApplication.cpp
+SOURCE HelloWorldBasicAppUi.cpp
+
+SOURCEPATH ../../common/src
+SOURCE HelloWorldBasic.cpp
+SOURCE HelloWorldBasicAppView.cpp
+SOURCE HelloWorldBasicDocument.cpp
+SOURCE HelloWorldBasicQueryDialog.cpp
+
+SOURCEPATH ../data
+
+START RESOURCE HelloWorldBasic1.rss
+HEADER
+TARGETPATH resource/apps
+END //RESOURCE
+
+START RESOURCE HelloWorldBasic1_reg.rss
+#ifdef WINSCW
+TARGETPATH /private/10003a3f/apps
+#else
+TARGETPATH /private/10003a3f/import/apps
+#endif
+END //RESOURCE
+
+
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common/inc
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include
+
+LIBRARY euser.lib
+LIBRARY apparc.lib
+LIBRARY cone.lib
+LIBRARY eikcore.lib
+LIBRARY avkon.lib
+LIBRARY commonengine.lib
+LIBRARY efsrv.lib
+LIBRARY estor.lib
+LIBRARY eikcoctl.lib
+LIBRARY eikdlg.lib
+
+
+LANG SC 01 09 31 32
+
+VENDORID 0
+CAPABILITY NONE
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/sis/helloworldbasic_armv5.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+; helloworldbasic_armv5.pkg
+;
+;Language - standard language definitions
+&EN,FI,ZH,JA
+
+; standard SIS file header
+#{"HelloWorldBasic", "HelloWorldBasic", "HelloWorldBasic", "HelloWorldBasic"},(0xA000018A),1,0,0
+
+;Localised Vendor name
+%{"Vendor-EN", "Vendor-FI", "Vendor-ZH", "Vendor-JA"}
+
+;Unique Vendor name
+:"Vendor"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID", "S60ProductID", "S60ProductID", "S60ProductID"}
+
+;Files
+"\epoc32\release\armv5\urel\HelloWorldBasic1.exe" -"!:\sys\bin\HelloWorldBasic1.exe"
+
+"\epoc32\data\z\resource\apps\HelloWorldBasic1.rsc" -"!:\resource\apps\HelloWorldBasic1.rsc"
+"\epoc32\data\z\resource\apps\HelloWorldBasic1.r09" -"!:\resource\apps\HelloWorldBasic1.r09"
+"\epoc32\data\z\resource\apps\HelloWorldBasic1.r31" -"!:\resource\apps\HelloWorldBasic1.r31"
+"\epoc32\data\z\resource\apps\HelloWorldBasic1.r32" -"!:\resource\apps\HelloWorldBasic1.r32"
+
+"\epoc32\data\z\private\10003a3f\import\apps\HelloWorldBasic1_reg.rsc" -"!:\private\10003a3f\import\apps\HelloWorldBasic1_reg.rsc"
+"\epoc32\data\z\private\10003a3f\import\apps\HelloWorldBasic1_reg.r09" -"!:\private\10003a3f\import\apps\HelloWorldBasic1_reg.r09"
+"\epoc32\data\z\private\10003a3f\import\apps\HelloWorldBasic1_reg.r31" -"!:\private\10003a3f\import\apps\HelloWorldBasic1_reg.r31"
+"\epoc32\data\z\private\10003a3f\import\apps\HelloWorldBasic1_reg.r32" -"!:\private\10003a3f\import\apps\HelloWorldBasic1_reg.r32"
+"\epoc32\data\z\resource\apps\helloworldbasic1_aif.mif" -"!:\resource\apps\helloworldbasic1_aif.mif"
+;end
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/src/helloworldbasicapplication.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2009 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 FILES
+#include "HelloWorldBasicDocument.h"
+#include "HelloWorldBasicApplication.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// UID for the application;
+// this should correspond to the uid defined in the mmp file
+const TUid KUidHelloWorldBasicApp = { 0xA000018A };
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicApplication::CreateDocumentL()
+// Creates CApaDocument object
+// -----------------------------------------------------------------------------
+//
+CApaDocument* CHelloWorldBasicApplication::CreateDocumentL()
+ {
+ // Create an HelloWorldBasic document, and return a pointer to it
+ return (static_cast<CApaDocument*>
+ ( CHelloWorldBasicDocument::NewL( *this ) ) );
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicApplication::AppDllUid()
+// Returns application UID
+// -----------------------------------------------------------------------------
+//
+TUid CHelloWorldBasicApplication::AppDllUid() const
+ {
+ // Return the UID for the HelloWorldBasic application
+ return KUidHelloWorldBasicApp;
+ }
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/generator/pattern/src/helloworldbasicappui.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2009 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 FILES
+#include <avkon.hrh>
+#include <aknnotewrappers.h>
+#include <stringloader.h>
+#include <HelloWorldBasic1.rsg>
+#include <f32file.h>
+#include <s32file.h>
+
+#include "HelloWorldBasic.pan"
+#include "HelloWorldBasicAppUi.h"
+#include "HelloWorldBasicAppView.h"
+#include "HelloWorldBasic.hrh"
+#include "HelloWorldBasicQueryDialog.h"
+
+_LIT( KHelloFileName, "Hello.txt" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppUi::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicAppUi::ConstructL()
+ {
+ // Initialise app UI with standard value.
+ BaseConstructL(CAknAppUi::EAknEnableSkin);
+
+ // Here the Hello.txt file is created. Because HelloWorld application is
+ // localized to various languages, the Hello.txt-file is created every time
+ // with current localization language
+ //
+ RFs fsSession;
+ User::LeaveIfError(fsSession.Connect());
+ CleanupClosePushL( fsSession );
+ TInt objectsInStack = 1;
+
+ #if defined(__WINS__) || defined(__WINSCW__)
+ // create private folder, when testing in emulator.
+ // ignore the return value; if this fails, then file.Replace() will fail
+ // and a warning note will be printed.
+ //
+ fsSession.CreatePrivatePath(EDriveC);
+ #endif
+
+ RFile file;
+
+ // Create a file to write the text to
+ TInt err = file.Replace(fsSession, KHelloFileName, EFileWrite );
+ if (KErrNone == err)
+ {
+ CleanupClosePushL( file );
+
+ RFileWriteStream outputFileStream( file );
+ CleanupClosePushL( outputFileStream );
+
+ // Load a string from the resource file and stream it to file
+ HBufC* textResource = StringLoader::LoadLC( R_HEWB_FILE_TEXT );
+ objectsInStack += 3; // file, outputFileStream, testResource
+
+ outputFileStream << *textResource;
+ }
+ else
+ {
+ _LIT(KFileWriteFailed,"Writing file %S failed: error %d");
+ CAknWarningNote* note = new ( ELeave ) CAknWarningNote(ETrue);
+
+ TBuf<64> text;
+ text.Format(KFileWriteFailed, &KHelloFileName, err);
+ note->ExecuteLD( text );
+ }
+
+ CleanupStack::PopAndDestroy(objectsInStack, &fsSession);
+
+ // Create view object
+ iAppView = CHelloWorldBasicAppView::NewL( ClientRect() );
+ RProcess::Rendezvous(KErrNone);
+
+ }
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppUi::CHelloWorldBasicAppUi()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicAppUi::CHelloWorldBasicAppUi()
+ {
+ // No implementation required
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi()
+ {
+ if ( iAppView )
+ {
+ delete iAppView;
+ iAppView = NULL;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CHelloWorldBasicAppUi::HandleCommandL()
+// Takes care of command handling.
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicAppUi::HandleCommandL( TInt aCommand )
+ {
+ // clear possible old user-given text
+ if (iAppView->GetText().Size() > 0)
+ {
+ iAppView->GetText().Zero();
+ iAppView->DrawNow();
+ }
+
+ switch( aCommand )
+ {
+ case EEikCmdExit:
+ case EAknSoftkeyExit:
+ Exit();
+ break;
+
+ case EHelloWorldBasicCommand1:
+ {
+ // Load a string from the resource file and display it
+ HBufC* textResource = StringLoader::LoadLC( R_HEWB_COMMAND1_TEXT );
+ CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
+
+ // Show the information Note with
+ // textResource loaded with StringLoader.
+ note->ExecuteLD( *textResource );
+
+ // Pop HBuf from CleanUpStack and Destroy it.
+ CleanupStack::PopAndDestroy( textResource );
+ }
+ break;
+
+ case EHelloWorldBasicCommand2:
+ {
+ RFs fsSession;
+ RFile rFile;
+
+ // Connects a client process to the fileserver
+ User::LeaveIfError(fsSession.Connect());
+ CleanupClosePushL(fsSession);
+
+ //Open file where the stream text is
+ User::LeaveIfError(rFile.Open(fsSession,KHelloFileName, EFileStreamText));
+ CleanupClosePushL(rFile);
+
+ // copy stream from file to RFileStream object
+ RFileReadStream inputFileStream(rFile);
+ CleanupClosePushL(inputFileStream);
+
+ // HBufC descriptor is created from the RFileStream object.
+ HBufC* fileData = HBufC::NewLC(inputFileStream, 32);
+
+ CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
+
+ // Show the information Note
+ note->ExecuteLD( *fileData );
+
+ // Pop loaded resources from the cleanup stack:
+ // filedata, inputFileStream, rFile, fsSession
+ CleanupStack::PopAndDestroy(4, &fsSession);
+ }
+ break;
+
+ case EHelloWorldBasicCommand3:
+ {
+ // Load a string from the resources and use it as a default value
+ HBufC* defaultText = StringLoader::LoadLC( R_HEWB_FILE_TEXT );
+
+ CHelloWorldQueryDialog *dlg = new (ELeave)
+ CHelloWorldQueryDialog( iAppView->GetText(), defaultText );
+
+ dlg->ExecuteLD( R_DIALOG_TEXT_EDIT_QUERY );
+ iAppView->DrawNow();
+
+ // Pop HBuf from CleanUpStack and Destroy it.
+ CleanupStack::PopAndDestroy( defaultText );
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+// -----------------------------------------------------------------------------
+// Called by framework when layout is changed.
+// Passes the new client rectangle to the AppView
+// -----------------------------------------------------------------------------
+//
+void CHelloWorldBasicAppUi::HandleResourceChangeL( TInt aType )
+{
+ // base-class call also
+ CAknAppUi::HandleResourceChangeL(aType);
+ if (aType == KEikDynamicLayoutVariantSwitch)
+ {
+ if (iAppView)
+ iAppView->SetRect( ClientRect() );
+ }
+}
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/hellostarter/hellostarter.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = hellostarter
+
+CONFIG += console
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+HEADERS += lunchwidget.h \
+
+LIBS += -lxqutils \
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/hellostarter/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <hbapplication>
+#include <QStringList>
+#include <HbComboBox>
+#include <HbIcon>
+#include <hbMainWindow>
+#include <hbinstance.h>
+#include "tstasksettings.h"
+#include <XQConversions>
+#include <e32base.h>
+#include <QFile>
+#include <QTextStream>
+#include <QTimer>
+#include <hblineedit.h>
+#include <HbValidator>
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent), mActionCounter(0)
+{
+ mFile = new QFile("c:\\data\\helloworldstarter.txt");
+ mFile->open(QIODevice::Append | QIODevice::Text);
+ mStream = new QTextStream(mFile);
+
+ mResultLabel = new HbLabel("idle");
+ mTenLabel= new HbLabel("10x");
+ mOneLabel= new HbLabel("1x");
+ mPlusLabel= new HbLabel("+");
+
+
+ mStartButton = new HbPushButton("Start");
+ mCloseButton = new HbPushButton("Close");
+ mAutoButton = new HbPushButton("Auto");
+
+
+ mTenCombo = new HbComboBox();
+ mOneCombo = new HbComboBox();
+ for (int i=0; i<10; i++) {
+ QString num;
+ num.setNum(i);
+ mTenCombo->addItem(num);
+ mOneCombo->addItem(num);
+ }
+
+ mTimesEdid = new HbLineEdit("300");
+ mTimesEdid->setObjectName("TimesEditLine");
+ mQTimesValidator = new QIntValidator(this);
+ mQTimesValidator->setRange(0, 1000000);
+ mTimesValidator = new HbValidator(this);
+ mTimesValidator->addField(mQTimesValidator, "300");
+ mTimesEdid->setValidator(mTimesValidator);
+
+ mTimesLabel = new HbLabel("Times:");
+ mCounterLabel = new HbLabel("Count:");
+ mCounterValueLabel = new HbLabel("");
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mResultLabel, 0, 0, 1, 6);
+ mGridLayout->addItem(mStartButton, 1, 0, 1, 2);
+ mGridLayout->addItem(mCloseButton, 1, 3, 1, 2);
+ mGridLayout->addItem(mAutoButton, 1, 5, 1, 2);
+ mGridLayout->addItem(mTenLabel, 2, 0, 1, 2);
+ mGridLayout->addItem(mPlusLabel, 2, 2, 1, 2);
+ mGridLayout->addItem(mOneLabel, 2, 4, 1, 2);
+ mGridLayout->addItem(mTenCombo, 3, 0, 1, 3);
+ mGridLayout->addItem(mOneCombo, 3, 4, 1, 3);
+ mGridLayout->addItem(mTimesLabel, 4, 0, 1, 2);
+ mGridLayout->addItem(mTimesEdid, 4, 3, 1, 4);
+ mGridLayout->addItem(mCounterLabel, 5, 0, 1, 3);
+ mGridLayout->addItem(mCounterValueLabel, 5, 4, 1, 3);
+
+ setLayout(mGridLayout);
+
+ connect( mStartButton, SIGNAL(released()), this, SLOT(start()) );
+ connect( mCloseButton, SIGNAL(released()), this, SLOT(stop()) );
+ connect( mAutoButton, SIGNAL(released()), this, SLOT(automat()) );
+
+ mTimer = new QTimer(this);
+ connect(mTimer, SIGNAL(timeout()), this, SLOT(timeout()));
+
+}
+
+lunchwidget::~lunchwidget()
+{
+ delete mFile;
+ delete mStream;
+ delete mQTimesValidator;
+ delete mTimesValidator;
+}
+
+void lunchwidget::start()
+{
+ int ten = mTenCombo->currentText().toInt();
+ int one = mOneCombo->currentText().toInt();
+ int num = ten*10+one;
+ for (int i=1; i<=num; i++) {
+ QString application;
+ application = tr("HelloWorldBasic%1").arg(i);
+ mResultLabel->setPlainText(application);
+ HBufC *appName = XQConversions::qStringToS60Desc(application);
+ CleanupStack::PushL(appName);
+
+ RProcess process;
+ CleanupClosePushL(process);
+
+ bool result = false;
+ if (process.Create(*appName, KNullDesC()) == KErrNone) {
+ // wait until process reports it's ready
+ TRequestStatus stat;
+ process.Rendezvous(stat);
+ process.Resume();
+ User::WaitForRequest(stat);
+
+ if (stat.Int() == KErrNone) {
+ result = true;
+ User::After(1000);
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&process);
+ CleanupStack::PopAndDestroy(appName);
+ }
+}
+
+void lunchwidget::stop()
+{
+ RProcess application;
+ TFindProcess finder(_L("*hello*"));
+ TFullName fullname;
+ while (finder.Next(fullname) == KErrNone) {
+ TInt err = application.Open(fullname);
+ if (err==KErrNone && (application.FileName().Find(_L("HelloWorldBasic"))>=0 || application.FileName().Find(_L("helloworldbasic"))>=0)) {
+ application.Terminate(KErrCancel);
+ User::After(1000);
+ }
+ application.Close();
+ }
+}
+
+void lunchwidget::timeout()
+{
+ if(mActionCounter == mTimes) {
+ stop();
+ mTimer->stop();
+ *mStream<<"end\n";
+ mStream->flush();
+ enableControls(true);
+ }
+ if(!mOpened) {
+ start();
+ mOpened = true;
+ }
+ else {
+ stop();
+ mOpened = false;
+ mActionCounter++;
+ *mStream<<mActionCounter<<"\n";
+ mStream->flush();
+ setCounterLabel(mActionCounter);
+ }
+
+
+}
+
+void lunchwidget::automat()
+{
+ mTimes = times();
+ mActionCounter = 0;
+ *mStream<<"auto open\n";
+ mStream->flush();
+ mOpened = false;
+ enableControls(false);
+ mTimer->start(2000);
+}
+
+void lunchwidget::enableControls(bool enable)
+{
+ mStartButton->setEnabled(enable);
+ mCloseButton->setEnabled(enable);
+ mAutoButton->setEnabled(enable);
+ mTenCombo->setEnabled(enable);
+ mOneCombo->setEnabled(enable);
+ mTimesEdid->setEnabled(enable);
+}
+
+void lunchwidget::setCounterLabel(int count)
+{
+ QString num;
+ num.setNum(count);
+ mCounterValueLabel->setPlainText(num);
+}
+
+int lunchwidget::times()
+{
+ QString ttext = mTimesEdid->text();
+ bool ok;
+ int times = ttext.toInt(&ok);
+ if(!ok) {
+ times = 0;
+ }
+ return times;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/hellostarter/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCHWIDGET_H_
+#define LUNCHWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class HbComboBox;
+class QFile;
+class QTextStream;
+class QTimer;
+class HbValidator;
+class HbLineEdit;
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mStartButton;
+ HbPushButton *mCloseButton;
+ HbPushButton *mAutoButton;
+ HbComboBox *mTenCombo;
+ HbComboBox *mOneCombo;
+ HbLineEdit* mTimesEdid;
+ HbLabel* mResultLabel;
+ HbLabel* mTenLabel;
+ HbLabel* mPlusLabel;
+ HbLabel* mOneLabel;
+ HbLabel* mTimesLabel;
+ HbLabel* mCounterLabel;
+ HbLabel* mCounterValueLabel;
+
+ QFile* mFile;
+ QTextStream* mStream;
+
+ QTimer* mTimer;
+ int mActionCounter;
+ int mTimes;
+ bool mOpened;
+
+ QIntValidator* mQTimesValidator;
+ HbValidator* mTimesValidator;
+
+
+private:
+
+
+private slots:
+ void start();
+ void stop();
+ void automat();
+ void timeout();
+
+private:
+ void enableControls(bool enable);
+ void setCounterLabel(int count);
+ int times();
+
+};
+
+#endif /* LUNCHWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/hellostarter/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "lunchwidget.h"
+
+
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/generator/hellostarter/sis/hellostarter_template.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,34 @@
+; hellostarter_template.pkg generated by qmake at 2010-06-22T12:32:21
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+
+; SIS header: name, uid, version
+#{"hellostarter"},(0xEfef8279),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+
+; Manual PKG pre-rules from PRO files
+; Default dependency to Qt libraries
+
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/hellostarter.exe" - "!:\sys\bin\hellostarter.exe"
+"/epoc32/data/z/resource/apps/hellostarter.rsc" - "!:\resource\apps\hellostarter.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/hellostarter_reg.rsc" - "!:\private\10003a3f\import\apps\hellostarter_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/embedded.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+# Copyright (c) 2009 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:
+
+TEMPLATE = app
+TARGET = embededservices
+load(hb.prf)
+CONFIG -= symbian_i18n
+CONFIG += service
+
+
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+
+MOC_DIR = moc
+
+# Input
+HEADERS += testservicemainwindow.h \
+ testservicehandler.h
+
+
+SOURCES += main.cpp \
+ testservicemainwindow.cpp \
+ testservicehandler.cpp
+
+
+# capability
+TARGET.CAPABILITY = CAP_APPLICATION
+
+
+
+TARGET.UID3 = 0xE9f8e3f9
+
+LIBS += -lxqservice \
+ -lxqserviceutil \
+ -lhbcore
+
+SERVICE.FILE = service_conf.xml
+SERVICE.OPTIONS = embeddable
+#SERVICE.OPTIONS += hidden
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include "testservicemainwindow.h"
+#include "testservicehandler.h"
+
+int main(int argc, char **argv)
+{
+ HbApplication a( argc, argv );
+
+ TestServiceHandler *handler = new TestServiceHandler();
+ TestServiceMainWindow mainWindow(handler);
+
+ mainWindow.show();
+
+ return a.exec();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/service_conf.xml Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<service name="com.nokia.services.embeddedservices" filepath="must-not-be-empty" >
+ <description>Embedded service</description>
+ <interface name="requestSetTitle" version="1.0" capabilities="">
+ <description>requestSetTitle interface</description>
+ </interface>
+</service>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/testservicehandler.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009 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 "testservicehandler.h"
+
+
+
+TestServiceHandler::TestServiceHandler(QObject *parent):
+ XQServiceProvider(QLatin1String("com.nokia.services.embeddedservices.requestSetTitle"), parent),
+ mCurrentRequestIndex(0), mTitle("Embedded")
+{
+ publishAll();
+}
+
+TestServiceHandler::~TestServiceHandler()
+{
+}
+
+void TestServiceHandler::completeRequestSetTitle(const QString& title)
+{
+ QVariant retValue;
+ retValue.setValue(title);
+ bool ok = completeRequest(mCurrentRequestIndex, retValue);
+ mCurrentRequestIndex = 0;
+}
+
+
+void TestServiceHandler::requestSetTitle(const QString &title)
+{
+ mTitle = title;
+ mCurrentRequestIndex = setCurrentRequestAsync();
+ emit launchSetTitle(title);
+}
+
+QString TestServiceHandler::title()
+{
+ return mTitle;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/testservicehandler.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 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:
+ *
+ */
+
+#ifndef TESTSERVICEHANDLER_H
+#define TESTSERVICEHANDLER_H
+
+#include <xqserviceprovider.h>
+#include <xqservicemanager.h>
+#include <qservicemanager.h>
+
+QTM_USE_NAMESPACE
+
+class TestServiceHandler : public XQServiceProvider
+{
+ Q_OBJECT
+public:
+ TestServiceHandler(QObject *parent = 0);
+ ~TestServiceHandler();
+
+public:
+ void completeRequestSetTitle(const QString& title);
+ QString title();
+
+public slots:
+ // Services offered to clients
+ void requestSetTitle(const QString &title);
+
+signals:
+ void launchSetTitle(const QString &title);
+
+
+private:
+ int mCurrentRequestIndex;
+ QString mTitle;
+};
+
+#endif /* TESTSERVICEHANDLER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/testservicemainwindow.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 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 "testservicemainwindow.h"
+#include "testservicehandler.h"
+#include <hbview.h>
+
+TestServiceMainWindow::TestServiceMainWindow(TestServiceHandler *handler, QWidget *parent):
+ HbMainWindow(parent),
+ mServiceHandler(handler)
+{
+ mView = new HbView;
+ addView( mView );
+ currentView()->setTitle(mServiceHandler->title());
+ connect(mServiceHandler, SIGNAL(launchSetTitle(QString)), this, SLOT(requestSetTitle(QString)));
+}
+
+TestServiceMainWindow::~TestServiceMainWindow()
+{
+ delete mServiceHandler;
+ mServiceHandler = 0;
+}
+
+void TestServiceMainWindow::requestSetTitle(const QString& title)
+{
+ QString newTitle = tr("Embedded ") + title;
+ currentView()->setTitle(newTitle);
+ mServiceHandler->completeRequestSetTitle(currentView()->title());
+}
+// end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/embedded/testservicemainwindow.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef TESTSERVICEMAINWINDOW_H
+#define TESTSERVICEMAINWINDOW_H
+
+#include <QObject>
+#include <hbmainwindow.h>
+
+class HbView;
+class TestServiceHandler;
+
+class TestServiceMainWindow : public HbMainWindow
+{
+ Q_OBJECT
+
+public:
+ TestServiceMainWindow(TestServiceHandler *handler, QWidget *parent=0);
+ ~TestServiceMainWindow();
+
+public slots:
+ void requestSetTitle(const QString& title);
+
+private:
+ HbView* mView;
+ TestServiceHandler* mServiceHandler;
+};
+
+#endif // TESTSERVICEMAINWINDOW_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/parent/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QUrl>
+#include <qservicemanager.h>
+#include <xqaiwrequest.h>
+#include <xqappmgr.h>
+#include <xqconversions.h>
+#include <hbapplication>
+QTM_USE_NAMESPACE
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+
+ mTitle = "trompka";
+ mLunchButton = new HbPushButton("Lunch embedded app");
+ mResultLabel = new HbLabel;
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mResultLabel, 0, 0, 1, 1);
+ mGridLayout->addItem(mLunchButton, 1, 0, 1, 1);
+ setLayout(mGridLayout);
+
+
+ connect(mLunchButton, SIGNAL(released()), this, SLOT(lunchApp()));
+
+ QStringList list = hbApp->arguments();
+ int count = list.count();
+
+ mTimer = new QTimer;
+ if( count >= 2 ) {
+ mTitle = list.at(1);
+ connect( mTimer, SIGNAL(timeout()), this, SLOT(timeout()) );
+ mTimer->start(1);
+ }
+}
+
+lunchwidget::~lunchwidget()
+{
+ delete mTimer;
+}
+
+void lunchwidget::lunchApp()
+{
+ QList<QVariant> args;
+ QString serviceName("com.nokia.services.embeddedservices");
+ QString operation("requestSetTitle(QString)");
+ XQAiwRequest* request;
+ XQApplicationManager appManager;
+ request = appManager.create(serviceName, "requestSetTitle", operation, true); //embedded
+ if ( request == NULL )
+ {
+ mResultLabel->setPlainText( "request failed" );
+ return;
+ }
+
+ // Result handlers
+ connect (request, SIGNAL(requestOk(const QVariant&)),
+ this, SLOT(setTitleCompleted(const QVariant&)));
+ connect (request, SIGNAL(requestError(int,const QString&)),
+ this, SLOT(serviceRequestError(int,const QString&)));
+
+ args << mTitle;
+
+
+ request->setArguments(args);
+ if(!request->send()) {
+ mResultLabel->setPlainText( "sending request failed" );
+ }
+ delete request;
+}
+
+void lunchwidget::setTitleCompleted(const QVariant& data)
+{
+ QString title = data.toString();
+ mResultLabel->setPlainText( title );
+}
+
+void lunchwidget::serviceRequestError(int err,const QString& msg)
+{
+ QString errmsg = tr("Error: %1, ").arg(err);
+ errmsg += msg;
+ mResultLabel->setPlainText( errmsg );
+}
+
+void lunchwidget::timeout()
+ {
+ mTimer->stop();
+ lunchApp();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/parent/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCWIDGET_H_
+#define LUNCWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mLunchButton;
+ HbLabel* mResultLabel;
+ QObject *mActivityManager;
+
+private slots:
+ void lunchApp();
+
+ void setTitleCompleted(const QVariant& data);
+ void serviceRequestError(int err,const QString& msg);
+ void timeout();
+
+private:
+ QTimer* mTimer;
+ QString mTitle;
+};
+
+#endif /* LUNCWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/parent/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include "lunchwidget.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.currentView()->setTitle("Parent");
+ mainWindow.show();
+ RProcess::Rendezvous(KErrNone);
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/parent/parent.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = parent
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+
+HEADERS += lunchwidget.h
+
+LIBS += -lxqutils \
+ -lxqservice \
+ -lxqserviceutil
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0xEf628f4b
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/parentembedded/parentembedded.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += parent
+SUBDIRS += embedded
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/sis/testscreenapp.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+; tstestcatapp_template.pkg generated by qmake at 2010-05-07T15:46:05
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"testscreenapp"},(0xE8d0bcd4),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Default dependency to Qt libraries
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/tstestcatapp.exe" - "!:\sys\bin\tstestcatapp.exe"
+"/epoc32/data/z/resource/apps/tstestcatapp.rsc" - "!:\resource\apps\tstestcatapp.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tstestcatapp_reg.rsc" - "!:\private\10003a3f\import\apps\tstestcatapp_reg.rsc"
+
+"/epoc32/release/armv5/urel/tstestdogapp.exe" - "!:\sys\bin\tstestdogapp.exe"
+"/epoc32/data/z/resource/apps/tstestdogapp.rsc" - "!:\resource\apps\tstestdogapp.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tstestdogapp_reg.rsc" - "!:\private\10003a3f\import\apps\tstestdogapp_reg.rsc"
+
+"/epoc32/release/armv5/urel/parent.exe" - "!:\sys\bin\parent.exe"
+"/epoc32/data/z/resource/apps/parent.rsc" - "!:\resource\apps\parent.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/parent_reg.rsc" - "!:\private\10003a3f\import\apps\parent_reg.rsc"
+
+"/epoc32/release/armv5/urel/embededservices.exe" - "!:\sys\bin\embededservices.exe"
+"/epoc32/data/z/resource/apps/embededservices.rsc" - "!:\resource\apps\embededservices.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/embededservices_reg.rsc" - "!:\private\10003a3f\import\apps\embededservices_reg.rsc"
+
+"/epoc32/release/armv5/urel/tssystemapp.exe" - "!:\sys\bin\tssystemapp.exe"
+"/epoc32/data/z/resource/apps/tssystemapp.rsc" - "!:\resource\apps\tssystemapp.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tssystemapp_reg.rsc" - "!:\private\10003a3f\import\apps\tssystemapp_reg.rsc"
+
+"/epoc32/release/armv5/urel/appiconstarter.exe" - "!:\sys\bin\appiconstarter.exe"
+"/epoc32/data/z/resource/apps/appiconstarter.rsc" - "!:\resource\apps\appiconstarter.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/appiconstarter_reg.rsc" - "!:\private\10003a3f\import\apps\appiconstarter_reg.rsc"
+
+"/epoc32/release/armv5/urel/tsserviceloader.exe" - "!:\sys\bin\tsserviceloader.exe"
+"/epoc32/data/z/resource/apps/tsserviceloader.rsc" - "!:\resource\apps\tsserviceloader.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tsserviceloader_reg.rsc" - "!:\private\10003a3f\import\apps\tsserviceloader_reg.rsc"
+
+"/epoc32/release/armv5/urel/tspluginmanager.exe" - "!:\sys\bin\tspluginmanager.exe"
+"/epoc32/data/z/resource/apps/tspluginmanager.rsc" - "!:\resource\apps\tspluginmanager.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tspluginmanager_reg.rsc" - "!:\private\10003a3f\import\apps\tspluginmanager_reg.rsc"
+; DEPLOYMENT
+"/epoc32/data/z/resource/qt/crml/tspluginmanager.qcrml" - "!:\resource\qt\crml\tspluginmanager.qcrml"
+
+"/epoc32/release/armv5/urel/fakeplugin.dll" - "!:\sys\bin\fakeplugin.dll"
+"/epoc32/data/z/resource/qt/plugins/fakeplugin.qtplugin" - "!:\resource\qt\plugins\fakeplugin.qtplugin"
+"/epoc32/data/z/resource/taskswitcher/tsfakelplugin.xml" - "!:\resource\taskswitcher\tsfakelplugin.xml"
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/testapplications.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += tstestdogapp
+SUBDIRS += tstestcatapp
+SUBDIRS += parentembedded
+SUBDIRS += appiconstarter
+SUBDIRS += tsserviceloader
+SUBDIRS += tstestpluginmanager
+SUBDIRS += tssystemapp
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tsserviceloader/data/tstestmodelplugin.xml Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<service>
+ <name>TsTestModelPlugin</name>
+ <filepath>tstestmodelplugin</filepath>
+ <description>Sample model plugin for Task Switcher</description>
+ <interface>
+ <name>com.nokia.qt.taskswitcher.dataprovider</name>
+ <version>1.0</version>
+ <description>test</description>
+ </interface>
+</service>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tsserviceloader/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QUrl>
+#include <hbapplication>
+
+
+
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ mManager = new QServiceManager;
+ mActivationButton = new HbPushButton("Activity");
+ mProviderButton = new HbPushButton("Provider");
+ mResultLabel = new HbLabel;
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mResultLabel, 0, 0, 1, 1);
+ mGridLayout->addItem(mActivationButton, 1, 0, 1, 1);
+ mGridLayout->addItem(mProviderButton, 2, 0, 1, 1);
+ setLayout(mGridLayout);
+
+
+ connect(mActivationButton, SIGNAL(released()), this, SLOT(lunchActivation()));
+ connect(mProviderButton, SIGNAL(released()), this, SLOT(lunchProvider()));
+
+}
+
+lunchwidget::~lunchwidget()
+{
+
+}
+
+void lunchwidget::lunchActivation()
+{
+ bool ok = mManager->addService(":/activityserviceplugin.xml");
+ setError(ok, mManager->error());
+}
+
+void lunchwidget::lunchProvider()
+{
+ bool ok = mManager->addService(":/tstestmodelplugin.xml");
+ setError(ok, mManager->error());
+}
+
+
+void lunchwidget::setError(bool ok, int err)
+{
+ if (!ok) {
+ QString num;
+ num.setNum(err);
+ mResultLabel->setPlainText(num);
+ }
+ else {
+ mResultLabel->setPlainText("Ok");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tsserviceloader/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCWIDGET_H_
+#define LUNCWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <qservicemanager.h>
+
+
+QTM_USE_NAMESPACE
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mActivationButton;
+ HbPushButton *mProviderButton;
+ HbLabel* mResultLabel;
+ QServiceManager* mManager;
+
+private slots:
+ void lunchActivation();
+ void lunchProvider();
+
+ void setError(bool ok, int err);
+};
+
+#endif /* LUNCWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tsserviceloader/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include "lunchwidget.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.currentView()->setTitle("Parent");
+ mainWindow.show();
+ RProcess::Rendezvous(KErrNone);
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tsserviceloader/tsserviceloader.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = tsserviceloader
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+
+HEADERS += lunchwidget.h
+
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+}
+
+
+RESOURCES += tsserviceloader.qrc
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tsserviceloader/tsserviceloader.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file alias="activityserviceplugin.xml">../../../activityfw/activityserviceplugin/data/afservice.xml</file>
+ <file alias="tstestmodelplugin.xml">./data/tstestmodelplugin.xml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tssystemapp/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <hbapplication>
+#include <QStringList>
+#include <HbComboBox>
+#include <HbIcon>
+#include <hbMainWindow>
+#include <hbinstance.h>
+#include "tstasksettings.h"
+#include <EIKENV.H>
+#include <APGWGNAM.H>
+#include <XQConversions>
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+
+ mSystemtLabel = new HbLabel;
+ //mNameLabel = new HbLabel;
+
+ mSystemToogleButton = new HbPushButton("Toogle system");
+ //mNameToogleButton = new HbPushButton("Toogle name");
+
+
+
+ mGridLayout = new QGraphicsGridLayout();
+
+ mGridLayout->addItem(mSystemtLabel, 0, 0, 1, 1);
+ mGridLayout->addItem(mSystemToogleButton, 1, 0, 1, 1);
+ //mGridLayout->addItem(mNameLabel, 2, 0, 1, 1);
+ //mGridLayout->addItem(mNameToogleButton, 3, 0, 1, 1);
+
+ setLayout(mGridLayout);
+
+ connect( mSystemToogleButton, SIGNAL(released()), this, SLOT(toogleSystem()) );
+ //connect( mNameToogleButton, SIGNAL(released()), this, SLOT(toogleName()) );
+
+ mSystemtLabel->setPlainText("system");
+ //toogleSystem();
+ //mNameLabel->setPlainText("name1");
+ //toogleName();
+}
+
+lunchwidget::~lunchwidget()
+{
+}
+
+void lunchwidget::toogleSystem()
+{
+ bool system;
+ if( mSystemtLabel->plainText() == "system" ) {
+ system = false;
+ mSystemtLabel->setPlainText("not system");
+ }
+ else {
+ system = true;
+ mSystemtLabel->setPlainText("system");
+ }
+
+ TRAPD(err, toogleSystemL(system));
+ if (err!=KErrNone) {
+ QString errstr;
+ errstr.setNum(err);
+ mSystemtLabel->setPlainText(errstr);
+ }
+
+}
+
+void lunchwidget::toogleSystemL(bool system)
+{
+ CEikonEnv * env = CEikonEnv::Static();
+ env->SetSystem(system);
+ /*CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
+ wgName->SetSystem(system);
+ wgName->SetAppUid(TUid::Uid(0xE9340220));
+ wgName->SetWindowGroupName(env->RootWin());
+ CleanupStack::PopAndDestroy(wgName);*/
+}
+
+void lunchwidget::toogleName()
+{
+ QString name;
+ if( mNameLabel->plainText() == "name1" ) {
+ name = "NAME2";
+ mNameLabel->setPlainText("NAME2");
+ }
+ else {
+ name = "name1";
+ mNameLabel->setPlainText("name1");
+ }
+
+ TRAPD(err, toogleNameL(name));
+ if (err!=KErrNone) {
+ QString errstr;
+ errstr.setNum(err);
+ mNameLabel->setPlainText(errstr);
+ }
+}
+
+void lunchwidget::toogleNameL(QString name)
+{
+ CEikonEnv * env = CEikonEnv::Static();
+ CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
+ HBufC *nameS60 = XQConversions::qStringToS60Desc(name);
+ CleanupStack::PushL(nameS60);
+ wgName->SetCaptionL(*nameS60);
+ CleanupStack::PopAndDestroy(nameS60);
+ env->UpdateTaskNameL();
+ CleanupStack::PopAndDestroy(wgName);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tssystemapp/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCHWIDGET_H_
+#define LUNCHWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class HbComboBox;
+class TsTaskSettings;
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mSystemToogleButton;
+ HbPushButton *mNameToogleButton;
+ HbLabel* mSystemtLabel;
+ HbLabel* mNameLabel;
+
+private:
+ void toogleSystemL(bool system);
+ void toogleNameL(QString name);
+
+
+private slots:
+ void toogleSystem();
+ void toogleName();
+
+
+private:
+};
+
+#endif /* LUNCHWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tssystemapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "lunchwidget.h"
+
+#include <EIKENV.H>
+#include <APGWGNAM.H>
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.show();
+
+ CEikonEnv * env = CEikonEnv::Static();
+ CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
+ env->SetSystem(true);
+ //wgName->SetCaptionL(_L("trompka"));
+ wgName->SetAppUid(TUid::Uid(0xE9340220));
+ wgName->SetSystem(true);
+ wgName->SetWindowGroupName(env->RootWin());
+
+ CleanupStack::PopAndDestroy(wgName);
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tssystemapp/tssystemapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = tssystemapp
+
+CONFIG += console
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+HEADERS += lunchwidget.h \
+
+
+ LIBS += -lxqutils
+ LIBS += -lapgrfx
+ LIBS += -leikcore
+ LIBS += -lcone
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0xE9340220
+}
\ No newline at end of file
Binary file taskswitcher/testapplications/tstestcatapp/images/lion.jpg has changed
Binary file taskswitcher/testapplications/tstestcatapp/images/puma.jpg has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestcatapp/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <hbapplication>
+#include <QStringList>
+#include <HbComboBox>
+#include <HbIcon>
+#include <hbMainWindow>
+#include <hbinstance.h>
+#include "tstasksettings.h"
+
+
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ mClient = new TsTaskSettings;
+
+ mAnimal1 = new QPixmap(":/images/lion.jpg");
+ mAnimal2 = new QPixmap(":/images/puma.jpg");
+
+ mResultLabel = new HbLabel;
+ mPhotoLabel= new HbLabel;
+ // mPriorityLabel = new HbLabel("Priority");
+
+ mRegisterButton = new HbPushButton("Register");
+ mUnregisterButton = new HbPushButton("Unregister");
+ mHideButton = new HbPushButton("Hide me");
+ mShowButton = new HbPushButton("Show me");
+ mAnimal1Button = new HbPushButton("Lion");
+ mAnimal2Button = new HbPushButton("Puma");
+ mClearButton = new HbPushButton("Clear");
+
+ /*mPriorityCombo = new HbComboBox();
+ mPriorityCombo->addItem("default");
+ mPriorityCombo->addItem("low");
+ mPriorityCombo->addItem("medium");
+ mPriorityCombo->addItem("high");*/
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mPhotoLabel, 0, 0, 6, 6);
+ mGridLayout->addItem(mResultLabel, 6, 0, 1, 3);
+ mGridLayout->addItem(mClearButton, 6, 4, 1, 3);
+ //mGridLayout->addItem(mPriorityLabel, 7, 0, 1, 3);
+ //mGridLayout->addItem(mPriorityCombo, 7, 4, 1, 3);
+ mGridLayout->addItem(mRegisterButton, 7, 0, 1, 3);
+ mGridLayout->addItem(mUnregisterButton, 7, 4, 1, 3);
+ mGridLayout->addItem(mAnimal1Button, 8, 0, 1, 3);
+ mGridLayout->addItem(mAnimal2Button, 8, 4, 1, 3);
+ mGridLayout->addItem(mHideButton, 9, 0, 1, 3);
+ mGridLayout->addItem(mShowButton, 9, 4, 1, 3);
+ mGridLayout->setRowFixedHeight(0, 300);
+ setLayout(mGridLayout);
+
+ connect( mRegisterButton, SIGNAL(released()), this, SLOT(regScr()) );
+ connect( mUnregisterButton, SIGNAL(released()), this, SLOT(unregScr()) );
+ connect( mHideButton, SIGNAL(released()), this, SLOT(hideMe()) );
+ connect( mShowButton, SIGNAL(released()), this, SLOT(showMe()) );
+ connect( mAnimal1Button, SIGNAL(released()), this, SLOT(animal1()) );
+ connect( mAnimal2Button, SIGNAL(released()), this, SLOT(animal2()) );
+ connect( mClearButton, SIGNAL(released()), this, SLOT(clear()) );
+}
+
+lunchwidget::~lunchwidget()
+{
+ delete mClient;
+ delete mAnimal1;
+ delete mAnimal2;
+}
+
+void lunchwidget::regScr()
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+
+ Before();
+ bool ok = mClient->registerScreenshot(screenshot);
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::unregScr()
+{
+ Before();
+ bool ok = mClient->unregisterScreenshot();
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::hideMe()
+{
+ Before();
+ bool ok = mClient->setVisibility(false);
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::showMe()
+{
+ Before();
+ bool ok = mClient->setVisibility(true);
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void lunchwidget::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void lunchwidget::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+void lunchwidget::animal1()
+{
+ mPhotoLabel->setIcon(QIcon(*mAnimal1));
+}
+
+void lunchwidget::animal2()
+{
+ mPhotoLabel->setIcon(QIcon(*mAnimal2));
+}
+
+void lunchwidget::clear()
+{
+ mPhotoLabel->setIcon(QIcon());
+ mResultLabel->setPlainText("");
+}
+
+void lunchwidget::setResult(bool ok)
+{
+ if ( ok ) {
+ QString msg;
+ msg = tr("%1 ms").arg(iResult);
+ mResultLabel->setPlainText(msg);
+ }
+ else {
+ mResultLabel->setPlainText("Fail");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestcatapp/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCHWIDGET_H_
+#define LUNCHWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class HbComboBox;
+class TsTaskSettings;
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mRegisterButton;
+ HbPushButton *mUnregisterButton;
+ HbPushButton *mHideButton;
+ HbPushButton *mShowButton;
+ HbPushButton *mAnimal1Button;
+ HbPushButton *mAnimal2Button;
+ HbPushButton *mClearButton;
+ HbLabel* mPhotoLabel;
+ HbLabel* mResultLabel;
+ //HbLabel* mPriorityLabel;
+ //HbComboBox *mPriorityCombo;
+
+ QPixmap* mAnimal1;
+ QPixmap* mAnimal2;
+
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+private:
+ void Before();
+ void After();
+ void Result();
+ void setResult(bool ok);
+
+private slots:
+ void regScr();
+ void unregScr();
+ void hideMe();
+ void showMe();
+ void animal1();
+ void animal2();
+ void clear();
+
+private:
+ TsTaskSettings* mClient;
+};
+
+#endif /* LUNCHWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestcatapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "lunchwidget.h"
+
+
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestcatapp/tstestcatapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = tstestcatapp
+
+CONFIG += console
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+HEADERS += lunchwidget.h \
+
+RESOURCES += tstestcatapp.qrc
+
+LIBS += -ltstaskmonitorclient.dll
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestcatapp/tstestcatapp.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/puma.jpg</file>
+ <file>images/lion.jpg</file>
+ </qresource>
+</RCC>
Binary file taskswitcher/testapplications/tstestdogapp/images/bernardyn.jpg has changed
Binary file taskswitcher/testapplications/tstestdogapp/images/newfunland.jpg has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestdogapp/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <hbapplication>
+#include <QStringList>
+#include <HbComboBox>
+#include <HbIcon>
+#include <hbMainWindow>
+#include <hbinstance.h>
+#include "tstasksettings.h"
+
+
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent)
+{
+ mClient = new TsTaskSettings;
+
+ mAnimal1 = new QPixmap(":/images/bernardyn.jpg");
+ mAnimal2 = new QPixmap(":/images/newfunland.jpg");
+
+ mResultLabel = new HbLabel;
+ mPhotoLabel= new HbLabel;
+ // mPriorityLabel = new HbLabel("Priority");
+
+ mRegisterButton = new HbPushButton("Register");
+ mUnregisterButton = new HbPushButton("Unregister");
+ mHideButton = new HbPushButton("Hide me");
+ mShowButton = new HbPushButton("Show me");
+ mAnimal1Button = new HbPushButton("Bernardyn");
+ mAnimal2Button = new HbPushButton("Newfunland");
+ mClearButton = new HbPushButton("Clear");
+
+ /*mPriorityCombo = new HbComboBox();
+ mPriorityCombo->addItem("default");
+ mPriorityCombo->addItem("low");
+ mPriorityCombo->addItem("medium");
+ mPriorityCombo->addItem("high");*/
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mPhotoLabel, 0, 0, 6, 6);
+ mGridLayout->addItem(mResultLabel, 6, 0, 1, 3);
+ mGridLayout->addItem(mClearButton, 6, 4, 1, 3);
+ //mGridLayout->addItem(mPriorityLabel, 7, 0, 1, 3);
+ //mGridLayout->addItem(mPriorityCombo, 7, 4, 1, 3);
+ mGridLayout->addItem(mRegisterButton, 7, 0, 1, 3);
+ mGridLayout->addItem(mUnregisterButton, 7, 4, 1, 3);
+ mGridLayout->addItem(mAnimal1Button, 8, 0, 1, 3);
+ mGridLayout->addItem(mAnimal2Button, 8, 4, 1, 3);
+ mGridLayout->addItem(mHideButton, 9, 0, 1, 3);
+ mGridLayout->addItem(mShowButton, 9, 4, 1, 3);
+ mGridLayout->setRowFixedHeight(0, 300);
+ setLayout(mGridLayout);
+
+ connect( mRegisterButton, SIGNAL(released()), this, SLOT(regScr()) );
+ connect( mUnregisterButton, SIGNAL(released()), this, SLOT(unregScr()) );
+ connect( mHideButton, SIGNAL(released()), this, SLOT(hideMe()) );
+ connect( mShowButton, SIGNAL(released()), this, SLOT(showMe()) );
+ connect( mAnimal1Button, SIGNAL(released()), this, SLOT(animal1()) );
+ connect( mAnimal2Button, SIGNAL(released()), this, SLOT(animal2()) );
+ connect( mClearButton, SIGNAL(released()), this, SLOT(clear()) );
+}
+
+lunchwidget::~lunchwidget()
+{
+ delete mClient;
+ delete mAnimal1;
+ delete mAnimal2;
+}
+
+void lunchwidget::regScr()
+{
+ HbMainWindow *mainWindow = hbInstance->allMainWindows().first();
+ QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect());
+
+ Before();
+ bool ok = mClient->registerScreenshot(screenshot);
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::unregScr()
+{
+ Before();
+ bool ok = mClient->unregisterScreenshot();
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::hideMe()
+{
+ Before();
+ bool ok = mClient->setVisibility(false);
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::showMe()
+{
+ Before();
+ bool ok = mClient->setVisibility(true);
+ After();
+ Result();
+ setResult(ok);
+}
+
+void lunchwidget::Before()
+{
+ TTime time;
+ time.HomeTime();
+ iBefore = time.Int64();
+}
+
+void lunchwidget::After()
+{
+ TTime time;
+ time.HomeTime();
+ iAfter = time.Int64();
+}
+
+void lunchwidget::Result()
+{
+ TInt64 res(0);
+ res = iAfter-iBefore;
+ res = res/1000;
+ iResult = res;
+}
+
+void lunchwidget::animal1()
+{
+ mPhotoLabel->setIcon(QIcon(*mAnimal1));
+}
+
+void lunchwidget::animal2()
+{
+ mPhotoLabel->setIcon(QIcon(*mAnimal2));
+}
+
+void lunchwidget::clear()
+{
+ mPhotoLabel->setIcon(QIcon());
+ mResultLabel->setPlainText("");
+}
+
+void lunchwidget::setResult(bool ok)
+{
+ if ( ok ) {
+ QString msg;
+ msg = tr("%1 ms").arg(iResult);
+ mResultLabel->setPlainText(msg);
+ }
+ else {
+ mResultLabel->setPlainText("Fail");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestdogapp/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCHWIDGET_H_
+#define LUNCHWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <HbPushButton>
+#include <hblabel.h>
+
+class HbComboBox;
+class TsTaskSettings;
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+private:
+
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mRegisterButton;
+ HbPushButton *mUnregisterButton;
+ HbPushButton *mHideButton;
+ HbPushButton *mShowButton;
+ HbPushButton *mAnimal1Button;
+ HbPushButton *mAnimal2Button;
+ HbPushButton *mClearButton;
+ HbLabel* mPhotoLabel;
+ HbLabel* mResultLabel;
+ //HbLabel* mPriorityLabel;
+ //HbComboBox *mPriorityCombo;
+
+ QPixmap* mAnimal1;
+ QPixmap* mAnimal2;
+
+ TInt64 iBefore;
+ TInt64 iAfter;
+ TInt64 iResult;
+
+private:
+ void Before();
+ void After();
+ void Result();
+ void setResult(bool ok);
+
+private slots:
+ void regScr();
+ void unregScr();
+ void hideMe();
+ void showMe();
+ void animal1();
+ void animal2();
+ void clear();
+
+private:
+ TsTaskSettings* mClient;
+};
+
+#endif /* LUNCHWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestdogapp/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include "lunchwidget.h"
+
+
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.show();
+
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestdogapp/tstestdogapp.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = tstestdogapp
+
+CONFIG += console
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+HEADERS += lunchwidget.h \
+
+RESOURCES += tstestdogapp.qrc
+
+LIBS += -ltstaskmonitorclient.dll
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestdogapp/tstestdogapp.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>images/bernardyn.jpg</file>
+ <file>images/newfunland.jpg</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/fakeplugin/data/tsfakelplugin.xml Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<service>
+ <name>fakeplugin</name>
+ <filepath>fakeplugin</filepath>
+ <description>Sample model plugin for Task Switcher</description>
+ <interface>
+ <name>com.nokia.qt.taskswitcher.dataprovider</name>
+ <version>1.0</version>
+ <description>test</description>
+ </interface>
+</service>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/fakeplugin/fakeplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = lib
+TARGET = fakeplugin
+
+CONFIG += plugin
+
+CONFIG += mobility
+MOBILITY = serviceframework publishsubscribe
+
+INCLUDEPATH += inc \
+ ../inc
+
+HEADERS += inc/tstestmodelplugin.h \
+ inc/tstestmodel.h \
+
+SOURCES += src/tstestmodelplugin.cpp \
+ src/tstestmodel.cpp \
+
+symbian {
+ load(data_caging_paths)
+ pluginDep.sources = fakeplugin.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR
+ DEPLOYMENT += pluginDep
+
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.CAPABILITY = ALL -TCB
+
+ LIBS += -lfbscli
+
+ # service framework XML deployment/export
+ xml.sources = ./data/tsfakelplugin.xml
+ xml.path = $$RESOURCE_FILES_DIR/taskswitcher
+
+ DEPLOYMENT += xml
+
+ #temporary workaround
+ BLD_INF_RULES.prj_exports += "data/tsfakelplugin.xml z:/resource/taskswitcher/tsfakelplugin.xml"
+}
+
+win32 {
+ DESTDIR = ../app/debug
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/fakeplugin/inc/tstestmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef TSTESTMODEL_H
+#define TSTESTMODEL_H
+
+#include <QObject>
+#include <QVariantHash>
+#include <QColor>
+#include <QPixmap>
+
+
+#include <qvaluespacesubscriber.h>
+QTM_USE_NAMESPACE
+
+#if defined(Q_OS_SYMBIAN)
+ #include <fbs.h>
+#endif
+
+class TsTestModel : public QObject
+{
+ Q_OBJECT
+
+public:
+ TsTestModel(QObject *parent = 0);
+ virtual ~TsTestModel();
+
+public slots:
+ QList<QVariantHash> taskList() const;
+ QList<QVariantHash> taskList(int limit) const;
+
+ bool openTask(const QVariant &id);
+ bool closeTask(const QVariant &id);
+
+
+private slots:
+ void verifyConnection();
+ void checkValue();
+
+signals:
+ void dataChanged();
+
+private:
+ void removeAll();
+ char byte(int numtoget, int byte);
+ QColor generateColor(int item);
+ QPixmap generatePixmap(int item);
+ void addItem(bool running, bool closeable);
+ void addItems(int num, bool running, bool closeable);
+
+private:
+ QList<QVariantHash> mData;
+ bool mWasValid;
+#if defined(Q_OS_SYMBIAN)
+ QList<CFbsBitmap*> mBitmaps;
+#endif
+ QValueSpaceSubscriber mSubscriber;
+};
+
+#endif // TSTESTMODEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/fakeplugin/inc/tstestmodelplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#ifndef TSTESTMODELPLUGIN_H
+#define TSTESTMODELPLUGIN_H
+
+#include <QObject>
+#include <qserviceplugininterface.h>
+
+QTM_USE_NAMESPACE
+
+class TsTestModelPlugin : public QObject, public QServicePluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QtMobility::QServicePluginInterface)
+
+public:
+ QObject *createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session);
+
+};
+
+#endif // TSTESTMODELPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/fakeplugin/src/tstestmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,207 @@
+/*
+* Copyright (c) 2009 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 "tstestmodel.h"
+
+#include <QPainter>
+#include <QDateTime>
+#include <QDebug>
+#include <QTimer>
+#include "tstestpropertydefs.h"
+
+TsTestModel::TsTestModel(QObject *parent) : QObject(parent), mWasValid(false)
+{
+ verifyConnection();
+}
+
+TsTestModel::~TsTestModel()
+{
+ qDeleteAll(mBitmaps);
+
+}
+
+QList<QVariantHash> TsTestModel::taskList() const
+{
+ return mData;
+}
+
+QList<QVariantHash> TsTestModel::taskList(int limit) const
+{
+ qDebug()<<"task list";
+ return mData.mid(0, limit);
+}
+
+bool TsTestModel::openTask(const QVariant &id)
+{
+ for (QList<QVariantHash>::iterator i = mData.begin(); i != mData.end(); ++i) {
+ if (i->value("TaskId") == id) {
+ if (!i->value("TaskIsRunning").toBool()) {
+ i->insert("TaskIsRunning", true);
+ i->insert("TaskCanBeClosed", true);
+ }
+ i->insert("TaskTimestamp", QDateTime::currentDateTime());
+ emit dataChanged();
+ return true;
+ }
+ }
+ return false;
+}
+
+bool TsTestModel::closeTask(const QVariant &id)
+{
+
+ for(int i=0; i<mData.count(); i++) {
+ QVariantHash vh = mData.at(i);
+ if(vh.value("TaskId") == id) {
+ if (vh.value("TaskCanBeClosed").toBool()) {
+ mData.removeAt(i);
+ if (mBitmaps.count()>i) {
+ delete mBitmaps.at(i);
+ mBitmaps.removeAt(i);
+ }
+ }
+ emit dataChanged();
+ return true;
+ }
+ }
+ return false;
+}
+
+void TsTestModel::checkValue()
+{
+ bool ok;
+ int value = mSubscriber.value().toInt(&ok);
+ if (!ok) {
+ return;
+ }
+ if(value == 0) {
+ return;
+ }
+ if(value == -1) {
+ removeAll();
+ return;
+ }
+
+ int itemnum = byte(value, 0);
+ if(itemnum == 0) {
+ return;
+ }
+ bool running = byte(value, 1);
+ bool closeable = byte(value, 2);
+ addItems(itemnum, running, closeable);
+
+}
+
+void TsTestModel::verifyConnection()
+{
+ mSubscriber.setPath(QString("%1/%2").arg(TsTestProperty::KTsTestPath).arg(TsTestProperty::KPluginPath));
+
+ if (mSubscriber.value().isValid()) {
+ if(mWasValid) {
+ QTimer::singleShot(20000, this, SLOT(verifyConnection()));
+ return;
+ }
+ mWasValid = true;
+ connect(&mSubscriber, SIGNAL(contentsChanged()), this, SLOT(checkValue()));
+ // might have missed first value change
+ checkValue();
+ } else {
+ mWasValid = false;
+ QTimer::singleShot(3000, this, SLOT(verifyConnection()));
+ }
+}
+
+void TsTestModel::removeAll()
+{
+ if(mData.count()>0) {
+ mData.clear();
+ qDeleteAll(mBitmaps);
+ mBitmaps.clear();
+ emit dataChanged();
+ }
+}
+
+char TsTestModel::byte(int numtoget, int byte)
+{
+ char ret = 0;
+ if(byte>3 || byte<0) {
+ return ret;
+ }
+ numtoget = numtoget>>8*byte;
+ ret = static_cast<char>(numtoget);
+
+ return ret;
+
+}
+
+QColor TsTestModel::generateColor(int item)
+{
+ int r = item*230%255;
+ int g = item*80%255;
+ int b = item*150%255;
+
+ QColor c(r, g, b);
+ return c;
+}
+
+QPixmap TsTestModel::generatePixmap(int item)
+{
+ QColor color = generateColor(item);
+ QPixmap pixmap(128, 128);
+ pixmap.fill(Qt::transparent);
+ {
+ QPainter painter(&pixmap);
+ painter.setBrush(Qt::white);
+ painter.setPen(QPen(color, 2));
+ QFont font;
+ font.setPointSize(8);
+ painter.setFont(font);
+ QString note;
+ note = tr("Task %1").arg(item);
+ painter.drawText(10, 80, note);
+ }
+ return pixmap;
+}
+
+void TsTestModel::addItem(bool running, bool closeable)
+{
+ QVariantHash entry;
+ int num = mData.count() + 1;
+ QPixmap pixmap = generatePixmap(num);
+ CFbsBitmap *bitmap = pixmap.toSymbianCFbsBitmap();
+ mBitmaps.append(bitmap);
+ entry.insert("TaskScreenshot", bitmap->Handle());
+ entry.insert("TaskIsRunning", running);
+ entry.insert("TaskCanBeClosed", closeable);
+
+ entry.insert("TaskId", num);
+ QString name;
+ name = tr("Task %1").arg(num);
+ entry.insert("TaskName", name);
+
+ entry.insert("TaskTimestamp", QDateTime::currentDateTime());
+ entry.insert("TaskUid", QString("EB002E%1").arg(num, 2, 10, QChar('0')).toUInt(0, 16));
+
+ mData.append(entry);
+}
+
+void TsTestModel::addItems(int num, bool running, bool closeable)
+{
+ for(int i=0; i<num; i++) {
+ addItem(running, closeable);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/fakeplugin/src/tstestmodelplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 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 "tstestmodelplugin.h"
+
+#include <qserviceinterfacedescriptor.h>
+#include <qabstractsecuritysession.h>
+#include <qservicecontext.h>
+
+#include "tstestmodel.h"
+
+QObject *TsTestModelPlugin::createInstance(const QServiceInterfaceDescriptor &descriptor, QServiceContext *context, QAbstractSecuritySession *session)
+{
+ Q_UNUSED(context);
+ Q_UNUSED(session);
+
+ if (descriptor.interfaceName() == "com.nokia.qt.taskswitcher.dataprovider") {
+ return new TsTestModel();
+ } else {
+ return NULL;
+ }
+}
+
+Q_EXPORT_PLUGIN2(tstestmodelplugin, TsTestModelPlugin)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/inc/tstestpropertydefs.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef TSTESTPROPERTYDEFS_H
+#define TSTESTPROPERTYDEFS_H
+
+namespace TsTestProperty {
+
+#if defined(__SYMBIAN32__) || defined(SYMBIAN)
+ const TUid KCategory = {0xE1f7fe4d};
+ const TUint KPluginKey = 0xE1f7fe4d;
+#endif
+ const char KTsTestPath[] = "/TaskSwitcherTest";
+ const char KPluginPath[] = "PluginSet";
+
+}
+
+#endif // TSTESTPROPERTYDEFS_H
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/sis/tstestpluginmanager.pkg Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,41 @@
+; tspluginmanager_template.pkg generated by qmake at 2010-07-08T16:34:25
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+
+; SIS header: name, uid, version
+#{"tstestpluginmanager"},(0xE1f7fe4d),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+
+; Manual PKG pre-rules from PRO files
+; Default dependency to Qt libraries
+
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Default dependency to QtMobility libraries
+(0x2002AC89), 1, 0, 1, {"QtMobility"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/tspluginmanager.exe" - "!:\sys\bin\tspluginmanager.exe"
+"/epoc32/data/z/resource/apps/tspluginmanager.rsc" - "!:\resource\apps\tspluginmanager.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tspluginmanager_reg.rsc" - "!:\private\10003a3f\import\apps\tspluginmanager_reg.rsc"
+; DEPLOYMENT
+"/epoc32/data/z/resource/qt/crml/tspluginmanager.qcrml" - "!:\resource\qt\crml\tspluginmanager.qcrml"
+
+"/epoc32/release/armv5/urel/fakeplugin.dll" - "!:\sys\bin\fakeplugin.dll"
+"/epoc32/data/z/resource/qt/plugins/fakeplugin.qtplugin" - "!:\resource\qt\plugins\fakeplugin.qtplugin"
+"/epoc32/data/z/resource/taskswitcher/tsfakelplugin.xml" - "!:\resource\taskswitcher\tsfakelplugin.xml"
+; Manual PKG post-rules from PRO files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/tspluginmanager/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2009 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 "lunchwidget.h"
+#include <QRect>
+#include <QPainter>
+#include <QUrl>
+#include <hbapplication>
+#include <tstestpropertydefs.h>
+#include <HbComboBox>
+#include <HbCheckBox>
+#include <qservicemanager.h>
+
+
+QTM_USE_NAMESPACE
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+ : HbWidget(parent), mPluginPublisher(TsTestProperty::KTsTestPath)
+{
+ mLoadLabel = new HbLabel;
+ QServiceManager manager;
+ bool ok = manager.addService(":/tsfakelplugin.xml");
+ if (!ok) {
+ int err = manager.error();
+ QString mess;
+ mess = tr("Load service: %1").arg(err);
+ mLoadLabel->setPlainText(mess);
+ }
+ else {
+ mLoadLabel->setPlainText("Load service: Ok");
+ }
+
+ mTenLabel= new HbLabel("10x");
+ mOneLabel= new HbLabel("1x");
+
+
+ mAdd = new HbPushButton("Add");
+ mRemove = new HbPushButton("Remove all");
+
+
+ mTenCombo = new HbComboBox();
+ mOneCombo = new HbComboBox();
+ for (int i=0; i<10; i++) {
+ QString num;
+ num.setNum(i);
+ mTenCombo->addItem(num);
+ mOneCombo->addItem(num);
+ }
+ mRunningCheckBox = new HbCheckBox("Is Running");
+ mRunningCheckBox->setCheckState(Qt::Checked);
+ mCloseableCheckBox = new HbCheckBox("Is Closeable");
+ mCloseableCheckBox->setCheckState(Qt::Checked);
+
+ mGridLayout = new QGraphicsGridLayout();
+ mGridLayout->addItem(mOneLabel, 0, 0, 1, 3);
+ mGridLayout->addItem(mTenLabel, 0, 3, 1, 3);
+ mGridLayout->addItem(mOneCombo, 1, 0, 1, 3);
+ mGridLayout->addItem(mTenCombo, 1, 3, 1, 3);
+ mGridLayout->addItem(mRunningCheckBox, 2, 0, 1, 6);
+ mGridLayout->addItem(mCloseableCheckBox, 3, 0, 1, 6);
+ mGridLayout->addItem(mAdd, 4, 0, 1, 6);
+ mGridLayout->addItem(mRemove, 5, 0, 1, 6);
+ mGridLayout->addItem(mLoadLabel, 6, 0, 1, 6);
+ setLayout(mGridLayout);
+
+
+ connect(mAdd, SIGNAL(released()), this, SLOT(add()));
+ connect(mRemove, SIGNAL(released()), this, SLOT(remove()));
+
+
+ mPluginPublisher.setValue(TsTestProperty::KPluginPath, 0);
+ mPluginPublisher.sync();
+
+}
+
+lunchwidget::~lunchwidget()
+{
+
+}
+
+void lunchwidget::add()
+{
+ int ten = mTenCombo->currentText().toInt();
+ int one = mOneCombo->currentText().toInt();
+ int num = ten*10+one;
+ bool running = false;
+ bool closeable = false;
+ if (mRunningCheckBox->checkState() == Qt::Checked) {
+ running = true;
+ }
+ if (mCloseableCheckBox->checkState() == Qt::Checked) {
+ closeable = true;
+ }
+
+ int message = 0;
+ setByte(message, 0, num);
+ setByte(message, 1, running);
+ setByte(message, 2, closeable);
+
+ mPluginPublisher.setValue(TsTestProperty::KPluginPath, message);
+ mPluginPublisher.sync();
+}
+
+void lunchwidget::remove()
+{
+ int message = -1;
+
+ mPluginPublisher.setValue(TsTestProperty::KPluginPath, message);
+ mPluginPublisher.sync();
+}
+
+
+void lunchwidget::setByte(int& numtoset, int byte, char value)
+{
+ if(byte>3 || byte<0) {
+ return;
+ }
+ int multiple = 255;//0b00000000000000000000000011111111;
+ unsigned int temp = 0;
+ temp = temp | value;
+ temp = temp & multiple;
+ temp = temp << byte*8;
+ numtoset = numtoset | temp;
+}
+
+char lunchwidget::byte(int numtoget, int byte)
+{
+ char ret = 0;
+ if(byte>3 || byte<0) {
+ return ret;
+ }
+ numtoget = numtoget>>8*byte;
+ ret = static_cast<char>(numtoget);
+
+ return ret;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/tspluginmanager/lunchwidget.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef LUNCWIDGET_H_
+#define LUNCWIDGET_H_
+
+#include <hbwidget.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsGridLayout>
+#include <QTimer>
+#include <HbPushButton>
+#include <hblabel.h>
+#include <qvaluespacepublisher.h>
+
+QTM_USE_NAMESPACE
+
+class HbComboBox;
+class HbCheckBox;
+
+class lunchwidget: public HbWidget
+{
+ Q_OBJECT
+public:
+ lunchwidget(QGraphicsItem *parent = 0);
+ ~lunchwidget();
+
+
+private slots:
+
+ void remove();
+ void add();
+
+private:
+ void setByte(int& numtoset, int byte, char value);
+ char byte(int numtoget, int byte);
+
+private:
+ HbLabel* mLoadLabel;
+ HbLabel* mTenLabel;
+ HbLabel* mOneLabel;
+ HbComboBox *mTenCombo;
+ HbComboBox *mOneCombo;
+ HbCheckBox* mRunningCheckBox;
+ HbCheckBox* mCloseableCheckBox;
+ QGraphicsGridLayout *mGridLayout;
+ HbPushButton *mAdd;
+ HbPushButton *mRemove;
+ QValueSpacePublisher mPluginPublisher;
+};
+
+#endif /* LUNCWIDGET_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/tspluginmanager/main.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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 <hbapplication.h>
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include "lunchwidget.h"
+
+
+int main(int argc, char **argv)
+{
+ HbApplication app(argc, argv);
+ lunchwidget* lw = new lunchwidget;
+ HbMainWindow mainWindow;
+ mainWindow.addView( lw );
+ mainWindow.currentView()->setTitle("Parent");
+ mainWindow.show();
+ RProcess::Rendezvous(KErrNone);
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/tspluginmanager/tspluginmanager.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,47 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+TARGET = tspluginmanager
+
+CONFIG += console mobility
+load(hb.prf)
+CONFIG -= symbian_i18n
+
+MOBILITY = serviceframework publishsubscribe
+
+INCLUDEPATH += ../inc
+
+SOURCES += main.cpp\
+lunchwidget.cpp
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+
+HEADERS += lunchwidget.h
+LIBS += -lxqsettingsmanager
+
+symbian {
+ TARGET.EPOCHEAPSIZE = 0x20000 0x500000 // 128kB - 5MB
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0xE1f7fe4d
+}
+
+crml.sources = ./resource/*.qcrml
+crml.path = /resource/qt/crml
+
+DEPLOYMENT += crml
+
+RESOURCES += tspluginmanager.qrc
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/tspluginmanager/tspluginmanager.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/" >
+ <file alias="tsfakelplugin.xml">../fakeplugin/data/tsfakelplugin.xml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tstestpluginmanager/tstestpluginmanager.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+SUBDIRS += tspluginmanager
+SUBDIRS += fakeplugin
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsdataobserver.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef DATAOBSERVER_H
+#define DATAOBSERVER_H
+
+#include <e32base.h>
+
+class MTsDataObserver {
+public:
+ virtual void DataChanged() =0;
+};
+
+class CTsDataObserver: public CBase,
+ public MTsDataObserver
+{
+public:
+ virtual void Cancel(const RMessage2& reason) =0;
+ virtual TBool IsParent(const CSession2 *session) =0;
+};
+
+class MTsDataObserverStorage
+{
+public:
+ virtual void PushL(CTsDataObserver*) =0;
+ virtual void Pop(CTsDataObserver*) =0;
+ virtual void Cancel(const RMessage2& reason) =0;
+ virtual void Invalidate(const CSession2* session) =0;
+};
+
+#endif //DATAOBSERVER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsentry.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+
+#ifndef TSENTRY_H
+#define TSENTRY_H
+
+#include <e32base.h>
+#include <e32cmn.h>
+#include <tsgraphicfilescalinghandler.h>
+
+#include "tsentrykey.h"
+#include "tstaskmonitorglobals.h"
+
+class CTsEntry;
+class CFbsBitmap;
+class MTsDataObserver;
+
+typedef RPointerArray<CTsEntry> RTsFswArray;
+
+/**
+ * An entry in the task list.
+ */
+NONSHARABLE_CLASS( CTsEntry ) : public CBase,
+ private MImageReadyCallBack
+{
+public:
+ static CTsEntry *NewL(const TTsEntryKey &key, MTsDataObserver &observer);
+ static CTsEntry *NewLC(const TTsEntryKey &key, MTsDataObserver &observer);
+ ~CTsEntry();
+
+public:
+ TUid AppUid() const;
+ const TDesC &AppName() const;
+ TBool CloseableApp() const;
+ Visibility GetVisibility() const;
+ CFbsBitmap *AppIconBitmap() const;
+ CFbsBitmap *Screenshot() const;
+ const TTsEntryKey &Key() const;
+ TTime Timestamp() const;
+
+ void SetAppUid(const TUid &uid);
+ void SetAppNameL(const TDesC &appName);
+ void SetCloseableApp(TBool value);
+ void SetVisibility(Visibility visibility);
+ void SetAppIcon(CFbsBitmap *aBitmap);
+ void SetScreenshotL(const CFbsBitmap &bitmap, UpdatePriority priority);
+ void RemoveScreenshotL();
+ void SetTimestamp(const TTime ×tamp);
+
+private:
+ CTsEntry(const TTsEntryKey &aKey, MTsDataObserver &observer);
+
+public: // from MImageReadyCallBack
+ void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap);
+
+private:
+ TUid mAppUid;
+ HBufC* mAppName;
+ TBool mCloseableApp;
+ Visibility mVisibility;
+ CFbsBitmap* mAppIconBitmap;
+ CFbsBitmap* mScreenshot;
+ TTsEntryKey mKey;
+ UpdatePriority mPriority;
+ TTime mTimestamp;
+
+private:
+ CTsGraphicFileScalingHandler *mImgTool;
+
+private:
+ MTsDataObserver &mObserver;
+
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsentrykey.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+ *
+*/
+
+
+#ifndef TSENTRYKEY_H
+#define TSENTRYKEY_H
+
+#include <e32base.h>
+
+class TTsEntryKey
+{
+public:
+ TTsEntryKey(TInt parentId =0);
+ TBool operator ==(const TTsEntryKey& key) const;
+ TInt WindowGroupId() const;
+
+private:
+ TInt mParentId;
+};
+
+#endif //TSENTRYKEY_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsentrykeygenerator.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+ *
+*/
+
+
+#ifndef TSENTRYKEYGENERATOR_H
+#define TSENTRYKEYGENERATOR_H
+
+#include <e32base.h>
+#include <e32cmn.h>
+#include <w32std.h>
+
+#include "tsentrykey.h"
+
+
+class TsEntryKeyGeneraror
+{
+public:
+ static TInt Generate(TTsEntryKey& returnKey, TInt windowGroupId,
+ const TArray<RWsSession::TWindowGroupChainInfo>& groupChain);
+};
+
+#endif //TSENTRYKEYGENERATOR_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsscreenshotmsg.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+
+#ifndef TSSCREENSHOTMSG_H
+#define TSSCREENSHOTMSG_H
+#include <e32base.h>
+#include <s32strm.h>
+#include "tstaskmonitorglobals.h"
+class CFbsBitmap;
+
+class CTsScreenshotMsg: public CBase
+{
+public:
+ static CTsScreenshotMsg* NewLC(RReadStream&);
+ static CTsScreenshotMsg* NewLC(TInt windowGroupId, const CFbsBitmap& bitmap, UpdatePriority prior);
+
+ static TInt size();
+ ~CTsScreenshotMsg();
+ TInt windowGroupId() const;
+ const CFbsBitmap& screenshot() const;
+ UpdatePriority priority() const;
+ HBufC8* ExternalizeLC() const;
+ void ExternalizeL(RWriteStream &stream) const;
+ void InternalizeL(RReadStream &stream);
+
+private:
+ CTsScreenshotMsg();
+ void ConstructL(RReadStream &stream);
+ void ConstructL(TInt windowGroupId, const CFbsBitmap& bitmap, UpdatePriority prior);
+
+private:
+ TInt mWindowGroupId;
+ UpdatePriority mPriority;
+ CFbsBitmap* mBitmap;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsunregscreenshotmsg.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+
+#ifndef TSUNREGISTERSCREENSHOTMSG_H
+#define TSUNREGISTERSCREENSHOTMSG_H
+#include <e32base.h>
+#include <s32strm.h>
+
+class CTsUnregisterScreenshotMsg: public CBase
+{
+public:
+ static CTsUnregisterScreenshotMsg* NewLC(RReadStream&);
+ static CTsUnregisterScreenshotMsg* NewLC(TInt windowGroupId);
+
+ static TInt size();
+ ~CTsUnregisterScreenshotMsg();
+ TInt windowGroupId() const;
+ HBufC8* ExternalizeLC() const;
+ void ExternalizeL(RWriteStream &stream) const;
+ void InternalizeL(RReadStream &stream);
+
+private:
+ CTsUnregisterScreenshotMsg();
+ void ConstructL(RReadStream &stream);
+ void ConstructL(TInt windowGroupId);
+
+private:
+ TInt mWindowGroupId;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsutils.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+namespace TaskSwitcher {
+ template <class T>
+ void RPointerArrayCleanupMethod(TAny *aPtr)
+ {
+ static_cast< RPointerArray<T>* >(aPtr)->ResetAndDestroy();
+ }
+
+ template <class T>
+ void CleanupResetAndDestroyPushL(RPointerArray<T> &array) {
+ CleanupStack::PushL(TCleanupItem(&RPointerArrayCleanupMethod<T>, &array));
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/inc/tsvisibilitymsg.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+
+#ifndef TSVISIBILITYMSG_H
+#define TSVISIBILITYMSG_H
+#include <e32base.h>
+#include <s32strm.h>
+
+#include "tstaskmonitorglobals.h"
+
+class CTsVisibilitMsg: public CBase
+{
+public:
+ static CTsVisibilitMsg* NewLC(RReadStream&);
+ static CTsVisibilitMsg* NewLC(TInt windowGroupId, Visibility visi);
+
+ static TInt size();
+ ~CTsVisibilitMsg();
+ TInt windowGroupId() const;
+ Visibility visibility() const;
+ HBufC8* ExternalizeLC() const;
+ void ExternalizeL(RWriteStream &stream) const;
+ void InternalizeL(RReadStream &stream);
+
+private:
+ CTsVisibilitMsg();
+ void ConstructL(RReadStream &stream);
+ void ConstructL(TInt windowGroupId, Visibility visi);
+
+private:
+ TInt mWindowGroupId;
+ Visibility mVisibility;
+};
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/src/tsentry.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2008 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: Task list entry
+ *
+ */
+
+#define __E32SVR_H__
+#include <s32strm.h>
+#include <fbs.h>
+#include "tsentry.h"
+#include "tsdataobserver.h"
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::NewL
+// --------------------------------------------------------------------------
+//
+CTsEntry* CTsEntry::NewL(const TTsEntryKey &key, MTsDataObserver &observer)
+{
+ CTsEntry* self = NewLC(key, observer);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::NewLC
+// --------------------------------------------------------------------------
+//
+CTsEntry* CTsEntry::NewLC(const TTsEntryKey &key, MTsDataObserver &observer)
+{
+ CTsEntry* self = new (ELeave) CTsEntry(key, observer);
+ CleanupStack::PushL(self);
+ return self;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::~CTsFswEntry
+// --------------------------------------------------------------------------
+//
+CTsEntry::~CTsEntry()
+{
+ delete mAppName;
+ delete mAppIconBitmap;
+ delete mScreenshot;
+ delete mImgTool;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::CTsFswEntry
+// --------------------------------------------------------------------------
+//
+CTsEntry::CTsEntry(const TTsEntryKey &key, MTsDataObserver &observer)
+:
+ mVisibility(Visible),
+ mKey(key),
+ mPriority(Low),
+ mObserver(observer)
+{
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::SetAppUid
+// --------------------------------------------------------------------------
+//
+void CTsEntry::SetAppUid(const TUid &uid)
+{
+ mAppUid = uid;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::SetAppNameL
+// --------------------------------------------------------------------------
+//
+void CTsEntry::SetAppNameL(const TDesC &appName)
+{
+ delete mAppName;
+ mAppName = 0;
+ mAppName = appName.AllocL();
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::SetSystemApp
+// --------------------------------------------------------------------------
+//
+void CTsEntry::SetCloseableApp(TBool value)
+{
+ mCloseableApp = value;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::SetAppIconHandles
+// --------------------------------------------------------------------------
+//
+void CTsEntry::SetAppIcon(CFbsBitmap * bitmap)
+{
+ mAppIconBitmap = bitmap;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Application uid.
+ */
+TUid CTsEntry::AppUid() const
+{
+ return mAppUid;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Application name.
+ */
+const TDesC& CTsEntry::AppName() const
+{
+ return mAppName ? *mAppName : KNullDesC();
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Retrieve entry visibilit status
+ */
+Visibility CTsEntry::GetVisibility() const
+{
+ return mVisibility;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Change entry visibility status
+ * @param visibility - new visibility status
+ */
+void CTsEntry::SetVisibility(Visibility visibility)
+{
+ mVisibility = visibility;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * ETrue if the application is closeable
+ */
+TBool CTsEntry::CloseableApp() const
+{
+ return mCloseableApp;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Application icon bitmap
+ */
+CFbsBitmap *CTsEntry::AppIconBitmap() const
+{
+ return mAppIconBitmap;
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Entry's key
+ */
+const TTsEntryKey &CTsEntry::Key() const
+{
+ return mKey;
+}
+
+TTime CTsEntry::Timestamp() const
+{
+ return mTimestamp;
+}
+
+void CTsEntry::SetTimestamp(const TTime ×tamp)
+{
+ mTimestamp = timestamp;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::SetScreenshot
+// --------------------------------------------------------------------------
+//
+void CTsEntry::SetScreenshotL(const CFbsBitmap &bitmapArg, UpdatePriority priority)
+{
+ TInt currentPriority = static_cast<TInt> (mPriority);
+ TInt newPriority = static_cast<TInt> (priority);
+ if(newPriority <currentPriority) {
+ User::Leave(KErrAccessDenied);
+ }
+
+ CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
+ CleanupStack::PushL(bitmap);
+ User::LeaveIfError(bitmap->Duplicate(bitmapArg.Handle()));
+ CleanupStack::Pop(bitmap);
+
+ mPriority = priority;
+ delete mScreenshot;
+ mScreenshot = bitmap;
+
+ delete mImgTool;
+ mImgTool = 0;
+
+ mImgTool = CTsGraphicFileScalingHandler::NewL(*this, *mScreenshot, TSize(128, 128),
+ CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding);
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::RemoveScreenshot
+// --------------------------------------------------------------------------
+//
+void CTsEntry::RemoveScreenshotL()
+{
+ if (!mScreenshot) {
+ User::Leave(KErrNotFound);
+ }
+ delete mScreenshot;
+ mScreenshot = NULL;
+ mPriority = Low;
+
+ mObserver.DataChanged();
+}
+
+// --------------------------------------------------------------------------
+/**
+ * Application screenshot.
+ */
+CFbsBitmap* CTsEntry::Screenshot() const
+{
+ return mScreenshot;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::Priority
+// --------------------------------------------------------------------------
+//
+void CTsEntry::ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap)
+{
+ if (KErrNone == error && 0 != bitmap) {
+ mScreenshot->Reset();
+ mScreenshot->Duplicate(bitmap->Handle());
+
+ mObserver.DataChanged();
+ }
+}
+
+// end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/src/tsentrykey.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+ *
+*/
+
+
+#include "tsentrykey.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TTsEntryKey::TTsEntryKey(TInt parentId)
+:
+ mParentId(parentId)
+{}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TBool TTsEntryKey::operator ==(const TTsEntryKey& key) const
+{
+ return (mParentId == key.mParentId);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TInt TTsEntryKey::WindowGroupId() const
+{
+ return mParentId;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/src/tsentrykeygenerator.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+ *
+*/
+#include "tsentrykeygenerator.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TInt TsEntryKeyGeneraror::Generate(TTsEntryKey& returnKey, TInt windowGroupId,
+ const TArray<RWsSession::TWindowGroupChainInfo>& groupChain)
+{
+ for (TInt iter(0); iter < groupChain.Count(); ++iter) {
+ if (groupChain[iter].iId == windowGroupId) {
+ returnKey = TTsEntryKey(windowGroupId);
+ if (groupChain[iter].iId == groupChain[iter].iParentId) {
+ return KErrBadHandle;
+ }
+ else if (0 >= groupChain[iter].iParentId) {
+ return KErrNone;
+ }
+ else {
+ return TsEntryKeyGeneraror::Generate(returnKey, groupChain[iter].iParentId, groupChain);
+ }
+ }
+ }
+ return KErrNotFound;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/src/tsscreenshotmsg.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+#include <s32mem.h>
+#include <fbs.h>
+
+#include "tsscreenshotmsg.h"
+
+// -----------------------------------------------------------------------------
+CTsScreenshotMsg* CTsScreenshotMsg::NewLC(RReadStream& stream)
+{
+ CTsScreenshotMsg *self = new(ELeave)CTsScreenshotMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(stream);
+ return self;
+}
+// -----------------------------------------------------------------------------
+CTsScreenshotMsg* CTsScreenshotMsg::NewLC(TInt windowGroupId, const CFbsBitmap& bitmap, UpdatePriority prior)
+{
+ CTsScreenshotMsg *self = new(ELeave)CTsScreenshotMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(windowGroupId, bitmap, prior);
+ return self;
+}
+// -----------------------------------------------------------------------------
+TInt CTsScreenshotMsg::CTsScreenshotMsg::size()
+{
+ return sizeof(TInt) * 3;
+}
+// -----------------------------------------------------------------------------
+CTsScreenshotMsg::~CTsScreenshotMsg()
+{
+ delete mBitmap;
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsScreenshotMsg::windowGroupId() const
+{
+ return mWindowGroupId;
+}
+
+// -----------------------------------------------------------------------------
+const CFbsBitmap& CTsScreenshotMsg::screenshot() const
+{
+ return *mBitmap;
+}
+
+// -----------------------------------------------------------------------------
+UpdatePriority CTsScreenshotMsg::priority() const
+{
+ return mPriority;
+}
+
+// -----------------------------------------------------------------------------
+HBufC8* CTsScreenshotMsg::ExternalizeLC() const
+{
+ HBufC8* retVal = HBufC8::NewLC(size());
+ TPtr8 des(retVal->Des());
+ RDesWriteStream stream(des);
+ CleanupClosePushL(stream);
+ stream << (*this);
+ CleanupStack::PopAndDestroy(&stream);
+ return retVal;
+}
+
+// -----------------------------------------------------------------------------
+void CTsScreenshotMsg::ExternalizeL(RWriteStream &stream) const
+{
+ stream.WriteInt32L(mWindowGroupId);
+ stream.WriteInt32L(mBitmap->Handle());
+ stream.WriteInt32L(mPriority);
+}
+// -----------------------------------------------------------------------------
+void CTsScreenshotMsg::InternalizeL(RReadStream &stream)
+{
+ mWindowGroupId = stream.ReadInt32L();
+ User::LeaveIfError(mBitmap->Duplicate(stream.ReadInt32L()));
+ mPriority = static_cast<UpdatePriority>(stream.ReadInt32L());
+}
+
+// -----------------------------------------------------------------------------
+CTsScreenshotMsg::CTsScreenshotMsg()
+{}
+// -----------------------------------------------------------------------------
+void CTsScreenshotMsg::ConstructL(RReadStream &stream)
+{
+ mBitmap = new(ELeave)CFbsBitmap();
+ stream >> (*this);
+}
+
+// -----------------------------------------------------------------------------
+void CTsScreenshotMsg::ConstructL(TInt windowGroupId, const CFbsBitmap& bitmap, UpdatePriority prior)
+{
+ mBitmap = new(ELeave)CFbsBitmap();
+ User::LeaveIfError(mBitmap->Duplicate(bitmap.Handle()));
+ mWindowGroupId = windowGroupId;
+ mPriority = prior;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/src/tsunregscreenshotmsg.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+#include "tsunregscreenshotmsg.h"
+#include <s32mem.h>
+// -----------------------------------------------------------------------------
+CTsUnregisterScreenshotMsg* CTsUnregisterScreenshotMsg::NewLC(RReadStream& stream)
+{
+ CTsUnregisterScreenshotMsg* self = new(ELeave)CTsUnregisterScreenshotMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(stream);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsUnregisterScreenshotMsg* CTsUnregisterScreenshotMsg::NewLC(TInt windowGroupId)
+{
+ CTsUnregisterScreenshotMsg* self = new(ELeave)CTsUnregisterScreenshotMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(windowGroupId);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsUnregisterScreenshotMsg::CTsUnregisterScreenshotMsg()
+{
+ //No implementation required
+}
+// -----------------------------------------------------------------------------
+void CTsUnregisterScreenshotMsg::ConstructL(RReadStream &stream)
+{
+ stream >> (*this);
+}
+
+// -----------------------------------------------------------------------------
+void CTsUnregisterScreenshotMsg::ConstructL(TInt windowGroupId)
+{
+ mWindowGroupId = windowGroupId;
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsUnregisterScreenshotMsg::size()
+{
+ return sizeof(TInt);
+}
+
+// -----------------------------------------------------------------------------
+CTsUnregisterScreenshotMsg::~CTsUnregisterScreenshotMsg()
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsUnregisterScreenshotMsg::windowGroupId() const
+{
+ return mWindowGroupId;
+}
+
+// -----------------------------------------------------------------------------
+HBufC8* CTsUnregisterScreenshotMsg::ExternalizeLC() const
+{
+ HBufC8* retVal = HBufC8::NewLC(size());
+ TPtr8 des(retVal->Des());
+ RDesWriteStream stream(des);
+ CleanupClosePushL(stream);
+ stream << (*this);
+ CleanupStack::PopAndDestroy(&stream);
+ return retVal;
+}
+
+// -----------------------------------------------------------------------------
+void CTsUnregisterScreenshotMsg::ExternalizeL(RWriteStream &stream) const
+{
+ stream.WriteInt32L(mWindowGroupId);
+}
+
+// -----------------------------------------------------------------------------
+void CTsUnregisterScreenshotMsg::InternalizeL(RReadStream &stream)
+{
+ mWindowGroupId = stream.ReadInt32L();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/src/tsvisibilitymsg.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2008 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: Task list entry
+*
+*/
+#include <s32mem.h>
+#include "tsvisibilitymsg.h"
+// -----------------------------------------------------------------------------
+CTsVisibilitMsg* CTsVisibilitMsg::NewLC(RReadStream& stream)
+{
+ CTsVisibilitMsg *self = new (ELeave)CTsVisibilitMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(stream);
+ return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsVisibilitMsg* CTsVisibilitMsg::NewLC(TInt windowGroupId, Visibility visi)
+{
+ CTsVisibilitMsg *self = new (ELeave)CTsVisibilitMsg();
+ CleanupStack::PushL(self);
+ self->ConstructL(windowGroupId, visi);
+ return self;
+}
+// -----------------------------------------------------------------------------
+TInt CTsVisibilitMsg::size()
+{
+ return sizeof(TInt) * 2;
+}
+
+// -----------------------------------------------------------------------------
+CTsVisibilitMsg::~CTsVisibilitMsg()
+{
+ //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsVisibilitMsg::windowGroupId() const
+{
+ return mWindowGroupId;
+}
+
+// -----------------------------------------------------------------------------
+Visibility CTsVisibilitMsg::visibility() const
+{
+ return mVisibility;
+}
+
+// -----------------------------------------------------------------------------
+HBufC8* CTsVisibilitMsg::ExternalizeLC() const
+{
+ HBufC8* retVal = HBufC8::NewLC(size());
+ TPtr8 des(retVal->Des());
+ RDesWriteStream stream(des);
+ CleanupClosePushL(stream);
+ stream << (*this);
+ CleanupStack::PopAndDestroy(&stream);
+ return retVal;
+}
+
+// -----------------------------------------------------------------------------
+void CTsVisibilitMsg::ExternalizeL(RWriteStream &stream) const
+{
+ stream.WriteInt32L(mWindowGroupId);
+ stream.WriteInt32L(mVisibility);
+
+}
+
+// -----------------------------------------------------------------------------
+void CTsVisibilitMsg::InternalizeL(RReadStream &stream)
+{
+ mWindowGroupId = stream.ReadInt32L();
+ mVisibility = static_cast<Visibility>(stream.ReadInt32L());
+}
+
+// -----------------------------------------------------------------------------
+CTsVisibilitMsg::CTsVisibilitMsg()
+{
+ //No implementaton required
+}
+
+// -----------------------------------------------------------------------------
+void CTsVisibilitMsg::ConstructL(RReadStream &stream)
+{
+ stream >> (*this);
+}
+
+// -----------------------------------------------------------------------------
+void CTsVisibilitMsg::ConstructL(TInt windowGroupId, Visibility visi)
+{
+ mWindowGroupId = windowGroupId;
+ mVisibility = visi;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/tsrc/t_tsentrykeyhandling/t_tsentrykeyhandling.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 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 <QtTest/QtTest>
+
+#include "t_tsentrykeyhandling.h"
+#include "tsentrykey.h"
+#include "tsentrykeygenerator.h"
+void T_TsEntryKeyHandling::testKeyGeneration()
+{
+ int errNo, iter;
+ const int rootWindowGroupId(1);
+ const int embApps(30);
+
+ RWsSession::TWindowGroupChainInfo item;
+ RArray<RWsSession::TWindowGroupChainInfo> items(embApps);
+
+ //generate root window
+ item.iId = rootWindowGroupId;
+ item.iParentId = -1;
+ items.Append(item);
+
+ //add some embedded windows
+ for (iter = rootWindowGroupId; iter < rootWindowGroupId + embApps;) {
+ item.iParentId = iter;
+ item.iId = ++iter;
+ items.Append(item);
+ }
+ TTsEntryKey root;
+ errNo = TsEntryKeyGeneraror::Generate(root, rootWindowGroupId, items.Array());
+ QCOMPARE(errNo, KErrNone);
+
+ TTsEntryKey key;
+ for (iter = 0; iter < items.Count(); ++iter) {
+ errNo = TsEntryKeyGeneraror::Generate(key, items[iter].iId,
+ items.Array());
+ QCOMPARE(errNo, KErrNone);
+ QCOMPARE(key, root);
+ }
+
+ //bad handle
+ items.Reset();
+ item.iId = rootWindowGroupId;
+ item.iParentId = rootWindowGroupId;
+ items.Append(item);
+ TTsEntryKey bad;
+ errNo = TsEntryKeyGeneraror::Generate(bad, rootWindowGroupId, items.Array());
+ QCOMPARE(errNo, KErrBadHandle);
+
+ //not found
+ items.Reset();
+ item.iId = rootWindowGroupId;
+ item.iParentId = rootWindowGroupId;
+ items.Append(item);
+ TTsEntryKey notFound;
+ errNo = TsEntryKeyGeneraror::Generate(notFound, 15002900, items.Array());
+ QCOMPARE(errNo, KErrNotFound);
+
+
+}
+
+QTEST_MAIN(T_TsEntryKeyHandling)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/tsrc/t_tsentrykeyhandling/t_tsentrykeyhandling.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSENTRYKEYHANDLING_H
+#define T_TSENTRYKEYHANDLING_H
+
+#include <QObject>
+
+/**
+* @test Test class for TsTaskMonitorClient
+*/
+class T_TsEntryKeyHandling : public QObject
+{
+ Q_OBJECT
+private slots:
+ void testKeyGeneration();
+
+};
+
+#endif //T_TSENTRYKEYHANDLING_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/tsrc/t_tsentrykeyhandling/t_tsentrykeyhandling.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+
+QT *= testlib
+CONFIG += console
+
+INCLUDEPATH += . \
+ ../../inc/
+
+HEADERS += t_tsentrykeyhandling.h \
+
+SOURCES += t_tsentrykeyhandling.cpp \
+ ../../src/tsentrykey.cpp \
+ ../../src/tsentrykeygenerator.cpp
+
+LIBS += -lestor.dll
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.EPOCALLOWDLLDATA=1
+}
+
+coverage {
+ DEFINES += COVERAGE_MEASUREMENT
+ DEFINES += QT_NO_DEBUG # omit ASSERTS in coverage measurements
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/utils/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS += t_tsentrykeyhandling
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/mocks/afmanager.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 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 "afmanager.h"
+#include <QPixmap>
+
+const char myName [] = "TestActivityManager";
+
+AfManager::AfManager(QObject *parent) : QObject(parent)
+{
+ setObjectName(myName);
+ mData = QList<QVariantHash>();
+}
+
+AfManager::~AfManager()
+{
+}
+
+QList<QVariantHash> AfManager::activitiesList()
+{
+ return mData;
+}
+
+void AfManager::setActivitiesList(const QList<QVariantHash>& activities)
+{
+ mData = activities;
+}
+
+void AfManager::launchActivity(const QString &uri)
+{
+ Q_UNUSED(uri);
+}
+
+void AfManager::launchActivity(int applicationId, const QString &activityId)
+{
+ Q_UNUSED(applicationId);
+ Q_UNUSED(activityId);
+}
+
+void AfManager::getThumbnail(QSize resolution, const QString &thumbnailId, void *userData)
+{
+ Q_UNUSED(thumbnailId);
+ Q_UNUSED(resolution);
+ emit thumbnailReady(QPixmap(), userData);
+}
+
+void AfManager::emitDataChanged()
+{
+ emit dataChanged();
+}
+
+void AfManager::clearActivities()
+{
+ mData.clear();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/mocks/afmanager.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef AFMANAGER_H
+#define AFMANAGER_H
+
+#include <QObject>
+#include <QVariant>
+#include <QList>
+#include <QPixmap>
+
+class AfManager : public QObject
+{
+
+ Q_OBJECT
+
+public:
+ AfManager(QObject *parent = 0);
+ ~AfManager();
+
+public slots:
+ QList<QVariantHash> activitiesList();
+ void launchActivity(const QString &uri);
+ void launchActivity(int applicationId, const QString &activityId);
+ void setActivitiesList(const QList<QVariantHash>&);
+ void getThumbnail(QSize resolution, const QString &thumbnailId, void * =0);
+ void emitDataChanged();
+ void clearActivities();
+
+signals:
+ void thumbnailReady(QPixmap, void *);
+ void dataChanged();
+
+private:
+ QList<QVariantHash> mData;
+};
+
+#endif // AFMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/mocks/mocktstask.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 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 "mocktstask.h"
+
+TsTaskContent::TsTaskContent(const QString &name, bool closable, bool active) : mName(name), mClosable(closable), mActive(active)
+{
+}
+
+TsTask::TsTask(TsTaskContent *content, TsTaskLauncher &launcher) : mContent(content), mLauncher(launcher)
+{
+}
+
+TsTask::~TsTask()
+{
+ delete mContent;
+}
+
+bool TsTask::isClosable() const
+{
+ return mContent->mClosable;
+}
+
+bool TsTask::isActive() const
+{
+ return mContent->mActive;
+}
+
+QPixmap TsTask::screenshot() const
+{
+ return QPixmap();
+}
+
+QString TsTask::name() const
+{
+ return mContent->mName;
+}
+
+void TsTask::open()
+{
+}
+
+void TsTask::close()
+{
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/mocks/mocktstask.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef MOCK_TSTASK_H
+#define MOCK_TSTASK_H
+
+#include <QPixmap>
+#include <QString>
+#include <tstask.h>
+
+class TsTaskContent
+{
+public:
+ TsTaskContent(const QString &name, bool closable, bool active);
+
+public:
+ QString mName;
+ bool mClosable;
+ bool mActive;
+};
+
+class TsTaskLauncher
+{
+};
+
+#endif //MOCK_TSTASK_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/mocks/mocktstaskmonitor.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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 "mocktstaskmonitor.h"
+
+TsTaskMonitor::TsTaskMonitor(QObject* parent)
+:
+ QObject(parent)
+{
+}
+
+TsTaskMonitor::~TsTaskMonitor()
+{}
+
+QList<TsTaskChange> TsTaskMonitor::changeList(bool /*fullList*/)
+{
+ void* ptr(this);
+ return static_cast<MockTsTaskMonitor*>(ptr)->mTasks;
+}
+
+MockTsTaskMonitor::MockTsTaskMonitor(QObject *parent)
+:
+ TsTaskMonitor(parent)
+{
+ mTasks = QList<TsTaskChange>();
+}
+
+MockTsTaskMonitor::~MockTsTaskMonitor()
+{}
+
+void MockTsTaskMonitor::setTaskList(QList<TsTaskChange> tasks)
+{
+ mTasks = tasks;
+ emit taskListChanged();
+}
+
+void MockTsTaskMonitor::clearTasks()
+{
+ mTasks.clear();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/mocks/mocktstaskmonitor.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef MOCKTSTASKMONITOR_H
+#define MOCKTSTASKMONITOR_H
+
+#include <QObject>
+#include <QList>
+#include <QSharedPointer>
+#include <tstask.h>
+#include <tstaskmonitor.h>
+
+#include "tstaskchangeinfo.h"
+
+class MockTsTaskMonitor : public TsTaskMonitor
+{
+ Q_OBJECT
+
+public:
+ MockTsTaskMonitor(QObject *parent = 0);
+ ~MockTsTaskMonitor();
+public slots:
+ void setTaskList(QList<TsTaskChange> tasks);
+ void clearTasks();
+
+public:
+ QList<TsTaskChange> mTasks;
+};
+
+#endif //MOCKTSTASKMONITOR_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdevicedialogplugin/t_tsdevicedialogplugin.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2009 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_tsdevicedialogplugin.h"
+
+#include <QtTest/QtTest>
+#include <HbDeviceDialogInterface>
+
+#include <qvaluespacesubscriber.h>
+#include <qvaluespacepublisher.h>
+QTM_USE_NAMESPACE
+
+#include <tstestutils.h>
+#include <tspropertydefs.h>
+
+#include "tsdevicedialogplugin.h"
+
+void T_TsDeviceDialogPlugin::testCreation()
+{
+ TsDeviceDialogPlugin *deviceDialogPlugin = new TsDeviceDialogPlugin;
+ delete deviceDialogPlugin;
+}
+
+void T_TsDeviceDialogPlugin::testAccessAllowed()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ QVERIFY(deviceDialogPlugin.accessAllowed(QString(), QVariantMap(), QVariantMap()));
+}
+
+void T_TsDeviceDialogPlugin::testDialogInfo()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+
+ HbDeviceDialogPlugin::DeviceDialogInfo info;
+ deviceDialogPlugin.deviceDialogInfo(QString(), QVariantMap(), &info);
+ QVERIFY(info.group == HbDeviceDialogPlugin::GenericDeviceDialogGroup);
+ QVERIFY(info.flags == HbDeviceDialogPlugin::SingleInstance);
+ QVERIFY(info.priority == HbDeviceDialogPlugin::DefaultPriority);
+}
+
+void T_TsDeviceDialogPlugin::testDialogTypes()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+
+ QStringList dialogTypes = deviceDialogPlugin.deviceDialogTypes();
+ QCOMPARE(1, dialogTypes.count());
+ QCOMPARE(QString("com.nokia.taskswitcher.tsdevicedialogplugin/1.0"), dialogTypes.first());
+}
+
+void T_TsDeviceDialogPlugin::testPluginFlags()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+
+ QVERIFY(deviceDialogPlugin.pluginFlags() & HbDeviceDialogPlugin::PreloadPlugin);
+ QVERIFY(deviceDialogPlugin.pluginFlags() & HbDeviceDialogPlugin::KeepPluginLoaded);
+}
+
+void T_TsDeviceDialogPlugin::testError()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ QCOMPARE(0, deviceDialogPlugin.error());
+}
+
+void T_TsDeviceDialogPlugin::testCreateDialog()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ QVERIFY(!deviceDialogPlugin.createDeviceDialog("InvalidDialogType", QVariantMap()));
+ foreach(const QString &dialogType, deviceDialogPlugin.deviceDialogTypes()) {
+ HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(dialogType, QVariantMap());
+ QVERIFY(dialog);
+ QVERIFY(0 != dialog->deviceDialogWidget());
+ QVERIFY(false == dialog->setDeviceDialogParameters(QVariantMap()));
+ dialog->closeDeviceDialog(true);
+ QVERIFY(0 == dialog->deviceDialogError());
+ delete dialog;
+ }
+}
+
+void T_TsDeviceDialogPlugin::testNoCrashOnOrientationChange()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap());
+ QVERIFY(dialog);
+ mMainWindow.setOrientation(Qt::Vertical);
+ QCoreApplication::processEvents();
+ mMainWindow.setOrientation(Qt::Horizontal);
+ QCoreApplication::processEvents();
+ delete dialog;
+}
+
+void T_TsDeviceDialogPlugin::testCreateDeviceDialogTwoTimes()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ HbDeviceDialogInterface *dialog1 = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap());
+ QVERIFY(dialog1);
+ HbDeviceDialogInterface *dialog2 = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap());
+ QVERIFY(dialog2);
+
+ delete dialog1;
+ delete dialog2;
+}
+
+void T_TsDeviceDialogPlugin::testCorrectSignalSenderIsReturned()
+{
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap());
+ QVERIFY(dialog);
+ QVERIFY(dialog->signalSender());
+}
+
+void T_TsDeviceDialogPlugin::testDialogSendsItsStatusNotifications()
+{
+ QString tsVisibilityPath = QString("%1/%2").arg(TsProperty::KTsPath).arg(TsProperty::KVisibilityPath);
+
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap());
+ QVERIFY(dialog);
+ QCOMPARE(QValueSpaceSubscriber(tsVisibilityPath).value().toBool(), true);
+
+ dialog->closeDeviceDialog(true);
+ QCOMPARE(QValueSpaceSubscriber(tsVisibilityPath).value().toBool(), false);
+
+ delete dialog;
+}
+
+void T_TsDeviceDialogPlugin::testDialogCanBeDismissedThroughProperty()
+{
+ QString tsDismissRequestPath = QString("%1/%2").arg(TsProperty::KTsPath).arg(TsProperty::KDismissRequestPath);
+
+ TsDeviceDialogPlugin deviceDialogPlugin;
+ HbDeviceDialogInterface *dialog = deviceDialogPlugin.createDeviceDialog(deviceDialogPlugin.deviceDialogTypes().first(), QVariantMap());
+ QVERIFY(dialog);
+ QCOMPARE(QValueSpaceSubscriber(tsDismissRequestPath).value().toBool(), false);
+
+ QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath);
+ dismissRequestPublisher.setValue(TsProperty::KDismissRequestPath, static_cast<int>(true));
+ dismissRequestPublisher.sync();
+
+ QVERIFY(TsTestUtils::waitForSignal(dialog->signalSender(), SIGNAL(deviceDialogClosed()), 3000));
+
+ delete dialog;
+}
+
+QTEST_MAIN(T_TsDeviceDialogPlugin)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdevicedialogplugin/t_tsdevicedialogplugin.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSDEVICEDIALOGPLUGIN_H
+#define T_TSDEVICEDIALOGPLUGIN_H
+
+#include <QObject>
+
+#include <HbMainWindow>
+
+/**
+* @test Test class for TsDeviceDialogPlugin
+*/
+class T_TsDeviceDialogPlugin : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testCreation();
+ void testAccessAllowed();
+ void testDialogInfo();
+ void testDialogTypes();
+ void testPluginFlags();
+ void testError();
+ void testCreateDialog();
+ void testNoCrashOnOrientationChange();
+ void testCreateDeviceDialogTwoTimes();
+ void testCorrectSignalSenderIsReturned();
+ void testDialogSendsItsStatusNotifications();
+ void testDialogCanBeDismissedThroughProperty();
+
+private:
+ HbMainWindow mMainWindow;
+
+};
+
+#endif //T_TSDEVICEDIALOGPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdevicedialogplugin/t_tsdevicedialogplugin.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,73 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+CONFIG += hb testcase mobility
+MOBILITY = serviceframework publishsubscribe
+
+INCLUDEPATH += . \
+ ../mocks \
+ ../../inc \
+ ../../../../inc \
+
+HEADERS += t_tsdevicedialogplugin.h \
+ ../mocks/afmanager.h \
+ ../../inc/tsdevicedialogplugin.h \
+ ../../inc/tsdocumentloader.h \
+ ../../inc/tstasksgrid.h \
+ ../../inc/tsdevicedialogcontainer.h \
+ ../../inc/tstasksgriditem.h \
+ ../../inc/tsmodel.h \
+ ../../inc/tsmodelitem.h \
+ ../../inc/tsentrymodelitem.h \
+ ../../inc/tsactivitymodelitem.h \
+ ../../inc/tsnoitemslabel.h \
+
+SOURCES += t_tsdevicedialogplugin.cpp \
+ ../mocks/afmanager.cpp \
+ ../../src/tsdevicedialogplugin.cpp \
+ ../../src/tsdocumentloader.cpp \
+ ../../src/tstasksgrid.cpp \
+ ../../src/tsdevicedialogcontainer.cpp \
+ ../../src/tstasksgriditem.cpp \
+ ../../src/tsmodel.cpp \
+ ../../src/tsentrymodelitem.cpp \
+ ../../src/tsactivitymodelitem.cpp \
+ ../../src/tsnoitemslabel.cpp \
+
+RESOURCES += ../../tsdevicedialogplugin.qrc
+
+LIBS += -ltstaskmonitorclient
+
+symbian {
+ CONFIG += symbian_test
+ LIBS += -lxqsettingsmanager \
+ -lapgrfx \ # for RApaLsSession
+ -lapparc \ # for TApaAppInfo
+
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ MMP_RULES += "$${LITERAL_HASH}if defined(WINSCW)" \
+ "SECUREID 0x20022FC5" \
+ "$${LITERAL_HASH}endif"
+}
+
+INCLUDEPATH += ../../../../internal/tstestutils/inc
+LIBS += -ltstestutils
+
+include(../../../common.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdocumentloader/resource/test.docml Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="0.6">
+ <widget name="hbwidget" type="HbWidget"/>
+ <widget name="grid" type="TsTasksGrid"/>
+ <widget name="item" type="TsTasksGridItem"/>
+ <widget name="noitemslabel" type="TsNoItemsLabel"/>
+</hbdocument>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdocumentloader/t_tsdocumentloader.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2009 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_tsdocumentloader.h"
+
+#include <QtTest/QtTest>
+#include <QGraphicsWidget>
+
+#include "tsdocumentloader.h"
+
+void T_TsDocumentLoader::initTestCase()
+{
+ mDocumentLoader = new TsDocumentLoader();
+ bool ok(false);
+ mDocumentLoader->load(":/resource/test.docml", &ok);
+ QVERIFY(ok);
+}
+
+void T_TsDocumentLoader::cleanupTestCase()
+{
+ delete mDocumentLoader;
+ mDocumentLoader = NULL;
+}
+
+void T_TsDocumentLoader::taskGridIsCreated()
+{
+ QGraphicsWidget *grid = mDocumentLoader->findWidget("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->metaObject()->className(), "TsTasksGrid");
+}
+
+void T_TsDocumentLoader::taskSwitcherGridItemIsCreated()
+{
+ QGraphicsWidget *item = mDocumentLoader->findWidget("item");
+ QVERIFY(item);
+ QCOMPARE(item->metaObject()->className(), "TsTasksGridItem");
+}
+
+void T_TsDocumentLoader::noItemsLabelIsCreated()
+{
+ QGraphicsWidget *noItemsLabel = mDocumentLoader->findWidget("noitemslabel");
+ QVERIFY(noItemsLabel);
+ QCOMPARE(noItemsLabel->metaObject()->className(), "TsNoItemsLabel");
+}
+
+void T_TsDocumentLoader::baseClassIsUsedForOtherTypes()
+{
+ QGraphicsWidget *hbwidget = mDocumentLoader->findWidget("hbwidget");
+ QVERIFY(hbwidget);
+ QCOMPARE(hbwidget->metaObject()->className(), "HbWidget");
+}
+
+QTEST_MAIN(T_TsDocumentLoader)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdocumentloader/t_tsdocumentloader.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSDOCUMENTLOADER_H
+#define T_TSDOCUMENTLOADER_H
+
+#include <QObject>
+
+class TsDocumentLoader;
+
+/**
+* @test Test class for TsDocumentLoader
+*/
+class T_TsDocumentLoader : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void taskGridIsCreated();
+ void taskSwitcherGridItemIsCreated();
+ void noItemsLabelIsCreated();
+ void baseClassIsUsedForOtherTypes();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private:
+ TsDocumentLoader *mDocumentLoader;
+
+};
+
+#endif //T_TSDOCUMENTLOADER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdocumentloader/t_tsdocumentloader.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+CONFIG += hb testcase
+
+INCLUDEPATH += . \
+ ../../inc \
+
+HEADERS += t_tsdocumentloader.h \
+ ../../inc/tsdocumentloader.h \
+ ../../inc/tstasksgrid.h \
+ ../../inc/tstasksgriditem.h \
+ ../../inc/tsnoitemslabel.h \
+
+SOURCES += t_tsdocumentloader.cpp \
+ ../../src/tsdocumentloader.cpp \
+ ../../src/tstasksgrid.cpp \
+ ../../src/tstasksgriditem.cpp \
+ ../../src/tsnoitemslabel.cpp \
+
+RESOURCES += t_tsdocumentloader.qrc
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+}
+
+include(../../../common.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdocumentloader/t_tsdocumentloader.qrc Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="">
+ <file>resource/test.docml</file>
+ </qresource>
+</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsmodel/t_tsmodel.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,451 @@
+/*
+* Copyright (c) 2009 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_tsmodel.h"
+#include <qservicemanager.h>
+#include <QtTest/QtTest>
+#include "tsmodel.h"
+#include "afmanager.h"
+#include <afstorageglobals.h>
+#include "tstaskchangeinfo.h"
+
+#include <hbicon.h>
+
+#define TSTASKMONITOR_TEST 1
+
+const int dataSetsCount(50);
+const char serviceName [] = "TestActivityService";
+const char ActivityIconKeyword [] = "screenshot";
+const char ActivityVisibleKeyword [] = "visible";
+
+//TEST CASES
+
+void T_TsModel::testData()
+{
+ QVERIFY(mModel);
+ QVERIFY(activityService());
+ for (int dataSet(0); dataSet < activityDataSetsCount(); ++dataSet) {
+ QList<QVariantHash>data(activityDataSet(dataSet));
+ //provide test data to TestActivityManager
+ QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, data));
+ QList<TsTaskChange> applications(appDataSetFull(dataSet));
+ QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, applications));
+ //force data update on model. framework doesnt provide observer functionality
+ mModel->fullUpdate();
+
+ int offset =0;
+
+ //Verify data. Applications come first...
+
+ foreach ( TsTaskChange application, applications) {
+ if(application.first.changeType() == TsTaskChangeInfo::EChangeCancel ) {
+ continue;
+ }
+ QVERIFY(application.second->name() == mModel->data(mModel->index(offset), Qt::DisplayRole).toString());
+ //icon can't be realy checked, but can be called
+ mModel->data(mModel->index(offset), Qt::DecorationRole);
+ QVERIFY(application.second->isClosable() == mModel->data(mModel->index(offset), Qt::UserRole + 1).toBool());//is closable
+
+ QVERIFY(!mModel->data(mModel->index(offset), Qt::UserRole + 100).isValid());//call some unsupported role
+ ++offset;//move to next model row
+ }
+
+ //Activity come second
+ QList<QVariantHash>::const_iterator activity(data.begin());
+ for (; activity != data.end(); ++activity) {
+ QString debstr = mModel->data(mModel->index(offset), Qt::DisplayRole).toString();
+ QVERIFY(0>=mModel->data(mModel->index(offset), Qt::DisplayRole).toString().length());
+ //icon can't be realy checked, but can be called
+ mModel->data(mModel->index(offset), Qt::DecorationRole);
+ QVERIFY(!mModel->data(mModel->index(offset), Qt::UserRole + 1).toBool());//is closable
+
+ QVERIFY(!mModel->data(mModel->index(offset), Qt::UserRole + 100).isValid());//call some unsupported role
+ ++offset;//move to next model row
+ }
+ //call data out of range
+ QVERIFY(!mModel->data(mModel->index(-1), Qt::DisplayRole).isValid());
+ }
+}
+
+void T_TsModel::testRowCount()
+{
+ QVERIFY(mModel);
+ QVERIFY(activityService());
+ for (int dataSet(0); dataSet < activityDataSetsCount(); ++dataSet) {
+ QList<QVariantHash> activity(activityDataSet(dataSet));
+ //provide test data to TestActivityManager
+ QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, activity));
+
+
+ QList<TsTaskChange> applications(appDataSetFull(dataSet));
+ //provide test data to TestActivityManager
+ QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, applications));
+
+
+ //force data update on model. framework doesnt provide observer functionality
+ mModel->fullUpdate();
+ QVERIFY(mModel->rowCount() <= (activity.count() + applications.count()));
+ }
+}
+
+void T_TsModel::testOpenApplication()
+{
+ QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, activityDataSet(1)));
+ mModel->fullUpdate();
+ for (int i =0; i < mModel->rowCount(); ++i) {
+ mModel->openApplication(mModel->index(i));//just call without veryfication
+ }
+ mModel->openApplication(mModel->index(-1));//just call without veryfication
+
+}
+
+void T_TsModel::testCloseApplication()
+{
+ QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, activityDataSet(1)));
+ mModel->fullUpdate();
+ for (int i =0; i < mModel->rowCount(); ++i) {
+ mModel->closeApplication(mModel->index(i));//just call without veryfication
+ }
+ mModel->closeApplication(mModel->index(-1));//just call without veryfication
+}
+
+void T_TsModel::testActivityWithNoIdDisplaysProperApplicationName()
+{
+ // prepare activity entry with no activity ID, but with proper application name
+ QVariantHash activity;
+ RProcess process;
+ activity.insert(ActivityApplicationKeyword, static_cast<int>(process.SecureId().iId));
+
+ // prepare data set with only prepared activity
+ QVERIFY(QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, QList<QVariantHash>() << activity)));
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, QList<TsTaskChange>())));
+ mModel->fullUpdate();
+
+ // verify the application name is correctly returned as a DisplayRole
+ QCOMPARE(mModel->rowCount(), 1);
+ QVERIFY(mModel->index(0).isValid());
+ QVERIFY(!mModel->data(mModel->index(0), Qt::DisplayRole).toString().isEmpty());
+}
+
+void T_TsModel::testDataChangedSignalIsEmittedWhenActivityScreenshotIsUpdated()
+{
+ // prepare activity entry
+ QVariantHash activity;
+ activity.insert(ActivityIconKeyword, "FakeScreenshotPath");
+
+ // prepare data set with only prepared activity
+ QVERIFY(QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, QList<QVariantHash>() << activity)));
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, QList<TsTaskChange>())));
+ mModel->fullUpdate();
+
+ // prepare signal spy
+ qRegisterMetaType<QModelIndex>("QModelIndex");
+ QSignalSpy spy(mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+ QVERIFY(spy.isValid());
+
+ // getting the decoration role should trigger asynchronous screenshot retrieval and dataChanged signal emission
+ QCOMPARE(mModel->rowCount(), 1);
+ QVERIFY(mModel->index(0).isValid());
+ mModel->data(mModel->index(0), Qt::DecorationRole);
+
+ // verify proper data passed in signal
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.first().at(0).value<QModelIndex>().row(), 0);
+ QCOMPARE(spy.first().at(1).value<QModelIndex>().row(), 0);
+}
+
+void T_TsModel::testCustomNameIsUsedIfPresent()
+{
+ RProcess process;
+ int applicationId = static_cast<int>(process.SecureId().iId);
+
+ // prepare activity entries
+ QVariantHash activityWithCustomName;
+ activityWithCustomName.insert(ActivityApplicationName, "Custom Activity Name");
+ activityWithCustomName.insert(ActivityApplicationKeyword, applicationId);
+
+ QVariantHash otherActivity;
+ otherActivity.insert(ActivityApplicationKeyword, applicationId);
+
+ // prepare data set with only prepared activities
+ QVERIFY(QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, QList<QVariantHash>() << activityWithCustomName << otherActivity)));
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, QList<TsTaskChange>())));
+ mModel->fullUpdate();
+
+ // first activity uses custom name
+ QCOMPARE(mModel->rowCount(), 2);
+ QCOMPARE(mModel->data(mModel->index(0), Qt::DisplayRole), QVariant("Custom Activity Name"));
+
+ // second one didn't define custom name, so it uses application name
+ QVERIFY(!mModel->data(mModel->index(1), Qt::DisplayRole).toString().isEmpty());
+}
+
+void T_TsModel::testInsert1()
+{
+ QVERIFY(mModel);
+ clearModel();
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSet5New())));
+ QCOMPARE(mModel->rowCount(), 5);
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSetInsert1(3))));
+ QCOMPARE(mModel->rowCount(), 6);
+ QVERIFY(changeDataSetInsert1(3)[0].second->name() == mModel->data(mModel->index(3), Qt::DisplayRole).toString());
+
+}
+
+void T_TsModel::testDelete1()
+{
+ QVERIFY(mModel);
+ clearModel();
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSet5New())));
+ QCOMPARE(mModel->rowCount(), 5);
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSetDelete1(1))));
+ QCOMPARE(mModel->rowCount(), 4);
+ QCOMPARE(changeDataSet5New()[3].second->name(), mModel->data(mModel->index(1), Qt::DisplayRole).toString());
+}
+
+void T_TsModel::testChange1()
+{
+ QVERIFY(mModel);
+ clearModel();
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSet5New())));
+ QCOMPARE(mModel->rowCount(), 5);
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSetChange1(2))));
+ QCOMPARE(mModel->rowCount(), 5);
+ QCOMPARE(changeDataSetChange1(2)[0].second->name(), mModel->data(mModel->index(2), Qt::DisplayRole).toString());
+}
+
+void T_TsModel::testMove1()
+{
+ QVERIFY(mModel);
+ clearModel();
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSet5New())));
+ QCOMPARE(mModel->rowCount(), 5);
+ QVERIFY(QMetaObject::invokeMethod(mAppSrv,
+ "setTaskList",
+ Q_ARG(QList<TsTaskChange>, changeDataSetMove1(1,2))));
+ QCOMPARE(mModel->rowCount(), 5);
+ QCOMPARE(changeDataSet5New()[2].second->name(), mModel->data(mModel->index(2), Qt::DisplayRole).toString());
+ QCOMPARE(changeDataSet5New()[3].second->name(), mModel->data(mModel->index(1), Qt::DisplayRole).toString());
+}
+
+void T_TsModel::testFullUpdateFromActivities()
+{
+ QVERIFY(mModel);
+ QVERIFY(activityService());
+ clearModel();
+ QList<QVariantHash> activity(activityDataSet(5));
+ //provide test data to TestActivityManager
+ QMetaObject::invokeMethod(activityService(),
+ "setActivitiesList",
+ Q_ARG(QList<QVariantHash>, activity));
+ QMetaObject::invokeMethod(activityService(),
+ "emitDataChanged");
+ QCOMPARE(mModel->rowCount(), 5);
+}
+
+//QTEST CALLBACKS
+
+void T_TsModel::initTestCase()
+{
+ mAppSrv = new MockTsTaskMonitor();
+ mActSrv = new AfManager();
+ QVERIFY(mAppSrv);
+ QVERIFY(mActSrv);
+ mModel = new TsModel(*mAppSrv, *mActSrv);
+ QVERIFY(mModel);
+
+}
+
+void T_TsModel::cleanupTestCase()
+{
+ delete mModel;
+ mModel = 0;
+ delete mActSrv;
+ mActSrv = 0;
+ QtMobility::QServiceManager manager;
+ manager.removeService(serviceName);
+ delete mAppSrv;
+}
+
+// HELPER FUNCTIONS
+
+QObject *T_TsModel::activityService()
+{
+ return mActSrv;
+}
+
+QList<QVariantHash> T_TsModel::activityDataSet(int setId)const
+{
+ if (setId >100) {
+ setId = 0;
+ }
+ QList<QVariantHash> retVal;
+ QVariantHash node;
+ int visibility = 0;
+ for (int i =0; i < setId; ++i) {
+
+ //valid node
+ node.clear();
+ node.insert(ActivityApplicationKeyword, i+120);
+ node.insert(ActivityActivityKeyword, QString("testactivity%1").arg(i+120));
+ node.insert(ActivityIconKeyword, QString());
+ switch (visibility++) {
+ case 0://visible
+ node.insert(ActivityVisibleKeyword, true);
+ break;
+ case 1://invisible
+ node.insert(ActivityVisibleKeyword, false);
+ break;
+ default://empty
+ break;
+ };
+ if (2 < visibility) {
+ visibility = 0;
+ }
+ retVal.append(node);
+ }
+ return retVal;
+}
+
+QList<TsTaskChange> T_TsModel::appDataSetFull(int setId)
+{
+ if (setId >100) {
+ setId = 0;
+ }
+ QList<TsTaskChange> retVal;
+ TsTaskChangeInfo qtChangeItem(-2, -2);
+
+ retVal.append(TsTaskChange(qtChangeItem, QSharedPointer<TsTask>()));
+ for (int iter(0); iter < setId; ++iter) {
+ //valid node
+ qtChangeItem = TsTaskChangeInfo(iter, TsTaskChangeInfo::KInvalidOffset);
+ QSharedPointer<TsTask> node(new TsTask(new TsTaskContent(QString("testapplication%1").arg(iter), iter % 2, iter % 3), *this));
+ retVal.append(TsTaskChange(qtChangeItem, node));
+ }
+ return retVal;
+}
+
+QList<TsTaskChange> T_TsModel::changeDataSet5New()
+{
+ QList<TsTaskChange> retVal;
+ TsTaskChangeInfo qtChangeItem = TsTaskChangeInfo();
+ // 1 cancel item at start of full update
+ retVal.append(TsTaskChange(qtChangeItem, QSharedPointer<TsTask>()));
+ // now 5 new items and changesetitem set to insert
+ for (int iter(0); iter < 5; iter++) {
+ qtChangeItem = TsTaskChangeInfo(iter, TsTaskChangeInfo::KInvalidOffset);
+ QSharedPointer<TsTask> node(new TsTask(new TsTaskContent(QString("test %1").arg(iter+1), true, true), *this));
+ retVal.append(TsTaskChange(qtChangeItem, node));
+ }
+ return retVal;
+}
+
+QList<TsTaskChange> T_TsModel::changeDataSetDelete1(int index)
+{
+ QList<TsTaskChange> retVal;
+ TsTaskChangeInfo qtChangeItem(TsTaskChangeInfo::KInvalidOffset, index);
+
+ retVal.append(TsTaskChange(qtChangeItem, QSharedPointer<TsTask>()));
+
+ return retVal;
+}
+
+QList<TsTaskChange> T_TsModel::changeDataSetInsert1(int index)
+{
+ QList<TsTaskChange> retVal;
+ TsTaskChangeInfo qtChangeItem(index, TsTaskChangeInfo::KInvalidOffset);
+ QSharedPointer<TsTask> node(new TsTask(new TsTaskContent(QString("inserted %1").arg(index+1), true, true), *this));
+
+ retVal.append(TsTaskChange(qtChangeItem, node));
+
+ return retVal;
+}
+
+QList<TsTaskChange> T_TsModel::changeDataSetChange1(int index)
+{
+ QList<TsTaskChange> retVal;
+ TsTaskChangeInfo qtChangeItem(index, index);
+ QSharedPointer<TsTask> node(new TsTask(new TsTaskContent(QString("changed %1").arg(index+1), true, true), *this));
+
+ retVal.append(TsTaskChange(qtChangeItem, node));
+
+ return retVal;
+}
+
+QList<TsTaskChange> T_TsModel::changeDataSetMove1(int newIndex, int oldIndex)
+{
+ QList<TsTaskChange> retVal;
+ TsTaskChangeInfo qtChangeItem(newIndex, oldIndex);
+
+ retVal.append(TsTaskChange(qtChangeItem, QSharedPointer<TsTask>()));
+
+ return retVal;
+}
+
+int T_TsModel::activityDataSetsCount()const
+{
+ return dataSetsCount;
+}
+
+void T_TsModel::clearModel()
+{
+ QMetaObject::invokeMethod(mAppSrv,
+ "clearTasks");
+ QMetaObject::invokeMethod(activityService(),
+ "clearActivities");
+ mModel->fullUpdate();
+}
+
+QTEST_MAIN(T_TsModel)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsmodel/t_tsmodel.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSMODEL_H
+#define T_TSMODEL_H
+
+
+
+#include <QObject>
+#include <qlist.h>
+#include <QSharedPointer>
+#include <QVariant>
+#include <QModelIndex>
+
+#include "mocktstask.h"
+#include "mocktstaskmonitor.h"
+
+class TsModel;
+class TsTaskChangeInfo;
+
+/**
+* @test Test class for TsModel
+*/
+class T_TsModel : public QObject, public TsTaskLauncher
+{
+ Q_OBJECT
+
+private slots:
+ void testData();
+ void testRowCount();
+ void testOpenApplication();
+ void testCloseApplication();
+ void testActivityWithNoIdDisplaysProperApplicationName();
+ void testDataChangedSignalIsEmittedWhenActivityScreenshotIsUpdated();
+ void testCustomNameIsUsedIfPresent();
+ void testInsert1();
+ void testDelete1();
+ void testChange1();
+ void testMove1();
+ void testFullUpdateFromActivities();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private:
+ QObject *activityService();
+ QList<QVariantHash> activityDataSet(int)const;
+ QList<TsTaskChange> appDataSetFull(int);
+ QList<TsTaskChange> changeDataSet5New();
+ QList<TsTaskChange> changeDataSetDelete1(int index);
+ QList<TsTaskChange> changeDataSetInsert1(int index);
+ QList<TsTaskChange> changeDataSetChange1(int index);
+ QList<TsTaskChange> changeDataSetMove1(int newIndex, int oldIndex);
+ void clearModel();
+
+ int activityDataSetsCount()const;
+
+
+private:
+ TsModel *mModel;
+ TsTaskMonitor *mAppSrv;
+ QObject *mActSrv;
+};
+
+Q_DECLARE_METATYPE(QModelIndex)
+
+#endif //T_TSMODEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsmodel/t_tsmodel.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,59 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+CONFIG += hb testcase mobility
+MOBILITY = serviceframework
+
+INCLUDEPATH += . \
+ ../mocks \
+ ../../inc \
+ ../../../../inc \
+
+HEADERS += t_tsmodel.h \
+ ../../../../inc/tstaskmonitor.h \
+ ../../../../inc/tstaskchangeinfo.h \
+ ../mocks/afmanager.h \
+ ../mocks/mocktstaskmonitor.h \
+ ../mocks/mocktstask.h \
+ ../../inc/tsmodel.h \
+ ../../inc/tsmodelitem.h \
+ ../../inc/tsentrymodelitem.h \
+ ../../inc/tsactivitymodelitem.h
+
+SOURCES += t_tsmodel.cpp \
+ ../mocks/afmanager.cpp \
+ ../mocks/mocktstaskmonitor.cpp \
+ ../mocks/mocktstask.cpp \
+ ../../src/tsmodel.cpp \
+ ../../src/tsentrymodelitem.cpp \
+ ../../src/tsactivitymodelitem.cpp \
+ ../../../../taskswitcher/client/src/tstaskchangeinfo.cpp
+
+DEFINES += TSTASKMONITOR_TEST
+
+symbian {
+ CONFIG += symbian_test
+ LIBS += -lxqsettingsmanager
+
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+
+ LIBS += -lapgrfx -lapparc
+}
+
+include(../../../common.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tstaskgriditem/t_tstaskgriditem.cpp Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 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_tstaskgriditem.h"
+#include "tstasksgriditem.h"
+#include <hbabstractviewitem.h>
+#include <QtTest/QtTest>
+void T_TsTaskGridItem::testConstructor()
+{
+ QVERIFY(0!=mInstance);
+}
+
+void T_TsTaskGridItem::testCreateItem()
+{
+ HbAbstractViewItem *const instance = mInstance->createItem();
+ delete instance;
+ QVERIFY(0!=instance);
+}
+
+void T_TsTaskGridItem::testUpdateChildItems()
+{
+ HbAbstractViewItem *item = mInstance->createItem();
+ item->updateChildItems();
+ delete item;
+}
+
+void T_TsTaskGridItem::init()
+{
+ mInstance = new TsTasksGridItem();
+ QVERIFY(0!=mInstance);
+}
+
+void T_TsTaskGridItem::clean()
+{
+ delete mInstance;
+ mInstance = 0;
+}
+
+QTEST_MAIN(T_TsTaskGridItem)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tstaskgriditem/t_tstaskgriditem.h Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef T_TSTSAKGRIDITEM_H
+#define T_TSTSAKGRIDITEM_H
+
+#include <QObject>
+class TsTasksGridItem;
+/**
+* @test Test class for TsDeviceDialogPlugin
+*/
+class T_TsTaskGridItem : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testConstructor();
+ void testCreateItem();
+ void testUpdateChildItems();
+private slots:
+ void init();
+ void clean();
+private:
+ TsTasksGridItem *mInstance;
+};
+
+#endif //T_TSTSAKGRIDITEM_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/t_tstaskgriditem/t_tstaskgriditem.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = app
+CONFIG += hb testcase
+
+INCLUDEPATH += . \
+ ../../inc \
+
+HEADERS += t_tstaskgriditem.h \
+ ../../inc/tstasksgriditem.h \
+
+SOURCES += t_tstaskgriditem.cpp \
+ ../../src/tstasksgriditem.cpp \
+
+symbian {
+ CONFIG += symbian_test
+ coverage: CONFIG -= symbian_test
+ TARGET.EPOCSTACKSIZE = 0x14000 // 80kB
+ TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // 128kB - 16MB
+}
+
+include(../../../common.pri)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsdevicedialog/tsdevicedialogplugin/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+CONFIG += ordered
+
+SUBDIRS += ../../../internal/tstestutils
+
+SUBDIRS += t_tsdevicedialogplugin \
+ t_tsdocumentloader \
+ t_tsmodel \
+ t_tstaskgriditem \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/applib_cov.pl Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Symbian Foundation License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+
+#USAGE:
+# Usage: 101ctc.pl [-make=command]
+# -make=instrument || run || ctcpost
+
+# import module
+use Getopt::Long;
+use Cwd;
+
+# read options
+my $make = "all";
+my $success = GetOptions ("make=s" => \$make);
+
+if($make) {
+
+ if (($make eq "instrument") || ($make eq "all")) {
+
+ `for /R .. %i IN (mon.*) DO del %i`;
+ system("del profile.txt");
+ `for /D %f IN (CTC*) DO rmdir /S /Q %f`;
+
+ system("call qmake -config tests_applib -config coverage");
+ system("call sbs -c winscw_udeb reallyclean");
+ system("ctcwrap -i fd -2comp -C EXCLUDE+*\\internal\\*,*\\tsrc\\*,*\\moc_*.cpp,*\\qrc_*.cpp -C SOURCE_IDENTIFICATION=absolute sbs -c winscw_udeb");
+ }
+ if (($make eq "run") || ($make eq "all")) {
+ system("\\epoc32\\release\\winscw\\udeb\\cmdrunner.exe srvtests.txt");
+
+ }
+ if (($make eq "ctcpost") || ($make eq "all")) {
+ system("call ctcpost -ff -p profile.txt");
+ system("call ctc2html -nsb -i profile.txt -o CTCFUNCTION");
+ system("call del profile.txt");
+ system("call ctcpost -T 70 -fd -p profile.txt");
+ system("call ctc2html -t 70 -nsb -i profile.txt -o CTCDECISION");
+ }
+}
+
+print "END.\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/tsrc.pro Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,80 @@
+#
+# Copyright (c) 2009 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:
+#
+
+TEMPLATE = subdirs
+
+tests: {
+ CONFIG += tests_applib
+ CONFIG += tests_ts
+}
+
+tests_applib: {
+SUBDIRS += \
+ ./../contentstorage/castorage/tsrc/t_castorage \
+ ./../contentstorage/casoftwareregistry/tsrc/t_casoftwareregistry \
+ ./../contentstorage/casrv/caappscanner/tsrc/t_caappscanner \
+ ./../contentstorage/casrv/causifscanner/tsrc/t_causifscanner \
+ ./../contentstorage/casrv/calocalizerscanner/tsrc/t_calocalizerscanner \
+ ./../contentstorage/casrv/carunningappmonitor/tsrc/t_carunningappmonitor \
+ ./../contentstorage/casrv/casatmonitor/tsrc/t_satmonitor \
+ ./../contentstorage/casrv/cawidgetscanner/tsrc/t_cawidgetscanner \
+ ./../contentstorage/tsrc/t_casrv \
+ ./../contentstorage/tsrc/t_sathandler \
+ ./../contentstorage/caclient/tsrc/t_caclient \
+ ./../homescreensrv_plat/menu_sat_interface_api/tsrc/t_menu_sat_interface_api \
+ ./../contentstorage/cahandler/app/tsrc/t_caapphandler \
+ ./../contentstorage/cahandler/url/tsrc/t_caurlhandler \
+ ./../contentstorage/cahandler/tapp/tsrc/t_catapphandler \
+ ./../contentstorage/camificonengine/tsrc/t_camificonengine \
+
+}
+
+tests_ts: {
+SUBDIRS += ./../internal/tstestutils \ #common test utilities
+ ./../activityfw/activityserviceplugin/tsrc/unittest_activityserviceplugin \
+ ./../activityfw/activityserviceplugin/tsrc/unittest_activityclient \
+ ./../activityfw/activityserviceplugin/tsrc/unittest_activitymanager \
+ ./../activityfw/activityserviceplugin/tsrc/unittest_applicationluncher \
+ ./../activityfw/activityserviceplugin/tsrc/unittest_commandlineparser \
+ ./../activityfw/activityserviceplugin/tsrc/t_afstorageproxy \
+ ./../activityfw/activityserviceplugin/tsrc/t_afactivation \
+ ./../activityfw/activityserviceplugin/tsrc/t_afactivitystorage \
+ ./../activityfw/afactivitylauncher/tsrc/t_afactivitylauncher \
+ ./../activityfw/afactivitylauncher/tsrc/t_tapplicationlauncher \
+ ./../activityfw/storage/client/t_afstorageclient \
+ ./../activityfw/storage/server/tsrc/t_server \
+ ./../hsappkeyhandler/tsrc/t_hsappkeyhandler \
+ ./../activityfw/tsutils/tsrc/t_tsgraphicfilescalinghandler \
+ ./../taskswitcher/client/tsrc/t_tstasksettings \
+ ./../taskswitcher/client/tsrc/t_tstaskmonitorclient \
+ ./../taskswitcher/server/tsrc/t_tsmodelitem \
+ ./../taskswitcher/server/tsrc/t_tsstorage \
+ ./../taskswitcher/server/tsrc/t_tsserializeddataprovider \
+ ./../taskswitcher/server/tsrc/t_tsservicesprovider \
+ ./../taskswitcher/server/tsrc/t_tsservicesproviderconfig \
+ ./../taskswitcher/screenshotplugin/tsrc/t_screenshotplugin \
+ ./../taskswitcher/utils/tsrc/t_tsentrykeyhandling \
+ ./../taskswitcher/backstepping/tsrc/t_tsbackstepping \
+ ./../internal/tsapps/testapp/appwithouticon \ #helper app for unittest_applicationluncher, t_tsrunningappstorage, t_tsbackstepping, t_tstaskmonitorclient
+ ./../internal/tsapps/testapp/appwithicon \ #helper app for t_tsrunningappstorage, t_tsbackstepping
+ ./../internal/tsapps/testapp/apppublishingactivity \ #helper app for unittest_applicationluncher
+ ./../tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdevicedialogplugin \
+ ./../tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsdocumentloader \
+ ./../tsdevicedialog/tsdevicedialogplugin/tsrc/t_tsmodel \
+ ./../tsdevicedialog/tsdevicedialogplugin/tsrc/t_tstaskgriditem \
+
+}
+CONFIG += ordered