lafagnosticuifoundation/cone/tef/TCONE2STEP.CPP
changeset 0 2f259fa3e83a
child 10 9f56a4e1b8ab
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The test step Tests the IsDisplayingDialog(),RemoveFromStack() APIs and 
       
    15 // Change to CCoeControl::DoMakeVisible to call Makevisible on its child controls.\n
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @test
       
    22  @internalComponent - Internal Symbian test code
       
    23 */
       
    24 
       
    25 #include <coeaui.h>
       
    26 #include <coemain.h>
       
    27 #include <coecntrl.h>
       
    28 #include <coeccntx.h>
       
    29 #include <coeutils.h>
       
    30 #include <bassnd.h>
       
    31 #include <coesndpy.h> 
       
    32 #include <gulcolor.h>
       
    33 #include <bautils.h>
       
    34 #include <tcone2.rsg>
       
    35 #include <ecom/ecom.h>
       
    36 
       
    37 #include "TCone2Step.h"
       
    38 
       
    39 //! Resource file path for Cone2 Test application.\n
       
    40 _LIT(KTCone2ResourceFilePath, "z:\\system\\data\\tcone2.rsc");
       
    41 
       
    42 //! This defines resource ID which signatures matches TCone2.rss, but ID does not exist in file.
       
    43 #define R_TCONE2_TEST_RESOURCE_CORRECT_SIGNATURE_MISSING_ID     R_TCONE2_TEST_LAST_RESOURCE_BUFFER + 1
       
    44 //! This defines resource ID that signature does not match with TCone2.rss signature
       
    45 #define R_TCONE2_TEST_RESOURCE_INCORRECT_SIGNATURE_FOR_THIS_RC     R_TCONE2_TEST_LAST_RESOURCE_BUFFER + 0x12340000
       
    46 
       
    47 /**
       
    48   Second phase constructor for component control "CTestCone2".\n
       
    49   Creates a control's window.\n
       
    50   The created window is the child of the application's window group.\n
       
    51   iDisplayed is set to ETrue to make the control visible.\n
       
    52 */    
       
    53 void CTestCone2Control::ConstructL()
       
    54     {
       
    55 	CreateWindowL();
       
    56 	iDisplayed = ETrue;
       
    57     }
       
    58 /**
       
    59   Sets this control as visible or invisible.\n
       
    60   This causes the control to disappear or reappear.\n
       
    61   When a control is created, it is made visible by default.\n
       
    62 */   
       
    63 void CTestCone2Control::MakeVisible(TBool aVisible)
       
    64     {
       
    65 	iDisplayed = aVisible;
       
    66 	DrawNow();
       
    67     }
       
    68 /**
       
    69   Destructor for the container control.\n
       
    70   Deletes the component control "CTestCone2Control".\n
       
    71 */
       
    72 CTestContainerControl::~CTestContainerControl()
       
    73 	{
       
    74 	delete iDialogCtrl;
       
    75 	}
       
    76 /**
       
    77   Second phase construcor for the Container control namely CTestContainerControl.\n
       
    78   The method creates a component control "CTestCone2Control".\n
       
    79   Sets components to inherit visibility setting from their container control.\n
       
    80   If set, when MakeVisible() is called on the compound control, 
       
    81   the value for visibility is propagated to all its components.
       
    82 
       
    83 */
       
    84 void CTestContainerControl::ConstructL()
       
    85 	{
       
    86     CreateWindowL();
       
    87 	iDialogCtrl  = new(ELeave)CTestCone2Control;
       
    88     iDialogCtrl->ConstructL();
       
    89 	iDialogCtrl->SetMopParent(this);
       
    90 	CTestCone2Control* objProv;
       
    91 	MopGetObject(objProv);
       
    92 
       
    93 	TBuf<KMaxFileName> name;
       
    94 	ControlEnv()->ReadResourceL(name, R_TCONE2_TEST_BUFFER2);
       
    95 	(name.Compare(_L("TCone2")));
       
    96 	SetComponentsToInheritVisibility();
       
    97 	DrawNow();
       
    98 	}
       
    99 /**
       
   100   CTestCone2Control is a component control for CTestContainerControl.\n
       
   101   The method returns the number of component controls for CTestContainer Control.\n
       
   102 */
       
   103 TInt CTestContainerControl::CountComponentControls() const
       
   104 	{
       
   105 	return 1;
       
   106 	}
       
   107 /**
       
   108   CTestCone2Control is a component control for CTestContainerControl.\n
       
   109   The method returns the handle for the component control.\n
       
   110 */
       
   111 CCoeControl* CTestContainerControl::ComponentControl(TInt /*aIndex*/) const
       
   112 	{
       
   113 	return(iDialogCtrl);
       
   114 	}
       
   115 /**
       
   116   CTestCone2Control is a component control for CTestContainerControl.\n
       
   117   The method returns the handle for the component control.\n
       
   118 */
       
   119 CTestCone2Control* CTestContainerControl::GetComponentControl()
       
   120 	{
       
   121 	return(iDialogCtrl);
       
   122 	}
       
   123 /**
       
   124   CTestCone2Control is a component control for CTestContainerControl.\n
       
   125   The method checks if the  TestCone2 control is displayed.\n
       
   126 */
       
   127 TBool CTestContainerControl::IsDialogControlVisible() const
       
   128 	{
       
   129 	return iDialogCtrl->iDisplayed;
       
   130 	}
       
   131 
       
   132 /**
       
   133   Single Argument constructor for CTestDriver class.\n
       
   134   Initializes the iAppUi and iStep member variables with the arguments.\n
       
   135 */
       
   136 CTestDriver::CTestDriver(CCoeAppUi& aAppUi,CTestStep* aStep) : iAppUi(aAppUi), iStep(aStep)
       
   137 	{
       
   138 	}
       
   139 /**
       
   140   Second phase constructor for CTestDriver class.\n
       
   141   Checks if the resource file "z:\\system\\data\\tcone2.rsc"exists.\n
       
   142   AAdds the specified resource file to the list maintained by CCoeEnv.\n
       
   143 */
       
   144 void CTestDriver::ConstructL()
       
   145 	{
       
   146 	ConeUtils::FileExists(KTCone2ResourceFilePath);	
       
   147 
       
   148 	TFileName* filename = new (ELeave) TFileName(KTCone2ResourceFilePath);
       
   149 	CleanupStack::PushL(filename);
       
   150 	CCoeEnv* coeEnv = CCoeEnv::Static();
       
   151 	BaflUtils::NearestLanguageFile(coeEnv->FsSession(),*filename);
       
   152 	iResourceFileFlag=coeEnv->AddResourceFileL(*filename);
       
   153 	CleanupStack::PopAndDestroy(filename); 
       
   154 	}
       
   155 
       
   156 CTestDriver::~CTestDriver()
       
   157 	{
       
   158 	CCoeEnv::Static()->DeleteResourceFile(iResourceFileFlag); 
       
   159 	}
       
   160 
       
   161 
       
   162 /**
       
   163    @SYMTestCaseID UIF-TCone2Step-TestMakeVisibleOnChildControlsL
       
   164   
       
   165    @SYMPREQ
       
   166   
       
   167    @SYMTestCaseDesc Test CTestContainerControl::MakeVisible() and CTestContainerControl::SetFocusing() methods.
       
   168   
       
   169    @SYMTestPriority High
       
   170   
       
   171    @SYMTestStatus Implemented
       
   172    
       
   173    @SYMTestActions The method creates a CTestContainerControl and adds it to the CCoeAppUi. 
       
   174    Calls CTestContainerControl::MakeVisible(EFalse) to hide the control. 
       
   175    Calls CTestContainerControl::MakeVisible(ETrue) to show the control.
       
   176    Calls CTestContainerControl::SetFocusing(ETrue) to highlight the control.
       
   177    
       
   178    @SYMTestExpectedResults. The code tests if the control is displayed while its visiable and hidden when 
       
   179    its set as invisible.
       
   180    
       
   181  */
       
   182 
       
   183 void CTestDriver::TestMakeVisibleOnChildControlsL()
       
   184 	{
       
   185 	CTestContainerControl* testControl = new(ELeave)CTestContainerControl;
       
   186 	CleanupStack::PushL(testControl);
       
   187 	testControl->ConstructL();
       
   188 	//Add control to the appUi control stack
       
   189 	iAppUi.AddToStackL(testControl, ECoeStackPriorityDialog);
       
   190 	testControl->MakeVisible(EFalse);
       
   191 	iStep->TEST(testControl->IsDialogControlVisible() == 0);
       
   192 	testControl->MakeVisible(ETrue);
       
   193 	testControl->SetFocusing(ETrue);
       
   194 	iStep->TEST(testControl->IsDialogControlVisible() == 1);
       
   195 	iAppUi.RemoveFromStack(testControl); 
       
   196 	CleanupStack::PopAndDestroy(testControl); 
       
   197 	}
       
   198 
       
   199 /**
       
   200    @SYMTestCaseID UIF-TCone2Step-TestIsDisplayingDialogAndRemoveFromStackAPIsL
       
   201   
       
   202    @SYMPREQ
       
   203   
       
   204    @SYMTestCaseDesc Test CCoeAppUi::IsDisplayingDialog() and CCoeAppUi::RemoveFromStack() methods.
       
   205   
       
   206    @SYMTestPriority High
       
   207   
       
   208    @SYMTestStatus Implemented
       
   209    
       
   210    @SYMTestActions The method creates a CTestContainerControl and adds it to the CCoeAppUi 
       
   211    control stack. Then it creates a child CCoeAppUi and sets it as the applications user interface, it passes the
       
   212    current CCoeAppUi so tht the its control stack is copied. It then removes the control from the child child 
       
   213    CCoeAppUi's control stack.
       
   214    
       
   215    @SYMTestExpectedResults. The code tests if the control is displayed while it is on the parent CCoeAppUi stack,
       
   216    and that it is not displayed once it is removed from the child CCoeAppUi's control stack.
       
   217    
       
   218  */
       
   219 void CTestDriver::TestIsDisplayingDialogAndRemoveFromStackAPIsL()
       
   220 	{
       
   221 	CTestContainerControl* testControl = new(ELeave)CTestContainerControl;
       
   222 	CleanupStack::PushL(testControl);
       
   223 	testControl->ConstructL();
       
   224 
       
   225 	//Add control to the appUi control stack
       
   226 	iAppUi.AddToStackL(testControl, ECoeStackPriorityDialog);
       
   227 
       
   228 	CCoeAppUi* childAppUi=new(ELeave) CCoeAppUi();
       
   229 	CCoeEnv::Static()->SetAppUi(childAppUi);
       
   230     childAppUi->ConstructL(&iAppUi);
       
   231 
       
   232 	iStep->TEST(iAppUi.IsDisplayingDialog() == 1);
       
   233 
       
   234  	//Remove the control from the appUi control stack
       
   235 	childAppUi->RemoveFromStack(testControl); 
       
   236 	iStep->TEST(iAppUi.IsDisplayingDialog() == 0);
       
   237 	iStep->TEST(iAppUi.IsDisplayingMenuOrDialog() == 0);
       
   238 
       
   239 	CCoeEnv::Static()->SetAppUi(&iAppUi);
       
   240 	delete childAppUi;
       
   241 	CleanupStack::PopAndDestroy(testControl);
       
   242 	}
       
   243 
       
   244 /**
       
   245    @SYMTestCaseID UIF-TCone2Step-TestAppHelpContextAPIL
       
   246   
       
   247    @SYMPREQ
       
   248   
       
   249    @SYMTestCaseDesc Test the CCoeAppUi::AppHelpContextL() method.
       
   250   
       
   251    @SYMTestPriority High
       
   252   
       
   253    @SYMTestStatus Implemented
       
   254    
       
   255    @SYMTestActions The method creates a list of relevant contexts within an application help file 
       
   256    appropriate for the current state of the application.  
       
   257    
       
   258    @SYMTestExpectedResults. The code tests that the list created is empty.
       
   259  * 
       
   260  */
       
   261 
       
   262 void CTestDriver::TestAppHelpContextAPIL()
       
   263 	{
       
   264 	CArrayFix<TCoeHelpContext>* contexts= iAppUi.AppHelpContextL();
       
   265 	CleanupStack::PushL(contexts);
       
   266 	iStep->TEST(contexts->Count() == KErrNone);
       
   267 	CleanupStack::PopAndDestroy(contexts);
       
   268 	}
       
   269 
       
   270 /**
       
   271    @SYMTestCaseID UIF-TCone2Step-TestSetAndGetSystemDefaultViewAPIsL
       
   272   
       
   273    @SYMPREQ
       
   274   
       
   275    @SYMTestCaseDesc Test's CCoeAppUi::CreateActivateViewEventL, CCoeAppUi::SetSystemDefaultViewL and
       
   276    SetSystemDefaultViewL::GetDefaultViewId() methods.
       
   277    @SYMTestPriority High
       
   278   
       
   279    @SYMTestStatus Implemented
       
   280    
       
   281    @SYMTestActions Creates a TVwsViewId and assigns it iAppUid iViewUid properties default values, 
       
   282    it then calls CCoeAppUi::CreateActivateViewEventL to create a default view with the id. 
       
   283    It then assigns the tests CCoeAppUi object's default view. Then it uses SetSystemDefaultViewL::GetDefaultViewId()
       
   284    to retriveve the defalt view.
       
   285    defalt view to be the   
       
   286    
       
   287    @SYMTestExpectedResults. The code tests that default view is the one previously set.
       
   288    
       
   289  */
       
   290 
       
   291 void CTestDriver::TestSetAndGetSystemDefaultViewAPIsL()
       
   292 	{
       
   293 	TVwsViewId viewId;
       
   294 	viewId.iAppUid = KNullUid;
       
   295 	viewId.iViewUid = KNullUid;
       
   296 	iAppUi.CreateActivateViewEventL(viewId, KNullUid, _L8(""));
       
   297 	iAppUi.SetSystemDefaultViewL(viewId, 0);
       
   298 	iAppUi.SetSystemDefaultViewL(viewId);
       
   299 	TVwsViewId defaultViewId;
       
   300 	iAppUi.GetDefaultViewId(defaultViewId);
       
   301 	iStep->TEST(viewId == defaultViewId);
       
   302 	}
       
   303 
       
   304 /**
       
   305    @SYMTestCaseID UIF-TCone2Step-TestCoeControlAPIsL
       
   306   
       
   307    @SYMPREQ
       
   308   
       
   309    @SYMTestCaseDesc Test's Tests CTestContainerControl::Index, CTestContainerControl::GetComponentControl(),
       
   310    CCoeControl::PrepareForFocusGainL,CCoeControl::PrepareForFocusLossL methods.
       
   311   
       
   312    @SYMTestPriority High
       
   313   
       
   314    @SYMTestStatus Implemented
       
   315    
       
   316    @SYMTestActions Tests that the control has itself as a component at index 0.
       
   317    
       
   318    @SYMTestExpectedResults. The code tests that the result of the above operation is KErrNone .
       
   319    
       
   320  */
       
   321 
       
   322 void CTestDriver::TestCoeControlAPIsL()
       
   323 	{
       
   324 	CTestContainerControl* testControl = new(ELeave)CTestContainerControl;
       
   325 	CleanupStack::PushL(testControl);
       
   326 	testControl->ConstructL();
       
   327 	iStep->TEST(testControl->Index(testControl->GetComponentControl()) == KErrNone);
       
   328 	CleanupStack::PopAndDestroy(testControl);
       
   329 
       
   330 	RWsSession ws;
       
   331 	User::LeaveIfError(ws.Connect());
       
   332 	RWindowGroup group(ws);
       
   333 	User::LeaveIfError(group.Construct(888));
       
   334 	RWindow win1(ws);
       
   335 	User::LeaveIfError(win1.Construct(group,111));
       
   336 	RBackedUpWindow backedUp(ws);
       
   337 	User::LeaveIfError(backedUp.Construct(group,EGray4,222));
       
   338 
       
   339 	CCoeControl* ctrl = new (ELeave) CCoeControl();
       
   340 	CleanupStack::PushL(ctrl);
       
   341 	ctrl->SetContainerWindowL(win1);
       
   342 	ctrl->SetContainerWindowL(backedUp);
       
   343 	ctrl->PrepareForFocusGainL();
       
   344 	ctrl->PrepareForFocusLossL();
       
   345 	iAppUi.HandleSwitchOnEventL(ctrl);
       
   346 	TCoeInputCapabilities capabilities = ctrl->InputCapabilities();
       
   347 	capabilities = ctrl->RecursivelyMergedInputCapabilities();
       
   348 	TCoeHelpContext helpContext;
       
   349 	ctrl->GetHelpContext(helpContext);
       
   350 	helpContext.IsNull();
       
   351 	ctrl->ControlContext();
       
   352 	
       
   353 	CleanupStack::PopAndDestroy(ctrl); 
       
   354 	win1.Close();
       
   355 	backedUp.Close();
       
   356 	group.Close();
       
   357 	ws.Close();
       
   358 	}
       
   359 
       
   360 /**
       
   361    @SYMTestCaseID UIF-TCone2Step-TestColorUseAPIsL
       
   362   
       
   363    @SYMPREQ
       
   364   
       
   365    @SYMTestCaseDesc Test's CCoeBrushAndPenContext::SetPenColor(), CCoeBrushAndPenContext::SetBrushStyle(), CCoeBrushAndPenContext::SetBrushColor()
       
   366    CCoeBrushAndPenContext::SetBrushBitmap(), CCoeBrushAndPenContext::PenColor(), CCoeBrushAndPenContext::BrushStyle()
       
   367    and CCoeBrushAndPenContext::BrushColor() methods.
       
   368   
       
   369    @SYMTestPriority High
       
   370   
       
   371    @SYMTestStatus Implemented
       
   372    
       
   373    @SYMTestActions Code uses TCoeColorUse and  CCoeBrushAndPenContext getters and setter.
       
   374    
       
   375    @SYMTestExpectedResults. The code tests that TCoeColorUse and CCoeBrushAndPenContext objects have the correct properties.  
       
   376    
       
   377  */
       
   378 
       
   379 void CTestDriver::TestColorUseAPIsL()
       
   380 	{
       
   381 	TInt commonAttributes = TCoeColorUse::EContents|TCoeColorUse::ENeutral;
       
   382 	TInt use = TCoeColorUse::EFore|TCoeColorUse::EActive|TCoeColorUse::ENormal|commonAttributes;
       
   383 	TCoeColorUse colorUse;
       
   384 	colorUse.SetLogicalColor(EColorButtonText);
       
   385 	colorUse.SetUse(use);
       
   386 
       
   387 	iStep->TEST(colorUse.LogicalColor() == EColorButtonText);
       
   388 	iStep->TEST(colorUse.Use() == use);
       
   389 	iStep->TEST(colorUse.IsForeground() == TCoeColorUse::EFore);
       
   390 	iStep->TEST(colorUse.IsBackground() == EFalse);
       
   391 	iStep->TEST(colorUse.IsContents() == TCoeColorUse::EContents);
       
   392 	iStep->TEST(colorUse.IsHighlights() == EFalse);
       
   393 	iStep->TEST(colorUse.IsSurrounds() == EFalse);
       
   394 	iStep->TEST(colorUse.IsBorders() == EFalse);
       
   395 	iStep->TEST(colorUse.IsActive() == TCoeColorUse::EActive);
       
   396 	iStep->TEST(colorUse.IsPressed() == EFalse);
       
   397 	iStep->TEST(colorUse.IsDimmed() == EFalse);
       
   398 	iStep->TEST(colorUse.IsNormal()== TCoeColorUse::ENormal);
       
   399 	iStep->TEST(colorUse.IsSet() == EFalse);
       
   400 
       
   401 	CCoeBrushAndPenContext* brushAndPen = CCoeBrushAndPenContext::NewL();
       
   402  	CFbsBitmap* bmp1=NULL;
       
   403 	brushAndPen->SetPenColor(KRgbBlue);
       
   404 	brushAndPen->SetBrushStyle(CWindowGc::ENullBrush);
       
   405 	brushAndPen->SetBrushColor(KRgbWhite);
       
   406 	brushAndPen->SetBrushBitmap(*bmp1);
       
   407 	iStep->TEST(brushAndPen->PenColor() == KRgbBlue);
       
   408 	iStep->TEST(brushAndPen->BrushStyle() == CWindowGc::ENullBrush);
       
   409 	iStep->TEST(brushAndPen->BrushColor() == KRgbWhite);
       
   410 	brushAndPen->BrushBitmap();
       
   411 	delete brushAndPen;
       
   412 	}
       
   413 
       
   414 /**
       
   415    @SYMTestCaseID UIF-TCone2Step-TestConeAppUiSimpleAndMiscAPIsL
       
   416   
       
   417    @SYMPREQ
       
   418   
       
   419    @SYMTestCaseDesc Test's CCoeEnv::Static()->Version(), CCoeEnv::Static()->DisableExitChecks(EFalse),
       
   420    and CCoeEnv::Static()->FepUid() API's.
       
   421   
       
   422    @SYMTestPriority High
       
   423   
       
   424    @SYMTestStatus Implemented
       
   425    
       
   426    @SYMTestActions Code uses CCoeEnv::Static
       
   427    
       
   428    @SYMTestExpectedResults. The code tests that the static CCoeEnv methods do not panic.  
       
   429  */
       
   430 
       
   431 void CTestDriver::TestConeMiscAPIsL()
       
   432 	{
       
   433 	ConeUtils::EnsurePathExistsL(_L("c:\\system\\conetest\\conte2step\\"));	// no capabilities required for this folder
       
   434 
       
   435 	// The following functions are called just to check they don't panic. 
       
   436 	CCoeEnv::Static()->Version();
       
   437 	CCoeEnv::Static()->DisableExitChecks(EFalse);
       
   438 	CCoeEnv::Static()->FepUid();
       
   439 	}
       
   440 
       
   441 /**
       
   442    @SYMTestCaseID UIF-TCone2Step-TestConeInputCapabilitiesAPIs
       
   443   
       
   444    @SYMPREQ
       
   445   
       
   446    @SYMTestCaseDesc Test's TCoeInputCapabilities API's.
       
   447   
       
   448    @SYMTestPriority High
       
   449   
       
   450    @SYMTestStatus Implemented
       
   451    
       
   452    @SYMTestActions Code uses getters and setters, merge functionality, assignment operator and copy constructors to test the
       
   453    TCoeInputCapabilities object.
       
   454    
       
   455    @SYMTestExpectedResults. The code tests that the object has the correct properties after using  getter's and setters, merge
       
   456    functionality, assignment operators and copy constructors. It also tests for correct default initialisation.
       
   457  
       
   458  */
       
   459 
       
   460 void CTestDriver::TestConeInputCapabilitiesAPIs()
       
   461 	{
       
   462 	TCoeInputCapabilities inputCapabilities1(TCoeInputCapabilities::EWesternAlphabetic);
       
   463 	TCoeInputCapabilities inputCapabilities2(inputCapabilities1.Capabilities());
       
   464 	iStep->TEST(inputCapabilities1 == inputCapabilities2);
       
   465 	inputCapabilities1 = iAppUi.InputCapabilities();
       
   466 	inputCapabilities1 = TCoeInputCapabilities::ESecretText;
       
   467 	iStep->TEST(inputCapabilities1 != inputCapabilities2);
       
   468 	inputCapabilities1.MergeWith(inputCapabilities2);
       
   469 	inputCapabilities1.SetCapabilities(TCoeInputCapabilities::EAllText);
       
   470 	iStep->TEST(inputCapabilities1.IsNone() == KErrNone);
       
   471 	iStep->TEST(inputCapabilities1.SupportsAllText() == TCoeInputCapabilities::EAllText);
       
   472 	iStep->TEST(inputCapabilities1.SupportsWesternNumericIntegerPositive() == 0);
       
   473 	iStep->TEST(inputCapabilities1.SupportsWesternNumericIntegerNegative() == 0);
       
   474 	iStep->TEST(inputCapabilities1.SupportsWesternNumericReal() == 0);
       
   475 	iStep->TEST(inputCapabilities1.SupportsWesternAlphabetic() == 0);
       
   476 	iStep->TEST(inputCapabilities1.SupportsJapaneseHiragana() == 0);
       
   477 	iStep->TEST(inputCapabilities1.SupportsJapaneseKatakanaHalfWidth() == 0);
       
   478 	iStep->TEST(inputCapabilities1.SupportsJapaneseKatakanaFullWidth() == 0);
       
   479 	iStep->TEST(inputCapabilities1.SupportsDialableCharacters() == 0);
       
   480 	iStep->TEST(inputCapabilities1.SupportsSecretText() == 0);
       
   481 	iStep->TEST(inputCapabilities1.SupportsAutoSentenceCase() == 0);
       
   482 	iStep->TEST(inputCapabilities1.SupportsNonPredictive() == 0);	
       
   483 	iStep->TEST(inputCapabilities1.SupportsNavigation() == 0);
       
   484 	inputCapabilities1.SetCapabilities(TCoeInputCapabilities::EAutoSentenceCase);
       
   485 	iStep->TEST(inputCapabilities1.SupportsAutoSentenceCase() == TCoeInputCapabilities::EAutoSentenceCase);
       
   486 	MCoeCaptionRetrieverForFep*  captionRetrieverForFep=inputCapabilities1.CaptionRetrieverForFep();
       
   487 	iStep->TEST(captionRetrieverForFep == NULL);
       
   488 	TCoeInputCapabilities::MCoeFepSpecificExtensions* fepSpecificInputCapabilityExtensions=inputCapabilities1.FepSpecificExtensions(KNullUid);
       
   489 	iStep->TEST(fepSpecificInputCapabilityExtensions ==NULL);
       
   490 	MCoeFepAwareTextEditor* fepAwareTextEditor=inputCapabilities1.FepAwareTextEditor();
       
   491 	TCoeInputCapabilities inputCapabilities3(TCoeInputCapabilities::EWesternAlphabetic, fepAwareTextEditor, captionRetrieverForFep );
       
   492 	TCoeInputCapabilities inputCapabilities4(TCoeInputCapabilities::EWesternAlphabetic, fepAwareTextEditor, captionRetrieverForFep, KNullUid , fepSpecificInputCapabilityExtensions);
       
   493 	iStep->TEST(inputCapabilities3 == inputCapabilities4);
       
   494 
       
   495 	// MObjectProvider api
       
   496 	// null initialisation
       
   497 	iStep->TEST(inputCapabilities1.ObjectProvider() == NULL);
       
   498 	iStep->TEST(inputCapabilities2.ObjectProvider() == NULL);
       
   499 	iStep->TEST(inputCapabilities3.ObjectProvider() == NULL);
       
   500 	iStep->TEST(inputCapabilities4.ObjectProvider() == NULL);
       
   501 	// get and set
       
   502 	MObjectProvider* mop = (MObjectProvider*)0x12345678;
       
   503 	inputCapabilities1.SetObjectProvider(mop);
       
   504 	iStep->TEST(inputCapabilities1.ObjectProvider() == mop);
       
   505 	// merge
       
   506 	inputCapabilities1.MergeWith(inputCapabilities2);
       
   507 	iStep->TEST(inputCapabilities1.ObjectProvider() == mop);
       
   508 	iStep->TEST(inputCapabilities2.ObjectProvider() == NULL);
       
   509 	inputCapabilities3.MergeWith(inputCapabilities1);
       
   510 	iStep->TEST(inputCapabilities1.ObjectProvider() == mop);
       
   511 	iStep->TEST(inputCapabilities3.ObjectProvider() == mop);
       
   512 	MObjectProvider* mop2 = (MObjectProvider*)0x87654320;
       
   513 	inputCapabilities4.SetObjectProvider(mop2);
       
   514 	inputCapabilities3.MergeWith(inputCapabilities4);
       
   515 	iStep->TEST(inputCapabilities3.ObjectProvider() == mop);
       
   516 	inputCapabilities2.MergeWith(inputCapabilities4);
       
   517 	iStep->TEST(inputCapabilities2.ObjectProvider() == mop2);
       
   518 	// assignment operator
       
   519 	inputCapabilities2 = inputCapabilities1;
       
   520 	iStep->TEST(inputCapabilities1.ObjectProvider() == inputCapabilities2.ObjectProvider());
       
   521 	// copy construction
       
   522 	TCoeInputCapabilities inputCapabilities5(inputCapabilities1);
       
   523 	iStep->TEST(inputCapabilities5.ObjectProvider() == mop);
       
   524 	// comparison operators
       
   525 	inputCapabilities1.SetObjectProvider(NULL);
       
   526 	iStep->TEST(inputCapabilities1 != inputCapabilities2);
       
   527 	inputCapabilities1.SetObjectProvider(mop);
       
   528 	iStep->TEST(inputCapabilities1 == inputCapabilities2);
       
   529 	}
       
   530 
       
   531 /**
       
   532    @SYMTestCaseID UIF-TCone2Step-TestReadResourceAPIsL
       
   533   
       
   534    @SYMPREQ
       
   535   
       
   536    @SYMTestCaseDesc Test's the CCoeEnv::ReadResourceL(),AllocReadResourceL,AllocReadResourceLC,ReadDesCArrayResourceL,
       
   537    AllocReadResourceAsDes8LC, ReadResourceAsDes8L, AllocReadResourceAsDes16LC, and Format256 methods.
       
   538   
       
   539    @SYMTestPriority High
       
   540   
       
   541    @SYMTestStatus Implemented
       
   542    
       
   543    @SYMTestActions The method creates a list of relevant contexts within an application help file 
       
   544    appropriate for the current state of the application.  
       
   545    
       
   546    @SYMTestExpectedResults. The code tests that the list created is empty.
       
   547    
       
   548  */
       
   549 
       
   550 void CTestDriver::TestReadResourceAPIsL()
       
   551 	{
       
   552 	__UHEAP_MARK;
       
   553 
       
   554 	CCoeEnv* coeEnv = CCoeEnv::Static();
       
   555 
       
   556 	TBuf<KMaxFileName> testBuffer;
       
   557 	coeEnv->ReadResourceL(testBuffer, R_TCONE2_TEST_BUFFER1);
       
   558 
       
   559 	HBufC* resourceBuf1=coeEnv->AllocReadResourceL(R_TCONE2_TEST_BUFFER1);
       
   560 	delete resourceBuf1;
       
   561 	resourceBuf1 = NULL;
       
   562 
       
   563 	resourceBuf1=coeEnv->AllocReadResourceLC(R_TCONE2_TEST_BUFFER1);
       
   564 	CleanupStack::PopAndDestroy(resourceBuf1);
       
   565 
       
   566 	INFO_PRINTF1(_L("coeEnv->IsResourceAvailable"));
       
   567 	TBool isResourceAvailable = coeEnv->IsResourceAvailableL( R_TCONE2_TEST_RESOURCE_CORRECT_SIGNATURE_MISSING_ID );
       
   568 	iStep->TEST( !isResourceAvailable );
       
   569 	isResourceAvailable = coeEnv->IsResourceAvailableL( R_TCONE2_TEST_RESOURCE_INCORRECT_SIGNATURE_FOR_THIS_RC );
       
   570 	iStep->TEST( !isResourceAvailable );
       
   571 	isResourceAvailable = coeEnv->IsResourceAvailableL( R_TCONE2_TEST_BUFFER1 );
       
   572 	iStep->TEST( isResourceAvailable );
       
   573 
       
   574 	INFO_PRINTF1(_L("coeEnv->ReadDesCArrayResourceL"));
       
   575 	CDesCArray* array=coeEnv->ReadDesCArrayResourceL(R_TCONE2_STRING_ARRAY);
       
   576 	CleanupStack::PushL(array);
       
   577 	iStep->TEST(array->MdcaCount() == 3);
       
   578 	CleanupStack::PopAndDestroy(array);  
       
   579 
       
   580 	INFO_PRINTF1(_L("coeEnv->AllocReadResourceAsDes8LC"));
       
   581 	HBufC8*  buf8 = coeEnv->AllocReadResourceAsDes8LC(R_TCONE2_TEST_BUFFER1);
       
   582 	HBufC8* tempbuf8 = HBufC8::NewLC(buf8->Size());
       
   583 	TPtr8 tempbuf8ptr = tempbuf8->Des(); 
       
   584 	coeEnv->ReadResourceAsDes8L(tempbuf8ptr, R_TCONE2_TEST_BUFFER1);
       
   585 	iStep->TEST(buf8->Des().Compare(*tempbuf8) == KErrNone);
       
   586 	CleanupStack::PopAndDestroy(2, buf8);
       
   587 	
       
   588 	INFO_PRINTF1(_L("coeEnv->AllocReadResourceAsDes16LC"));
       
   589 	HBufC16*  buf16 = coeEnv->AllocReadResourceAsDes16LC(R_TCONE2_TEST_BUFFER1);
       
   590 	iStep->TEST(*buf16 == _L16("Cone"));
       
   591 	TPtr16 tempbuf16 = buf16->Des();
       
   592 
       
   593 	INFO_PRINTF1(_L("coeEnv->ReadResourceAsDes16L"));
       
   594 	coeEnv->ReadResourceAsDes16L(tempbuf16, R_TCONE2_TEST_BUFFER1);
       
   595 	iStep->TEST(tempbuf16 == _L16("Cone"));
       
   596 
       
   597 	CleanupStack::PopAndDestroy(buf16);
       
   598 
       
   599 	TBuf<KMaxFileName> formatBuf;	
       
   600 	INFO_PRINTF1(_L("coeEnv->Format256"));
       
   601 	coeEnv->Format256(formatBuf,R_TCONE2_TEST_FORMAT_BUFFER,KTCone2ResourceFilePath().Length());
       
   602 
       
   603 	REComSession::FinalClose();	
       
   604 	__UHEAP_MARKEND;
       
   605 	}
       
   606 
       
   607  
       
   608 /**
       
   609    @SYMTestCaseID UIF-TCone2Step-TestSetandGetCCoeControlAPIsL
       
   610   
       
   611    @SYMPREQ
       
   612   
       
   613    @SYMTestCaseDesc Test's the CCoeControl::MaximumWidth() and CCoeControl::SetMaximumWidth methods. Also tests the
       
   614    defalut initialisation of CCoeControl's Maximum Width property.
       
   615   	
       
   616    @SYMTestPriority High
       
   617   
       
   618    @SYMTestStatus Implemented
       
   619    
       
   620    @SYMTestActions The test creates a CCoeControl object and checks that it maximum width property is 0. 
       
   621    It then sets this value and retrives it using getteers and setters.
       
   622    
       
   623    @SYMTestExpectedResults. The code tests the MaximumWidth property is initially 0, and that it can be set 
       
   624    and retrieved correctly.
       
   625    
       
   626  */
       
   627 
       
   628 void CTestDriver::TestSetandGetCCoeControlAPIsL()
       
   629 	{
       
   630  	// Create a new CCoeControl object
       
   631 	CCoeControl* testCtrl = new (ELeave) CCoeControl();
       
   632 	CleanupStack::PushL(testCtrl);
       
   633 	
       
   634 	// Part 1: Check that a default value of 0 is returned when no
       
   635 	// max width value has been set yet.  
       
   636 	iStep->TEST(testCtrl->MaximumWidth() == 0);
       
   637 	
       
   638 	// Part 2: Set the maximum width to a new value.
       
   639 	TInt newMaxWidth = 5;
       
   640 	iStep->TEST(testCtrl->SetMaximumWidth(newMaxWidth) == KErrNone);
       
   641  
       
   642  	// Part 3: Access maximum width. Test that it equals the
       
   643  	// value previously set.
       
   644  	iStep->TEST(testCtrl->MaximumWidth() == newMaxWidth);
       
   645  	
       
   646 	CleanupStack::PopAndDestroy(testCtrl); 	
       
   647 	}
       
   648 
       
   649 /**
       
   650   Single Argument Constructor for CCone2TestAppUi class.\n
       
   651 */
       
   652 CCone2TestAppUi::CCone2TestAppUi(CTmsTestStep* aStep) :
       
   653 	CTestCoeAppUi(aStep)
       
   654 	{}
       
   655 /**
       
   656   Destructor for CCone2TestAppUi class.\n
       
   657 */
       
   658 CCone2TestAppUi::~CCone2TestAppUi()
       
   659     {
       
   660 	delete iDriver;
       
   661 	}
       
   662  /**
       
   663   Second phase Constructor for CCone2TestAppUi class.\n
       
   664   Invokes the base class CTestCoeAppUi second phase constructor.\n
       
   665   Instantiates a Test Driver used to drive the tests.\n
       
   666   Executes the testcases asynchronously using Autotest Manager.\n
       
   667 */   
       
   668 void CCone2TestAppUi::ConstructL(CTmsTestStep* aStep)
       
   669     {
       
   670     CTestCoeAppUi::ConstructL();
       
   671 
       
   672 	iDriver=new (ELeave) CTestDriver(*this, aStep); 
       
   673 	iDriver->ConstructL();
       
   674 	
       
   675 	AutoTestManager().StartAutoTest();
       
   676 
       
   677    }
       
   678 
       
   679 /**
       
   680    Auxiliary Function for all Test Cases
       
   681   
       
   682    The method is an override from CTestCoeAppUi. 
       
   683    This function is called asynchronously by RunL function of the
       
   684    AutotestManager after previous test case is executed.\n
       
   685    Calls the following functions one by one.\n
       
   686    1. TestIsDisplayingDialogAndRemoveFromStackAPIsL
       
   687    2. TestMakeVisibleOnChildControlsL
       
   688    3. TestAppHelpContextAPIL
       
   689    4. TestReadResourceAPIsL
       
   690    5. TestCoeControlAPIsL
       
   691    6. TestColorUseAPIsL
       
   692    7. TestConeAppUiSimpleAndMiscAPIsL
       
   693    8. TestConeInputCapabilitiesAPIs
       
   694    9. TestSetAndGetSystemDefaultViewAPIsL
       
   695    10. TestSetandGetCCoeControlAPIsL
       
   696  */
       
   697 
       
   698 void CCone2TestAppUi::RunTestStepL(TInt aStepNum)
       
   699 	{
       
   700 
       
   701 	switch(aStepNum)
       
   702 		{	 
       
   703 		case 1:
       
   704 			{
       
   705 			SetTestStepID(_L("UIF-TCone2Step-TestIsDisplayingDialogAndRemoveFromStackAPIsL"));
       
   706 			INFO_PRINTF1(_L("Test IsDisplayingDialog() and RemoveFromStack() APIs"));
       
   707 			TRAPD(ret, iDriver->TestIsDisplayingDialogAndRemoveFromStackAPIsL());
       
   708 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   709 			TEST(ret==KErrNone);
       
   710 			RecordTestResultL();
       
   711 			break;
       
   712 			}
       
   713 		case 2:
       
   714 			{
       
   715 			SetTestStepID(_L("UIF-TCone2Step-TestMakeVisibleOnChildControlsL"));
       
   716 			INFO_PRINTF1(_L("Test makevisible on its child controls"));
       
   717 			TRAPD(ret, iDriver->TestMakeVisibleOnChildControlsL());
       
   718 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   719 			TEST(ret==KErrNone);
       
   720 			RecordTestResultL();
       
   721 			break;
       
   722 			}
       
   723 		case 3:
       
   724 			{
       
   725 			SetTestStepID(_L("UIF-TCone2Step-TestAppHelpContextAPIL"));
       
   726 			INFO_PRINTF1(_L("Test AppHelpContext API"));
       
   727 			TRAPD(ret, iDriver->TestAppHelpContextAPIL());
       
   728 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   729 			TEST(ret==KErrNone);
       
   730 			RecordTestResultL();
       
   731 			break;
       
   732 			}
       
   733 		case 4:
       
   734 			{
       
   735 			SetTestStepID(_L("UIF-TCone2Step-TestReadResourceAPIsL"));
       
   736 			INFO_PRINTF1(_L("Test ReadResource APIs"));
       
   737 			TRAPD(ret, iDriver->TestReadResourceAPIsL());
       
   738 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   739 			TEST(ret==KErrNone);
       
   740 			RecordTestResultL();
       
   741 			break;
       
   742 			}
       
   743 		case 5:
       
   744 			{
       
   745 			SetTestStepID(_L("UIF-TCone2Step-TestCoeControlAPIsL"));
       
   746 			INFO_PRINTF1(_L("Test SetContainerWindow APIs"));
       
   747 			TRAPD(ret, iDriver->TestCoeControlAPIsL());
       
   748 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   749 			TEST(ret==KErrNone);
       
   750 			RecordTestResultL();
       
   751 			break;
       
   752 			}
       
   753 		case 6:
       
   754 			{
       
   755 			SetTestStepID(_L("UIF-TCone2Step-TestColorUseAPIsL"));
       
   756 			INFO_PRINTF1(_L("Test ColorUse APIs"));
       
   757 			TRAPD(ret, iDriver->TestColorUseAPIsL());
       
   758 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   759 			TEST(ret==KErrNone);
       
   760 			RecordTestResultL();
       
   761 			break;
       
   762 			}
       
   763 		case 7:
       
   764 			{
       
   765 			SetTestStepID(_L("UIF-TCone2Step-TestConeAppUiSimpleAndMiscAPIsL"));
       
   766 			INFO_PRINTF1(_L("Test Cone Misc APIs"));
       
   767 			TRAPD(ret, iDriver->TestConeMiscAPIsL());
       
   768 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   769 			TEST(ret==KErrNone);
       
   770 			RecordTestResultL();
       
   771 			break;
       
   772 			}
       
   773 		case 8:
       
   774 			{
       
   775 			SetTestStepID(_L("UIF-TCone2Step-TestConeInputCapabilitiesAPIs"));
       
   776 			INFO_PRINTF1(_L("Test InputCapabilities APIs"));
       
   777 			TRAPD(ret, iDriver->TestConeInputCapabilitiesAPIs());
       
   778 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   779 			TEST(ret==KErrNone);
       
   780 			RecordTestResultL();
       
   781 			break;
       
   782 			}
       
   783 		case 9:
       
   784 			{
       
   785 			SetTestStepID(_L("UIF-TCone2Step-TestSetAndGetSystemDefaultViewAPIsL"));
       
   786 			INFO_PRINTF1(_L("Test Set and Get system default view APIs"));
       
   787 			TRAPD(ret, iDriver->TestSetAndGetSystemDefaultViewAPIsL());
       
   788 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   789 			TEST(ret==KErrNone);
       
   790 			RecordTestResultL();
       
   791 			break;
       
   792 			}
       
   793 		case 10:
       
   794 			{
       
   795 			SetTestStepID(_L("UIF-TCone2Step-TestSetandGetCCoeControlAPIsL"));
       
   796 			INFO_PRINTF1(_L("Test Set and Get APIs for CCoeControl"));
       
   797 			TRAPD(ret, iDriver->TestSetandGetCCoeControlAPIsL());
       
   798 			INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret);
       
   799 			TEST(ret==KErrNone);
       
   800 			RecordTestResultL();
       
   801 			CloseTMSGraphicsStep();
       
   802 			break;
       
   803 			}
       
   804 		case 11:
       
   805 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
   806 			break;
       
   807 		default:
       
   808 			break;
       
   809 		}
       
   810 
       
   811 	}
       
   812 
       
   813 /**
       
   814   Completes the construction of the Control Environment(CCoeEnv object).\n
       
   815   Instantiates the CCone2TestAppUi class which serves as a AppUi class.\n
       
   816   Sets the CCone2TestAppUi object as the application's user interface object.\n
       
   817   Invokes the second phase constructor of the application's UI.\n
       
   818 */
       
   819 void CTCone2Step::ConstructCone2AppL(CCoeEnv* aCoe)
       
   820 	{ // runs inside a TRAP harness
       
   821 	aCoe->ConstructL();
       
   822 	CCone2TestAppUi* appUi=new(ELeave) CCone2TestAppUi(this);
       
   823 	aCoe->SetAppUi(appUi);
       
   824 	appUi->ConstructL(this);
       
   825 	}
       
   826 
       
   827 CTCone2Step::CTCone2Step()
       
   828 	{
       
   829 	SetTestStepName(KTCone2Step);
       
   830 	}
       
   831 
       
   832 CTCone2Step::~CTCone2Step()
       
   833 	{
       
   834 	}
       
   835 
       
   836 TVerdict CTCone2Step::doTestStepL()
       
   837 	{
       
   838 
       
   839 	INFO_PRINTF1(_L("Test Started"));
       
   840 
       
   841 	PreallocateHALBuffer();
       
   842 	
       
   843 	__UHEAP_MARK;
       
   844 
       
   845 	CCoeEnv* coe=new(ELeave) CCoeEnv;
       
   846 	TRAPD(err,ConstructCone2AppL(coe));
       
   847 	if (!err)
       
   848 		coe->ExecuteD();
       
   849 	else
       
   850 		{
       
   851 		SetTestStepResult(EFail);
       
   852 		delete coe;
       
   853 		}
       
   854 
       
   855 	REComSession::FinalClose();	
       
   856 	__UHEAP_MARKEND;
       
   857 
       
   858 	INFO_PRINTF1(_L("Test Finished"));
       
   859 	return TestStepResult();
       
   860 	}
       
   861