homescreenapp/hsdomainmodel/tsrc/t_hsdomainmodel/src/t_hsidlewidget.cpp
changeset 90 3ac3aaebaee5
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:  Tests for HsIdleState class.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "hsscene.h"
       
    19 #include "hsgui.h"
       
    20 #include "hspage.h"
       
    21 #include "hspageindicator.h"
       
    22 #include "hsconfiguration.h"
       
    23 #include "hsidlewidget.h"
       
    24 #include "t_hsdomainmodel.h"
       
    25 #include "hsdomainmodeldatastructures.h"
       
    26 
       
    27 void TestHsDomainModel::testIdleWidgetConstruction()
       
    28 {
       
    29     HsIdleWidget *iw = new HsIdleWidget();
       
    30     delete iw;
       
    31 }
       
    32 
       
    33 void TestHsDomainModel::testIdleWidgetSetGeometry()
       
    34 {
       
    35     HsIdleWidget *iw = new HsIdleWidget();
       
    36     
       
    37     iw->setGeometry(QRectF(0,0,100,100));
       
    38     HSCONFIGURATION_SET(setSceneType, HsConfiguration::SceneWallpaper);
       
    39     iw->setGeometry(QRectF(0,0,100,100));
       
    40     delete iw;    
       
    41     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
    42 }
       
    43 
       
    44 void TestHsDomainModel::testIdleWidgetSetSceneX()
       
    45 {
       
    46     HsIdleWidget *iw = new HsIdleWidget();
       
    47     iw->setSceneX(100);
       
    48     QVERIFY(iw->sceneX() == 100);
       
    49     
       
    50     HSCONFIGURATION_SET(setSceneType, HsConfiguration::SceneWallpaper);
       
    51     iw->setSceneX(200);
       
    52     QVERIFY(iw->sceneX() == 200);
       
    53     
       
    54     delete iw;    
       
    55     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
    56 }
       
    57 
       
    58 void TestHsDomainModel::testIdleWidgetSetActivePage()
       
    59 {
       
    60     HsIdleWidget *iw = new HsIdleWidget();
       
    61     iw->mPageIndicator->initialize(3, 2);
       
    62     iw->setActivePage(0);
       
    63     QCOMPARE(iw->mPageIndicator->activeItemIndex(), 0);
       
    64     delete iw;   
       
    65 }
       
    66 
       
    67 void TestHsDomainModel::testIdleWidgetInsertPage()
       
    68 {
       
    69     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
    70     HsIdleWidget *iw = new HsIdleWidget();
       
    71     HsPage *page = new HsPage();
       
    72     iw->insertPage(0, page);
       
    73     delete iw;
       
    74     HSCONFIGURATION_SET(setSceneType, HsConfiguration::SceneWallpaper);
       
    75     iw = new HsIdleWidget();
       
    76     page = new HsPage();
       
    77     iw->insertPage(0, page);
       
    78     delete iw;
       
    79     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
    80 }
       
    81 
       
    82 void TestHsDomainModel::testIdleWidgetRemovePage()
       
    83 {
       
    84     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
    85     HsIdleWidget *iw = new HsIdleWidget();
       
    86 
       
    87     HsPage *pageOne = new HsPage();
       
    88     HsPage *pageTwo = new HsPage();
       
    89 
       
    90     iw->insertPage(0, pageTwo);
       
    91     iw->insertPage(0, pageOne);
       
    92     iw->removePage(1);
       
    93     iw->removePage(0);
       
    94     delete iw;
       
    95     
       
    96     HSCONFIGURATION_SET(setSceneType, HsConfiguration::SceneWallpaper);
       
    97     iw = new HsIdleWidget();
       
    98 
       
    99     pageOne = new HsPage();
       
   100     pageTwo = new HsPage();
       
   101 
       
   102     iw->insertPage(0, pageTwo);
       
   103     iw->insertPage(0, pageOne);
       
   104     iw->removePage(1);
       
   105     iw->removePage(0);
       
   106     delete iw;
       
   107     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
   108 }
       
   109 
       
   110 void TestHsDomainModel::testIdleWidgetLayers()
       
   111 {
       
   112     HsIdleWidget *iw = new HsIdleWidget();
       
   113     iw->controlLayer();
       
   114     iw->pageLayer();
       
   115     iw->pageWallpaperLayer();
       
   116     iw->sceneLayer();
       
   117     delete iw;
       
   118 }
       
   119 
       
   120 void TestHsDomainModel::testIdleWidgetTrashbin()
       
   121 {
       
   122     HsIdleWidget *iw = new HsIdleWidget();
       
   123     iw->trashBin();
       
   124     delete iw;
       
   125 }
       
   126 
       
   127 void TestHsDomainModel::testIdleWidgetPageIndicator()
       
   128 {
       
   129     HsIdleWidget *iw = new HsIdleWidget();
       
   130     iw->pageIndicator();
       
   131     delete iw;
       
   132 }
       
   133 
       
   134 void TestHsDomainModel::testIdleWidgetParallaxFactor() 
       
   135 {
       
   136     HsIdleWidget *iw = new HsIdleWidget();
       
   137     
       
   138     // factor == 1 when page count < 2
       
   139     QCOMPARE( (int)iw->parallaxFactor(), 1);
       
   140     
       
   141     createSceneWithPages(3, 0);
       
   142     // factor must be != 0 when page count >= 2
       
   143     QVERIFY(iw->parallaxFactor());
       
   144     delete iw;
       
   145     destroySceneAndPages();
       
   146 }
       
   147 
       
   148 void TestHsDomainModel::testIdleWidgetShowTrashBin() 
       
   149 {
       
   150     HsIdleWidget *iw = new HsIdleWidget();
       
   151     iw->showTrashBin();
       
   152     delete iw;
       
   153 }
       
   154 
       
   155 void TestHsDomainModel::testIdleWidgetShowPageIndicator() 
       
   156 {
       
   157     HsIdleWidget *iw = new HsIdleWidget();
       
   158     iw->showPageIndicator();
       
   159     delete iw;
       
   160 }
       
   161 
       
   162 
       
   163 void TestHsDomainModel::testIdleWidgetShowSnapLines() 
       
   164 {
       
   165     HsIdleWidget *iw = new HsIdleWidget();
       
   166     QLineF verticalSnapLine(0,0,0,100);
       
   167     iw->showVerticalSnapLine(verticalSnapLine);
       
   168     QLineF horizontalSnapLine(0,0,100,0);
       
   169     iw->showHorizontalSnapLine(horizontalSnapLine);
       
   170     iw->hideVerticalSnapLine();
       
   171     iw->hideHorizontalSnapLine();
       
   172     delete iw;
       
   173 }
       
   174 
       
   175 void TestHsDomainModel::testIdleWidgetPolishEvent() 
       
   176 {
       
   177     HsIdleWidget *iw = new HsIdleWidget();
       
   178     iw->polishEvent();
       
   179     
       
   180     createSceneWithPages(3, 0);
       
   181     iw->polishEvent();
       
   182     HSCONFIGURATION_SET(setSceneType, HsConfiguration::SceneWallpaper);
       
   183     iw->polishEvent();
       
   184     HSCONFIGURATION_SET(setSceneType, HsConfiguration::PageWallpapers);
       
   185     
       
   186     delete iw;
       
   187     destroySceneAndPages();
       
   188 }