homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/src/t_hshomescreenclientplugin.cpp
changeset 36 cdae8c6c3876
child 39 4e8ebe173323
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hshomescreenclientplugin/tsrc/t_hshomescreenclientplugin/src/t_hshomescreenclientplugin.cpp	Fri Apr 16 14:54:01 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* 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:  Test class for hshomescreenclientplugin
+*
+*/
+
+#include "t_hshomescreenclientplugin.h"
+#include "hshomescreenclient.h"
+
+#include <xqservicerequest.h>
+
+#include <QSignalSpy>
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::initTestCase()
+{ 
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::cleanupTestCase()
+{
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::testConstruction()
+{
+    HsHomescreenClient *client = new HsHomescreenClient;
+    QVERIFY(client);
+    delete client;
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::testAddWidget()
+{  
+    HsHomescreenClient *client = new HsHomescreenClient;
+    
+    QSignalSpy requestFinishedSpy(client, SIGNAL(requestFinished()));
+    
+    // add invalid widget
+    QVariantHash preferences;
+    bool result = client->addWidget("invalidwidget", preferences);
+    
+    // but emit correct signals
+    connect(this, SIGNAL(onRequestCompletedTest(QVariant)), client, SLOT(onRequestCompleted(QVariant)));
+    emit onRequestCompletedTest(true);
+    
+    QVERIFY(requestFinishedSpy.count());
+    QVERIFY(client->mRequestResult);
+    
+    delete client;    
+}
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void HsHomescreenClientPluginTest::testAddInvalidWidget()
+{  
+    HsHomescreenClient *client = new HsHomescreenClient;
+    
+    QVariantHash preferences;
+    bool result = client->addWidget("invalidwidget", preferences);
+    
+    QVERIFY(!result);
+    QVERIFY(!client->mRequestResult);
+
+    delete client;
+}
+
+QTEST_MAIN(HsHomescreenClientPluginTest)