homescreenapp/stateplugins/hshomescreenstateplugin/tsrc/t_hshomescreenstateplugin/src/t_hshomescreenmain.cpp
changeset 90 3ac3aaebaee5
child 101 ba1b7e218624
equal deleted inserted replaced
86:e4f038c420f7 90:3ac3aaebaee5
       
     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:  Main test class for hsHomeScreenStatePlugin library.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QMetaType>
       
    19 #include <QAction>
       
    20 #include <QState>
       
    21 
       
    22 #include <HbMainWindow>
       
    23 #include <HbInstance>
       
    24 #include <HbView>
       
    25 
       
    26 #include "t_hshomescreenstateplugin.h"
       
    27 #include "hshomescreenstateplugin.h"
       
    28 #include "testwidget.h"
       
    29 #include "hsdatabase.h"
       
    30 #include "hsscene.h"
       
    31 #include "hsgui.h"
       
    32 #include "hswidgethost.h"
       
    33 #include "hsdomainmodeldatastructures.h"
       
    34 #include "hsconfiguration.h"
       
    35 
       
    36 #include "hswidgetpositioningonorientationchange.h"
       
    37 #include "hswidgetpositioningonwidgetadd.h"
       
    38 #include "hswidgetpositioningonwidgetmove.h"
       
    39 
       
    40 #ifdef Q_OS_SYMBIAN
       
    41 #include <e32base.h>
       
    42 #endif
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void HomeScreenStatePluginTest::initTestCase()
       
    49 {
       
    50     mMainWindow = 0;
       
    51 
       
    52 #ifdef Q_OS_SYMBIAN
       
    53     mImageProcessingDelay = 5000;
       
    54 #else
       
    55     mImageProcessingDelay = 2000;
       
    56 #endif
       
    57 
       
    58     HsWidgetPositioningOnOrientationChange::setInstance(
       
    59         new HsAdvancedWidgetPositioningOnOrientationChange);
       
    60 
       
    61     HsWidgetPositioningOnWidgetAdd::setInstance(
       
    62         new HsAnchorPointInBottomRight);
       
    63 
       
    64     HsWidgetPositioningOnWidgetMove::setInstance(new HsSnapToLines);
       
    65 
       
    66     HsDatabase::setInstance(new HsDatabase);
       
    67 
       
    68     HsConfiguration::setInstance(new HsConfiguration);
       
    69    
       
    70 }
       
    71 
       
    72 void HomeScreenStatePluginTest::cleanupTestCase()
       
    73 {
       
    74     
       
    75 }
       
    76 
       
    77 void HomeScreenStatePluginTest::cleanup()
       
    78 {
       
    79     //Scene already deleted as child of mainwindow
       
    80     HsScene *scene = HsScene::takeInstance();
       
    81     delete scene;
       
    82 }
       
    83 
       
    84 void HomeScreenStatePluginTest::init()
       
    85 {
       
    86 
       
    87 }
       
    88 
       
    89 void HomeScreenStatePluginTest::createSceneAndWindow(int pageCount, int defaultPageIndex, int maximumPageCount)
       
    90 {
       
    91     HSCONFIGURATION_SET(setMaximumPageCount, maximumPageCount);
       
    92 
       
    93     HbInstance::instance();
       
    94     mMainWindow = new HbMainWindow;
       
    95     mMainWindow->move(0, 0);
       
    96     mMainWindow->show();
       
    97     
       
    98     QEventLoop waitUntilMainWindowCreated;
       
    99     QTimer eventLoopTimer;
       
   100     eventLoopTimer.setInterval(15000);
       
   101     eventLoopTimer.setSingleShot(true);
       
   102     connect(mMainWindow, SIGNAL(viewReady()),
       
   103             &waitUntilMainWindowCreated, SLOT(quit()));
       
   104     connect(&eventLoopTimer, SIGNAL(timeout()), 
       
   105             &waitUntilMainWindowCreated, SLOT(quit()));
       
   106     eventLoopTimer.start();
       
   107     waitUntilMainWindowCreated.exec();
       
   108     eventLoopTimer.stop();
       
   109 
       
   110     HsScene *scene = HsScene::instance();
       
   111     scene->setProperty("pageCount", pageCount);
       
   112     scene->setProperty("defaultPageIndex", defaultPageIndex);
       
   113     scene->setProperty("maximumPageCount", maximumPageCount);
       
   114     scene->load();
       
   115 }
       
   116 
       
   117 void HomeScreenStatePluginTest::deleteSceneAndWindow()
       
   118 {
       
   119     delete mMainWindow;
       
   120     mMainWindow = 0;
       
   121     delete HsGui::takeInstance();
       
   122 }
       
   123 
       
   124 #ifdef Q_OS_SYMBIAN
       
   125 //QTEST_MAIN corrected since crashes if TRAP not in correct place.
       
   126 //Will be corrected in later (estimate 4.6.0) Qt release for Symbian.
       
   127 int main(int argc, char *argv[])
       
   128 {
       
   129     QApplication app(argc, argv);
       
   130     int error = 0;
       
   131     TRAPD(err, \
       
   132     QTEST_DISABLE_KEYPAD_NAVIGATION \
       
   133     HomeScreenStatePluginTest tc; \
       
   134     error = QTest::qExec(&tc, argc, argv););
       
   135     Q_UNUSED(err);
       
   136     return error;
       
   137 }
       
   138 #else //Q_OS_SYMBIAN
       
   139 QTEST_MAIN(HomeScreenStatePluginTest)
       
   140 #endif //Q_OS_SYMBIAN