uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestcmdlg/src/bctestfilenamedlg.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 <caknfilenamepromptdialog.h>
       
    22 #include <MAknFileSelectionObserver.h>
       
    23 #include <MaknFileFilter.h>
       
    24 
       
    25 #include "BCTestFileNameDlg.h"
       
    26 #include "BCTestCmDlg.hrh"
       
    27 #include "streamlogger.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // Symbian 2nd static Constructor
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CBCTestFileNameDlg* CBCTestFileNameDlg::NewL()
       
    36     {
       
    37     CBCTestFileNameDlg* self = new( ELeave ) CBCTestFileNameDlg();
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43     
       
    44 // ---------------------------------------------------------------------------
       
    45 // C++ default constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CBCTestFileNameDlg::CBCTestFileNameDlg():iDlg(0)
       
    49     {    
       
    50     }
       
    51     
       
    52 // ---------------------------------------------------------------------------
       
    53 // Destructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CBCTestFileNameDlg::~CBCTestFileNameDlg()
       
    57     {  
       
    58 	delete iDlg;
       
    59     }
       
    60     
       
    61 // ---------------------------------------------------------------------------
       
    62 // Symbian 2nd Constructor
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CBCTestFileNameDlg::ConstructL()
       
    66     {    
       
    67     BuildScriptL();    
       
    68     }
       
    69     
       
    70 // ---------------------------------------------------------------------------
       
    71 // CBCTestFileNameDlg::BuildScriptL
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CBCTestFileNameDlg::BuildScriptL()
       
    75     { 
       
    76 	AddTestL( DELAY(1), TEND);
       
    77 
       
    78     // Add script as your need.   
       
    79 	for(int i=0; i<EBCTestCmdFileNameDlgEnd - EBCTestCmdFileNameDlgBegin -1; ++i)
       
    80 		{
       
    81 		AddTestL( LeftCBA, REP(Down, 3), Right, TEND );
       
    82 		for(int j=0; j<i; ++j)
       
    83 			AddTestL( Down, TEND);
       
    84 		AddTestL( LeftCBA, TEND );	
       
    85 		AddCancelL();		//OK may enter a folder and ask user to select more.
       
    86 		}
       
    87     }
       
    88     
       
    89 void CBCTestFileNameDlg::AddOKL()
       
    90 	{
       
    91 	// add dlg response sciprts
       
    92 	for(int i=0; i<1; ++i)
       
    93 		AddTestL( WAIT(5), KeyOK, TEND);
       
    94 	}
       
    95 
       
    96 void CBCTestFileNameDlg::AddCancelL()
       
    97 	{
       
    98 	// add dlg response sciprts
       
    99 	for(int i=0; i<1; ++i)
       
   100 		AddTestL( WAIT(5), RightCBA, TEND);
       
   101 	}
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CBCTestFileNameDlg::RunL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CBCTestFileNameDlg::RunL( TInt aCmd )
       
   108     {
       
   109 	SetupL();
       
   110 	switch(aCmd){
       
   111 	case EBCTestCmdFileNameDlgCreate:
       
   112 		TestCreateL();
       
   113 		break;
       
   114 	case EBCTestCmdFileNameDlgCreateRes:
       
   115 		TestCreateL(0);		// 0 is default res id
       
   116 		break;
       
   117 	case EBCTestCmdFileNameDlgQuickCreate:
       
   118 		TestQuickCreateL();
       
   119 		break;
       
   120 	case EBCTestCmdFileNameDlgQuickCreateTitle:
       
   121 		TestQuickCreateL(_L("a title"));
       
   122 		break;
       
   123 	case EBCTestCmdFileNameDlgQuickCreateRes:
       
   124 		TestQuickCreateL(0);	// 0 is the default res id
       
   125 		break;
       
   126 	case EBCTestCmdFileNameDlgSettings:
       
   127 		TestSettingsL();
       
   128 		break;
       
   129 	default:
       
   130 		break;
       
   131 	}
       
   132     Teardown();
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CBCTestFileNameDlg::ReleaseCaseL
       
   137 // ---------------------------------------------------------------------------
       
   138 //   
       
   139 void CBCTestFileNameDlg::Teardown()
       
   140     {
       
   141 	delete iDlg;
       
   142 	iDlg = NULL;
       
   143     }
       
   144 
       
   145 void CBCTestFileNameDlg::TestCreateL()
       
   146 	{
       
   147 	TFileName emptyFileName(KNullDesC);
       
   148 	iDlg = CAknFileNamePromptDialog::NewL();
       
   149 	TInt returnValue = iDlg->ExecuteL( emptyFileName );
       
   150 	TFileName msg;
       
   151 	msg.Format(_L("create User hit %d, filename: %s"), returnValue, &emptyFileName );	
       
   152 	msg.ZeroTerminate();
       
   153 	AssertTrueL(ETrue, msg);
       
   154 	}
       
   155 
       
   156 void CBCTestFileNameDlg::TestCreateL(TInt aResID)
       
   157 	{
       
   158 	TFileName emptyFileName(KNullDesC);
       
   159 	iDlg = CAknFileNamePromptDialog::NewL(aResID);
       
   160 	TInt returnValue = iDlg->ExecuteL( emptyFileName );
       
   161 	AssertTrueL(ETrue, _L("Create by res ID"));
       
   162 	}
       
   163 
       
   164 void CBCTestFileNameDlg::TestQuickCreateL()
       
   165 	{
       
   166 	_LIT(KRootPath, "C:\\Nokia\\Data");
       
   167 	TFileName defaultFileName;
       
   168 	TInt returnValue = CAknFileNamePromptDialog::RunDlgLD( defaultFileName, KRootPath );
       
   169 	AssertTrueL(ETrue, _L("RunDlgLD invoked"));
       
   170 	}
       
   171 
       
   172 void CBCTestFileNameDlg::TestQuickCreateL(const TDesC &aTitle)
       
   173 	{
       
   174 	_LIT(KRootPath, "C:\\Nokia\\Data");
       
   175 	TFileName defaultFileName;
       
   176 	TInt returnValue = CAknFileNamePromptDialog::RunDlgLD( defaultFileName, KRootPath, aTitle );
       
   177 	AssertTrueL(ETrue, _L("RunDlgLD invoked"));
       
   178 	}
       
   179 
       
   180 void CBCTestFileNameDlg::TestQuickCreateL(TInt aResID)
       
   181 	{
       
   182 	_LIT(KRootPath, "C:\\Nokia\\Data");
       
   183 	TFileName defaultFileName;
       
   184 	TInt returnValue = CAknFileNamePromptDialog::RunDlgLD( defaultFileName, KRootPath, aResID );
       
   185 	AssertTrueL(ETrue, _L("RunDlgLD invoked"));
       
   186 	}
       
   187 
       
   188 void CBCTestFileNameDlg::SetupL()
       
   189 	{
       
   190 	}
       
   191 
       
   192 
       
   193 void CBCTestFileNameDlg::TestSettingsL()
       
   194 	{
       
   195 	iDlg = CAknFileNamePromptDialog::NewL();
       
   196 	iDlg->SetPathL(_L("C:\\"));
       
   197 	AssertTrueL(ETrue, _L("path set"));
       
   198 
       
   199 	iDlg->SetTitleL(_L("a title"));
       
   200 	AssertTrueL(ETrue, _L("title set"));
       
   201 
       
   202 	iDlg->SetLeftSoftkeyL(_L("left key"));
       
   203 	AssertTrueL(ETrue, _L("left soft key set"));
       
   204 
       
   205 	iDlg->SetRightSoftkeyL(_L("right key"));
       
   206 	AssertTrueL(ETrue, _L("right soft key set"));
       
   207 
       
   208 	//Add fileter and set Observer
       
   209 	struct MonkObserver: public MAknFileSelectionObserver{
       
   210 		TBool OkToExitL( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/ ){
       
   211 			return ETrue;
       
   212 		}
       
   213 	} monkObserver;
       
   214 	
       
   215 	iDlg->SetObserver(&monkObserver);
       
   216 	AssertTrueL(ETrue, _L("Observer set"));
       
   217 
       
   218 	TFileName filename;
       
   219 	iDlg->ExecuteL(filename);
       
   220 	}