controlpanel/tsrc/unit/ut_cputility/src/ut_cputility.cpp
branchRCL_3
changeset 25 7e0eff37aedb
parent 24 8ee96d21d9bf
child 26 e78c61e77b1a
equal deleted inserted replaced
24:8ee96d21d9bf 25:7e0eff37aedb
     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 #include "ut_cputility.h"
       
    18 #include "cputility.h"
       
    19 
       
    20 #include <QtTest/QtTest>
       
    21 
       
    22 /*!
       
    23     \class TestCpUtility
       
    24     \brief This class is used for the unit test for class CpUtility.\n
       
    25       CpUtility class is an utility class to provide functionalities about drive and dir related processing.\n
       
    26       This unit test is supported by QTest.\n
       
    27       There are total 6 test cases in this unit.\n 
       
    28  */
       
    29 
       
    30 void TestCpUtility::initTestCase()
       
    31     {
       
    32     }
       
    33 
       
    34 void TestCpUtility::cleanupTestCase()
       
    35     {
       
    36     QCoreApplication::processEvents();
       
    37     }
       
    38 
       
    39 /*!
       
    40  * Test Case Description:\n &nbsp;
       
    41  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
    42       static CpUtility::drives();\n&nbsp;
       
    43             
       
    44    2. Function Descrition: \n &nbsp;&nbsp;
       
    45         Get and store driver letter into QStringList object, using QDir::drives().\n&nbsp;
       
    46    3. Input Parameters: none.\n&nbsp;&nbsp;
       
    47        
       
    48    4. Expected result: \n&nbsp;&nbsp;
       
    49        case run without verify failed.\n 
       
    50  */
       
    51 void TestCpUtility::testDrivesOnce()
       
    52     {
       
    53     QStringList strListDrives = CpUtility::drives();
       
    54     QVERIFY(!strListDrives.isEmpty());
       
    55     
       
    56     verifyDrivesList(strListDrives);
       
    57     }
       
    58 
       
    59 /*!
       
    60  * Test Case Description:\n &nbsp;
       
    61  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
    62       static CpUtility::drives();\n&nbsp;
       
    63             
       
    64    2. Function Descrition: \n &nbsp;&nbsp;
       
    65         Get and store driver letter into QStringList object, using QDir::drives().\n&nbsp;
       
    66    3. Input Parameters: none.\n&nbsp;&nbsp;
       
    67        
       
    68    4. Expected result: \n&nbsp;&nbsp;
       
    69        case run without verify failed.\n 
       
    70  */
       
    71 void TestCpUtility::testDrivesRepeatTwice()
       
    72     {
       
    73     QStringList strListDrives1 = CpUtility::drives();
       
    74     QVERIFY(!strListDrives1.isEmpty());
       
    75     
       
    76     verifyDrivesList(strListDrives1);
       
    77     
       
    78     QStringList strListDrives2 = CpUtility::drives();
       
    79     QVERIFY(!strListDrives2.isEmpty());
       
    80     
       
    81     verifyDrivesList(strListDrives2);
       
    82     }
       
    83 
       
    84 /*!
       
    85  * Test Case Description:\n &nbsp;
       
    86  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
    87       static CpUtility::pluginDirectories();\n&nbsp;
       
    88             
       
    89    2. Function Descrition: \n &nbsp;&nbsp;
       
    90         Get and store plugin directories into QStringList object.\n&nbsp;
       
    91    3. Input Parameters: none.\n&nbsp;&nbsp;
       
    92        
       
    93    4. Expected result: \n&nbsp;&nbsp;
       
    94        case run without verify failed.\n 
       
    95  */
       
    96 void TestCpUtility::testPluginDirectoriesOnce()
       
    97     {
       
    98     QStringList strListDirs = CpUtility::pluginDirectories();
       
    99     QVERIFY(!strListDirs.isEmpty());
       
   100     
       
   101     verifyDirectoriesList(strListDirs);
       
   102     }
       
   103 
       
   104 /*!
       
   105  * Test Case Description:\n &nbsp;
       
   106  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   107       static CpUtility::pluginDirectories();\n&nbsp;
       
   108             
       
   109    2. Function Descrition: \n &nbsp;&nbsp;
       
   110         Get and store plugin directories into QStringList object.\n&nbsp;
       
   111    3. Input Parameters: none.\n&nbsp;&nbsp;
       
   112        
       
   113    4. Expected result: \n&nbsp;&nbsp;
       
   114        case run without verify failed.\n 
       
   115  */
       
   116 void TestCpUtility::testPluginDirectoriesRepeatTwice()
       
   117     {
       
   118     QStringList strListDirs1 = CpUtility::pluginDirectories();
       
   119     QVERIFY(!strListDirs1.isEmpty());
       
   120     
       
   121     verifyDirectoriesList(strListDirs1);
       
   122     
       
   123     QStringList strListDirs2 = CpUtility::pluginDirectories();
       
   124     QVERIFY(!strListDirs2.isEmpty());
       
   125     
       
   126     verifyDirectoriesList(strListDirs2);
       
   127     }
       
   128 
       
   129 /*!
       
   130  * Test Case Description:\n &nbsp;
       
   131  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   132       static CpUtility::configFileDirectories();\n&nbsp;
       
   133             
       
   134    2. Function Descrition: \n &nbsp;&nbsp;
       
   135         Get and store cpcfg file directories into QStringList object.\n&nbsp;
       
   136    3. Input Parameters: none.\n&nbsp;&nbsp;
       
   137        
       
   138    4. Expected result: \n&nbsp;&nbsp;
       
   139        case run without verify failed.\n 
       
   140  */
       
   141 void TestCpUtility::testConfigFileDirectoriesOnce()
       
   142     {
       
   143     QStringList strListConfigDirs = CpUtility::configFileDirectories();
       
   144     QVERIFY(!strListConfigDirs.isEmpty());
       
   145     
       
   146     verifyConfigFileDirectories(strListConfigDirs);
       
   147     }
       
   148 
       
   149 /*!
       
   150  * Test Case Description:\n &nbsp;
       
   151  * 1. Fucntion Name: \n&nbsp;&nbsp;
       
   152       static CpUtility::configFileDirectories();\n&nbsp;
       
   153             
       
   154    2. Function Descrition: \n &nbsp;&nbsp;
       
   155         Get and store cpcfg file directories into QStringList object.\n&nbsp;
       
   156    3. Input Parameters: none.\n&nbsp;&nbsp;
       
   157        
       
   158    4. Expected result: \n&nbsp;&nbsp;
       
   159        case run without verify failed.\n 
       
   160  */
       
   161 void TestCpUtility::testConfigFileDirectoriesRepeatTwice()
       
   162     {
       
   163     QStringList strListConfigDirs1 = CpUtility::configFileDirectories();
       
   164     QVERIFY(!strListConfigDirs1.isEmpty());
       
   165     
       
   166     verifyConfigFileDirectories(strListConfigDirs1);
       
   167     
       
   168     QStringList strListConfigDirs2 = CpUtility::configFileDirectories();
       
   169     QVERIFY(!strListConfigDirs2.isEmpty());
       
   170     
       
   171     verifyConfigFileDirectories(strListConfigDirs2);
       
   172     }
       
   173 
       
   174 void TestCpUtility::verifyDrivesList(const QStringList &strList)
       
   175     {
       
   176     QVERIFY( strList.contains("C:", Qt::CaseInsensitive) );
       
   177     QVERIFY( strList.contains("Z:", Qt::CaseInsensitive) );
       
   178     }
       
   179 
       
   180 void TestCpUtility::verifyDirectoriesList(const QStringList &strList)
       
   181     {
       
   182     QVERIFY( strList.contains(QString("C:/resource/qt/plugins/controlpanel") + QDir::separator(), Qt::CaseInsensitive));
       
   183     }
       
   184 
       
   185 void TestCpUtility::verifyConfigFileDirectories(const QStringList &strList)
       
   186     {
       
   187     QVERIFY( strList.contains(QString("C:/resource/qt/plugins/controlpanel/config") + QDir::separator(), Qt::CaseInsensitive));
       
   188     }
       
   189 
       
   190 QTEST_APPLESS_MAIN(TestCpUtility)