controlpanel/tsrc/unit/ut_cpsettingformitemdata/src/ut_cpsettingformitemdata.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
       
     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 *       test application for qt control panel public apis.
       
    16 */
       
    17 
       
    18 #include "ut_cpsettingformitemdata.h"
       
    19 
       
    20 #include <cpsettingformitemdata.h>
       
    21 #include <QtTest/QtTest>
       
    22 
       
    23 /*!
       
    24     \class TestCpSettingFormItemData
       
    25     \brief This class is used for the unit test for class CpSettingFormItemData.\n
       
    26       CpSettingFormItemData class is derived from HbDataFormModelItem, customed model item for control panel.\n
       
    27       This unit test is supported by QTest.\n
       
    28       There are total 11 test cases in this unit.\n 
       
    29  */
       
    30 
       
    31 void TestCpSettingFormItemData::initTestCase()
       
    32     {
       
    33     }
       
    34 
       
    35 void TestCpSettingFormItemData::cleanupTestCase()
       
    36     {
       
    37     QCoreApplication::processEvents();
       
    38     }
       
    39 
       
    40 /*!
       
    41  * Test Case Description:\n &nbsp;
       
    42  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
    43       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
    44         const QString &label,
       
    45         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
    46             
       
    47    2. Function Descrition: \n &nbsp;&nbsp;
       
    48         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
    49    3. Input Parameters: \n&nbsp;&nbsp;
       
    50            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
    51            QString &label\n&nbsp;&nbsp;
       
    52            HbDataFormModelItem *parent\n&nbsp;
       
    53        
       
    54    4. Expected result: \n&nbsp;&nbsp;
       
    55        case run without verify failed.\n 
       
    56  */
       
    57 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeTextItem()
       
    58     {
       
    59     CpSettingFormItemData *pdata = new CpSettingFormItemData( HbDataFormModelItem::TextItem, "label" );
       
    60     QVERIFY( pdata !=0 );
       
    61     QVERIFY( pdata->type() == HbDataFormModelItem::TextItem );
       
    62     QVERIFY( pdata->label() == "label");
       
    63     
       
    64     delete pdata;
       
    65     }
       
    66 
       
    67 /*!
       
    68  * Test Case Description:\n &nbsp;
       
    69  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
    70       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
    71         const QString &label,
       
    72         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
    73             
       
    74    2. Function Descrition: \n &nbsp;&nbsp;
       
    75         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
    76    3. Input Parameters: \n&nbsp;&nbsp;
       
    77            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
    78            QString &label\n&nbsp;&nbsp;
       
    79            HbDataFormModelItem *parent\n&nbsp;
       
    80    4. Expected result: \n&nbsp;&nbsp;
       
    81        case run without verify failed.\n 
       
    82  */
       
    83 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeSliderItem()
       
    84     {
       
    85     CpSettingFormItemData *pdata = new CpSettingFormItemData( HbDataFormModelItem::SliderItem, "label" );
       
    86     QVERIFY( pdata !=0 );
       
    87     QVERIFY( pdata->type() == HbDataFormModelItem::SliderItem );
       
    88     QVERIFY( pdata->label() == "label");
       
    89     
       
    90     delete pdata;
       
    91     }
       
    92 
       
    93 /*!
       
    94  * Test Case Description:\n &nbsp;
       
    95  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
    96       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
    97         const QString &label,
       
    98         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
    99             
       
   100    2. Function Descrition: \n &nbsp;&nbsp;
       
   101         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   102    3. Input Parameters: \n&nbsp;&nbsp;
       
   103            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   104            QString &label\n&nbsp;&nbsp;
       
   105            HbDataFormModelItem *parent\n&nbsp;
       
   106    4. Expected result: \n&nbsp;&nbsp;
       
   107        case run without verify failed.\n 
       
   108  */
       
   109 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeVolumeSliderItem()
       
   110     {
       
   111     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::VolumeSliderItem, "label" );
       
   112     QVERIFY( pdata !=0 );
       
   113     QVERIFY( pdata->type() == HbDataFormModelItem::VolumeSliderItem );
       
   114     QVERIFY( pdata->label() == "label");
       
   115     
       
   116     delete pdata;
       
   117     }
       
   118 
       
   119 /*!
       
   120  * Test Case Description:\n &nbsp;
       
   121  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   122       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   123         const QString &label,
       
   124         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   125             
       
   126    2. Function Descrition: \n &nbsp;&nbsp;
       
   127         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   128    3. Input Parameters: \n&nbsp;&nbsp;
       
   129            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   130            QString &label\n&nbsp;&nbsp;
       
   131            HbDataFormModelItem *parent\n&nbsp;
       
   132    4. Expected result: \n&nbsp;&nbsp;
       
   133        case run without verify failed.\n 
       
   134  */
       
   135 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeCheckBoxItem()
       
   136     {
       
   137     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::CheckBoxItem, "label" );
       
   138     QVERIFY( pdata !=0 );
       
   139     QVERIFY( pdata->type() == HbDataFormModelItem::CheckBoxItem );
       
   140     QVERIFY( pdata->label() == "label");
       
   141     
       
   142     delete pdata;
       
   143     }
       
   144 
       
   145 /*!
       
   146  * Test Case Description:\n &nbsp;
       
   147  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   148       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   149         const QString &label,
       
   150         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   151             
       
   152    2. Function Descrition: \n &nbsp;&nbsp;
       
   153         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   154    3. Input Parameters: \n&nbsp;&nbsp;
       
   155            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   156            QString &label\n&nbsp;&nbsp;
       
   157            HbDataFormModelItem *parent\n&nbsp;
       
   158    4. Expected result: \n&nbsp;&nbsp;
       
   159        case run without verify failed.\n 
       
   160  */
       
   161 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeToggleValueItem()
       
   162     {
       
   163     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::ToggleValueItem, "label" );
       
   164     QVERIFY( pdata !=0 );
       
   165     QVERIFY( pdata->type() == HbDataFormModelItem::ToggleValueItem );
       
   166     QVERIFY( pdata->label() == "label");
       
   167     
       
   168     delete pdata;
       
   169     }
       
   170     
       
   171 /*!
       
   172  * Test Case Description:\n &nbsp;
       
   173  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   174       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   175         const QString &label,
       
   176         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   177             
       
   178    2. Function Descrition: \n &nbsp;&nbsp;
       
   179         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   180    3. Input Parameters: \n&nbsp;&nbsp;
       
   181            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   182            QString &label\n&nbsp;&nbsp;
       
   183            HbDataFormModelItem *parent\n&nbsp;
       
   184    4. Expected result: \n&nbsp;&nbsp;
       
   185        case run without verify failed.\n 
       
   186  */
       
   187 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeRadioButtonListItem()
       
   188     {
       
   189     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::RadioButtonListItem, "label" );
       
   190     QVERIFY( pdata !=0 );
       
   191     QVERIFY( pdata->type() == HbDataFormModelItem::RadioButtonListItem );
       
   192     QVERIFY( pdata->label() == "label");
       
   193     
       
   194     delete pdata;
       
   195     }
       
   196     
       
   197 /*!
       
   198  * Test Case Description:\n &nbsp;
       
   199  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   200       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   201         const QString &label,
       
   202         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   203             
       
   204    2. Function Descrition: \n &nbsp;&nbsp;
       
   205         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   206    3. Input Parameters: \n&nbsp;&nbsp;
       
   207            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   208            QString &label\n&nbsp;&nbsp;
       
   209            HbDataFormModelItem *parent\n&nbsp;
       
   210    4. Expected result: \n&nbsp;&nbsp;
       
   211        case run without verify failed.\n 
       
   212  */
       
   213 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeMultiselectionItem()
       
   214     {
       
   215     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::MultiselectionItem, "label" );
       
   216     QVERIFY( pdata !=0 );
       
   217     QVERIFY( pdata->type() == HbDataFormModelItem::MultiselectionItem );
       
   218     QVERIFY( pdata->label() == "label");
       
   219     
       
   220     delete pdata;
       
   221     }
       
   222     
       
   223 /*!
       
   224  * Test Case Description:\n &nbsp;
       
   225  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   226       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   227         const QString &label,
       
   228         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   229             
       
   230    2. Function Descrition: \n &nbsp;&nbsp;
       
   231         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   232    3. Input Parameters: \n&nbsp;&nbsp;
       
   233            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   234            QString &label\n&nbsp;&nbsp;
       
   235            HbDataFormModelItem *parent\n&nbsp;
       
   236    4. Expected result: \n&nbsp;&nbsp;
       
   237        case run without verify failed.\n 
       
   238  */
       
   239 void TestCpSettingFormItemData::testCpSettingFormItemDataWithTypeComboBoxItem()
       
   240     {
       
   241     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::ComboBoxItem, "label" );
       
   242     QVERIFY( pdata !=0 );
       
   243     QVERIFY( pdata->type() == HbDataFormModelItem::ComboBoxItem );
       
   244     QVERIFY( pdata->label() == "label");
       
   245     
       
   246     delete pdata;
       
   247     }
       
   248 
       
   249 /*!
       
   250  * Test Case Description:\n &nbsp;
       
   251  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   252       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   253         const QString &label,
       
   254         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   255             
       
   256    2. Function Descrition: \n &nbsp;&nbsp;
       
   257         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   258    3. Input Parameters: \n&nbsp;&nbsp;
       
   259            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   260            QString &label\n&nbsp;&nbsp;
       
   261            HbDataFormModelItem *parent\n&nbsp;
       
   262    4. Expected result: \n&nbsp;&nbsp;
       
   263        case run without verify failed.\n 
       
   264  */
       
   265 void TestCpSettingFormItemData::testCpSettingFormItemDataWithParent()
       
   266     {
       
   267     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::SliderItem, "parent", 0 );
       
   268     QVERIFY( pdata !=0 );
       
   269     QVERIFY( pdata->type() == HbDataFormModelItem::SliderItem );
       
   270 
       
   271     CpSettingFormItemData * cdata = new CpSettingFormItemData( HbDataFormModelItem::TextItem, "label", pdata);
       
   272     QVERIFY( cdata != 0 );
       
   273     QVERIFY( cdata->type() == HbDataFormModelItem::TextItem );
       
   274     
       
   275     delete pdata;
       
   276     }
       
   277 
       
   278 /*!
       
   279  * Test Case Description:\n &nbsp;
       
   280  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   281       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   282         const QString &label,
       
   283         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   284             
       
   285    2. Function Descrition: \n &nbsp;&nbsp;
       
   286         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   287    3. Input Parameters: \n&nbsp;&nbsp;
       
   288            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   289            QString &label\n&nbsp;&nbsp;
       
   290            HbDataFormModelItem *parent\n&nbsp;
       
   291    4. Expected result: \n&nbsp;&nbsp;
       
   292        case run without verify failed.\n 
       
   293  */
       
   294 void TestCpSettingFormItemData::testCpSettingFormItemDataNoParameter()
       
   295     {
       
   296     CpSettingFormItemData * pdata = new CpSettingFormItemData();
       
   297     QVERIFY( pdata !=0 );
       
   298     pdata->setType(HbDataFormModelItem::SliderItem);
       
   299     pdata->setLabel("label");
       
   300     
       
   301     QVERIFY( pdata->type() == HbDataFormModelItem::SliderItem );
       
   302     delete pdata;
       
   303     }
       
   304 
       
   305 /*!
       
   306  * Test Case Description:\n &nbsp;
       
   307  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   308       CpSettingFormItemData(HbDataFormModelItem::DataItemType type,
       
   309         const QString &label,
       
   310         const HbDataFormModelItem *parent = 0);\n&nbsp;
       
   311             
       
   312    2. Function Descrition: \n &nbsp;&nbsp;
       
   313         Construct a new CpSettingFormItemData with the given type,label and parent.\n&nbsp;
       
   314    3. Input Parameters: \n&nbsp;&nbsp;
       
   315            HbDataFormModelItem::DataItemType type\n&nbsp;&nbsp;
       
   316            QString &label\n&nbsp;&nbsp;
       
   317            HbDataFormModelItem *parent\n&nbsp;
       
   318    4. Expected result: \n&nbsp;&nbsp;
       
   319        case run without verify failed.\n 
       
   320  */
       
   321 void TestCpSettingFormItemData::testCpSettingFormItemDataWithParentNoType()
       
   322     {
       
   323     CpSettingFormItemData * pdata = new CpSettingFormItemData( HbDataFormModelItem::SliderItem, "parent", 0 );
       
   324     QVERIFY( pdata !=0 );
       
   325     QVERIFY( pdata->type() == HbDataFormModelItem::SliderItem );
       
   326 
       
   327     CpSettingFormItemData * cdata = new CpSettingFormItemData(pdata);
       
   328     QVERIFY( cdata != 0 );
       
   329     cdata->setType(HbDataFormModelItem::TextItem);
       
   330     QVERIFY( cdata->type() == HbDataFormModelItem::TextItem );
       
   331     
       
   332     delete pdata;
       
   333     }
       
   334 
       
   335 QTEST_APPLESS_MAIN(TestCpSettingFormItemData)