classicui_pub/common_file_dialogs_api/tsrc/src/testsdkcfdblocksfileselectiondialog.cpp
changeset 39 407d15c32f24
parent 30 56e9a0aaad89
child 40 7165f928e888
equal deleted inserted replaced
30:56e9a0aaad89 39:407d15c32f24
     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 CAknFileSelectionDialog.h
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // [INCLUDE FILES]
       
    20 #include <maknfileselectionobserver.h>
       
    21 #include <maknfilefilter.h>
       
    22 
       
    23 #include "testsdkcfd.h"
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CTestSDKCFD::TestFSDNewL
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 TInt CTestSDKCFD::TestFSDNewL( CStifItemParser& /*aItem*/)
       
    33     {
       
    34 
       
    35     // Print to UI
       
    36     _LIT( KCFDTestModule, "CFDTestModule" );
       
    37     _LIT( KTestFSDNewL, "In TestFSDNewL" );
       
    38     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDNewL );
       
    39     // Print to log file
       
    40     iLog->Log( KTestFSDNewL );
       
    41 
       
    42     TCommonDialogType iDlgType = ECFDDialogTypeSelect;
       
    43     TInt err = KErrNone;
       
    44     TRAP( err, iFDlg = CAknFileSelectionDialog::NewL( iDlgType ) );
       
    45     return err;
       
    46 
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CTestSDKCFD::TestFSDNewLWithResL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 TInt CTestSDKCFD::TestFSDNewLWithResL( CStifItemParser& /*aItem*/)
       
    54     {
       
    55 
       
    56     // Print to UI
       
    57     _LIT( KCFDTestModule, "CFDTestModule" );
       
    58     _LIT( FDlgNewWithResL, "In FDlgNewWithResL" );
       
    59     TestModuleIf().Printf( 0, KCFDTestModule, FDlgNewWithResL );
       
    60     // Print to log file
       
    61     iLog->Log( FDlgNewWithResL );
       
    62 
       
    63     TCommonDialogType iDlgType = ECFDDialogTypeSelect;
       
    64     TInt err = KErrNone;
       
    65     TRAP( err, iFDlg = CAknFileSelectionDialog::NewL( iDlgType, 0 ) );
       
    66     return err;
       
    67 
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CTestSDKCFD::TestFSDExecuteL
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 TInt CTestSDKCFD::TestFSDExecuteL( CStifItemParser& /*aItem*/)
       
    75     {
       
    76 
       
    77     // Print to UI
       
    78     _LIT( KCFDTestModule, "CFDTestModule" );
       
    79     _LIT( KFDlgExecuteL, "In FDlgExecuteL" );
       
    80     TestModuleIf().Printf( 0, KCFDTestModule, KFDlgExecuteL );
       
    81     // Print to log file
       
    82     iLog->Log( KFDlgExecuteL );
       
    83 
       
    84     _LIT( KRootPath, "C:\\TestFramework\\" );
       
    85     TFileName rootFileName( KRootPath );
       
    86     TInt err = KErrNone;
       
    87     TRAP( err, iFDlg->ExecuteL( rootFileName ) );
       
    88  
       
    89     return err;
       
    90 
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CTestSDKCFD::TestFSDRunDlgLD
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 TInt CTestSDKCFD::TestFSDRunDlgLD( CStifItemParser& /*aItem*/)
       
    98     {
       
    99 
       
   100     // Print to UI
       
   101     _LIT( KCFDTestModule, "CFDTestModule" );
       
   102     _LIT( FDlgQuickCreateL, "In FDlgQuickCreateL" );
       
   103     TestModuleIf().Printf( 0, KCFDTestModule, FDlgQuickCreateL );
       
   104     // Print to log file
       
   105     iLog->Log( FDlgQuickCreateL );
       
   106 
       
   107     TFileName filename(_L("C:\\data\\"));
       
   108     TFileName folder(_L("C:\\"));
       
   109     TInt err = KErrNone;
       
   110 
       
   111     TRAP( err, CAknFileSelectionDialog::RunDlgLD( filename, folder ) );
       
   112 
       
   113     return err;
       
   114 
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CTestSDKCFD::TestFSDRunDlgLDWithTitleLD
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TInt CTestSDKCFD::TestFSDRunDlgLDWithTitleLD( CStifItemParser& /*aItem*/)
       
   122     {
       
   123 
       
   124     // Print to UI
       
   125     _LIT( KCFDTestModule, "CFDTestModule" );
       
   126     _LIT( FDlgQuickCreateWithTitleL, "In FDlgQuickCreateWithTitleL" );
       
   127     TestModuleIf().Printf( 0, KCFDTestModule, FDlgQuickCreateWithTitleL );
       
   128     // Print to log file
       
   129     iLog->Log( FDlgQuickCreateWithTitleL );
       
   130 
       
   131     TFileName filename;
       
   132     TFileName folder(_L("C:\\Data\\"));
       
   133     TInt err = KErrNone;
       
   134 
       
   135     TRAP( err, CAknFileSelectionDialog::RunDlgLD( filename, folder, _L( "a title" ) ) );
       
   136 
       
   137     return err;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CTestSDKCFD::TestFSDRunDlgLDWithResLD
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 TInt CTestSDKCFD::TestFSDRunDlgLDWithResLD( CStifItemParser& /*aItem*/)
       
   145     {
       
   146 
       
   147     // Print to UI
       
   148     _LIT( KCFDTestModule, "CFDTestModule" );
       
   149     _LIT( FDlgQuickCreateWithResL, "In FDlgQuickCreateWithResL" );
       
   150     TestModuleIf().Printf( 0, KCFDTestModule, FDlgQuickCreateWithResL );
       
   151     // Print to log file
       
   152     iLog->Log( FDlgQuickCreateWithResL );
       
   153 
       
   154     TFileName filename;
       
   155     TFileName folder(_L("C:\\Data\\"));
       
   156     TInt err = KErrNone;
       
   157 
       
   158     TRAP( err, CAknFileSelectionDialog::RunDlgLD( filename, folder, 0 ) );
       
   159 
       
   160     return err;
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CTestSDKCFD::TestFSDDelete
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 TInt CTestSDKCFD::TestFSDDelete( CStifItemParser& /*aItem*/)
       
   168     {
       
   169     // Print to UI
       
   170     _LIT( KCFDTestModule, "CFDTestModule" );
       
   171     _LIT( KFDlgDeleteL, "In FDlgDeleteL" );
       
   172     TestModuleIf().Printf( 0, KCFDTestModule, KFDlgDeleteL );
       
   173     // Print to log file
       
   174     iLog->Log( KFDlgDeleteL );
       
   175 
       
   176     if( iFDlg )
       
   177         {
       
   178         delete iFDlg;
       
   179         iFDlg = NULL;
       
   180         }
       
   181 
       
   182     return KErrNone;
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // CTestSDKCFD::TestFSDSetDefaultFolderL
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 TInt CTestSDKCFD::TestFSDSetDefaultFolderL( CStifItemParser& /*aItem*/)
       
   190     {
       
   191     // Print to UI
       
   192     _LIT( KCFDTestModule, "CFDTestModule" );
       
   193     _LIT( KTestFSDSetDefaultFolderL, "In TestFSDSetDefaultFolderL" );
       
   194     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetDefaultFolderL );
       
   195     // Print to log file
       
   196     iLog->Log( KTestFSDSetDefaultFolderL );
       
   197 
       
   198     TInt err = KErrNone;
       
   199 
       
   200     TRAP( err, iFDlg->SetDefaultFolderL(_L("Data\\") ) );
       
   201 
       
   202     return err;
       
   203 
       
   204     }
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CTestSDKCFD::TestFSDSetTitleL
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 TInt CTestSDKCFD::TestFSDSetTitleL( CStifItemParser& /*aItem*/)
       
   211     {
       
   212     // Print to UI
       
   213     _LIT( KCFDTestModule, "CFDTestModule" );
       
   214     _LIT( KTestFSDSetTitleL, "In TestFSDSetTitleL" );
       
   215     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetTitleL );
       
   216     // Print to log file
       
   217     iLog->Log( KTestFSDSetTitleL );
       
   218 
       
   219     TInt err = KErrNone;
       
   220 
       
   221     TRAP( err, iFDlg->SetTitleL( _L("a title") ) );
       
   222 
       
   223     return err;
       
   224     }
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CTestSDKCFD::TestFSDSetLeftSoftkeyFileL
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 TInt CTestSDKCFD::TestFSDSetLeftSoftkeyFileL( CStifItemParser& /*aItem*/)
       
   231     {
       
   232     // Print to UI
       
   233     _LIT( KCFDTestModule, "CFDTestModule" );
       
   234     _LIT( KTestFSDSetLeftSoftkeyFileL, "In TestFSDSetLeftSoftkeyFileL" );
       
   235     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetLeftSoftkeyFileL );
       
   236     // Print to log file
       
   237     iLog->Log( KTestFSDSetLeftSoftkeyFileL );
       
   238 
       
   239     TInt err = KErrNone;
       
   240 
       
   241     TRAP( err, iFDlg->SetLeftSoftkeyFileL( _L("left fkey") ) );
       
   242 
       
   243     return err;
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CTestSDKCFD::TestFSDSetLeftSoftkeyFolderL
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 TInt CTestSDKCFD::TestFSDSetLeftSoftkeyFolderL( CStifItemParser& /*aItem*/)
       
   251     {
       
   252     // Print to UI
       
   253     _LIT( KCFDTestModule, "CFDTestModule" );
       
   254     _LIT( KTestFSDSetLeftSoftkeyFolderL, "In TestFSDSetLeftSoftkeyFolderL" );
       
   255     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetLeftSoftkeyFolderL );
       
   256     // Print to log file
       
   257     iLog->Log( KTestFSDSetLeftSoftkeyFolderL );
       
   258 
       
   259     TInt err = KErrNone;
       
   260 
       
   261     TRAP( err, iFDlg->SetLeftSoftkeyFolderL( _L( "left dkey" ) ) );
       
   262 
       
   263     return err;
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CTestSDKCFD::TestFSDSetRightSoftkeyRootFolderL
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 TInt CTestSDKCFD::TestFSDSetRightSoftkeyRootFolderL( CStifItemParser& /*aItem*/)
       
   271     {
       
   272     // Print to UI
       
   273     _LIT( KCFDTestModule, "CFDTestModule" );
       
   274     _LIT( KTestFSDSetRightSoftkeyRootFolderL, "In TestFSDSetRightSoftkeyRootFolderL" );
       
   275     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetRightSoftkeyRootFolderL );
       
   276     // Print to log file
       
   277     iLog->Log( KTestFSDSetRightSoftkeyRootFolderL );
       
   278 
       
   279     TInt err = KErrNone;
       
   280 
       
   281     TRAP( err, iFDlg->SetRightSoftkeyRootFolderL( _L( "right root" ) ) );
       
   282 
       
   283     return err;
       
   284     }
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CTestSDKCFD::TestFSDSetRightSoftkeySubfolderL
       
   288 // -----------------------------------------------------------------------------
       
   289 //
       
   290 TInt CTestSDKCFD::TestFSDSetRightSoftkeySubfolderL( CStifItemParser& /*aItem*/)
       
   291     {
       
   292     // Print to UI
       
   293     _LIT( KCFDTestModule, "CFDTestModule" );
       
   294     _LIT( KTestFSDSetRightSoftkeySubfolderL, "In TestFSDSetRightSoftkeySubfolderL" );
       
   295     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetRightSoftkeySubfolderL );
       
   296     // Print to log file
       
   297     iLog->Log( KTestFSDSetRightSoftkeySubfolderL );
       
   298 
       
   299     TInt err = KErrNone;
       
   300 
       
   301     TRAP( err, iFDlg->SetRightSoftkeySubfolderL( _L( "right sdir" ) ) );
       
   302 
       
   303     return err;
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CTestSDKCFD::TestFSDSetObserverL
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 TInt CTestSDKCFD::TestFSDSetObserverL( CStifItemParser& /*aItem*/)
       
   311     {
       
   312     // Print to UI
       
   313     _LIT( KCFDTestModule, "CFDTestModule" );
       
   314     _LIT( KTestFSDSetObserverL, "In TestFSDSetObserverL" );
       
   315     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDSetObserverL );
       
   316     // Print to log file
       
   317     iLog->Log( KTestFSDSetObserverL );
       
   318 
       
   319     struct MonkObserver : public MAknFileSelectionObserver
       
   320         {
       
   321         TBool OkToExitL( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/)
       
   322             {
       
   323             return ETrue;
       
   324             }
       
   325         } monkObserver;
       
   326 
       
   327     TInt err = KErrNone;
       
   328 
       
   329     TRAP( err, iFDlg->SetObserver( &monkObserver ) );
       
   330 
       
   331     TFileName folder( _L( "C:\\Data\\" ) );
       
   332     iFDlg->ExecuteL( folder );
       
   333 
       
   334     return err;
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CTestSDKCFD::TestFSDAddFilterL
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 TInt CTestSDKCFD::TestFSDAddFilterL( CStifItemParser& /*aItem*/)
       
   342     {
       
   343     // Print to UI
       
   344     _LIT( KCFDTestModule, "CFDTestModule" );
       
   345     _LIT( KTestFSDAddFilterL, "In TestFSDAddFilterL" );
       
   346     TestModuleIf().Printf( 0, KCFDTestModule, KTestFSDAddFilterL );
       
   347     // Print to log file
       
   348     iLog->Log( KTestFSDAddFilterL );
       
   349 
       
   350     struct MonkFilter : public MAknFileFilter
       
   351         {
       
   352         TBool Accept( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/) const
       
   353             {
       
   354             return ETrue;
       
   355             }
       
   356         };
       
   357 
       
   358     TInt err = KErrNone;
       
   359 
       
   360     TRAP( err, iFDlg->AddFilterL( new (ELeave) MonkFilter ) );//problems, should be push into stack
       
   361 
       
   362     return err;
       
   363     }
       
   364 
       
   365 //  [End of File]