mpx/mpxviewframeworkqt/tsrc/src/tst_mpxviewframework.cpp
changeset 64 92dbd2a406d9
equal deleted inserted replaced
61:3b098142db83 64:92dbd2a406d9
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtGui>
       
    19 #include <QtTest/QtTest>
       
    20 #include <QDebug>
       
    21 
       
    22 #include <hbview.h>
       
    23 
       
    24 #include <mpxviewpluginqt.h>
       
    25 #include <mpxviewframeworkqt.h>
       
    26 #include <xqpluginloader.h>
       
    27 
       
    28 class TestMpxViewFramework : public QObject
       
    29 {
       
    30     Q_OBJECT
       
    31 
       
    32 public:
       
    33     TestMpxViewFramework(): QObject(), fw(0) {};
       
    34 
       
    35 private slots:
       
    36 
       
    37     void initTestCase();
       
    38     void cleanupTestCase();
       
    39     
       
    40     void init();
       
    41     void cleanup();
       
    42     
       
    43     void testDryPluginViewInstance();
       
    44     
       
    45     void testMpxResolver();
       
    46     
       
    47 private:
       
    48     
       
    49     void testMpxPlugViewInstance(MpxViewPlugin *plugin);
       
    50 
       
    51 public:
       
    52     MpxViewFramework* fw;
       
    53 };
       
    54 
       
    55 void TestMpxViewFramework::initTestCase()
       
    56 {
       
    57 }
       
    58     
       
    59 void TestMpxViewFramework::cleanupTestCase()
       
    60 {
       
    61 }
       
    62 
       
    63 void TestMpxViewFramework::init()
       
    64 {
       
    65     fw = new MpxViewFramework();
       
    66     QVERIFY(fw != 0);
       
    67 }
       
    68     
       
    69 void TestMpxViewFramework::cleanup()
       
    70 {
       
    71     delete fw;
       
    72 }
       
    73 
       
    74 // = = Actual Tests = = 
       
    75 
       
    76 void TestMpxViewFramework::testDryPluginViewInstance()
       
    77 {
       
    78     // #1 instantiate it as real plugin
       
    79 
       
    80     QList<int> uidList;
       
    81     uidList << 0xE1253177 << 0xE1253178 << 0xE1253179;
       
    82     
       
    83     foreach (int uid, uidList) {
       
    84         XQPluginLoader pluginLoader(uid);
       
    85         QObject *objInstance = pluginLoader.instance();
       
    86         QVERIFY(objInstance != 0);
       
    87         
       
    88         MpxPluginViewInterface *interfaceInstance = qobject_cast<MpxPluginViewInterface*>(objInstance);
       
    89         QVERIFY(interfaceInstance != 0);
       
    90         
       
    91         MpxViewPlugin *plugView = interfaceInstance->viewPlugin();
       
    92         QVERIFY(plugView != 0);
       
    93         
       
    94         HbView *view = qobject_cast<HbView*>(plugView->getView());
       
    95         qDebug(view->title().toLatin1().data());
       
    96 
       
    97         pluginLoader.unload();
       
    98     }
       
    99     
       
   100 }
       
   101 
       
   102 void TestMpxViewFramework::testMpxResolver()
       
   103 {
       
   104     QList<int> uids;
       
   105     
       
   106     uids.append( 0x10000123 );
       
   107     uids.append( 0x30000001 );
       
   108     
       
   109     MpxViewPlugin *plugin = fw->resolvePlugin(uids);
       
   110     QVERIFY(plugin != 0);
       
   111 
       
   112     HbView *view = qobject_cast<HbView*>(plugin->getView());
       
   113     qDebug(view->title().toLatin1().data());
       
   114 
       
   115 }
       
   116 
       
   117 void TestMpxViewFramework::testMpxPlugViewInstance(MpxViewPlugin *plugin)
       
   118 {
       
   119     QVERIFY(plugin != 0);
       
   120     QGraphicsWidget *widget = plugin->getView();
       
   121     QVERIFY(widget != 0);
       
   122 }
       
   123 
       
   124 
       
   125 
       
   126 QTEST_MAIN(TestMpxViewFramework)
       
   127 
       
   128 #include "tst_mpxviewframework.moc"