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