controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemelistview/unittest_cpthemelistview.cpp
branchRCL_3
changeset 13 90fe62538f66
equal deleted inserted replaced
12:3fec62e6e7fc 13:90fe62538f66
       
     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 CpThemeControl class from themeplugin
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 #include <QGraphicsWidget>
       
    20 #include <QStandardItemModel>
       
    21 
       
    22 #include "cpthemelistview.h"
       
    23 
       
    24 class TestCpThemeListView : public QObject
       
    25 {
       
    26     Q_OBJECT
       
    27 
       
    28 private slots:
       
    29     void testConstructor();
       
    30     void testSetWidget();
       
    31     void testThemeList();
       
    32     void testSetModel();
       
    33     void testCloseView();
       
    34 };
       
    35 
       
    36 void TestCpThemeListView::testConstructor()
       
    37 {
       
    38     CpThemeListView* obj = new CpThemeListView();
       
    39     QVERIFY( obj != 0 );
       
    40     delete obj;
       
    41 }
       
    42 
       
    43 void TestCpThemeListView::testSetWidget()
       
    44 {
       
    45     CpThemeListView *listView = new CpThemeListView();
       
    46     QGraphicsWidget *testWidget = new QGraphicsWidget();
       
    47 
       
    48     listView->setWidget(testWidget);
       
    49 
       
    50     QVERIFY( listView->widget() == testWidget);
       
    51 
       
    52     delete testWidget;
       
    53     delete listView;
       
    54 }
       
    55 
       
    56 void TestCpThemeListView::testThemeList()
       
    57 {
       
    58     CpThemeListView *listView = new CpThemeListView();
       
    59 
       
    60     QVERIFY( listView->themeList() != 0 );
       
    61 
       
    62     delete listView;
       
    63 }
       
    64 
       
    65 void TestCpThemeListView::testSetModel()
       
    66 {
       
    67     CpThemeListView *listView = new CpThemeListView();
       
    68     QStandardItemModel *model = new QStandardItemModel(this);
       
    69 
       
    70     listView->setModel(model);
       
    71     QVERIFY(listView->themeList()->model() == model);
       
    72 
       
    73     // model shouldn't be deleted because it is a QObject with a parent.
       
    74 
       
    75     delete listView;
       
    76 }
       
    77 
       
    78 // null test
       
    79 void TestCpThemeListView::testCloseView()
       
    80 {
       
    81     CpThemeListView *listView = new CpThemeListView();
       
    82 
       
    83     listView->closeView();
       
    84 
       
    85     delete listView;
       
    86 }
       
    87 
       
    88 
       
    89 
       
    90 QTEST_MAIN(TestCpThemeListView)
       
    91 #include "unittest_cpthemelistview.moc"