controlpanelui/src/cpcategorymodel/tsrc/ut_cpcategorysettingformmodel/src/ut_cpcategorysettingformmodel.cpp
changeset 40 593f946f4fec
equal deleted inserted replaced
22:a5692c68d772 40:593f946f4fec
       
     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 cpcategorymodel functions.
       
    16 */
       
    17 
       
    18 #include "ut_cpcategorysettingformmodel.h"
       
    19 
       
    20 #include <QtTest/QtTest>
       
    21 #include <cpitemdatahelper.h>
       
    22 #include <hbdataformmodel.h>
       
    23 #include <hbdataformmodelitem.h>
       
    24 #include <HbView.h>
       
    25 //the class for test
       
    26 #include "cpcategorysettingformmodel.h"
       
    27 /*!
       
    28     \class TestCpCategorySettingFormModel 
       
    29     \brief describe the test case's goal, like: \n
       
    30       class name: cpcategorysettingformmodel \n
       
    31       class's description \n
       
    32       type of test case: unit test \n
       
    33       test cases' number totally: 2\n
       
    34  */
       
    35 
       
    36 void TestCpCategorySettingFormModel::initTestCase()
       
    37 {
       
    38     // initialize public test data here
       
    39 }
       
    40 
       
    41 /*!
       
    42      Test Case Description:\n 
       
    43      1. Fucntion Name:  explicit CpCategorySettingFormModel(const QString &configFile);\n
       
    44      2. Case Descrition: test the constructor function. \n
       
    45      3. Input Parameters: \n &nbsp;&nbsp;
       
    46       (1) configFile = QString("pluginfileforformmodel.cpcfg")\n &nbsp;&nbsp;
       
    47       (2) configFile = QString()\n
       
    48       (3) conFile = QString("invaildConfigFile")\n
       
    49 4. Expected result:  \n &nbsp;&nbsp;
       
    50     (1) no crash\n &nbsp;&nbsp;
       
    51     (2) no crash\n &nbsp;&nbsp;
       
    52     (3) no crash \n
       
    53  */
       
    54 void TestCpCategorySettingFormModel::testConstructor()
       
    55 {
       
    56     CpCategorySettingFormModel *testCategoryModel = new CpCategorySettingFormModel(QString("pluginfileforformmodel.cpcfg"));
       
    57     QVERIFY(testCategoryModel!=0);
       
    58     delete testCategoryModel;
       
    59     testCategoryModel = 0;
       
    60     testCategoryModel = new CpCategorySettingFormModel(QString());
       
    61     QVERIFY(testCategoryModel!=0);
       
    62     delete testCategoryModel;
       
    63     testCategoryModel = 0;
       
    64     testCategoryModel = new CpCategorySettingFormModel(QString("invaildConfigFile"));
       
    65     QVERIFY(testCategoryModel!=0);
       
    66     delete testCategoryModel;
       
    67     testCategoryModel = 0;
       
    68 }
       
    69 
       
    70 /*!
       
    71      Test Case Description: \n
       
    72      1. Fucntion Name:  virtual void initialize(CpItemDataHelper &itemDataHelper)\n
       
    73      2. Case Descrition: Verify that it can initialize the new categoryformmodel. \n
       
    74      3. Input Parameters: (1) itemDataHelper = CpItemDataHelper\n
       
    75      4. Expected result:  (1) no crash\n
       
    76  */
       
    77 void TestCpCategorySettingFormModel::testInit()
       
    78 {
       
    79     CpCategorySettingFormModel *testCategoryModel = new CpCategorySettingFormModel(QString("pluginfileforformmodel.cpcfg"));
       
    80     CpItemDataHelper *pHelper = new CpItemDataHelper();
       
    81     testCategoryModel->initialize(*pHelper);   
       
    82     // set mInitialized = TRUE
       
    83     testCategoryModel->initialize(*pHelper);    
       
    84     delete testCategoryModel;
       
    85     testCategoryModel = 0;
       
    86     delete pHelper;
       
    87     pHelper = 0;
       
    88 }
       
    89 
       
    90 /*!
       
    91     Release all the test data.
       
    92  */
       
    93 void TestCpCategorySettingFormModel::cleanupTestCase()
       
    94 {
       
    95     // release all test data
       
    96     QCoreApplication::processEvents();
       
    97 }
       
    98 
       
    99 QTEST_MAIN(TestCpCategorySettingFormModel)
       
   100 //QTEST_APPLESS_MAIN(TestCpCategorySettingFormModel)