uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestcmdlg/src/bctestcommondlg.cpp
changeset 22 75713bee6484
parent 21 558113899881
child 26 62ef28f7b435
child 28 d33307312dfe
equal deleted inserted replaced
21:558113899881 22:75713bee6484
     1 /*
       
     2 * Copyright (c) 2006 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 case
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <w32std.h>
       
    20 #include <coecntrl.h>
       
    21 #include <akncommondialogs.h>
       
    22 //#include <AknCommonDialogsDynMem.h>
       
    23 
       
    24 #include <MAknFileSelectionObserver.h>
       
    25 #include <MaknFileFilter.h>
       
    26 #include <bctestcmdlg.rsg>
       
    27 
       
    28 #include "BCTestCommonDlg.h"
       
    29 #include "BCTestCmDlg.hrh"
       
    30 #include "streamlogger.h"
       
    31 
       
    32 //helper class
       
    33 
       
    34 struct MonkFilter: public MAknFileFilter{
       
    35     TBool Accept( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/ ) const{
       
    36         return ETrue;
       
    37     }
       
    38 };
       
    39 
       
    40 // ======== MEMBER FUNCTIONS ========
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Symbian 2nd static Constructor
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CBCTestCommonDlg* CBCTestCommonDlg::NewL()
       
    47     {
       
    48     CBCTestCommonDlg* self = new( ELeave ) CBCTestCommonDlg();
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54     
       
    55 // ---------------------------------------------------------------------------
       
    56 // C++ default constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CBCTestCommonDlg::CBCTestCommonDlg()
       
    60     {    
       
    61     }
       
    62     
       
    63 // ---------------------------------------------------------------------------
       
    64 // Destructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CBCTestCommonDlg::~CBCTestCommonDlg()
       
    68     {  
       
    69     }
       
    70     
       
    71 // ---------------------------------------------------------------------------
       
    72 // Symbian 2nd Constructor
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void CBCTestCommonDlg::ConstructL()
       
    76     {    
       
    77     BuildScriptL();    
       
    78     }
       
    79 
       
    80 void CBCTestCommonDlg::SetupL()
       
    81     {
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CBCTestCommonDlg::BuildScriptL
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CBCTestCommonDlg::BuildScriptL()
       
    89     { 
       
    90     AddTestL( DELAY(1), TEND);
       
    91 
       
    92     // Add script as your need.   
       
    93     for(int i=0; i<EBCTestCmdCommonDlgEnd - EBCTestCmdCommonDlgBegin -1; ++i)
       
    94         {
       
    95         AddTestL( LeftCBA, REP(Down, 4), Right, TEND ); //navigate to common dialog menu
       
    96 
       
    97         for(int j=0; j<i; ++j)
       
    98             AddTestL( Down, TEND);  // navigate to each sub menu item
       
    99         AddTestL( LeftCBA, TEND );  // trigger the menu item.
       
   100 
       
   101         BuildSelectScriptL(i);
       
   102         BuildMoveScriptL(i);
       
   103         BuildSaveScriptL(i);
       
   104         BuildCopyScriptL(i);
       
   105         }
       
   106     }
       
   107 
       
   108 void CBCTestCommonDlg::BuildSelectScriptL(int i)
       
   109     {
       
   110     AddCancelL();       //OK may enter a folder and ask user to select more.
       
   111     
       
   112     // some sepcial cases
       
   113     if( i >= (EBCTestCmdCommonDlgSelect5 - EBCTestCmdCommonDlgBegin -1) &&
       
   114         i <= (EBCTestCmdCommonDlgSelect8 - EBCTestCmdCommonDlgBegin -1))
       
   115         AddCancelL();   //first back, 2nd cancel.
       
   116     
       
   117     if( i == (EBCTestCmdCommonDlgSelect8 - EBCTestCmdCommonDlgBegin -1))
       
   118         AddCancelL();   //first back, then back again, finally cancel.
       
   119     }
       
   120 
       
   121 void CBCTestCommonDlg::BuildMoveScriptL( int )
       
   122     {
       
   123     }
       
   124 
       
   125 void CBCTestCommonDlg::BuildSaveScriptL( int )
       
   126     {
       
   127     }
       
   128 
       
   129 void CBCTestCommonDlg::BuildCopyScriptL( int )
       
   130     {
       
   131     }
       
   132     
       
   133 void CBCTestCommonDlg::AddOKL()
       
   134     {
       
   135     // add dlg response sciprts
       
   136     for(int i=0; i<1; ++i)
       
   137         AddTestL( WAIT(5), KeyOK, TEND);
       
   138     }
       
   139 
       
   140 void CBCTestCommonDlg::AddCancelL()
       
   141     {
       
   142     // add dlg response sciprts
       
   143     for(int i=0; i<1; ++i)
       
   144         AddTestL( WAIT(5), RightCBA, TEND);
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CBCTestCommonDlg::RunL
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CBCTestCommonDlg::RunL( TInt aCmd )
       
   152     {
       
   153     SetupL();
       
   154     RunSelectL(aCmd);
       
   155     RunMoveL(aCmd);
       
   156     RunSaveL(aCmd);
       
   157     RunCopyL(aCmd);
       
   158     Teardown();
       
   159     }
       
   160 
       
   161 void CBCTestCommonDlg::RunSelectL(TInt aCmd)
       
   162     {
       
   163     switch(aCmd)
       
   164         {
       
   165         case EBCTestCmdCommonDlgSelect1:
       
   166             TestSelectL();
       
   167             break;
       
   168         case EBCTestCmdCommonDlgSelect2:
       
   169             TestSelectL(_L("a title"));
       
   170             break;
       
   171         case EBCTestCmdCommonDlgSelect3:
       
   172             {
       
   173             MonkFilter filter;
       
   174             TestSelectL(&filter);
       
   175             break;
       
   176             }
       
   177         case EBCTestCmdCommonDlgSelect4:
       
   178             TestSelectL(R_BCTEST_FILE_SELECTION_ALL);
       
   179             break;
       
   180         case EBCTestCmdCommonDlgSelect5:
       
   181             TestSelectL(_L("C:\\Data"), R_BCTEST_MEMORY_SELECTION_LOCATIONS);
       
   182             break;
       
   183         case EBCTestCmdCommonDlgSelect6:
       
   184             {
       
   185             MonkFilter filter;
       
   186             TestSelectL(_L("C:\\Data"), &filter);
       
   187             break;
       
   188             }
       
   189         case EBCTestCmdCommonDlgSelect7:
       
   190             TestSelectL(_L("C:\\Data"), _L("a title"));
       
   191             break;
       
   192         case EBCTestCmdCommonDlgSelect8:
       
   193             TestSelectL(_L("C:\\Data"), R_BCTEST_MEMORY_SELECTION_LOCATIONS, R_BCTEST_FILE_SELECTION_ALL);
       
   194             break;
       
   195         default:
       
   196             break;
       
   197         }
       
   198     }
       
   199 
       
   200 void CBCTestCommonDlg::RunMoveL(TInt aCmd)
       
   201     {
       
   202     switch(aCmd)
       
   203         {
       
   204         case EBCTestCmdCommonDlgMove1:
       
   205             TestMoveL();
       
   206             break;
       
   207         case EBCTestCmdCommonDlgMove2:
       
   208             TestMoveL(_L("a title"));
       
   209             break;
       
   210         case EBCTestCmdCommonDlgMove3:
       
   211             {
       
   212             MonkFilter filter;
       
   213             TestMoveL(&filter);
       
   214             break;
       
   215             }
       
   216         case EBCTestCmdCommonDlgMove4:
       
   217             TestMoveL(R_BCTEST_FILE_SELECTION_ALL);
       
   218             break;
       
   219         default:
       
   220             break;
       
   221         }
       
   222     }
       
   223 
       
   224 void CBCTestCommonDlg::RunSaveL(TInt aCmd)
       
   225     {
       
   226     switch(aCmd)
       
   227         {
       
   228         case EBCTestCmdCommonDlgSave1:
       
   229             TestSaveL();
       
   230             break;
       
   231         case EBCTestCmdCommonDlgSave2:
       
   232             TestSaveL(_L("a sel title"), _L("a name prompt"));
       
   233             break;
       
   234         case EBCTestCmdCommonDlgSave3:
       
   235             {
       
   236             MonkFilter filter;
       
   237             TestSaveL(&filter);
       
   238             break;
       
   239             }
       
   240         case EBCTestCmdCommonDlgSave4:
       
   241             TestSaveL(R_BCTEST_FILE_SELECTION_ALL);
       
   242             break;
       
   243         case EBCTestCmdCommonDlgSave5:
       
   244             TestSaveL(R_BCTEST_FILE_SELECTION_ALL, _L("a prompt"));
       
   245             break;
       
   246         case EBCTestCmdCommonDlgSave6:
       
   247             TestSaveL(EFalse, R_BCTEST_MEMORY_SELECTION_LOCATIONS);
       
   248             break;
       
   249         case EBCTestCmdCommonDlgSave7:
       
   250             TestSaveL(EFalse, R_BCTEST_MEMORY_SELECTION_LOCATIONS, _L("a prompt"));
       
   251             break;
       
   252         default:
       
   253             break;
       
   254         }
       
   255     }
       
   256 
       
   257 void CBCTestCommonDlg::RunCopyL(TInt aCmd)
       
   258     {
       
   259     switch(aCmd)
       
   260         {
       
   261         case EBCTestCmdCommonDlgCopy1:
       
   262             TestCopyL();
       
   263             break;
       
   264         case EBCTestCmdCommonDlgCopy2:
       
   265             TestCopyL(R_BCTEST_FILE_SELECTION_ALL);
       
   266             break;
       
   267         case EBCTestCmdCommonDlgCopy3:
       
   268             {
       
   269             MonkFilter filter;
       
   270             TestCopyL(&filter);
       
   271             break;
       
   272             }
       
   273         default:
       
   274             break;
       
   275         }
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // CBCTestCommonDlg::ReleaseCaseL
       
   280 // ---------------------------------------------------------------------------
       
   281 //   
       
   282 void CBCTestCommonDlg::Teardown()
       
   283     {
       
   284     }
       
   285 
       
   286 void CBCTestCommonDlg::TestSelectL()
       
   287     {
       
   288     TFileName emptyFileName;
       
   289     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   290         R_BCTEST_MEMORY_SELECTION_LOCATIONS );
       
   291     AssertTrueL(ETrue, _L("Select with Res ID"));
       
   292     }
       
   293 
       
   294 void CBCTestCommonDlg::TestSelectL(const TDesC &aTitle)
       
   295     {
       
   296     TFileName emptyFileName;
       
   297     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   298         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   299         aTitle);
       
   300     AssertTrueL(ETrue, _L("Select with Res ID and Title"));
       
   301     }
       
   302 
       
   303 void CBCTestCommonDlg::TestSelectL(MAknFileFilter* aFilter)
       
   304     {
       
   305     TFileName emptyFileName;
       
   306     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   307         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   308         aFilter);
       
   309     AssertTrueL(ETrue, _L("Select with Res ID and Filter"));
       
   310     }
       
   311 
       
   312 void CBCTestCommonDlg::TestSelectL(TInt aFileSelResID)
       
   313     {
       
   314     TFileName emptyFileName;
       
   315     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   316         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   317         aFileSelResID);
       
   318     AssertTrueL(ETrue, _L("Select with Res ID and File Selection Res ID"));
       
   319     }
       
   320 
       
   321 void CBCTestCommonDlg::TestSelectL(const TDesC& aStartFolder, TInt aMemSelResID)
       
   322     {
       
   323     TFileName emptyFileName;
       
   324     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   325         aStartFolder,
       
   326         aMemSelResID);
       
   327     AssertTrueL(ETrue, _L("Select with start folder"));
       
   328     }
       
   329 
       
   330 
       
   331 void CBCTestCommonDlg::TestSelectL(const TDesC& aStartFolder, MAknFileFilter* aFilter)
       
   332     {
       
   333     TFileName emptyFileName;
       
   334     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   335         aStartFolder,
       
   336         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   337         aFilter);
       
   338     AssertTrueL(ETrue, _L("Select with start folder and filter"));
       
   339     }
       
   340 
       
   341 void CBCTestCommonDlg::TestSelectL(const TDesC &aStartFolder, const TDesC &aTitle)
       
   342     {
       
   343     TFileName emptyFileName;
       
   344     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   345         aStartFolder, 
       
   346         R_BCTEST_MEMORY_SELECTION_LOCATIONS, 
       
   347         aTitle);
       
   348     AssertTrueL(ETrue, _L("Select with start folder and title"));
       
   349     }
       
   350 
       
   351 void CBCTestCommonDlg::TestSelectL(const TDesC &aStartFolder, TInt aMemSelResID, TInt aFileSelResID)
       
   352     {
       
   353     TFileName emptyFileName;
       
   354     TInt returnValue = AknCommonDialogs::RunSelectDlgLD( emptyFileName, 
       
   355         aStartFolder, 
       
   356         aMemSelResID, 
       
   357         aFileSelResID);
       
   358     AssertTrueL(ETrue, _L("Select with start folder and file selection res ID"));
       
   359     }
       
   360 
       
   361 void CBCTestCommonDlg::TestMoveL()
       
   362     {
       
   363     TFileName emptyFileName;
       
   364     TInt returnValue = AknCommonDialogs::RunMoveDlgLD( emptyFileName, 
       
   365         R_BCTEST_MEMORY_SELECTION_LOCATIONS );
       
   366     AssertTrueL(ETrue, _L("Move"));
       
   367     }
       
   368 
       
   369 void CBCTestCommonDlg::TestMoveL(const TDesC &aTitle)
       
   370     {
       
   371     TFileName emptyFileName;
       
   372     TInt returnValue = AknCommonDialogs::RunMoveDlgLD( emptyFileName, 
       
   373         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   374         aTitle);
       
   375     AssertTrueL(ETrue, _L("Move with title"));
       
   376     }
       
   377 
       
   378 void CBCTestCommonDlg::TestMoveL(MAknFileFilter *aFilter)
       
   379     {
       
   380     TFileName emptyFileName;
       
   381     TInt returnValue = AknCommonDialogs::RunMoveDlgLD( emptyFileName, 
       
   382         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   383         aFilter);
       
   384     AssertTrueL(ETrue, _L("Move with filter"));
       
   385     }
       
   386 
       
   387 void CBCTestCommonDlg::TestMoveL(TInt aFileSelResID)
       
   388     {
       
   389     TFileName emptyFileName;
       
   390     TInt returnValue = AknCommonDialogs::RunMoveDlgLD( emptyFileName, 
       
   391         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   392         aFileSelResID);
       
   393     AssertTrueL(ETrue, _L("Move with file selection Res ID"));
       
   394     }
       
   395 
       
   396 void CBCTestCommonDlg::TestSaveL()
       
   397     {
       
   398     TFileName defaultFileName(_L("foo.jpg"));
       
   399     TInt returnValue = AknCommonDialogs::RunSaveDlgLD( defaultFileName, 
       
   400         R_BCTEST_MEMORY_SELECTION_LOCATIONS );
       
   401     AssertTrueL(ETrue, _L("Save"));
       
   402     }
       
   403 
       
   404 void CBCTestCommonDlg::TestSaveL(MAknFileFilter *aFilter)
       
   405     {
       
   406     TFileName defaultFileName(_L("foo.jpg"));
       
   407     TInt returnValue = AknCommonDialogs::RunSaveDlgLD( defaultFileName, 
       
   408         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   409         aFilter);
       
   410     AssertTrueL(ETrue, _L("Save with filter"));
       
   411     }
       
   412 
       
   413 void CBCTestCommonDlg::TestSaveL(const TDesC &aFileTitle, const TDesC &aPromptTitle)
       
   414     {
       
   415     TFileName defaultFileName(_L("foo.jpg"));
       
   416     TInt returnValue = AknCommonDialogs::RunSaveDlgLD( defaultFileName, 
       
   417         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   418         aFileTitle,
       
   419         aPromptTitle);
       
   420     AssertTrueL(ETrue, _L("Save with title"));
       
   421     }
       
   422 
       
   423 void CBCTestCommonDlg::TestSaveL(TInt aFileSelResID)
       
   424     {
       
   425     TFileName defaultFileName(_L("foo.jpg"));
       
   426     TInt returnValue = AknCommonDialogs::RunSaveDlgLD( defaultFileName, 
       
   427         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   428         aFileSelResID);
       
   429     AssertTrueL(ETrue, _L("Save with file selection res ID"));
       
   430     }
       
   431 
       
   432 void CBCTestCommonDlg::TestSaveL(TInt aFileSelResID, const TDesC &aPrompt)
       
   433     {
       
   434     TFileName defaultFileName(_L("foo.jpg"));
       
   435     TInt returnValue = AknCommonDialogs::RunSaveDlgLD( defaultFileName, 
       
   436         R_BCTEST_MEMORY_SELECTION_LOCATIONS,
       
   437         aFileSelResID,
       
   438         aPrompt);
       
   439     AssertTrueL(ETrue, _L("Save with file selection res ID and Prompt"));
       
   440     }
       
   441 
       
   442 void CBCTestCommonDlg::TestSaveL(TBool /*aDirFlag*/, TInt aMemSelResID)
       
   443     {
       
   444     TFileName defaultFileName(_L("foo.jpg"));
       
   445     TInt returnValue = AknCommonDialogs::RunSaveDlgNoDirectorySelectionLD( defaultFileName, 
       
   446         aMemSelResID);
       
   447     AssertTrueL(ETrue, _L("Save without dir selection"));
       
   448     }
       
   449 
       
   450 void CBCTestCommonDlg::TestSaveL(TBool /*aDirFlag*/, TInt aMemSelResID, const TDesC& aPrompt)
       
   451     {
       
   452     TFileName defaultFileName(_L("foo.jpg"));
       
   453     TInt returnValue = AknCommonDialogs::RunSaveDlgNoDirectorySelectionLD( defaultFileName, 
       
   454         aMemSelResID, aPrompt);
       
   455     AssertTrueL(ETrue, _L("Save without dir selection but with a prompt"));
       
   456     }
       
   457 
       
   458 void CBCTestCommonDlg::TestCopyL()
       
   459     {
       
   460     TFileName emptyFileName;
       
   461     TInt returnValue = AknCommonDialogs::RunCopyDlgLD( emptyFileName, 
       
   462         R_BCTEST_MEMORY_SELECTION_LOCATIONS);
       
   463     AssertTrueL(ETrue, _L("Copy"));
       
   464     }
       
   465 
       
   466 void CBCTestCommonDlg::TestCopyL(MAknFileFilter *aFilter)
       
   467     {
       
   468     TFileName emptyFileName;
       
   469     TInt returnValue = AknCommonDialogs::RunCopyDlgLD( emptyFileName, 
       
   470         R_BCTEST_MEMORY_SELECTION_LOCATIONS, aFilter);
       
   471     AssertTrueL(ETrue, _L("Copy with filter"));
       
   472     }
       
   473 
       
   474 void CBCTestCommonDlg::TestCopyL(TInt aFileSelResID)
       
   475     {
       
   476     TFileName emptyFileName;
       
   477     TInt returnValue = AknCommonDialogs::RunCopyDlgLD( emptyFileName, 
       
   478         R_BCTEST_MEMORY_SELECTION_LOCATIONS, aFileSelResID);
       
   479     AssertTrueL(ETrue, _L("Copy with file selection res ID"));
       
   480     }
       
   481 
       
   482 // EOF