controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistmodel/unittest_cpthemelistmodel.cpp
branchRCL_3
changeset 14 5f281e37a2f5
parent 13 90fe62538f66
equal deleted inserted replaced
13:90fe62538f66 14:5f281e37a2f5
     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: XENT-MV
       
    13 *
       
    14 * Description:  unit tests for the CpThemeListModel class from themeplugin
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 
       
    20 #include "cpthemelistmodel.h"
       
    21 
       
    22 class TestCpThemeListModel : public QObject
       
    23 {
       
    24     Q_OBJECT
       
    25 
       
    26 private slots:
       
    27     
       
    28     void testConstructor();
       
    29     void testRowCount();
       
    30     void testData();
       
    31     void testIndexOf();
       
    32 };    
       
    33 
       
    34 
       
    35 void TestCpThemeListModel::testConstructor()
       
    36 {
       
    37     
       
    38     CpThemeListModel *obj = new CpThemeListModel();
       
    39     
       
    40     
       
    41     QVERIFY (obj != 0 );
       
    42     QVERIFY (obj->rowCount() > 0);
       
    43     
       
    44     delete obj;
       
    45 
       
    46 }
       
    47 
       
    48 void TestCpThemeListModel::testRowCount()
       
    49 {
       
    50     CpThemeListModel *themeModel = new CpThemeListModel();
       
    51     QList<QPair<QString, QString> > allThemes = CpThemeUtil::availableThemes();
       
    52     QVERIFY(themeModel->rowCount() >= allThemes.size());
       
    53 }
       
    54 
       
    55 void TestCpThemeListModel::testData()
       
    56 {
       
    57     CpThemeListModel *themeModel = new CpThemeListModel();
       
    58     QList<QPair<QString, QString> > allThemes = CpThemeUtil::availableThemes();
       
    59     
       
    60     QModelIndex index = themeModel->index(0,0, QModelIndex());
       
    61     
       
    62     //Check theme name (first) and theme path (second).  Skipping icons for now.
       
    63     QCOMPARE(themeModel->data(index, Qt::DisplayRole).toString(), allThemes.at(0).first);
       
    64     QCOMPARE(themeModel->data(index, CpThemeListModel::ItemDataRole).toString(), allThemes.at(0).second);
       
    65         
       
    66         
       
    67 }
       
    68 
       
    69 void TestCpThemeListModel::testIndexOf()
       
    70 {
       
    71     CpThemeListModel *themeModel = new CpThemeListModel();
       
    72     QList<QPair<QString, QString> > allThemes = CpThemeUtil::availableThemes();
       
    73     
       
    74     CpThemeInfo *themeInfo = CpThemeUtil::buildThemeInfo(allThemes.at(1).second, allThemes.at(1).first);
       
    75        
       
    76     int index = themeModel->indexOf(*themeInfo);
       
    77        
       
    78      QVERIFY(index == 1);
       
    79     
       
    80 }
       
    81 QTEST_MAIN(TestCpThemeListModel)
       
    82 #include "unittest_cpthemelistmodel.moc"
       
    83