uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestcmdlg/src/bctestcmdlgcase.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 
       
    22 #include "BCTestCmDlgcase.h"
       
    23 #include "BCTestCmDlgcontainer.h"
       
    24 #include "BCTestCmDlg.hrh"
       
    25 #include "streamlogger.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // Symbian 2nd static Constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CBCTestCmDlgCase* CBCTestCmDlgCase::NewL()
       
    34     {
       
    35     CBCTestCmDlgCase* self = new( ELeave ) CBCTestCmDlgCase();
       
    36     CleanupStack::PushL( self );
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop( self );
       
    39     return self;
       
    40     }
       
    41     
       
    42 // ---------------------------------------------------------------------------
       
    43 // C++ default constructor
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CBCTestCmDlgCase::CBCTestCmDlgCase():iDlg(0)
       
    47     {    
       
    48     }
       
    49     
       
    50 // ---------------------------------------------------------------------------
       
    51 // Destructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CBCTestCmDlgCase::~CBCTestCmDlgCase()
       
    55     {  
       
    56 	delete iDlg;
       
    57     }
       
    58     
       
    59 // ---------------------------------------------------------------------------
       
    60 // Symbian 2nd Constructor
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CBCTestCmDlgCase::ConstructL()
       
    64     {    
       
    65     BuildScriptL();    
       
    66     }
       
    67     
       
    68 // ---------------------------------------------------------------------------
       
    69 // CBCTestCmDlgCase::BuildScriptL
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CBCTestCmDlgCase::BuildScriptL()
       
    73     { 
       
    74     // Add script as your need.   
       
    75 	AddTestL( DELAY(1), TEND);
       
    76 
       
    77 	for(int i=0; i<EBCTestCmdMemSelDlgEnd - EBCTestCmdMemSelDlgBegin -1; ++i)
       
    78 		{
       
    79 		AddTestL( LeftCBA, Right, TEND );
       
    80 		for(int j=0; j<i; ++j)
       
    81 			AddTestL( Down, TEND);
       
    82 		AddTestL( LeftCBA, TEND );	
       
    83 		AddOKL();
       
    84 		}
       
    85     }
       
    86     
       
    87 void CBCTestCmDlgCase::AddOKL()
       
    88 	{
       
    89 	// add dlg response sciprts
       
    90 	for(int i=0; i<1; ++i)
       
    91 		AddTestL( WAIT(5), KeyOK, TEND);
       
    92 	}
       
    93 
       
    94 void CBCTestCmDlgCase::AddCancelL()
       
    95 	{
       
    96 	// add dlg response sciprts
       
    97 	for(int i=0; i<1; ++i)
       
    98 		AddTestL( WAIT(5), RightCBA, TEND);
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CBCTestCmDlgCase::RunL
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CBCTestCmDlgCase::RunL( TInt aCmd )
       
   106     {
       
   107 	SetupL();
       
   108 	switch(aCmd){
       
   109 	case EBCTestCmdMemSelDlgCreate:
       
   110 		TestCreateL();
       
   111 		break;
       
   112 	case EBCTestCmdMemSelDlgCreateWithRes:
       
   113 		TestCreateL(0);		//0 indicate to default res
       
   114 		break;
       
   115 	case EBCTestCmdMemSelDlgWithRoot:
       
   116 		TestWithRootL();
       
   117 		break;
       
   118 	case EBCTestCmdMemSelDlgQuick:
       
   119 		TestQuickCreateL();
       
   120 		break;
       
   121 	case EBCTestCmdMemSelDlgQuickTitle:
       
   122 		TestQuickCreateL(_L("a title"));
       
   123 		break;
       
   124 	case EBCTestCmdMemSelDlgQuickRes:
       
   125 		TestQuickCreateL(0);	//0 means default res
       
   126 		break;
       
   127 	case EBCTestCmdMemSelDlgSetting:
       
   128 		TestSettingsL();
       
   129 		break;
       
   130 	default:
       
   131 		break;
       
   132 	}
       
   133 
       
   134     Teardown();
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CBCTestCmDlgCase::ReleaseCaseL
       
   139 // ---------------------------------------------------------------------------
       
   140 //   
       
   141 void CBCTestCmDlgCase::Teardown()
       
   142     {
       
   143 	delete iDlg;
       
   144 	iDlg = NULL;
       
   145     }
       
   146 
       
   147 void CBCTestCmDlgCase::TestCreateL()
       
   148 	{
       
   149     iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, EFalse );
       
   150 
       
   151 	AssertNotNullL(iDlg, _L("mem sel dlg created"));
       
   152 	AssertTrueL(iDlg->ExecuteL( iMemory ), _L("User Hit OK"));
       
   153 	AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memory created"));
       
   154 	}
       
   155 
       
   156 void CBCTestCmDlgCase::TestCreateL(TInt aResID)
       
   157 {
       
   158 	iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, aResID, EFalse );
       
   159 
       
   160 	AssertNotNullL(iDlg, _L("mem sel dlg with resID created"));
       
   161 	AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory), _L("Quick create, User hit OK"));
       
   162 	AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created"));
       
   163 }
       
   164 
       
   165 void CBCTestCmDlgCase::TestQuickCreateL()
       
   166 	{
       
   167 	AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory), _L("Quick create, User hit OK"));
       
   168 	AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created"));
       
   169 	}
       
   170 
       
   171 void CBCTestCmDlgCase::TestQuickCreateL(const TDesC &aTitle)
       
   172 	{
       
   173 	AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory, aTitle), _L("Quick create with title, User hit OK"));
       
   174 	AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created"));
       
   175 	}
       
   176 
       
   177 void CBCTestCmDlgCase::TestQuickCreateL(TInt aResID)
       
   178 	{
       
   179 	AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory, aResID), _L("Quick create with ResID, User hit OK"));
       
   180 	AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created"));
       
   181 	}
       
   182 
       
   183 void CBCTestCmDlgCase::SetupL()
       
   184 	{
       
   185 	iMemory = CAknMemorySelectionDialog::EPhoneMemory;
       
   186 	}
       
   187 
       
   188 void CBCTestCmDlgCase::TestWithRootL()
       
   189 {
       
   190 	_LIT( KRootPath,					"C:\\Nokia\\Images\\" );
       
   191 	_LIT( KDefaultFileName,				"DynamicFilename.jpg" );
       
   192 	TFileName rootFileName( KRootPath );
       
   193 	TFileName defaultFileName( KDefaultFileName );
       
   194 	iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, EFalse );
       
   195 	if(TInt res = iDlg->ExecuteL(iMemory, &rootFileName, &defaultFileName))
       
   196 	{
       
   197 		TFileName msg(_L("default root: "));
       
   198 		msg.Append(rootFileName);
       
   199 		msg.Append(_L(" default file: "));
       
   200 		msg.Append(defaultFileName);
       
   201 		msg.ZeroTerminate();
       
   202 		AssertTrueL(res, msg);
       
   203 	}
       
   204 }
       
   205 
       
   206 void CBCTestCmDlgCase::TestSettingsL()
       
   207 {
       
   208 	iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, EFalse );
       
   209 
       
   210 	iDlg->SetObserver(NULL);
       
   211 	AssertTrueL(ETrue, _L("Null Observer set"));
       
   212 
       
   213 	iDlg->SetTitleL(_L("a title"));
       
   214 	AssertTrueL(ETrue, _L("title set"));
       
   215 
       
   216 	iDlg->SetLeftSoftkeyL(_L("left key"));
       
   217 	AssertTrueL(ETrue, _L("left key text set"));
       
   218 
       
   219 	iDlg->SetRightSoftkeyL(_L("right key"));
       
   220 	AssertTrueL(ETrue, _L("right key text set"));
       
   221 	if(iDlg->ExecuteL(iMemory))
       
   222 	{
       
   223 		//get
       
   224 		TFileName emptyFileName( KNullDesC );
       
   225 		iDlg->GetItem( iMemory, emptyFileName );
       
   226 		TFileName msg(_L("item got: "));
       
   227 		msg.Append(emptyFileName);
       
   228 		msg.ZeroTerminate();
       
   229 		AssertTrueL(ETrue, msg);
       
   230 
       
   231 		_LIT( KRootPath,					"C:\\Nokia\\Images\\" );
       
   232 		_LIT( KDefaultFileName,				"DynamicFilename.jpg" );
       
   233 		TFileName rootFileName( KRootPath );
       
   234 		TFileName defaultFileName( KDefaultFileName );
       
   235 		iDlg->GetMemories(iMemory, &rootFileName, &defaultFileName);
       
   236 
       
   237 		msg = (_L("memory got, root: "));
       
   238 		msg.Append(rootFileName);
       
   239 		msg.Append(_L(" default file: "));
       
   240 		msg.Append(defaultFileName);
       
   241 		msg.ZeroTerminate();
       
   242 		AssertTrueL(ETrue, msg);
       
   243 	}
       
   244 }
       
   245