classicui_pub/common_file_dialogs_api/tsrc/src/testsdkcfdblocksmemoryselectiondialogmultidrive.cpp
branchGCC_SURGE
changeset 44 484cb5040995
parent 32 512f698a535d
parent 40 7165f928e888
equal deleted inserted replaced
32:512f698a535d 44:484cb5040995
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  Test CAknMemorySelectionDialogMultiDrive.h
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // [INCLUDE FILES]
       
    20 #include <caknmemoryselectiondialogmultidrive.h> 
       
    21 #include <cakncommondialogsbase.h>
       
    22 
       
    23 #include "testsdkcfd.h"
       
    24 
       
    25 
       
    26 const TInt KRootPathLength = 16;
       
    27 const TInt KDefaultFolderLength = 512;
       
    28 const TInt KItemDiscriptor = 512;
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CTestSDKCFD::TestMSDMDNewL
       
    34 // -----------------------------------------------------------------------------
       
    35 TInt CTestSDKCFD::TestMSDMDNewL( CStifItemParser& /*aItem*/ )
       
    36     {
       
    37 
       
    38     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
    39     _LIT( KCall, "Test MemorySelectionDialogMultiDrive::TestMSDMDNewL" );
       
    40 
       
    41     iLog->Log( KTitle );
       
    42     iLog->Log( KCall );
       
    43 
       
    44     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
    45         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
    46     CleanupStack::PushL( memorySelectionDialog );
       
    47     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
    48 
       
    49     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
    50 
       
    51     return KErrNone;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CTestSDKCFD::TestMSDMDNewWithResourceL
       
    56 // -----------------------------------------------------------------------------
       
    57 TInt CTestSDKCFD::TestMSDMDNewWithResourceL( CStifItemParser& /*aItem*/ )
       
    58     {
       
    59     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
    60     _LIT( KCall, "Test MemorySelectionDialogMultiDrive::TestMSDMDNewWithResourceL" );
       
    61 
       
    62     iLog->Log( KTitle );
       
    63     iLog->Log( KCall );
       
    64 
       
    65     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
    66         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, 0, ETrue );
       
    67     CleanupStack::PushL( memorySelectionDialog );
       
    68     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
    69     
       
    70     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
    71 
       
    72     return KErrNone;
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CTestSDKCFD::TestMSDMDNewWithMediaL
       
    77 // -----------------------------------------------------------------------------
       
    78 TInt CTestSDKCFD::TestMSDMDNewWithMediaL( CStifItemParser& /*aItem*/ )
       
    79     {
       
    80     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
    81     _LIT( KCall, "Test MemorySelectionDialogMultiDrive::TestMSDMDNewWithMediaL" );
       
    82 
       
    83     iLog->Log( KTitle );
       
    84     iLog->Log( KCall );
       
    85     TInt media = 1;
       
    86     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
    87         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, 0, ETrue,
       
    88         media );
       
    89     CleanupStack::PushL( memorySelectionDialog );
       
    90     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
    91     
       
    92     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
    93 
       
    94     return KErrNone;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CTestSDKCFD::TestMSDMDSetTitleL
       
    99 // -----------------------------------------------------------------------------
       
   100 TInt CTestSDKCFD::TestMSDMDSetTitleL( CStifItemParser& /*aItem*/ )
       
   101     {
       
   102     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   103     _LIT( KCall, "Test MemorySelectionDialogMultiDrive::SetTitleL" );
       
   104 
       
   105     iLog->Log( KTitle );
       
   106     iLog->Log( KCall );
       
   107 
       
   108     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   109         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   110     CleanupStack::PushL( memorySelectionDialog );
       
   111     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   112 
       
   113     _LIT( KDialogTitle, "Hello Dialog!" );
       
   114     TDesC dialogTitle(KDialogTitle);
       
   115     memorySelectionDialog->SetTitleL( dialogTitle );
       
   116 
       
   117     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   118     
       
   119     return KErrNone;
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CTestSDKCFD::TestMSDMDSetLeftSoftkeyL
       
   124 // -----------------------------------------------------------------------------
       
   125 TInt CTestSDKCFD::TestMSDMDSetLeftSoftkeyL( CStifItemParser& /*aItem*/ )
       
   126     {
       
   127 
       
   128     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   129     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::SetLeftSoftkeyL" );
       
   130     iLog->Log( KTitle );
       
   131     iLog->Log( KCall1 );
       
   132 
       
   133     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   134         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   135     CleanupStack::PushL( memorySelectionDialog );
       
   136     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   137 
       
   138     _LIT( KLeftKey, "Enter" );
       
   139     TDesC dialogLeftKey( KLeftKey );
       
   140 
       
   141     memorySelectionDialog->SetLeftSoftkeyL( dialogLeftKey );
       
   142 
       
   143     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   144 
       
   145     return KErrNone;
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CTestSDKCFD::TestMSDMDSetRightSoftkeyL
       
   150 // -----------------------------------------------------------------------------
       
   151 TInt CTestSDKCFD::TestMSDMDSetRightSoftkeyL( CStifItemParser& /*aItem*/ )
       
   152     {
       
   153 
       
   154     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   155     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::SetRightSoftkeyL" );
       
   156     iLog->Log( KTitle );
       
   157     iLog->Log( KCall1 );
       
   158 
       
   159     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   160         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   161     CleanupStack::PushL( memorySelectionDialog );
       
   162     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   163 
       
   164     _LIT( KRightKey, "Enter" );
       
   165     TDesC dialogRightKey( KRightKey );
       
   166 
       
   167     memorySelectionDialog->SetRightSoftkeyL( dialogRightKey );
       
   168 
       
   169     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   170 
       
   171     return KErrNone;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CTestSDKCFD::TestMSDMDExecuteL
       
   176 // -----------------------------------------------------------------------------
       
   177 TInt CTestSDKCFD::TestMSDMDExecuteL( CStifItemParser& /*aItem*/ )
       
   178     {
       
   179 
       
   180     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   181     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::ExecuteL" );
       
   182     iLog->Log( KTitle );
       
   183     iLog->Log( KCall1 );
       
   184 
       
   185     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   186         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   187     CleanupStack::PushL( memorySelectionDialog );
       
   188     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   189 
       
   190     _LIT( KCallExecuteL1True, "MemorySelectionDialogMultiDrive::ExecuteL Return ETrue" );
       
   191     _LIT( KCallExecuteL1False, "MemorySelectionDialogMultiDrive::ExecuteL Return EFalse" );
       
   192 
       
   193     TDriveNumber selectedDrive = EDriveC;
       
   194     CAknCommonDialogsBase::TReturnKey returnKey;
       
   195 
       
   196     returnKey = memorySelectionDialog->ExecuteL( selectedDrive );
       
   197 
       
   198     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   199 
       
   200     if ( returnKey )
       
   201         {
       
   202         iLog->Log( KCallExecuteL1True );
       
   203         }
       
   204     else
       
   205         {
       
   206         iLog->Log( KCallExecuteL1False );
       
   207         }
       
   208 
       
   209     return KErrNone;
       
   210     }
       
   211 // -----------------------------------------------------------------------------
       
   212 // CTestSDKCFD::TestMSDMDExecuteLDefaultFolderL
       
   213 // -----------------------------------------------------------------------------
       
   214 TInt CTestSDKCFD::TestMSDMDExecuteLDefaultFolderL( CStifItemParser& /*aItem*/ )
       
   215     {
       
   216     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   217     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::TestMSDMDExecuteLDefaultFolderL" );
       
   218 
       
   219     iLog->Log( KTitle );
       
   220     iLog->Log( KCall1 );
       
   221 
       
   222     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   223         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   224     CleanupStack::PushL( memorySelectionDialog );
       
   225     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   226     
       
   227     _LIT( KCallExecuteL1True, "MemorySelectionDialogMultiDrive::ExecuteL Return ETrue" );
       
   228     _LIT( KCallExecuteL1False, "MemorySelectionDialogMultiDrive::ExecuteL Return EFalse" );
       
   229     
       
   230     TDriveNumber selectedDrive = EDriveC;
       
   231     _LIT( KRootPath, "C:\\" );
       
   232     _LIT( KDefaultFolder, " " );
       
   233     TBuf<KRootPathLength> rootBuf( KRootPath );
       
   234     TBuf<KDefaultFolderLength> defaultBuf( KDefaultFolder );
       
   235 
       
   236     CAknCommonDialogsBase::TReturnKey returnKey;
       
   237     returnKey = memorySelectionDialog->ExecuteL( selectedDrive, &rootBuf,
       
   238         &defaultBuf );
       
   239     
       
   240     if ( returnKey )
       
   241         {
       
   242         iLog->Log( KCallExecuteL1True );
       
   243         }
       
   244     else
       
   245         {
       
   246         iLog->Log( KCallExecuteL1False );
       
   247         }
       
   248     
       
   249     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   250 
       
   251     return KErrNone;
       
   252     }
       
   253 // -----------------------------------------------------------------------------
       
   254 // CTestSDKCFD::TestMSDMDRunDlgLD
       
   255 // -----------------------------------------------------------------------------
       
   256 TInt CTestSDKCFD::TestMSDMDRunDlgLD( CStifItemParser& /*aItem*/ )
       
   257     {
       
   258     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   259     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::NewL1" );
       
   260     iLog->Log( KTitle );
       
   261     iLog->Log( KCall1 );
       
   262     
       
   263     TDriveNumber selectedDrive = EDriveC;
       
   264     CAknMemorySelectionDialogMultiDrive::RunDlgLD( selectedDrive );
       
   265 
       
   266     return KErrNone;
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CTestSDKCFD::TestMSDMDRunDlgLDTitleL
       
   271 // -----------------------------------------------------------------------------
       
   272 TInt CTestSDKCFD::TestMSDMDRunDlgLDTitleL( CStifItemParser& /*aItem*/ )
       
   273     {
       
   274 
       
   275     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   276     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::TestMSDMDRunDlgLDTitleL" );
       
   277 
       
   278     iLog->Log( KTitle );
       
   279     iLog->Log( KCall1 );
       
   280 
       
   281     _LIT( KDialogTitle, "Hello Dialog!" );
       
   282     TBuf<KMaxFileName> dialogTitle( KDialogTitle );
       
   283     
       
   284     TDriveNumber selectedDrive = EDriveC;
       
   285 
       
   286     CAknMemorySelectionDialogMultiDrive::RunDlgLD( selectedDrive, dialogTitle );
       
   287 
       
   288     return KErrNone;
       
   289     }
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CTestSDKCFD::TestMSDMDRunDlgLDResourceL
       
   293 // -----------------------------------------------------------------------------
       
   294 TInt CTestSDKCFD::TestMSDMDRunDlgLDResourceL( CStifItemParser& /*aItem*/ )
       
   295     {
       
   296     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   297     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::TestMSDMDRunDlgLDResourceL" );
       
   298     iLog->Log( KTitle );
       
   299     iLog->Log( KCall1 );
       
   300 
       
   301     TDriveNumber selectedDrive = EDriveC;
       
   302 
       
   303     _LIT( KRootPath, "C:\\" );
       
   304     _LIT( KDefaultFolder, " " );
       
   305 
       
   306     TBuf<KRootPathLength> rootBuf( KRootPath );
       
   307     TBuf<KDefaultFolderLength> defaultBuf( KDefaultFolder );
       
   308     CAknMemorySelectionDialogMultiDrive::RunDlgLD( selectedDrive, 0, &rootBuf,
       
   309         &defaultBuf );
       
   310 
       
   311     return KErrNone;
       
   312     }
       
   313 
       
   314 // -----------------------------------------------------------------------------
       
   315 // CTestSDKCFD::TestMSDMDGetItemL
       
   316 // -----------------------------------------------------------------------------
       
   317 TInt CTestSDKCFD::TestMSDMDGetItemL( CStifItemParser& /*aItem*/ )
       
   318     {
       
   319     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   320     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::TestMSDMDGetItemL" );
       
   321 
       
   322     iLog->Log( KTitle );
       
   323     iLog->Log( KCall1 );
       
   324 
       
   325     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   326         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   327     CleanupStack::PushL( memorySelectionDialog );
       
   328     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   329 
       
   330     TInt index = 0;
       
   331     TBuf<KItemDiscriptor> itemdes;
       
   332     memorySelectionDialog->GetItem( index, itemdes );
       
   333 
       
   334     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   335 
       
   336     return KErrNone;
       
   337     }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CTestSDKCFD::TestMSDMDAddDrivePathsL
       
   341 // -----------------------------------------------------------------------------
       
   342 TInt CTestSDKCFD::TestMSDMDAddDrivePathsL( CStifItemParser& /*aItem*/ )
       
   343     {
       
   344 
       
   345     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   346     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::TestMSDMDAddDrivePathsL" );
       
   347 
       
   348     iLog->Log( KTitle );
       
   349     iLog->Log( KCall1 );
       
   350 
       
   351     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   352         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   353     CleanupStack::PushL( memorySelectionDialog );
       
   354     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   355 
       
   356     _LIT( KRootPath, "C:\\Data" );
       
   357     _LIT( KDefaultFolder, "Others" );
       
   358     TBuf<KRootPathLength> rootBuf(KRootPath);
       
   359     TBuf<KDefaultFolderLength> defaultBuf(KDefaultFolder);
       
   360     memorySelectionDialog->AddDrivePathsL( rootBuf, defaultBuf );
       
   361 
       
   362     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   363 
       
   364     return KErrNone;
       
   365     }
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // CTestSDKCFD::TestMSDMDFindIndexByDriveL
       
   369 // -----------------------------------------------------------------------------
       
   370 TInt CTestSDKCFD::TestMSDMDFindIndexByDriveL( CStifItemParser& /*aItem*/ )
       
   371     {
       
   372 
       
   373     _LIT( KTitle, "Class <MemorySelectionDialogMultiDrive>" );
       
   374     _LIT( KCall1, "Test MemorySelectionDialogMultiDrive::TestMSDMDFindIndexByDriveL" );
       
   375 
       
   376     iLog->Log( KTitle );
       
   377     iLog->Log( KCall1 );
       
   378 
       
   379     CAknMemorySelectionDialogMultiDrive* memorySelectionDialog =
       
   380         CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeNormal, ETrue );
       
   381     CleanupStack::PushL( memorySelectionDialog );
       
   382     STIF_ASSERT_NOT_NULL( memorySelectionDialog );
       
   383 
       
   384     TDriveNumber drive = EDriveC;
       
   385     memorySelectionDialog->FindIndexByDrive( drive );
       
   386 
       
   387     CleanupStack::PopAndDestroy( memorySelectionDialog );
       
   388 
       
   389     return KErrNone;
       
   390     }
       
   391 
       
   392 //  [End of File]