filemanager/tsrc/unit/ut_fminternalfmutils/src/ut_fminternalfmutils.cpp
changeset 47 12b82dc0e8db
child 49 81668a704644
equal deleted inserted replaced
40:4167eb56f30d 47:12b82dc0e8db
       
     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 the file manager internal apis.
       
    16 */
       
    17 
       
    18 #include "ut_fminternalfmutils.h"
       
    19 #include "fmutils.h"
       
    20 #include "fmdrivemodel.h"
       
    21 #include <QtTest/QtTest>
       
    22 #include <qdir.h>
       
    23 #include <qdebug.h>
       
    24 #include <hbglobal.h>
       
    25 
       
    26 /*!
       
    27     \class TestFmInternalFmUtils
       
    28     \brief \n
       
    29       class name:  FmDriveModel \n
       
    30       class's description: Test the File Manager internal api functions. \n
       
    31       type of test case: unit test\n 
       
    32       test cases' number totally: 63 \n
       
    33  */
       
    34 
       
    35 /*!
       
    36      Description of test data 
       
    37  */
       
    38 void TestFmInternalFmUtils::initTestCase()
       
    39 {
       
    40     QString lang = QLocale::system().name(); 
       
    41     QString path = "z:/resource/qt/translations/"; 
       
    42     mTranslator.load( path + "filemanager_" + lang );
       
    43     qApp->installTranslator(&mTranslator);
       
    44     
       
    45     // init the path of test data.
       
    46     mFilePath = Drive_C + QString("data") + QDir::separator() + QString("resource") + QDir::separator() + QString( "fmtestdata" ) + QDir::separator();
       
    47     // get all the drives
       
    48     QFileInfoList fileInfoList = QDir::drives();
       
    49     foreach(const QFileInfo &fileInfo,fileInfoList) {
       
    50         QString str = fileInfo.filePath();
       
    51         if (str.length() > 2) {
       
    52             str = str.left(3);
       
    53         }
       
    54         // append the drives to mDrives1 which drive type is USB or Memory card.
       
    55         FmDriverInfo driverInfo = FmUtils::queryDriverInfo( str );
       
    56         FmDriverInfo::DriveType driveType = driverInfo.driveType();
       
    57         if( driveType == FmDriverInfo::EDriveTypeMemoryCard || 
       
    58             driveType == FmDriverInfo::EDriveTypeUsbMemory){ 
       
    59             mDrives1.append(str);
       
    60             mDrives.append(str);
       
    61         }else{
       
    62             mDrives2.append(str);
       
    63             mDrives.append(str);
       
    64         }
       
    65     }
       
    66     qDebug() << mDrives;
       
    67     qDebug() << mDrives1;
       
    68     qDebug() << mDrives2;
       
    69 }
       
    70 
       
    71 /*!
       
    72      Test Case Description:\n 
       
    73      1. Fucntion Name: \n &nbsp;&nbsp;
       
    74         static QString getDriveNameFromPath( const QString &path ); \n &nbsp;&nbsp;
       
    75         static QString fillPathWithSplash( const QString &filePath ); \n
       
    76      2. Case Descrition: verify that it return the right drive name. \n
       
    77      3. Input Parameters:  \n &nbsp;&nbsp;
       
    78         <1> strpath = QString() \n &nbsp;&nbsp;
       
    79         <2> strpath = QString(XX) [XX.length() < 3] \n &nbsp;&nbsp;
       
    80         <3> strpath = QString(XX) [XX.length() >= 3] \n &nbsp;&nbsp;
       
    81      4. Expected result: \n &nbsp;&nbsp;
       
    82         <1> retPath = QString() \n &nbsp;&nbsp;
       
    83         <2> retPath = QString() \n &nbsp;&nbsp;
       
    84         <3> retPath = checkpath.left(3) \n 
       
    85  */
       
    86 void TestFmInternalFmUtils::testGetDriveNameFromPath()
       
    87 {
       
    88     QString strPath1 = "C";
       
    89     QString strPath2 = "D:\\dir\\subdir";
       
    90     QString strPath3 = "T:/dir/subdir";
       
    91     QString strPath4 = "pathwithoutLetter";
       
    92     QString strPath5 = "C:";
       
    93     QString strPath6 = "C:\\";
       
    94     // path = QString().
       
    95     QString retDriveName1 = FmUtils::getDriveNameFromPath(QString());
       
    96     QVERIFY(retDriveName1.isEmpty());
       
    97     // path1.length() < 3
       
    98     QString retDriveName2 = FmUtils::getDriveNameFromPath(strPath1);
       
    99     QVERIFY(retDriveName2.isEmpty());
       
   100     // path1.length() >= 3
       
   101     QString retDriveName3 = FmUtils::getDriveNameFromPath(strPath2);
       
   102     QVERIFY(retDriveName3 == QString("D:") + QDir::separator());
       
   103     
       
   104     QString retDriveName4 = FmUtils::getDriveNameFromPath(strPath3);
       
   105     QVERIFY(retDriveName4 == QString("T:") + QDir::separator());
       
   106     
       
   107     QString retDriveName5 = FmUtils::getDriveNameFromPath(strPath5);
       
   108     QVERIFY(retDriveName5 == QString("C:") + QDir::separator());
       
   109     
       
   110     QString retDriveName6 = FmUtils::getDriveNameFromPath(strPath6);
       
   111     QVERIFY(retDriveName6 == QString("C:") + QDir::separator());
       
   112 }
       
   113 
       
   114 /*!
       
   115      Test Case Description:\n 
       
   116      1. Fucntion Name: \n &nbsp;&nbsp;
       
   117         static QString getDriveLetterFromPath( const QString &path ); \n &nbsp;&nbsp;
       
   118      2. Case Descrition: verify that it return the right first drive letter. \n
       
   119      3. Input Parameters:  \n &nbsp;&nbsp;
       
   120         <1> strpath = QString(XX) [XX.length() < 2] \n &nbsp;&nbsp;
       
   121         <2> strpath = QString(XX) [XX.length() >= 2] \n 
       
   122      4. Expected result: \n &nbsp;&nbsp;
       
   123         <1> retPath = QString() \n &nbsp;&nbsp;
       
   124         <2> retPath = strPath.left(1) \n &nbsp;&nbsp;
       
   125  */
       
   126 void TestFmInternalFmUtils::testGetDriveLetterFromPath()
       
   127 {
       
   128     QString strPath1 = "C";
       
   129     QString strPath2 = "X:\\dir\\subdir";
       
   130     // path = QString().
       
   131     QString retDriveName1 = FmUtils::getDriveLetterFromPath(QString());
       
   132     QVERIFY(retDriveName1.isEmpty());
       
   133     // path1.length() < 2
       
   134     QString retDriveName2 = FmUtils::getDriveLetterFromPath(strPath1);
       
   135     QVERIFY(retDriveName2.isEmpty());
       
   136     // path1.length() >= 2
       
   137     QString retDriveName3 = FmUtils::getDriveLetterFromPath(strPath2);
       
   138     QVERIFY(retDriveName3 == QString("X"));
       
   139 }
       
   140 
       
   141 /*!
       
   142      Test Case Description:\n 
       
   143      1. Fucntion Name: \n &nbsp;&nbsp;
       
   144         static QString formatStorageSize( quint64 size ); \n &nbsp;&nbsp;
       
   145      2. Case Descrition: verify that it return the correct storage size. \n
       
   146      3. Input Parameters:  \n &nbsp;&nbsp;
       
   147         <1> size = Q_UINT64_C( 555 ) \n &nbsp;&nbsp;
       
   148         <2> size = Q_UINT64_C( 1024 ) \n &nbsp;&nbsp;
       
   149         <3> size = Q_UINT64_C( 1200000 ) \n &nbsp;&nbsp;
       
   150         <4> size = Q_UINT64_C( 1000*1000*1000 + 1024 ) \n &nbsp;&nbsp;
       
   151         <5> size = Q_UINT64_C( -5 ) \n
       
   152      4. Expected result: \n &nbsp;&nbsp;
       
   153         <1> retSize = QString( "555 B" ) \n &nbsp;&nbsp;
       
   154         <2> retSize = QString( "1.00 KB" ) \n &nbsp;&nbsp;
       
   155         <3> retSize = QString( "1.1 MB" ) \n &nbsp;&nbsp;
       
   156         <4> retSize = QString( "0.9 GB" ) \n &nbsp;&nbsp;
       
   157         <5> no crash. \n
       
   158  */
       
   159 void TestFmInternalFmUtils::testFormatStorageSize()
       
   160 {
       
   161     quint64 size1 = Q_UINT64_C(555);
       
   162 //    quint64 sizetemp = Q_UINT64_C(1000);
       
   163     quint64 size2 = Q_UINT64_C( 1024 );
       
   164     quint64 size3 = Q_UINT64_C( 1200000 );
       
   165     quint64 size4 = Q_UINT64_C( 1000*1000*1000 + 1024 );
       
   166 #ifdef BUG_TO_BE_FIX
       
   167     quint64 sizeInvalid = Q_UINT64_C( -5 );
       
   168 #endif
       
   169 //    X < 1000
       
   170     QString retSize1 = FmUtils::formatStorageSize(size1);
       
   171     QVERIFY( retSize1 == QString::number(size1) + QString(" B") );
       
   172 //    1000 < X < 1000*1000 
       
   173     QString retSize2 = FmUtils::formatStorageSize(size2);
       
   174     QVERIFY( retSize2 == QString::number( size2 / 1024.0, 'f', 2 ) + " KB" );
       
   175 //   1000*1000 < X < 1000*1000*1000 
       
   176      QString retSize3 = FmUtils::formatStorageSize(size3);
       
   177     QVERIFY( retSize3 == QString::number( size3 / (1024.0 * 1024.0), 'f', 1 ) + " MB" );
       
   178 //    X > 1000*1000*1000
       
   179      QString retSize4 = FmUtils::formatStorageSize(size4);
       
   180     QVERIFY( retSize4 == QString::number( size4 / ( 1024.0 * 1024.0 * 1024.0 ), 'f', 1 ) + " GB" );     
       
   181 
       
   182 #ifdef BUG_TO_BE_FIX
       
   183      QString retSize5 = FmUtils::formatStorageSize(sizeInvalid);
       
   184      qDebug()<<retSize5;
       
   185 #endif
       
   186 }
       
   187 
       
   188 /*!
       
   189      Test Case Description:\n 
       
   190      1. Fucntion Name: \n &nbsp;&nbsp;
       
   191         static bool     isDrive( const QString &path ); \n &nbsp;&nbsp;
       
   192      2. Case Descrition: verify it is a drive with correct path. \n
       
   193      3. Input Parameters:  \n &nbsp;&nbsp;
       
   194         <1> driverName = "C:\" \n
       
   195      4. Expected result: \n &nbsp;&nbsp;
       
   196         <1> retResult = true \n
       
   197  */
       
   198 void TestFmInternalFmUtils::testIsDriveYes()
       
   199 {
       
   200     bool retResult = FmUtils::isDrive("C:/");
       
   201     QVERIFY( retResult == true );
       
   202 }
       
   203 
       
   204 /*!
       
   205      Test Case Description:\n 
       
   206      1. Fucntion Name: \n &nbsp;&nbsp;
       
   207         static bool     isDrive( const QString &path ); \n &nbsp;&nbsp;
       
   208      2. Case Descrition: verify it is not a drive with wrong path. \n
       
   209      3. Input Parameters:  \n &nbsp;&nbsp;
       
   210         <1> driverName = "C" \n &nbsp;&nbsp;
       
   211         <2> driverName = "D:\path" \n
       
   212      4. Expected result: \n &nbsp;&nbsp;
       
   213         <1> retResult = false \n &nbsp;&nbsp;
       
   214         <2> retResult = false \n
       
   215  */
       
   216 void TestFmInternalFmUtils::testIsDriveNo()
       
   217 {
       
   218     bool retResult1 = FmUtils::isDrive("C");
       
   219     QVERIFY( retResult1 == false );
       
   220     
       
   221     bool retResult2 = FmUtils::isDrive("D:\\path");
       
   222     QVERIFY( retResult2 == false );
       
   223 }
       
   224 
       
   225 /*!
       
   226      Test Case Description:\n 
       
   227      1. Fucntion Name: \n &nbsp;&nbsp;
       
   228         static QString  formatPath( const QString &path  ); \n &nbsp;&nbsp;
       
   229      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   230      3. Input Parameters:  \n &nbsp;&nbsp;
       
   231         <1> path = QString() \n 
       
   232      4. Expected result: \n &nbsp;&nbsp;
       
   233         <1> retPath = QString() \n 
       
   234  */
       
   235 void TestFmInternalFmUtils::testFormatPathWithEmptyPath()
       
   236 {
       
   237     QString retPath = FmUtils::formatPath(QString());
       
   238     QVERIFY( retPath.isEmpty() );
       
   239 }
       
   240 
       
   241 /*!
       
   242      Test Case Description:\n 
       
   243      1. Fucntion Name: \n &nbsp;&nbsp;
       
   244         static QString  formatPath( const QString &path  ); \n &nbsp;&nbsp;
       
   245      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   246      3. Input Parameters:  \n &nbsp;&nbsp;
       
   247         <1> path = QString("C:\\path1\\subpath") \n &nbsp;&nbsp;
       
   248         <2> path = QString("C:/path2/subpath") \n
       
   249      4. Expected result: \n &nbsp;&nbsp;
       
   250         <1> retPath = QString("C:")+QDir::QDir::separator()+QString("path1")+QDir::separator()+QString("subpath") \n &nbsp;&nbsp;
       
   251         <2> retPath = QString("C:")+QDir::QDir::separator()+QString("path2")+QDir::separator()+QString("subpath") \n
       
   252  */
       
   253 void TestFmInternalFmUtils::testFormatPath()
       
   254 {
       
   255     QString retPath1 = FmUtils::formatPath("C:\\path1\\subpath");
       
   256     QVERIFY( retPath1 == QString("C:") + QDir::separator() +QString("path1") +QDir::separator() + QString("subpath") );
       
   257     
       
   258     QString retPath2 = FmUtils::formatPath("C:/path2/subpath");
       
   259     QVERIFY( retPath2 == QString("C:")+ QDir::separator()+QString("path2")+ QDir::separator()+QString("subpath") );
       
   260 }
       
   261 
       
   262 /*!
       
   263      Test Case Description:\n 
       
   264      1. Fucntion Name: \n &nbsp;&nbsp;
       
   265         static QString  fillPathWithSplash( const QString &filePath ); \n &nbsp;&nbsp;
       
   266      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   267      3. Input Parameters:  \n &nbsp;&nbsp;
       
   268         <1> path = QString() \n
       
   269      4. Expected result: \n &nbsp;&nbsp;
       
   270         <1> retPath = QString() \n 
       
   271  */
       
   272 void TestFmInternalFmUtils::testFillPathWithSplashUseEmptyPath()
       
   273 {
       
   274     QString retPath = FmUtils::fillPathWithSplash(QString());
       
   275     QVERIFY( retPath.isEmpty() );
       
   276 }
       
   277 
       
   278 /*!
       
   279      Test Case Description:\n 
       
   280      1. Fucntion Name: \n &nbsp;&nbsp;
       
   281         static QString  fillPathWithSplash( const QString &filePath ); \n &nbsp;&nbsp;
       
   282      2. Case Descrition: verify it doesn't add splash again when the path has the splash in the end. \n
       
   283      3. Input Parameters:  \n &nbsp;&nbsp;
       
   284         <1> path = QString(XX) \n
       
   285      4. Expected result: \n &nbsp;&nbsp;
       
   286         <1> retPath = path \n 
       
   287  */
       
   288 void TestFmInternalFmUtils::testFillPathWithSplashHasSplash()
       
   289 {
       
   290     QString path1 = "C:\\hasSplash\\";
       
   291     QString path2 = "D:/hasSplash/";
       
   292     QString retPath1 = FmUtils::fillPathWithSplash(path1);
       
   293     QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("hasSplash") + QDir::separator());
       
   294     
       
   295     QString retPath2 = FmUtils::fillPathWithSplash(path2);
       
   296     QVERIFY(retPath2 == QString("D:") + QDir::separator() + QString("hasSplash") + QDir::separator());
       
   297 }
       
   298 
       
   299 /*!
       
   300      Test Case Description:\n 
       
   301      1. Fucntion Name: \n &nbsp;&nbsp;
       
   302         static QString  fillPathWithSplash( const QString &filePath ); \n &nbsp;&nbsp;
       
   303      2. Case Descrition: verify the splash is added at the end of the path. \n
       
   304      3. Input Parameters:  \n &nbsp;&nbsp;
       
   305         <1> path = QString(XX) \n
       
   306      4. Expected result: \n &nbsp;&nbsp;
       
   307         <1> retPath = QString(XX) + QDir::separator() \n 
       
   308  */
       
   309 void TestFmInternalFmUtils::testFillPathWithSplashWithoutSplash()
       
   310 {
       
   311     QString path1 = "C:\\noSplash";
       
   312     QString path2 = "D:/noSplash";
       
   313     QString retPath1 = FmUtils::fillPathWithSplash(path1);
       
   314     QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("noSplash") + QDir::separator());
       
   315     
       
   316     QString retPath2 = FmUtils::fillPathWithSplash(path2);
       
   317     QVERIFY(retPath2 == QString("D:") + QDir::separator() + QString("noSplash") + QDir::separator());
       
   318 }
       
   319 
       
   320 /*!
       
   321      Test Case Description:\n 
       
   322      1. Fucntion Name: \n &nbsp;&nbsp;
       
   323         static QString  removePathSplash( const QString &filePath ); \n &nbsp;&nbsp;
       
   324      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   325      3. Input Parameters:  \n &nbsp;&nbsp;
       
   326         <1> path = QString() \n
       
   327      4. Expected result: \n &nbsp;&nbsp;
       
   328         <1> retPath = QString() \n 
       
   329  */
       
   330 void TestFmInternalFmUtils::testRemovePathSplashUseEmptyPath()
       
   331 {
       
   332     QString retPath = FmUtils::removePathSplash(QString());
       
   333     QVERIFY( retPath.isEmpty());
       
   334 }
       
   335 
       
   336 /*!
       
   337      Test Case Description:\n 
       
   338      1. Fucntion Name: \n &nbsp;&nbsp;
       
   339         static QString  removePathSplash( const QString &filePath ); \n &nbsp;&nbsp;
       
   340      2. Case Descrition: verify the splash at the end is removed. \n
       
   341      3. Input Parameters:  \n &nbsp;&nbsp;
       
   342         <1> path = QString(XX) \n
       
   343      4. Expected result: \n &nbsp;&nbsp;
       
   344         <1> retPath = QString(XX) \n 
       
   345  */
       
   346 void TestFmInternalFmUtils::testRemovePathSplashHasSplash()
       
   347 {
       
   348     QString path1 = "C:\\hasSplash\\";
       
   349     QString path2 = "D:/hasSplash/";
       
   350     QString path3 = "/";
       
   351     QString path4 = "\\";
       
   352     
       
   353     QString retPath1 = FmUtils::removePathSplash(path1);
       
   354     QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("hasSplash"));
       
   355     
       
   356     QString retPath2 = FmUtils::removePathSplash(path2);
       
   357     QVERIFY(retPath2 == "D:/hasSplash");
       
   358     
       
   359     QString retPath3 = FmUtils::removePathSplash( path3 );
       
   360     QVERIFY(retPath3.isEmpty());
       
   361     
       
   362     QString retPath4 = FmUtils::removePathSplash( path4 );
       
   363     QVERIFY(retPath4.isEmpty());
       
   364 }
       
   365 
       
   366 /*!
       
   367      Test Case Description:\n 
       
   368      1. Fucntion Name: \n &nbsp;&nbsp;
       
   369         static QString  removePathSplash( const QString &filePath ); \n &nbsp;&nbsp;
       
   370      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   371      3. Input Parameters:  \n &nbsp;&nbsp;
       
   372         <1> path = QString() \n
       
   373      4. Expected result: \n 
       
   374         <1> retPath = QString() \n 
       
   375  */
       
   376 void TestFmInternalFmUtils::testRemovePathSplashWithoutSplash()
       
   377 {
       
   378     QString path1 = "C:\\withoutSplash";
       
   379     QString path2 = "D:/withoutSplash";
       
   380     QString retPath1 = FmUtils::removePathSplash(path1);
       
   381     QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("withoutSplash"));
       
   382     
       
   383     QString retPath2 = FmUtils::removePathSplash(path2);
       
   384     QVERIFY(retPath2 == "D:/withoutSplash");
       
   385 }
       
   386 
       
   387 /*!
       
   388      Test Case Description:\n 
       
   389      1. Fucntion Name: \n &nbsp;&nbsp;
       
   390         static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); \n &nbsp;&nbsp;
       
   391      2. Case Descrition: verify the correct drives are returned.  \n
       
   392      3. Input Parameters:  \n &nbsp;&nbsp;
       
   393         <1> driveList = QStringList, isHideUnAvailableDrive = false \n
       
   394      4. Expected result: \n &nbsp;&nbsp;
       
   395         <1> driveList == driveListForVerify\n 
       
   396  */
       
   397 void TestFmInternalFmUtils::testGetDriveListAll()
       
   398 {
       
   399     QStringList driveList;
       
   400     QStringList driveListForVerify;
       
   401     
       
   402     FmUtils::getDriveList(driveList, false);
       
   403     qDebug()<<driveList;
       
   404     
       
   405     QFileInfoList fileInfoList = QDir::drives();
       
   406     foreach(const QFileInfo &fileInfo,fileInfoList) {
       
   407         QString str = fileInfo.filePath();
       
   408         if (str.length() > 2) {
       
   409             str = str.left(3);
       
   410         }
       
   411         // append the drives to driveListForVerify except the drive type are EDriveRam and EDriveRom.
       
   412         FmDriverInfo driverInfo = FmUtils::queryDriverInfo( str );
       
   413         FmDriverInfo::DriveType driveType = driverInfo.driveType();
       
   414         // fliter the drives which drive type are EDriveRam and EDriveRom.
       
   415         bool driveFilter = ( driverInfo.driveState()& FmDriverInfo::EDriveRam ) ||( driverInfo.driveState()& FmDriverInfo::EDriveRom );
       
   416         if( !driveFilter ){ 
       
   417         driveListForVerify.append(str);
       
   418         }
       
   419     }
       
   420     qDebug()<<driveListForVerify;
       
   421     // verify all the drives in driveListForVerify are get in driveList too.
       
   422     foreach(QString driveName, driveListForVerify){
       
   423         QVERIFY(driveList.contains(driveName, Qt::CaseSensitive));
       
   424     }
       
   425 }
       
   426 
       
   427 /*!
       
   428      Test Case Description:\n 
       
   429      1. Fucntion Name: \n &nbsp;&nbsp;
       
   430         static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); \n &nbsp;&nbsp;
       
   431      2. Case Descrition: verify the correct drives are returned. \n
       
   432      3. Input Parameters:  \n &nbsp;&nbsp;
       
   433         <1> driveList = QStringList, isHideUnAvailableDrive = true \n
       
   434      4. Expected result: \n &nbsp;&nbsp;
       
   435         <1> driveList == driveListForVerify \n 
       
   436  */
       
   437 void TestFmInternalFmUtils::testGetDriveListPart()
       
   438 {
       
   439     QStringList driveList;
       
   440     QStringList driveListForVerify;
       
   441     
       
   442     FmUtils::getDriveList(driveList, true);
       
   443     qDebug() << driveList;
       
   444     
       
   445     QFileInfoList fileInfoList = QDir::drives();
       
   446     foreach(const QFileInfo &fileInfo,fileInfoList) {
       
   447         QString str = fileInfo.filePath();
       
   448         if (str.length() > 2) {
       
   449             str = str.left(3);
       
   450         }
       
   451         FmDriverInfo driverInfo = FmUtils::queryDriverInfo( str );
       
   452         FmDriverInfo::DriveType driveType = driverInfo.driveType();
       
   453         // fliter the drives which drive type are EDriveRam and EDriveRom.
       
   454         bool driveFilter = ( driverInfo.driveState()& FmDriverInfo::EDriveRam ) ||( driverInfo.driveState()& FmDriverInfo::EDriveRom );
       
   455         // filter the unavailable drive
       
   456         if( !driveFilter && FmUtils::isDriveAvailable( str ) ){         
       
   457         driveListForVerify.append(str);
       
   458         }
       
   459     }
       
   460     qDebug()<<driveListForVerify;    
       
   461 
       
   462     // verify all the drives in driveListForVerify are get in driveList too.
       
   463     foreach(QString driveName, driveListForVerify){
       
   464         QVERIFY(driveList.contains(driveName, Qt::CaseSensitive));
       
   465     }
       
   466 }
       
   467 
       
   468 /*!
       
   469      Test Case Description:\n 
       
   470      1. Fucntion Name: \n &nbsp;&nbsp;
       
   471         static QString  fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); \n &nbsp;&nbsp;
       
   472      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   473      3. Input Parameters:  \n &nbsp;&nbsp;
       
   474         <1> driveName = QString(), isFillWithDefaultVolume = false \n &nbsp;&nbsp;
       
   475         <2> driveName = QString(), isFillWithDefaultVolume = true \n
       
   476      4. Expected result: \n &nbsp;&nbsp;
       
   477         <1> retDriveVolume2 == QString() \n
       
   478  */
       
   479 void TestFmInternalFmUtils::testFillDriveVolumeEmptyName()
       
   480 {
       
   481     QString retDriveVolume1 = FmUtils::fillDriveVolume( QString(), false );
       
   482     QVERIFY(retDriveVolume1.isEmpty());
       
   483 
       
   484     QString retDriveVolume2 = FmUtils::fillDriveVolume( QString(), false );
       
   485     QVERIFY(retDriveVolume2.isEmpty());
       
   486 }
       
   487 
       
   488 /*!
       
   489      Test Case Description:\n 
       
   490      1. Fucntion Name: \n &nbsp;&nbsp;
       
   491         static QString  fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); \n &nbsp;&nbsp;
       
   492      2. Case Descrition: verify the default volume is set when the isFillWithDefaultVolume is true. \n
       
   493      3. Input Parameters:  \n &nbsp;&nbsp;
       
   494         <1> driveName = QString(XX), isFillWithDefaultVolume = true \n
       
   495      4. Expected result: \n &nbsp;&nbsp;
       
   496         <1> return the right drive volume(e.g.: C:memory) \n 
       
   497  */
       
   498 void TestFmInternalFmUtils::testFillDriveVolumeDefaultVolume()
       
   499 {
       
   500     foreach(QString strDriveName, mDrives ){
       
   501         QString retDriveVolume = FmUtils::fillDriveVolume(strDriveName, true );
       
   502             
       
   503             QString tempDriveName = FmUtils::fillPathWithSplash( strDriveName );
       
   504             FmDriverInfo driverInfo = FmUtils::queryDriverInfo( tempDriveName );
       
   505             QString checkedDriveName( FmUtils::removePathSplash( strDriveName ) );
       
   506             QString volumeName = driverInfo.volumeName();
       
   507             if(volumeName.isEmpty()){
       
   508             switch ( driverInfo.driveType() )
       
   509                         {
       
   510                         case FmDriverInfo::EDriveTypeMassStorage:
       
   511                             QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_mass_storage").arg(checkedDriveName));
       
   512                             break;
       
   513                         case FmDriverInfo::EDriveTypeUsbMemory:
       
   514                             QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_usb_memory").arg(checkedDriveName));
       
   515                             break;
       
   516                         case FmDriverInfo::EDriveTypeMemoryCard:
       
   517                             QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_memory_card").arg(checkedDriveName));
       
   518                             break;
       
   519                         case FmDriverInfo::EDriveTypePhoneMemory:
       
   520                             QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_device_memory").arg(checkedDriveName));
       
   521                             break;
       
   522                         default:
       
   523                             break;
       
   524                         }
       
   525             }
       
   526     }        
       
   527 }
       
   528 
       
   529 /*!
       
   530      Test Case Description:\n 
       
   531      1. Fucntion Name: \n &nbsp;&nbsp;
       
   532         static QString  fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); \n &nbsp;&nbsp;
       
   533      2. Case Descrition: verify it doesn't crash with empty path. \n
       
   534      3. Input Parameters:  \n &nbsp;&nbsp;
       
   535         <1> driveList = QStringList, isHideUnAvailableDrive = false \n
       
   536      4. Expected result: \n 
       
   537         <1>  \n 
       
   538  */
       
   539 void TestFmInternalFmUtils::testFillDriveVolume()
       
   540 {
       
   541     foreach(QString strDriveName, mDrives ){
       
   542         QString retDriveVolume = FmUtils::fillDriveVolume(strDriveName, false );
       
   543         
       
   544         FmDriverInfo driverInfo = FmUtils::queryDriverInfo( strDriveName );
       
   545         QString checkedDriveName( FmUtils::removePathSplash( strDriveName ) );
       
   546         QString volumeName = driverInfo.volumeName();
       
   547         QString volumeNameForVerify = hbTrId( "%1 %2" ).arg( checkedDriveName ).arg( volumeName );
       
   548         QVERIFY(retDriveVolume == volumeNameForVerify);
       
   549     }
       
   550 }
       
   551 
       
   552 /*!
       
   553      Test Case Description:\n 
       
   554      1. Fucntion Name: \n &nbsp;&nbsp;
       
   555         static QString  getDefaultVolumeName( const QString &driveName ); \n &nbsp;&nbsp;
       
   556      2. Case Descrition: verify the correct default volume is returned \n
       
   557      3. Input Parameters:  \n &nbsp;&nbsp;
       
   558         <1> driveName = QString(XX) \n
       
   559      4. Expected result: \n &nbsp;&nbsp;
       
   560         <1> return the right drive volume(e.g.: "Device memory" when crive name is "C:") \n 
       
   561  */
       
   562 void TestFmInternalFmUtils::testGetDefaultVolumeName()
       
   563 {  
       
   564     foreach(QString strDriveName, mDrives ){
       
   565         // get the volume using getDefaultVolumeName function.
       
   566         QString retDriveVolume = FmUtils::getDefaultVolumeName(strDriveName);
       
   567             
       
   568             FmDriverInfo driverInfo = FmUtils::queryDriverInfo( strDriveName );
       
   569             switch ( driverInfo.driveType() )
       
   570                         {
       
   571                         case FmDriverInfo::EDriveTypeMassStorage:
       
   572                             QVERIFY(retDriveVolume == hbTrId("Mass storage")); 
       
   573                             break;
       
   574                         case FmDriverInfo::EDriveTypeUsbMemory:
       
   575                             QVERIFY(retDriveVolume == hbTrId("USB memory")); 
       
   576                             break;
       
   577                         case FmDriverInfo::EDriveTypeMemoryCard:
       
   578                             QVERIFY(retDriveVolume == hbTrId("Memory card"));
       
   579                             break;
       
   580                         case FmDriverInfo::EDriveTypePhoneMemory:
       
   581                             QVERIFY(retDriveVolume == hbTrId("Device memory"));
       
   582                             break;
       
   583                         case FmDriverInfo::EDriveTypeNotExist:
       
   584                         default:
       
   585                             break;
       
   586                         }
       
   587             }
       
   588 }
       
   589 
       
   590 /*!
       
   591      Test Case Description:\n 
       
   592      1. Fucntion Name: \n &nbsp;&nbsp;
       
   593         static QString  getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName ); \n &nbsp;&nbsp;
       
   594      2. Case Descrition: verify the right volume name is returned. \n
       
   595      3. Input Parameters:  \n &nbsp;&nbsp;
       
   596         <1> driveName = QString(XX) \n
       
   597      4. Expected result: \n &nbsp;&nbsp;
       
   598         <1> return the right drive volume(e.g.: "Device memory" when drive name is "C:" & is empty) \n 
       
   599  */
       
   600 void TestFmInternalFmUtils::testGetVolumeNameWithDefaultNameIfNull()
       
   601 {  
       
   602     foreach(QString strDriveName, mDrives ){
       
   603         // get the volume using getVolumeNameWithDefaultNameIfNull() function.
       
   604         bool isDefaultName = false;
       
   605         QString retDriveVolume = FmUtils::getVolumeNameWithDefaultNameIfNull(strDriveName, isDefaultName);
       
   606         
       
   607             FmDriverInfo driverInfo = FmUtils::queryDriverInfo( strDriveName );
       
   608             QString volumeName = driverInfo.volumeName(); 
       
   609             if ( volumeName.isEmpty() ){
       
   610                 switch ( driverInfo.driveType() )
       
   611                         {
       
   612                         case FmDriverInfo::EDriveTypeMassStorage:
       
   613                             QVERIFY(retDriveVolume == hbTrId("Mass storage")); 
       
   614                             break;
       
   615                         case FmDriverInfo::EDriveTypeUsbMemory:
       
   616                             QVERIFY(retDriveVolume == hbTrId("USB memory")); 
       
   617                             break;
       
   618                         case FmDriverInfo::EDriveTypeMemoryCard:
       
   619                             QVERIFY(retDriveVolume == hbTrId("Memory card"));
       
   620                             break;
       
   621                         case FmDriverInfo::EDriveTypePhoneMemory:
       
   622                             QVERIFY(retDriveVolume == hbTrId("Device memory"));
       
   623                             break;
       
   624                         case FmDriverInfo::EDriveTypeNotExist:
       
   625                         default:
       
   626                             break;
       
   627                         }
       
   628             }
       
   629             }
       
   630 }
       
   631 /*!
       
   632      Test Case Description:\n 
       
   633      1. Fucntion Name: \n &nbsp;&nbsp;
       
   634         static bool isPathEqual( const QString &pathFst, const QString &pathLast ); \n &nbsp;&nbsp;
       
   635      2. Case Descrition: Verify the two path are the same. \n
       
   636      3. Input Parameters:  \n &nbsp;&nbsp;
       
   637         <1> pathFst = QString(X), pathLast = QString(X)\n
       
   638      4. Expected result: \n &nbsp;&nbsp;
       
   639         <1> isEqual = true \n 
       
   640  */
       
   641 void TestFmInternalFmUtils::testisPathEqualWithSamePath()
       
   642 {
       
   643     QString path1 = "C:\\the path is same";
       
   644     QString path2 = "C:\\the path is same";
       
   645     QString path3 = "C:\\ frontbland\\isSame";
       
   646     QString path4 = "C:\\ frontbland\\isSame";
       
   647     QString path5 = "C:\\endwithbland \\isSame";
       
   648     QString path6 = "C:\\endwithbland \\isSame";
       
   649     bool isEqual1 = FmUtils::isPathEqual(QString(), QString());
       
   650     QVERIFY(isEqual1 == true);
       
   651     
       
   652     bool isEqual2 = FmUtils::isPathEqual(path1, path2);
       
   653     QVERIFY(isEqual2 == true);
       
   654     
       
   655     bool isEqual3 = FmUtils::isPathEqual(path3, path4);
       
   656     QVERIFY(isEqual3 == true);
       
   657     
       
   658     bool isEqual4 = FmUtils::isPathEqual(path5, path6);
       
   659     QVERIFY(isEqual4 == true);
       
   660 }
       
   661 
       
   662 /*!
       
   663      Test Case Description:\n 
       
   664      1. Fucntion Name: \n &nbsp;&nbsp;
       
   665         static bool isPathEqual( const QString &pathFst, const QString &pathLast ); \n &nbsp;&nbsp;
       
   666      2. Case Descrition: Verify the two path are different. \n
       
   667      3. Input Parameters:  \n &nbsp;&nbsp;
       
   668         <1> pathFst = QString(X), pathLast = QString(Y)\n
       
   669      4. Expected result: \n &nbsp;&nbsp;
       
   670         <1> isEqual = false \n 
       
   671  */
       
   672 void TestFmInternalFmUtils::testisPathEqualWithDiffPath()
       
   673 {
       
   674     QString path1 = "C:\\the path is different";
       
   675     QString path2 = "C:\\the path is not same\\subdir\\";
       
   676     bool isEqual = FmUtils::isPathEqual(path1, path2);
       
   677     QVERIFY(isEqual == false);
       
   678 }
       
   679 
       
   680 /*!
       
   681      Test Case Description:\n 
       
   682      1. Fucntion Name: \n &nbsp;&nbsp;
       
   683         static bool checkFolderFileName( const QString& name ); \n &nbsp;&nbsp;
       
   684      2. Case Descrition: Verify folder or file name is OK. \n
       
   685      3. Input Parameters:  \n &nbsp;&nbsp;
       
   686         <1> pathFst = QString(XX)\n
       
   687      4. Expected result: \n &nbsp;&nbsp;
       
   688         <1> isValid= true \n 
       
   689  */
       
   690 void TestFmInternalFmUtils::testcheckFolderFileNameNormal()
       
   691 {
       
   692     QString name = "This is a valid name";
       
   693     bool isValid = FmUtils::checkFolderFileName(name);
       
   694     QVERIFY(isValid == true);
       
   695 }
       
   696 
       
   697 /*!
       
   698      Test Case Description:\n 
       
   699      1. Fucntion Name: \n &nbsp;&nbsp;
       
   700         static bool checkFolderFileName( const QString& name ); \n &nbsp;&nbsp;
       
   701      2. Case Descrition: Verify the folder or file name is invalid. \n
       
   702      3. Input Parameters:  \n &nbsp;&nbsp;
       
   703         <1> pathFst = QString(XX)\n
       
   704      4. Expected result: \n &nbsp;&nbsp;
       
   705         <1> isValid= false \n 
       
   706  */
       
   707 void TestFmInternalFmUtils::testcheckFolderFileNameUnNormal()
       
   708 {
       
   709     QList<QChar> list;
       
   710     list << '\\' << '/' << ':' << '*' << '?' << '\"' << '<' << '>' <<'|';
       
   711     foreach(QChar ilegelChar, list){
       
   712         QString name = QString("This is an invalid name") + ilegelChar;
       
   713         bool isValid = FmUtils::checkFolderFileName(name);
       
   714         QVERIFY(isValid == false);
       
   715     }
       
   716     // end with "."
       
   717     QString nameEndWithDot = "End with dot.";
       
   718     bool isValid1 = FmUtils::checkFolderFileName(nameEndWithDot);
       
   719     QVERIFY(isValid1 == false);
       
   720     // more than max size
       
   721     QString nameMax;
       
   722     nameMax.fill('x', 300);
       
   723     bool isValid2 = FmUtils::checkFolderFileName(nameMax);
       
   724     QVERIFY(isValid2 == false);
       
   725     // name is empty
       
   726     bool isValid3 = FmUtils::checkFolderFileName(QString());
       
   727     QVERIFY(isValid3 == false);
       
   728 }
       
   729 
       
   730 /*!
       
   731      Test Case Description:\n 
       
   732      1. Fucntion Name: \n &nbsp;&nbsp;
       
   733         static bool     checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); \n &nbsp;&nbsp;
       
   734      2. Case Descrition: Verify it is a new folder or file.\n
       
   735      3. Input Parameters:  \n &nbsp;&nbsp;
       
   736         <1> fileName = QString(XX), path = QString(XX), errString = QString(XX)\n
       
   737      4. Expected result: \n &nbsp;&nbsp;
       
   738         <1> isNew = true \n 
       
   739  */
       
   740 void TestFmInternalFmUtils::testCheckNewFolderOrFileUnNormal()
       
   741 {
       
   742     QString fileName = "newFolder";
       
   743     QString path = mFilePath + "newFolder";
       
   744     QString errStr;
       
   745     bool isNew = FmUtils::checkNewFolderOrFile(fileName, path, errStr);
       
   746     QVERIFY(isNew == true);
       
   747 }
       
   748 
       
   749 /*!
       
   750      Test Case Description:\n 
       
   751      1. Fucntion Name: \n &nbsp;&nbsp;
       
   752         static bool     checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); \n &nbsp;&nbsp;
       
   753      2. Case Descrition: Verify the function when the folder/file name with ilegel characters.\n
       
   754      3. Input Parameters:  \n &nbsp;&nbsp;
       
   755         <1> fileName = QString(XX), path = QString(XX), errString = QString(XX)\n
       
   756      4. Expected result: \n &nbsp;&nbsp;
       
   757         <1> isNew = false \n 
       
   758  */
       
   759 void TestFmInternalFmUtils::testCheckNewFolderOrFileIlegel()
       
   760 {
       
   761     QString validName = "Image.jpg";
       
   762     QString ilegelFileName = "isInvalidName?";
       
   763     QString validPath = mFilePath + "newFolder";
       
   764     QString inValidPath;
       
   765     inValidPath.fill('x', 300);
       
   766     QString errStr;
       
   767     
       
   768     // file name is invalid
       
   769     bool isNew1 = FmUtils::checkNewFolderOrFile(ilegelFileName, validPath, errStr);
       
   770     QVERIFY(isNew1 == false);
       
   771     QVERIFY(errStr == hbTrId( "Invalid file or folder name!" ));
       
   772     // path is too long
       
   773     bool isNew2 = FmUtils::checkNewFolderOrFile(validName, inValidPath, errStr);
       
   774     QVERIFY(isNew2 == false);
       
   775     QVERIFY(errStr == hbTrId( "the path you specified is too long!" ));
       
   776 }
       
   777 
       
   778 /*!
       
   779      Test Case Description:\n 
       
   780      1. Fucntion Name: \n &nbsp;&nbsp;
       
   781         static bool     checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); \n &nbsp;&nbsp;
       
   782      2. Case Descrition: Verify it is not a new folder or file.\n
       
   783      3. Input Parameters:  \n &nbsp;&nbsp;
       
   784         <1> fileName = QString(XX), path = QString(XX), errString = QString(XX)\n
       
   785      4. Expected result: \n &nbsp;&nbsp;
       
   786         <1> isNew = false \n 
       
   787  */
       
   788 void TestFmInternalFmUtils::testCheckNewFolderOrFileNo()
       
   789 {
       
   790     QString validName = "Image.jpg";
       
   791     QString exsitPath = mFilePath;
       
   792     QString errStr;
       
   793     // the file\folder has been exsit
       
   794     bool isNew3 = FmUtils::checkNewFolderOrFile(validName, exsitPath, errStr);
       
   795     QVERIFY(isNew3 == false);
       
   796     QFileInfo fileInfo( exsitPath );
       
   797     QVERIFY(errStr == hbTrId( "%1 already exist!" ).arg( fileInfo.fileName()));
       
   798 }
       
   799 
       
   800 /*!
       
   801      Test Case Description:\n 
       
   802      1. Fucntion Name: \n &nbsp;&nbsp;
       
   803         static bool     isSubLevelPath( const QString &src, const QString &dest ); \n &nbsp;&nbsp;
       
   804      2. Case Descrition: Verify the path is a sub level path.\n
       
   805      3. Input Parameters:  \n &nbsp;&nbsp;
       
   806         <1> src = QString(XX), dest = QString(XX)\n
       
   807      4. Expected result: \n &nbsp;&nbsp;
       
   808         <1> isSubLevelPath = true \n 
       
   809  */
       
   810 void TestFmInternalFmUtils::testIsSubLevelPathYes()
       
   811 {
       
   812     QString src = "C:\\dir";
       
   813     QString dest = "C:\\dir\\subdir";
       
   814     bool isSubLevelPath = FmUtils::isSubLevelPath(src, dest);
       
   815     QVERIFY(isSubLevelPath == true);
       
   816 }
       
   817 
       
   818 /*!
       
   819      Test Case Description:\n 
       
   820      1. Fucntion Name: \n &nbsp;&nbsp;
       
   821         static bool     isSubLevelPath( const QString &src, const QString &dest ); \n &nbsp;&nbsp;
       
   822      2. Case Descrition: Verify the path is a sub level path.\n
       
   823      3. Input Parameters:  \n &nbsp;&nbsp;
       
   824         <1> src = QString(XX), dest = QString(XX)\n
       
   825      4. Expected result: \n &nbsp;&nbsp;
       
   826         <1> isSubLevelPath = false \n 
       
   827  */
       
   828 void TestFmInternalFmUtils::testIsSubLevelPathNo()
       
   829 {
       
   830     QString src1 = "C:\\dir1";
       
   831     QString dest1 = "C:\\dir2\\subdir";
       
   832     QString src2 = "C:\\dir1\\subdir";
       
   833     QString dest2 = "C:\\dir1";
       
   834     // dest does not contain src.
       
   835     bool isSubLevelPath1 = FmUtils::isSubLevelPath(src1, dest1);
       
   836     QVERIFY(isSubLevelPath1 == false);
       
   837     // dest.length < src.length
       
   838     bool isSubLevelPath2 = FmUtils::isSubLevelPath(src2, dest2);
       
   839     QVERIFY(isSubLevelPath2 == false);
       
   840 }
       
   841 
       
   842 /*!
       
   843      Test Case Description:\n 
       
   844      1. Fucntion Name: \n &nbsp;&nbsp;
       
   845         static int removeDrivePwd( const QString &driverName, const QString &Pwd ); \n &nbsp;&nbsp;
       
   846      2. Case Descrition: verify this function can remove the password successfully. \n
       
   847      3. Input Parameters:  \n &nbsp;&nbsp;
       
   848         <1> driverName = QString(), password = QString(XX) \n &nbsp;&nbsp;
       
   849      4. Expected result: \n 
       
   850         <1> retErr = FmErrNone, \n 
       
   851  */
       
   852 void TestFmInternalFmUtils::testRemoveDrivePwdNormal()
       
   853 {
       
   854     if( ! mDrives1.empty() ){
       
   855     //  set the password.
       
   856     FmUtils::setDrivePwd( mDrives1[0], QString(), QString("123456") );
       
   857     FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   858     int a = driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected;
       
   859     QVERIFY( a == FmDriverInfo::EDrivePasswordProtected );
       
   860     //remove the password and verify the drive state.
       
   861     int retRemovePwdErr = FmUtils::removeDrivePwd( mDrives1[0], QString("123456") );
       
   862     driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   863 //    int b = driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected;
       
   864     QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) );
       
   865      
       
   866     QVERIFY( retRemovePwdErr == FmErrNone );
       
   867    }
       
   868     else
       
   869         QWARN("No memory crad or USB device are available.");
       
   870 }
       
   871 
       
   872 /*!
       
   873      Test Case Description:\n 
       
   874      1. Fucntion Name: \n &nbsp;&nbsp;
       
   875         static int removeDrivePwd( const QString &driverName, const QString &Pwd ); \n &nbsp;&nbsp;
       
   876      2. Case Descrition: verify this function can remove the password successfully. \n
       
   877      3. Input Parameters:  \n &nbsp;&nbsp;
       
   878         <1> driverName = QString(), password = QString(XX) \n &nbsp;&nbsp;
       
   879         <2> driverName = QString(XX), password = QString(XX) \n &nbsp;&nbsp;
       
   880      4. Expected result: \n &nbsp;&nbsp;
       
   881         <1> retErr = FmErrWrongParam, \n &nbsp;&nbsp;
       
   882         <2> no crash. \n
       
   883  */
       
   884 void TestFmInternalFmUtils::testRemoveDrivePwdUnNormal()
       
   885 {
       
   886     int retErr1 = FmUtils::removeDrivePwd( QString(), QString() );
       
   887     QVERIFY( retErr1 == FmErrWrongParam );   
       
   888     
       
   889     int retErr2 = FmUtils::removeDrivePwd( QString("C:/"), QString("5t0Lfezb") );
       
   890     QVERIFY( retErr2 == FmErrUnKnown );
       
   891 
       
   892     int retErr3 = FmUtils::removeDrivePwd( QString("U:/"), QString("5t0Lfezb") );
       
   893     QVERIFY( retErr3 == FmErrUnKnown );
       
   894 }
       
   895 /*!
       
   896      Test Case Description:\n 
       
   897      1. Fucntion Name: \n &nbsp;&nbsp;
       
   898         static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); \n &nbsp;&nbsp;
       
   899      2. Case Descrition: verify this function can set the password correctly. \n
       
   900      3. Input Parameters:  \n &nbsp;&nbsp;
       
   901         <1> driverName = QString(XX), oldPwd = QString(), newPwd = QString(XX) \n
       
   902      4. Expected result: \n &nbsp;&nbsp;
       
   903         <1> retErr = FmErrNone
       
   904  */
       
   905 void TestFmInternalFmUtils::testSetDrivePwdNormal()
       
   906 {
       
   907     if( ! mDrives1.empty() ){
       
   908     //set the password
       
   909     int retErr = FmUtils::setDrivePwd( mDrives1[0], QString(), QString("123456") );
       
   910     // get the drive state and verify it.
       
   911     FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   912     int a = driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected;
       
   913     QVERIFY( a == FmDriverInfo::EDrivePasswordProtected );  
       
   914     QVERIFY( retErr == FmErrNone );  
       
   915     
       
   916     FmUtils::removeDrivePwd( mDrives1[0], QString("123456") );
       
   917     }
       
   918     else
       
   919         QWARN("No memory crad or USB device are available.");
       
   920 }
       
   921 
       
   922 /*!
       
   923      Test Case Description:\n 
       
   924      1. Fucntion Name: \n &nbsp;&nbsp;
       
   925         static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); \n &nbsp;&nbsp;
       
   926      2. Case Descrition: verify this function can set the password correctly. \n
       
   927      3. Input Parameters:  \n &nbsp;&nbsp;
       
   928         <1> driverName = QString(), oldPwd = QString(), newPwd = QString(X) \n &nbsp;&nbsp;
       
   929         <2> driverName = QString(X), oldPwd = QString(), newPwd = QString(X.length()>8) \n &nbsp;&nbsp;
       
   930         <3> driverName = QString(C:), oldPwd = QString(), newPwd = QString(X) \n 
       
   931      4. Expected result: \n &nbsp;&nbsp;
       
   932         <1> retErr = FmErrWrongParam \n &nbsp;&nbsp;
       
   933         <2> retErr = FmErrWrongParam \n &nbsp;&nbsp;
       
   934         <3> retErr = FmErrNotSupported \n 
       
   935  */
       
   936 void TestFmInternalFmUtils::testSetDrivePwdUnNormal()
       
   937 {
       
   938     // The drive name is empty
       
   939     int retSetPwdErr1 = FmUtils::setDrivePwd( QString(""), QString(""), QString("123456") );
       
   940     QVERIFY( retSetPwdErr1 == FmErrWrongParam );
       
   941     
       
   942     if( !mDrives1.empty() ){
       
   943     int retSetPwdEr2 = FmUtils::setDrivePwd( mDrives1[0], QString(""), QString("1234567890123456") );
       
   944     FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   945     QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) );
       
   946     QVERIFY( retSetPwdEr2 == FmErrWrongParam );
       
   947     }else
       
   948          QWARN("No memory crad or USB device are available.");
       
   949     
       
   950     int retSetPwdErr3 = FmUtils::setDrivePwd( mDrives2[0], QString(""), QString("123456") );
       
   951     QVERIFY( retSetPwdErr3 == FmErrNotSupported );
       
   952     
       
   953     // return 
       
   954     int retSetPwdErr4 = FmUtils::setDrivePwd( QString("9527"), QString("oldpwd"), QString("123456") );
       
   955     QVERIFY( retSetPwdErr4 == FmErrUnKnown );  
       
   956 }
       
   957 
       
   958 /*!
       
   959      Test Case Description:\n 
       
   960      1. Fucntion Name: \n &nbsp;&nbsp;
       
   961         static int checkDrivePwd( const QString &driverName, const QString &pwd); \n &nbsp;&nbsp;
       
   962      2. Case Descrition: verify this function can check whether the drive having password . \n
       
   963      3. Input Parameters:  \n &nbsp;&nbsp;
       
   964         <1> driverName = QString(), password = QString(X.length()<8) \n &nbsp;&nbsp;
       
   965         <2> driverName = QString(X), password = QString(X.length()>8) \n &nbsp;&nbsp;
       
   966         <3> driverName = QString(X), password = QString(X.length()<8) \n
       
   967      4. Expected result: \n &nbsp;&nbsp;
       
   968         <1> retErr = FmErrWrongParam \n &nbsp;&nbsp;
       
   969         <2> retErr = FmErrWrongParam \n &nbsp;&nbsp;
       
   970         <3> retErr = FmErrNone\n 
       
   971  */
       
   972 void TestFmInternalFmUtils::testCheckDrivePwd()
       
   973 {
       
   974     if( !mDrives1.empty() ){
       
   975     //the drive name is empty
       
   976     int retCheckStatus1 = FmUtils::checkDrivePwd( QString(), QString("password"));
       
   977     FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   978 
       
   979     QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) );
       
   980     QVERIFY( retCheckStatus1 == FmErrWrongParam );
       
   981     
       
   982     // the length of the password is more than 8
       
   983     int retCheckStatus2 = FmUtils::checkDrivePwd( mDrives1[0], QString("oldpassword"));
       
   984     driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   985 
       
   986     QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) );  
       
   987     QVERIFY( retCheckStatus2 == FmErrWrongParam );
       
   988     
       
   989     int retCheckStatus3 = FmUtils::checkDrivePwd( mDrives1[0], QString("password"));
       
   990     driverInfo = FmUtils::queryDriverInfo( mDrives1[0] );
       
   991 #ifdef BUG_TO_FIX
       
   992     QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) );  //The drive state of FmDriverInfo::EDrivePasswordProtected should not be changed with a valid pwd parameter.
       
   993     QVERIFY( retCheckStatus3 == FmErrNone );
       
   994 #endif
       
   995     }
       
   996     else
       
   997         QWARN("No memory crad or USB device are available.");
       
   998 }
       
   999 
       
  1000 /*!
       
  1001      Test Case Description:\n 
       
  1002      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1003         static void emptyPwd( QString &pwd ); \n &nbsp;&nbsp;
       
  1004      2. Case Descrition: verify this function can empty the password . \n
       
  1005      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1006         <1> pwd = QString() \n &nbsp;&nbsp;
       
  1007         <2> pwd = QString(XX) \n
       
  1008      4. Expected result: \n &nbsp;&nbsp;
       
  1009         <1> no crash \n &nbsp;&nbsp;
       
  1010         <2> no crash. \n
       
  1011  */
       
  1012 void TestFmInternalFmUtils::testEmptyPwd()
       
  1013 {
       
  1014     QString strPassword= QString("password");
       
  1015     QString pwdEmpty = QString();
       
  1016     FmUtils::emptyPwd( pwdEmpty );
       
  1017     FmUtils::emptyPwd( strPassword );
       
  1018 }
       
  1019 
       
  1020 /*!
       
  1021      Test Case Description:\n 
       
  1022      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1023         static int renameDrive( const QString &driverName, const QString &newVolumeName); \n
       
  1024      2. Case Descrition: verify that it does not crash with bad names. \n
       
  1025      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1026         <1> driveName = QString(), newVolumeName = QString(XX) \n &nbsp;&nbsp;
       
  1027         <2> driveName = "C:", newVolumeName = QString() \n &nbsp;&nbsp;
       
  1028         <3> driveName = "C:", newVolumeName = QString("!$@^#*#dsfljlke").  \n &nbsp;&nbsp;
       
  1029         <4> driveName = "C:", newVolumeName = QString("more than maximum words").  \n
       
  1030      4. Expected result: \n &nbsp;&nbsp;
       
  1031         <1> return FmErrWrongParam \n &nbsp;&nbsp;
       
  1032         <2> return FmErrUnKnown \n &nbsp;&nbsp;
       
  1033         <3> return FmErrBadName \n &nbsp;&nbsp;
       
  1034         <4> return FmErrBadName \n
       
  1035  */
       
  1036 void TestFmInternalFmUtils::testRenameDriveWithBadName()
       
  1037 {
       
  1038     int retInfo1 = FmUtils::renameDrive( QString(),QString("new volume name") );
       
  1039     QVERIFY( retInfo1 == FmErrWrongParam );
       
  1040     
       
  1041     if( !mDrives1.empty() ){
       
  1042     int retInfo2 = FmUtils::renameDrive( mDrives1[0],QString("") );
       
  1043     QVERIFY( retInfo2 == FmErrNone );
       
  1044     
       
  1045     int retInfo3 = FmUtils::renameDrive( mDrives1[0],QString("!$@^#*e") );
       
  1046     QVERIFY( retInfo3 == FmErrBadName );
       
  1047     
       
  1048     int retInfo4 = FmUtils::renameDrive( mDrives1[0],QString("more than maximum words") );
       
  1049     QVERIFY( retInfo4 == FmErrUnKnown );
       
  1050     }else
       
  1051         QWARN("No memory crad or USB device are available.");
       
  1052 }
       
  1053 
       
  1054 /*!
       
  1055      Test Case Description:\n 
       
  1056      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1057         static int renameDrive( const QString &driverName, const QString &newVolumeName); \n
       
  1058      2. Case Descrition: verify this function can empty the password . \n
       
  1059      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1060         <1> driveName = QString(X), newVolumeName = QString(XX) \n &nbsp;&nbsp;
       
  1061         <2> driveName = "C:", newVolumeName = QString() \n
       
  1062      4. Expected result: \n &nbsp;&nbsp;
       
  1063         <1> return FmErrWrongParam \n &nbsp;&nbsp;
       
  1064         <2> return FmErrBadName \n
       
  1065  */
       
  1066 void TestFmInternalFmUtils::testRenameDriveWithNormalName()
       
  1067 {
       
  1068     if( !mDrives1.empty() ){
       
  1069     int retInfo1 = FmUtils::renameDrive(mDrives1[0],QString("newname") );
       
  1070     bool defaultName = false;
       
  1071     QString retVolumeName = FmUtils::getVolumeNameWithDefaultNameIfNull( mDrives1[0], defaultName );
       
  1072     QVERIFY( retVolumeName == "newname" );
       
  1073     QVERIFY( retInfo1 == FmErrNone );
       
  1074     //set the name back
       
  1075     FmUtils::renameDrive(mDrives1[0],QString());
       
  1076     }else
       
  1077         QWARN("No memory crad or USB device are available.");
       
  1078 }
       
  1079 
       
  1080 /*!
       
  1081      Test Case Description:\n 
       
  1082      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1083         static bool     checkDriveAccessFilter( const QString &driveName ); \n
       
  1084      2. Case Descrition: verify whether the drive can be accessable. \n
       
  1085      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1086         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1087         <2> driveName = QString(XX) \n
       
  1088      4. Expected result: \n &nbsp;&nbsp;
       
  1089         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1090         <2> return true if it's accessful, or return false \n 
       
  1091  */
       
  1092 void TestFmInternalFmUtils::testCheckDriveAccessFilter()
       
  1093 {
       
  1094     foreach(QString strDriveName, mDrives ){
       
  1095         bool isAccessable1 = FmUtils::checkDriveAccessFilter(strDriveName);
       
  1096         
       
  1097         FmDriverInfo driveInfo = FmUtils::queryDriverInfo( strDriveName );
       
  1098         if ((driveInfo.driveState()& FmDriverInfo::EDriveRam ) ||
       
  1099             +( driveInfo.driveState()& FmDriverInfo::EDriveRom ) ) {
       
  1100             QVERIFY(isAccessable1 == false);
       
  1101         }else
       
  1102         QVERIFY(isAccessable1 == true);
       
  1103     }
       
  1104     // set drive name as QString
       
  1105     bool isAccessable2 = FmUtils::checkDriveAccessFilter(QString());
       
  1106     QVERIFY(isAccessable2 == false);
       
  1107 }
       
  1108 
       
  1109 /*!
       
  1110      Test Case Description:\n 
       
  1111      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1112         static QString  checkDriveToFolderFilter( const QString &path ); \n
       
  1113      2. Case Descrition: Verify the correct path is returned. \n
       
  1114      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1115         <1> path = QString("C:") \n
       
  1116      4. Expected result: \n &nbsp;&nbsp;
       
  1117         <1> retPath == path + QDir::separator() + QString( "data" ) + QDir::separator() \n &nbsp;&nbsp;       
       
  1118  */
       
  1119 void TestFmInternalFmUtils::testCheckDriveToFolderFilterC()
       
  1120 {
       
  1121     QString path = Drive_C;
       
  1122     QString retPath = FmUtils::checkDriveToFolderFilter(path);
       
  1123     QVERIFY(retPath == path + QString( "data" ) + QDir::separator());
       
  1124 }
       
  1125 
       
  1126 /*!
       
  1127      Test Case Description:\n 
       
  1128      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1129         static QString  checkDriveToFolderFilter( const QString &path ); \n
       
  1130      2. Case Descrition: Verify the correct path is returned. \n
       
  1131      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1132         <1> path = QString(XX) \n
       
  1133      4. Expected result: \n &nbsp;&nbsp;
       
  1134         <1> retPath == path \n &nbsp;&nbsp;       
       
  1135  */
       
  1136 void TestFmInternalFmUtils::testCheckDriveToFolderFilterNormal()
       
  1137 {
       
  1138     QString path = "D:";
       
  1139     QString retPath1 = FmUtils::checkDriveToFolderFilter(path);
       
  1140     QVERIFY(retPath1 == path);
       
  1141     
       
  1142     QString retPath2 = FmUtils::checkDriveToFolderFilter(QString());
       
  1143     QVERIFY(retPath2.isEmpty());
       
  1144 }
       
  1145 
       
  1146 /*!
       
  1147      Test Case Description:\n 
       
  1148      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1149         static QString  checkFolderToDriveFilter( const QString &path );\n
       
  1150      2. Case Descrition:  \n
       
  1151      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1152         <1> path = "C:\\data" \n 
       
  1153      4. Expected result: \n &nbsp;&nbsp;
       
  1154         <1> retPath == "C:" \n
       
  1155  */
       
  1156 void TestFmInternalFmUtils::testCheckFolderToDriveFilterC()
       
  1157 {
       
  1158     QString path = "C:\\data";
       
  1159     QString retPath = FmUtils::checkFolderToDriveFilter(path);
       
  1160     QVERIFY(retPath == Drive_C);
       
  1161 }
       
  1162 
       
  1163 /*!
       
  1164      Test Case Description:\n 
       
  1165      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1166         static QString  checkFolderToDriveFilter( const QString &path );\n
       
  1167      2. Case Descrition: Verify the correct path is returned. \n
       
  1168      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1169         <1> path = QString() \n &nbsp;&nbsp;
       
  1170         <2> path = QString(XX) \n
       
  1171      4. Expected result: \n &nbsp;&nbsp;
       
  1172         <1> retPath == QString() \n &nbsp;&nbsp;
       
  1173         <2> retPath == path \n 
       
  1174  */
       
  1175 void TestFmInternalFmUtils::testCheckFolderToDriveFilterNormal()
       
  1176 {
       
  1177     QString path = "E:\\thisIsNotCDrive";
       
  1178     QString retPath1 = FmUtils::checkDriveToFolderFilter(path);
       
  1179     QVERIFY(retPath1 == path);
       
  1180     
       
  1181     QString retPath2 = FmUtils::checkDriveToFolderFilter(QString());
       
  1182     QVERIFY(retPath2.isEmpty());
       
  1183 }
       
  1184 
       
  1185 /*!
       
  1186      Test Case Description:\n 
       
  1187      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1188         static int      isPathAccessabel( const QString &path );\n
       
  1189      2. Case Descrition: Verify the right info is returned when using empty path \n
       
  1190      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1191         <1> path = QString() \n 
       
  1192      4. Expected result: \n &nbsp;&nbsp;
       
  1193         <1> retInfo == FmErrPathNotExist \n 
       
  1194  */
       
  1195 void TestFmInternalFmUtils::testIsPathAccessableEmpty()
       
  1196 {
       
  1197     int retInfo = FmUtils::isPathAccessabel(QString());
       
  1198     QVERIFY(retInfo == FmErrPathNotExist);
       
  1199 }
       
  1200 
       
  1201 /*!
       
  1202      Test Case Description:\n 
       
  1203      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1204         static int      isPathAccessabel( const QString &path );\n
       
  1205      2. Case Descrition: Verify the right info is returned when using valid path \n
       
  1206      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1207         <1> path = Folder_C_Data\n 
       
  1208      4. Expected result: \n &nbsp;&nbsp;
       
  1209         <1> retInfo == FmErrNone \n 
       
  1210  */
       
  1211 void TestFmInternalFmUtils::testIsPathAccessableOK()
       
  1212 {
       
  1213     QString path = Folder_C_Data;
       
  1214     int retInfo = FmUtils::isPathAccessabel(path);
       
  1215     QVERIFY(retInfo == FmErrNone);
       
  1216 }
       
  1217 
       
  1218 /*!
       
  1219      Test Case Description:\n 
       
  1220      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1221         static int      isPathAccessabel( const QString &path );\n
       
  1222      2. Case Descrition: Verify the right info is returned when using unAccessable path \n
       
  1223      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1224         <1> path = Drive_C +QString(XX) \n &nbsp;&nbsp;
       
  1225         <2> path = QString(XX) \n
       
  1226      4. Expected result: \n &nbsp;&nbsp;
       
  1227         <1> retInfo == FmErrDriveDenied \n
       
  1228         <2> retInfo == FmErrPathNotExist \n 
       
  1229  */
       
  1230 void TestFmInternalFmUtils::testIsPathAccessableNo()
       
  1231 {
       
  1232      QString path = "cannotaccesspath";
       
  1233     int retInfo = FmUtils::isPathAccessabel(path);
       
  1234     QVERIFY(retInfo == FmErrPathNotExist);
       
  1235 }
       
  1236 
       
  1237 /*!
       
  1238      Test Case Description:\n 
       
  1239      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1240         static bool     isDriveAvailable( const QString &path );\n
       
  1241      2. Case Descrition: Verify the drive is available of the path. \n
       
  1242      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1243         <1> path = QString(XX) \n &nbsp;&nbsp;
       
  1244         <2> path = QString() \n
       
  1245      4. Expected result: \n &nbsp;&nbsp;
       
  1246         <1>  \n &nbsp;&nbsp;
       
  1247         <2> isAvailable == fasle \n
       
  1248  */
       
  1249 void TestFmInternalFmUtils::testIsDriveAvailable()
       
  1250 {
       
  1251     foreach(QString strDriveName, mDrives ){
       
  1252         bool isAvailable1 = FmUtils::isDriveAvailable(strDriveName + QString("availableOrNot"));
       
  1253         
       
  1254         FmDriverInfo::DriveState driveState = FmUtils::queryDriverInfo( strDriveName + QString("availableOrNot") ).driveState();
       
  1255         if( ( driveState & FmDriverInfo::EDriveAvailable ) ) {
       
  1256         QVERIFY(isAvailable1 == true);
       
  1257         }else
       
  1258             QVERIFY(isAvailable1 == false);
       
  1259     }
       
  1260     // set drive name as QString
       
  1261     bool isAccessable2 = FmUtils::isDriveAvailable(QString());
       
  1262     QVERIFY(isAccessable2 == false);
       
  1263     
       
  1264     QString pathNotAvailable = "A:\\notAvailabel";
       
  1265     bool isAccessable3 = FmUtils::isDriveAvailable(pathNotAvailable);
       
  1266     QVERIFY(isAccessable3 == false);
       
  1267 }
       
  1268 
       
  1269 /*!
       
  1270      Test Case Description:\n 
       
  1271      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1272         static bool     isDefaultFolder( const QString &folderPath  );\n
       
  1273      2. Case Descrition: Verify the folder is default folder. \n
       
  1274      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1275         <1> filePath = QString(XX) \n 
       
  1276      4. Expected result: \n &nbsp;&nbsp;
       
  1277         <1> isDefault == true \n  
       
  1278  */
       
  1279 void TestFmInternalFmUtils::testIsDefaultFolder()
       
  1280 {
       
  1281     QString filePath1 = "C:\\data\\Games";
       
  1282     QString filePath2 = "C:\\data\\Images";
       
  1283     QString filePath3 = "C:\\data\\Installs";
       
  1284     bool isDefault1 = FmUtils::isDefaultFolder(filePath1);
       
  1285     QVERIFY(isDefault1 == true);
       
  1286     bool isDefault2 = FmUtils::isDefaultFolder(filePath2);
       
  1287     QVERIFY(isDefault2 == true);
       
  1288     bool isDefault3 = FmUtils::isDefaultFolder(filePath3);
       
  1289     QVERIFY(isDefault3 == true);
       
  1290     
       
  1291     bool isDefaultPath1 = FmUtils::isDefaultFolder(QString());
       
  1292     QVERIFY(isDefaultPath1 == false);
       
  1293     bool isDefaultPath2 = FmUtils::isDefaultFolder(mFilePath);
       
  1294     QVERIFY(isDefaultPath2 == false);
       
  1295 }
       
  1296 
       
  1297 /*!
       
  1298      Test Case Description:\n 
       
  1299      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1300         static void     createDefaultFolders( const QString &driverName );\n
       
  1301      2. Case Descrition:  \n
       
  1302      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1303         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1304         <2> driveName = QString(XX) \n
       
  1305      4. Expected result: \n &nbsp;&nbsp;
       
  1306         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1307         <2> return true if it's accessful, or return false \n 
       
  1308  */
       
  1309 void TestFmInternalFmUtils::testCreateDefaultFolders()
       
  1310 {
       
  1311     FmUtils::createDefaultFolders( Folder_C_Data );
       
  1312 }
       
  1313 
       
  1314 /*!
       
  1315      Test Case Description:\n 
       
  1316      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1317         static int      setFileAttributes( const QString &srcFile, const QString &desFile );\n
       
  1318      2. Case Descrition:  \n
       
  1319      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1320         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1321         <2> driveName = QString(XX) \n
       
  1322      4. Expected result: \n &nbsp;&nbsp;
       
  1323         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1324         <2> return true if it's accessful, or return false \n 
       
  1325  */
       
  1326 void TestFmInternalFmUtils::testSetFileAttributes()
       
  1327 {
       
  1328     QString srcFile = mFilePath +"Image.jpg";
       
  1329     QString desFile = mFilePath +"Tone.mp3";
       
  1330     int err = FmUtils::setFileAttributes( srcFile, desFile );
       
  1331     QVERIFY(err == 0);
       
  1332     //crash when run to these lines below.    
       
  1333 //    User::LeaveIfError( src.Open( fsSession, *buf1, EFileRead | EFileShareReadersOnly ) );
       
  1334 //    User::LeaveIfError( des.Open( fsSession, *buf2, EFileWrite | EFileShareExclusive ) );
       
  1335 }
       
  1336 
       
  1337 /*!
       
  1338      Test Case Description:\n 
       
  1339      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1340         static bool     hasEnoughSpace( const QString &targetDrive, qint64 size );\n
       
  1341      2. Case Descrition: Verify the Specified drive has enough space. \n
       
  1342      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1343         <1> driveName = QString(XX), size = qint64 \n
       
  1344      4. Expected result: \n &nbsp;&nbsp;
       
  1345         <1> isHasSpace == true \n 
       
  1346  */
       
  1347 void TestFmInternalFmUtils::testHasEnoughSpaceYes()
       
  1348 {
       
  1349     qint64 size = 1024;
       
  1350     bool isHasSpace = FmUtils::hasEnoughSpace(mDrives[0], size);
       
  1351     QVERIFY(isHasSpace == true);
       
  1352 }
       
  1353 
       
  1354 /*!
       
  1355      Test Case Description:\n 
       
  1356      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1357         static bool     hasEnoughSpace( const QString &targetDrive, qint64 size );\n
       
  1358      2. Case Descrition: Verify the Specified drive does not has enough space when using large size. \n
       
  1359      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1360         <1> driveName = QString(XX), size = qint64 \n
       
  1361      4. Expected result: \n &nbsp;&nbsp;
       
  1362         <1> isHasSpace == false \n 
       
  1363  */
       
  1364 void TestFmInternalFmUtils::testHasEnoughSpaceNo()
       
  1365 {
       
  1366     qint64 size = 999999999999999;
       
  1367     bool isHasSpace = FmUtils::hasEnoughSpace(mDrives[0], size);
       
  1368     QVERIFY(isHasSpace == false);
       
  1369 }
       
  1370 /*!
       
  1371      Test Case Description:\n 
       
  1372      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1373         static int      moveInsideDrive( const QString &source, const QString &target );\n
       
  1374      2. Case Descrition:  \n
       
  1375      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1376         <1> source = QString(XX) \n &nbsp;&nbsp;
       
  1377         <2> target = QString(XX) \n
       
  1378      4. Expected result: \n &nbsp;&nbsp;
       
  1379         <1> isAccessable == false \n 
       
  1380  */
       
  1381 void TestFmInternalFmUtils::testMoveInsideDrive()
       
  1382 {
       
  1383     QString source = mFilePath + "Imageformove.jpg";
       
  1384     QString target = Drive_C + QString("data") + QDir::separator() + QString("resource") + QDir::separator() + "Imagenew.jpg";
       
  1385     QString errStr1;
       
  1386     QString errStr2;
       
  1387     FmUtils::moveInsideDrive(source,target);
       
  1388     FmUtils::checkNewFolderOrFile("Imagenew.jpg", target, errStr1);
       
  1389     bool isNotExsit = FmUtils::checkNewFolderOrFile("Imageformove.jpg", source, errStr2);
       
  1390     qDebug()<<errStr1;
       
  1391     //verify the image.jpg is moved to the new path with the new name.
       
  1392     QVERIFY(errStr1 == "Imagenew.jpg already exist!");
       
  1393     qDebug()<<isNotExsit;
       
  1394 }
       
  1395 
       
  1396 /*!
       
  1397      Test Case Description:\n 
       
  1398      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1399         static int      launchFile( const QString &filePath );\n
       
  1400      2. Case Descrition: Verify the file can be launched or not. \n
       
  1401      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1402         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1403         <2> driveName = QString(XX) \n
       
  1404      4. Expected result: \n &nbsp;&nbsp;
       
  1405         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1406         <2> return true if it's accessful, or return false \n 
       
  1407  */
       
  1408 void TestFmInternalFmUtils::testLaunchFile()
       
  1409 {
       
  1410 //    QString filePath = mFilePath + "Image.jpg";
       
  1411 //    int retInfo = FmUtils::launchFile(filePath); // switch to other thread, test app will shut down.
       
  1412 }
       
  1413 
       
  1414 /*!
       
  1415      Test Case Description:\n 
       
  1416      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1417         static void     sendFiles( QStringList &filePathList );\n
       
  1418      2. Case Descrition:  \n
       
  1419      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1420         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1421         <2> driveName = QString(XX) \n
       
  1422      4. Expected result: \n &nbsp;&nbsp;
       
  1423         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1424         <2> return true if it's accessful, or return false \n 
       
  1425  */
       
  1426 void TestFmInternalFmUtils::testSendFiles()
       
  1427 {
       
  1428     // will delete this case in future
       
  1429 }
       
  1430 
       
  1431 /*!
       
  1432      Test Case Description:\n 
       
  1433      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1434         static QString  getBurConfigPath( QString appPath );\n
       
  1435      2. Case Descrition: verify the right path for backup restore config file. \n
       
  1436      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1437         <1> driveName = QString() \n 
       
  1438      4. Expected result: \n &nbsp;&nbsp;
       
  1439         <1> isAccessable == false \n 
       
  1440  */
       
  1441 void TestFmInternalFmUtils::testGetBurConfigPath()
       
  1442 {
       
  1443     QString retPath = FmUtils::getBurConfigPath(QString());
       
  1444     QVERIFY(retPath == "z:/private/2002BCC0/burconfig.xml");
       
  1445 }
       
  1446 
       
  1447 /*!
       
  1448      Test Case Description:\n 
       
  1449      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1450         static bool     isDriveC( const QString &driverName );\n
       
  1451      2. Case Descrition: Verify the drive is C. \n
       
  1452      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1453         <1> driveName = Drive_C + QString("ItisCDrive") \n 
       
  1454      4. Expected result: \n &nbsp;&nbsp;
       
  1455         <1> isDriveC == true \n 
       
  1456  */
       
  1457 void TestFmInternalFmUtils::testIsDriveCYes()
       
  1458 {
       
  1459     QString pathToVerify = Drive_C +"ItisCDrive";
       
  1460     bool isDriveC = FmUtils::isDriveC(pathToVerify);
       
  1461     QVERIFY(isDriveC == true);
       
  1462 }
       
  1463 
       
  1464 /*!
       
  1465      Test Case Description:\n 
       
  1466      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1467         static bool     isDriveC( const QString &driverName );\n
       
  1468      2. Case Descrition: Verify the drive is C. \n
       
  1469      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1470         <1> driveName = Drive_C + QString("ItisCDrive") \n 
       
  1471      4. Expected result: \n &nbsp;&nbsp;
       
  1472         <1> isDriveC == true \n 
       
  1473  */
       
  1474 void TestFmInternalFmUtils::testIsDriveCNo()
       
  1475 {
       
  1476     QString pathToVerify ="A:\\ItisCDrive";
       
  1477     bool isDriveC1 = FmUtils::isDriveC(pathToVerify);
       
  1478     QVERIFY(isDriveC1 == false);
       
  1479     
       
  1480     bool isDriveC2 = FmUtils::isDriveC(QString());
       
  1481     QVERIFY(isDriveC2 == false);
       
  1482 }
       
  1483 /*!
       
  1484      Test Case Description:\n 
       
  1485      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1486         static int      getMaxFileNameLength();\n
       
  1487      2. Case Descrition:  \n
       
  1488      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1489         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1490         <2> driveName = QString(XX) \n
       
  1491      4. Expected result: \n &nbsp;&nbsp;
       
  1492         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1493         <2> return true if it's accessful, or return false \n 
       
  1494  */
       
  1495 void TestFmInternalFmUtils::testGetMaxFileNameLength()
       
  1496 {
       
  1497     QVERIFY( FmUtils::getMaxFileNameLength() == KMaxFileName );
       
  1498 }
       
  1499 
       
  1500 /*!
       
  1501      Test Case Description:\n 
       
  1502      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1503         static bool     checkMaxPathLength( const QString& path );\n
       
  1504      2. Case Descrition: Verify whether the path length is exceed max path length.  \n
       
  1505      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1506         <1> driveName = QString() \n &nbsp;&nbsp;
       
  1507         <2> driveName = QString(XX) \n
       
  1508      4. Expected result: \n &nbsp;&nbsp;
       
  1509         <1> isAccessable == false \n &nbsp;&nbsp;
       
  1510         <2> return true if it's accessful, or return false \n 
       
  1511  */
       
  1512 void TestFmInternalFmUtils::testCheckMaxPathLength()
       
  1513 {
       
  1514     QString nameMaxPath;
       
  1515     nameMaxPath.fill('x',320);
       
  1516     QString nameNormalPath = "D:\\ThisIsNormalName";
       
  1517     
       
  1518     bool isMax1 = FmUtils::checkMaxPathLength(nameMaxPath);
       
  1519     QVERIFY(isMax1 == false);
       
  1520     
       
  1521     bool isMax2 = FmUtils::checkMaxPathLength(nameNormalPath);
       
  1522     QVERIFY(isMax2 == true);
       
  1523 }
       
  1524 
       
  1525 /*!
       
  1526      Test Case Description:\n 
       
  1527      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1528         static QString getFileType( const QString &filePath  ); \n
       
  1529      2. Case Descrition: verify the right file type is returned. \n
       
  1530      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1531         <1> path =QString(XX) \n
       
  1532      4. Expected result: \n &nbsp;&nbsp;
       
  1533         <1> return the right file type(e.g.: the file is "*.jpg", then return "image/jpeg" \n 
       
  1534  */
       
  1535 void TestFmInternalFmUtils::testGetFileTypeWithSupportType()
       
  1536 {
       
  1537     QString path1 = mFilePath + QString("Image.jpg");
       
  1538     QString path2 = mFilePath + QString("Tone.mp3");
       
  1539     
       
  1540     QString retType = FmUtils::getFileType(path2);   
       
  1541     QVERIFY( FmUtils::getFileType(path1) == "image/jpeg");
       
  1542     QVERIFY( FmUtils::getFileType(path2) == "audio/mpeg");    
       
  1543 }
       
  1544 /*!
       
  1545      Test Case Description:\n 
       
  1546      1. Fucntion Name: \n &nbsp;&nbsp;
       
  1547         static QString getFileType( const QString &filePath  ); \n
       
  1548      2. Case Descrition: verify the funtion when using unsupported file type \n
       
  1549      3. Input Parameters:  \n &nbsp;&nbsp;
       
  1550         <1> path =QString(XX) \n
       
  1551      4. Expected result: \n &nbsp;&nbsp;
       
  1552         <1>  \n 
       
  1553  */
       
  1554 void TestFmInternalFmUtils::testGetFileTypeWithUnSupportType()
       
  1555 {
       
  1556     QString path1 = mFilePath + QString("unknow.unknow");
       
  1557     
       
  1558     QString retType = FmUtils::getFileType(path1);   
       
  1559 //    QVERIFY( FmUtils::getFileType(path1) == ""); 
       
  1560 }
       
  1561 /*!
       
  1562     Descrition of what you will do in this function
       
  1563  */
       
  1564 void TestFmInternalFmUtils::cleanupTestCase()
       
  1565 {
       
  1566 }
       
  1567 
       
  1568 QTEST_MAIN(TestFmInternalFmUtils)