commonuisupport/uikon/test/tspane/tspane.cpp
changeset 0 2f259fa3e83a
child 21 558113899881
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2005-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 // Tests CEikStatusPane APIs.\n
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent - Internal Symbian test code
       
    21 */
       
    22 
       
    23  
       
    24 #include <e32keys.h>
       
    25 #include <coemain.h>
       
    26 #include <eikenv.h>
       
    27 #include <eikdef.h>
       
    28 #include <tspane.rsg>
       
    29 #include "tspane.hrh"
       
    30 #include "tspane.h"
       
    31 #include <techview/eikmenup.h>
       
    32 #include <techview/eiklabel.h>
       
    33 #include <techview/eikclock.h>
       
    34 #include <barsread.h>
       
    35 #include <techview/eikmenub.h>
       
    36 #include <ecom/ecom.h>
       
    37 #include <test/testexecutelog.h>
       
    38 #include <test/testexecutelogext.h>
       
    39 #include <uikon/eikdefmacros.h>
       
    40 
       
    41 _LIT(KTSpaneResourceFilePath, "z:\\system\\test\\uiktest\\tspane.rsc");
       
    42 
       
    43 
       
    44 void Panic(TInt aPanic)
       
    45 	{
       
    46 	User::Panic(_L("Tspane App"),aPanic);
       
    47 	}
       
    48 
       
    49 
       
    50 CControlStackedGlobalTextEditor::~CControlStackedGlobalTextEditor()
       
    51 /**
       
    52    Destructor
       
    53  */
       
    54 	{
       
    55 	CCoeAppUi* const appUi=iEikonEnv->EikAppUi();
       
    56 	if (appUi!=NULL)
       
    57 		{
       
    58 		appUi->RemoveFromStack(this);
       
    59 		}
       
    60 	}
       
    61 
       
    62 // Class CTspaneContainer
       
    63 
       
    64 /**
       
    65    Auxiliary function for all Test Cases
       
    66   
       
    67    This method creates the status pane control on which all tests are
       
    68    carried out & a window to hold the control.
       
    69    
       
    70  */
       
    71 void CTspaneContainer::ConstructL(const TRect& aRect)
       
    72     {
       
    73 	CreateWindowL();
       
    74 	CreateStatusPaneL();
       
    75 	TRect rect(aRect);
       
    76 	iStatusPane->ReduceRect(rect);
       
    77 	SetRect(rect);
       
    78 	ActivateL();
       
    79     }
       
    80 
       
    81 CTspaneContainer::~CTspaneContainer()
       
    82 /**
       
    83    Destructor
       
    84  */
       
    85     {
       
    86 	delete iStatusPane;
       
    87     }
       
    88 
       
    89 /**
       
    90    Auxiliary function for Container
       
    91   
       
    92    The method is an override from CCoeControl. The method is called by
       
    93    the windows server or the application itself to redraw the status pane.
       
    94   
       
    95  */
       
    96 void CTspaneContainer::Draw(const TRect& /*aRect*/) const
       
    97 	{
       
    98 	CWindowGc& gc = SystemGc();
       
    99 	gc.SetPenColor(KRgbWhite);
       
   100 	gc.SetPenSize(TSize(2,2));
       
   101 	gc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   102 	gc.SetBrushColor(KRgbGray);
       
   103 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   104 	gc.DrawRect(Rect());
       
   105 	}
       
   106 
       
   107 /**
       
   108    Auxiliary function for Container
       
   109   
       
   110    The method is an override from MEikStatusPaneObserver. The method is
       
   111    invoked on a change in the position or size of the screen area
       
   112    occupied by the status pane.
       
   113   
       
   114  */
       
   115 void CTspaneContainer::HandleStatusPaneSizeChange()
       
   116 	{
       
   117 	TRect rect = iEikonEnv->EikAppUi()->ClientRect();
       
   118 	iStatusPane->ReduceRect(rect);
       
   119 	SetRect(rect);
       
   120 	DrawNow();
       
   121 	}
       
   122 
       
   123 /**
       
   124    @SYMTestCaseID UIF-tspane-AutoTestL
       
   125   
       
   126    @SYMPREQ
       
   127   
       
   128    @SYMTestCaseDesc Performs automated tests
       
   129   
       
   130    @SYMTestPriority High
       
   131   
       
   132    @SYMTestStatus Implemented
       
   133    
       
   134    @SYMTestActions The method initiates the following tests:\n
       
   135    (1) Out of Memory Tests.\n
       
   136    (2) Tests status pane observer provided by MEikStatusPaneObserver.\n
       
   137    (3) API testing for the following:\n
       
   138    (a) CEikStatusPane::NewL()\n
       
   139    (b) CEikStatusPaneBase::ReduceRect()\n
       
   140    (c) CEikStatusPaneBase::SwitchLayoutL()\n
       
   141    (d) CEikStatusPaneBase::PaneCapabilities()\n
       
   142    (e) CEikStatusPaneBase::PaneRectL()\n
       
   143    (f) CEikStatusPaneBase::ControlL()\n
       
   144    (g) CEikStatusPaneBase::ContainerControlL()\n
       
   145   
       
   146    @SYMTestExpectedResults All automated tests should complete.
       
   147     
       
   148  */
       
   149 void CTspaneContainer::AutoTestL(TAutoTest aTestId)
       
   150 	{
       
   151 	switch (aTestId)
       
   152 		{
       
   153 		case ETotal:
       
   154 			ASSERT(CEikStatusPaneBase::Current()!=NULL);
       
   155 			AutoTestL(EAllNormal);
       
   156 			AutoTestL(EOOM);
       
   157 			break;
       
   158 
       
   159 		case EOOM:
       
   160 			AutoTestOom();
       
   161 			if (CEikStatusPaneBase::Current()==NULL)
       
   162 				{
       
   163 				CreateStatusPaneL();
       
   164 				}
       
   165 			ASSERT(CEikStatusPaneBase::Current()!=NULL);
       
   166 			break;
       
   167 
       
   168 		case EAllNormal:
       
   169 			{
       
   170 			CreateStatusPaneL();
       
   171 			for (TInt i=0; i<ENumNormalTests; i++)
       
   172 				AutoTestL(TAutoTest(i));
       
   173 			if (CEikStatusPaneBase::Current()==NULL)
       
   174 				{
       
   175 				CreateStatusPaneL();
       
   176 				}
       
   177 			ASSERT(CEikStatusPaneBase::Current()!=NULL);
       
   178 			break;
       
   179 			}
       
   180 
       
   181 		case EObserver:
       
   182 			AutoTestObserverL();
       
   183 			break;
       
   184 
       
   185 		case ENew:
       
   186 			AutoTestNewL();
       
   187 			break;
       
   188 
       
   189 		case EReduceRect:
       
   190 			AutoTestReduceL();
       
   191 			break;
       
   192 
       
   193 		case ESwitchLayout:
       
   194 			AutoTestSwitchL();
       
   195 			break;
       
   196 
       
   197 		case ECaps:
       
   198 			AutoTestCapsL();
       
   199 			break;
       
   200 
       
   201 		case ERect:
       
   202 			AutoTestRectL();
       
   203 			break;
       
   204 
       
   205 		case EControl:
       
   206 			AutoTestControlL();
       
   207 			break;
       
   208 
       
   209 		case ESwap:
       
   210 			AutoTestSwapL();
       
   211 			break;
       
   212 
       
   213 		case EContainer:
       
   214 			AutoTestContainerL();
       
   215 			break;
       
   216 
       
   217 		case EBackground:
       
   218 			AutoTestBackgroundL();
       
   219 			break;
       
   220 		
       
   221 		default:
       
   222 			Panic(0);
       
   223 			break;
       
   224 		}
       
   225 	}
       
   226 
       
   227 /**
       
   228    @SYMTestCaseID UIF-tspane-AutoTestOom
       
   229   
       
   230    @SYMPREQ
       
   231   
       
   232    @SYMTestCaseDesc Perform Out of Memory tests
       
   233   
       
   234    @SYMTestPriority High
       
   235   
       
   236    @SYMTestStatus Implemented
       
   237    
       
   238    @SYMTestActions The method runs all auto tests under a simulated OOM situation.
       
   239   
       
   240    @SYMTestExpectedResults All tests should pass under the simulated OOM situation.
       
   241    
       
   242  */
       
   243 void CTspaneContainer::AutoTestOom()
       
   244 	{
       
   245 	TInt i = 0;
       
   246 	TInt err = KErrNoMemory;
       
   247 
       
   248 	while (err != KErrNone)
       
   249 		{
       
   250 		User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, i);
       
   251 
       
   252 		TRAP(err, 
       
   253 			{
       
   254 			AutoTestL(EAllNormal);
       
   255 			});
       
   256 
       
   257 		i++;
       
   258 
       
   259 		TBuf<32> buf;
       
   260 		buf.Format(_L("OOM %d"), i);
       
   261 		iEikonEnv->InfoMsg(buf);
       
   262 		}
       
   263 
       
   264 	User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, i);
       
   265 	}
       
   266 
       
   267 /**
       
   268    @SYMTestCaseID UIF-tspane-AutoTestObserverL
       
   269   
       
   270    @SYMPREQ
       
   271   
       
   272    @SYMTestCaseDesc Tests status pane observer.
       
   273   
       
   274    @SYMTestPriority High
       
   275   
       
   276    @SYMTestStatus Implemented
       
   277    
       
   278    @SYMTestActions The test resets two status pane observers and allocates
       
   279    one of them to be the observer for the test status pane.
       
   280    The method then changes the layout and checks whether the observer
       
   281    set for the test status pane receives notification of the change. The
       
   282    same test is carried out when no observer is set for the status pane.
       
   283   
       
   284    @SYMTestExpectedResults Only the observer to which the test status pane
       
   285    is set should receive the position change notification. The other
       
   286    observers should not receive any notifications.
       
   287   
       
   288  */
       
   289 void CTspaneContainer::AutoTestObserverL()
       
   290 	{
       
   291 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_TOP);
       
   292 	iObs1.Reset();
       
   293 	iObs2.Reset();
       
   294 	iStatusPane->SetObserver(&iObs1);
       
   295 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_BOTTOM);
       
   296 	if (!iObs1.Test() || iObs2.Test())
       
   297 		Panic(0);
       
   298 	iObs1.Reset();
       
   299 	iStatusPane->SetObserver(&iObs2);
       
   300 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_TOP);
       
   301 	if (iObs1.Test() || !iObs2.Test())
       
   302 		Panic(0);
       
   303 	iObs2.Reset();
       
   304 	iStatusPane->SetObserver(NULL);
       
   305 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_BOTTOM);
       
   306 	if (iObs1.Test() || iObs2.Test())
       
   307 		Panic(0);
       
   308 	iStatusPane->SetObserver(this);
       
   309 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_COMPLEX);
       
   310 	}
       
   311 
       
   312 /**
       
   313    @SYMTestCaseID UIF-tspane-AutoTestReduceL
       
   314   
       
   315    @SYMPREQ
       
   316   
       
   317    @SYMTestCaseDesc Test CEikStatusPaneBase::ReduceRect() API.
       
   318   
       
   319    @SYMTestPriority High
       
   320   
       
   321    @SYMTestStatus Implemented
       
   322    
       
   323    @SYMTestActions The method tests CEikStatusPaneBase::ReduceRect() API
       
   324    under the following situations:
       
   325    (1)When status pane does not extend beyond the screen size.
       
   326    (2)When status pane extends beyond the screen size.
       
   327   
       
   328    @SYMTestExpectedResults Test checks results against expected values.
       
   329    
       
   330  */
       
   331 void CTspaneContainer::AutoTestReduceL()
       
   332 	{
       
   333 	const TRect spRect(TPoint(0,0), TSize(iEikonEnv->ScreenDevice()->SizeInPixels().iWidth, ETspaneTopHeight));
       
   334 	TRect test;
       
   335 
       
   336 	// Normal edge of rectangle reduces, top, left, bottom & right.
       
   337 	test = spRect;
       
   338  
       
   339 	test.iBr.iY += 10;
       
   340 	iStatusPane->ReduceRect(test);
       
   341 	if (!(test.iTl.iX == 0 && test.iTl.iY == spRect.iBr.iY && 
       
   342 		 test.iBr.iX == spRect.iBr.iX && test.Height() == 10))
       
   343 		Panic(0);
       
   344 	
       
   345 	test = spRect;
       
   346 	test.iBr.iX += 10;
       
   347 	iStatusPane->ReduceRect(test);
       
   348 	if (!(test.iTl.iX == spRect.iBr.iX && test.iTl.iY == 0 && 
       
   349 		  test.Width() == 10 && test.iBr.iY == spRect.iBr.iY))
       
   350 		Panic(0);
       
   351 	
       
   352 	test = spRect;
       
   353 	test.iTl.iY -= 10;
       
   354 	iStatusPane->ReduceRect(test);
       
   355 	if (!(test.iTl.iX == 0 && test.iTl.iY == -10 && 
       
   356 		  test.iBr.iX == spRect.iBr.iX && test.Height() == 10))
       
   357 		Panic(0);
       
   358 	
       
   359 	test = spRect;
       
   360 	test.iTl.iX -= 10;
       
   361 	iStatusPane->ReduceRect(test);
       
   362 	if (!(test.iTl.iX == -10 && test.iTl.iY == 0 && 
       
   363 		  test.Width() == 10 && test.iBr.iY == spRect.iBr.iY))
       
   364 		Panic(0);
       
   365 	
       
   366 	// reductions where status pane extends beyond edge of rect.
       
   367 	test = spRect;
       
   368 	test.Shrink(2,2);
       
   369 	test.iBr.iY += 10;
       
   370 	iStatusPane->ReduceRect(test);
       
   371 	if (!(test.iTl.iX == 2 && test.iTl.iY == spRect.iBr.iY && 
       
   372 		  test.iBr.iX == spRect.iBr.iX-2 && test.Height() == 8))
       
   373 		Panic(0);
       
   374 	
       
   375 	test = spRect;
       
   376 	test.Shrink(2,2);
       
   377 	test.iBr.iX += 10;
       
   378 	iStatusPane->ReduceRect(test);
       
   379 	if (!(test.iTl.iX == spRect.iBr.iX && test.iTl.iY == 2 && 
       
   380 		  test.Width() == 8 && test.iBr.iY == spRect.iBr.iY-2))
       
   381 		Panic(0);
       
   382 	
       
   383 	test = spRect;
       
   384 	test.Shrink(2,2);
       
   385 	test.iTl.iY -= 10;
       
   386 	iStatusPane->ReduceRect(test);
       
   387 	if (!(test.iTl.iX == 2 && test.iTl.iY == -8 && 
       
   388 		  test.iBr.iX == spRect.iBr.iX-2 && test.Height() == 8))
       
   389 		Panic(0);
       
   390 
       
   391 	test = spRect;
       
   392 	test.Shrink(2,2);
       
   393 	test.iTl.iX -= 10;
       
   394 	iStatusPane->ReduceRect(test);
       
   395 	if (!(test.iTl.iX == -8 && test.iTl.iY == 2 && 
       
   396 		  test.Width() == 8 && test.iBr.iY == spRect.iBr.iY-2))
       
   397 		Panic(0);
       
   398 	}
       
   399 
       
   400 /**
       
   401    @SYMTestCaseID UIF-tspane-AutoTestSwitchL
       
   402   
       
   403    @SYMPREQ
       
   404   
       
   405    @SYMTestCaseDesc Test CEikStatusPaneBase::SwitchLayoutL() API.
       
   406   
       
   407    @SYMTestPriority High
       
   408   
       
   409    @SYMTestStatus Implemented
       
   410    
       
   411    @SYMTestActions The method tests switching of layouts with valid &
       
   412    invalid layouts. The leave error code is observed on each attempt to
       
   413    verify success or failure of layout switch. It also tests whether an
       
   414    observer is notified on change in layout.
       
   415   
       
   416    @SYMTestExpectedResults For all valid layouts CEikStatusPaneBase::SwitchLayoutL()
       
   417    should change to the specified layout and should return KErrNone. Otherwise
       
   418    the method should return KErrNotFound
       
   419    
       
   420  */
       
   421 void CTspaneContainer::AutoTestSwitchL()
       
   422 	{
       
   423 	iLayoutNum = 0;
       
   424 
       
   425 	for (TInt ii=0; ii<7; ii++)
       
   426 		{
       
   427 		TRAPD(err, SwitchLayoutL());
       
   428 		if (err != KErrNone && err != KErrNotFound)
       
   429 			User::Leave(err);
       
   430 		if ((ii!=5 && err!=KErrNone) || (ii==5 && err!=KErrNotFound))
       
   431 			Panic(0);
       
   432 		}
       
   433 
       
   434 	iStatusPane->SetObserver(&iObs1);
       
   435 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_DIFSIZE);
       
   436 	iObs1.Reset();
       
   437 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_TOP);
       
   438 	if (!iObs1.Test())
       
   439 		Panic(0);
       
   440 	iObs1.Reset();
       
   441 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_COMPLEX);
       
   442 	if (iObs1.Test())
       
   443 		Panic(0);
       
   444 	iObs1.Reset();
       
   445 	iStatusPane->SetObserver(this);
       
   446 	}
       
   447 
       
   448 /**
       
   449    @SYMTestCaseID UIF-tspane-AutoTestCapsL
       
   450   
       
   451    @SYMPREQ
       
   452   
       
   453    @SYMTestCaseDesc Test CEikStatusPaneBase::PaneCapabilities() API
       
   454   
       
   455    @SYMTestPriority High
       
   456   
       
   457    @SYMTestStatus Implemented
       
   458    
       
   459    @SYMTestActions The method tests whether CEikStatusPanBase::PaneCapabilities()
       
   460    sets flags to indicate that the subpane specified is present and part of the
       
   461    current status pane layout owned by an application. The test is carried out
       
   462    on subpanes that are defined and undefined.
       
   463   
       
   464    @SYMTestExpectedResults For a defined subpane 
       
   465    CEikStatusPanBase::PaneCapabilities() should set flags to represent that
       
   466    the subpane is present & owned by the application. For an undefined subpane
       
   467    specified the method should not set any flag.
       
   468    
       
   469  */
       
   470 void CTspaneContainer::AutoTestCapsL()
       
   471 	{
       
   472 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_TOP);
       
   473 	TInt ii;
       
   474 	for (ii = ETSpanePaneUid1; ii <= ETSpanePaneUid7; ii++)
       
   475 		{
       
   476 		CEikStatusPaneBase::TPaneCapabilities caps = iStatusPane->PaneCapabilities(TUid::Uid(ii));
       
   477 		if (!caps.IsPresent() || !caps.IsAppOwned())
       
   478 			Panic(0);
       
   479 		}
       
   480 	iStatusPane->SwitchLayoutL(R_TSPANE_LAYOUT_COMPLEX);
       
   481 	for (ii = ETSpanePaneUid1; ii <= ETSpanePaneUid7; ii++)
       
   482 		{
       
   483 		CEikStatusPaneBase::TPaneCapabilities caps = iStatusPane->PaneCapabilities(TUid::Uid(ii));
       
   484 		if (!caps.IsPresent() || !caps.IsAppOwned())
       
   485 			Panic(0);
       
   486 		}
       
   487 
       
   488 	CEikStatusPaneBase::TPaneCapabilities caps = iStatusPane->PaneCapabilities(TUid::Uid(0x12345678));
       
   489 	if (caps.IsPresent() || caps.IsAppOwned())
       
   490 		Panic(0);	
       
   491 	}
       
   492 
       
   493 /**
       
   494    @SYMTestCaseID UIF-tspane-AutoTestRectL
       
   495   
       
   496    @SYMPREQ
       
   497   
       
   498    @SYMTestCaseDesc Test CEikStatusPaneBase::PaneRectL() API
       
   499   
       
   500    @SYMTestPriority High
       
   501   
       
   502    @SYMTestStatus Implemented
       
   503    
       
   504    @SYMTestActions The method tests CEikStatusPaneBase::PaneRectL() retrieves the
       
   505    size of subpanes present in the current status pane. The tests is carried
       
   506    by specifying defined & undefined subpane uids.
       
   507   
       
   508    @SYMTestExpectedResults For each defined sub-pane 
       
   509    CEikStatusPaneBase::PaneRectL() should return it's size.For undefined
       
   510    subpane the method should return leave error code KErrNotFound.
       
   511    
       
   512  */
       
   513 void CTspaneContainer::AutoTestRectL()
       
   514 	{
       
   515 	const TRect spRect(TPoint(0,0), TSize(iEikonEnv->ScreenDevice()->SizeInPixels().iWidth, ETspaneTopHeight));
       
   516 	const TInt w = spRect.Width()/4;
       
   517 	const TInt h = spRect.Height()/2;
       
   518 
       
   519 	const TRect rects[7] = 
       
   520 		{
       
   521 			TRect(TPoint(0,0), TSize(w, h)),
       
   522 			TRect(TPoint(0,h), TSize(w, h)),
       
   523 			TRect(TPoint(w,0), TSize(w, 2*h)),
       
   524 			TRect(TPoint(2*w,0), TSize(w, h)),
       
   525 			TRect(TPoint(2*w,h), TSize(w/2, h)),
       
   526 			TRect(TPoint(2*w+w/2,h), TSize(w/2, h)),
       
   527 			TRect(TPoint(3*w,0), TSize(w, 2*h))
       
   528 		};
       
   529 
       
   530 	// This test might fail due to rounding errors if your screen is not a
       
   531 	// multiple of 8 pixels across & a multiple of 2 pixels high.
       
   532 	TRect rect;
       
   533 	for (TInt ii = ETSpanePaneUid1; ii <= ETSpanePaneUid7; ii++)
       
   534 		{
       
   535 		rect = iStatusPane->PaneRectL(TUid::Uid(ii));
       
   536 		if (rect != rects[ii-ETSpanePaneUid1])
       
   537 			Panic(0);
       
   538 		}
       
   539 
       
   540 	TRAPD(err, rect = iStatusPane->PaneRectL(TUid::Uid(0x12345678)));
       
   541 	if (err != KErrNotFound)
       
   542 		Panic(0);
       
   543 	}
       
   544 
       
   545 /**
       
   546    @SYMTestCaseID UIF-tspane-AutoTestControlL
       
   547   
       
   548    @SYMPREQ
       
   549   
       
   550    @SYMTestCaseDesc Test CEikStatusPaneBase::ControlL() API
       
   551   
       
   552    @SYMTestPriority High
       
   553   
       
   554    @SYMTestStatus Implemented
       
   555    
       
   556    @SYMTestActions The method tests whether CEikStatusPaneBase::ControlL() returns 
       
   557    a sub-pane control represented by the uid specified. To do this the metho 
       
   558    changes the sub-pane control properties such as visibilty, fading & dimne s.
       
   559    Then it retreives controls from the subpane by specifying their uids an 
       
   560    checks the above mentioned properties against expected results. The tes 
       
   561    also verifies the scenario where an invalid subpane control uid i 
       
   562    specified
       
   563   
       
   564    @SYMTestExpectedResults The properties of control retreived from status pane
       
   565    should match the expected results. When an invalid control uid is specified
       
   566    the method should return leave error code KErrNotFound.
       
   567    
       
   568  */
       
   569 void CTspaneContainer::AutoTestControlL()
       
   570 	{
       
   571 	CCoeControl* control;
       
   572 
       
   573 	for (TInt vis=0; vis<2; vis++)
       
   574 		{
       
   575 		iStatusPane->MakeVisible(vis);
       
   576 		for (TInt dim=1; dim>=0; dim--)
       
   577 			{
       
   578 			iStatusPane->SetDimmed(dim);
       
   579 			for (TInt fade=1; fade>=0; fade--)
       
   580 				{
       
   581 				iStatusPane->SetFaded(fade);
       
   582 				for (TInt ii = ETSpanePaneUid1; ii <= ETSpanePaneUid7; ii++)
       
   583 					{
       
   584 					control = iStatusPane->ControlL(TUid::Uid(ii));
       
   585 					if (!COMPARE_BOOLS(dim, control->IsDimmed()) ||
       
   586 						!COMPARE_BOOLS(vis, control->IsVisible()))
       
   587 						Panic(0);
       
   588 					}
       
   589 				}
       
   590 			}
       
   591 		}
       
   592 
       
   593 	TRAPD(err, control = iStatusPane->ControlL(TUid::Uid(0x12345678)));
       
   594 	if (err != KErrNotFound)
       
   595 		Panic(0);
       
   596 	}
       
   597 
       
   598 /**
       
   599    @SYMTestCaseID UIF-tspane-AutoTestSwapL
       
   600   
       
   601    @SYMPREQ
       
   602   
       
   603    @SYMTestCaseDesc Test CEikStatusPaneBase::SwapControlL
       
   604    
       
   605    @SYMTestPriority High
       
   606   
       
   607    @SYMTestStatus Implemented
       
   608   
       
   609    @SYMTestActions The method tests whether CEikStatusPaneBase::SwapControlL()
       
   610    can swap control on valid sub-pane with the control specified. It
       
   611    also tests the behaviour of the method when an undefined sub-pane uid is
       
   612    specified.
       
   613   
       
   614    @SYMTestExpectedResults CEikStatusPaneBase::SwapControlL() should swap the
       
   615    control on a valid sub-pane with the control specified. If an undefined
       
   616    sub-pane uid is passed to it it should leave with error code KErrNotFound.
       
   617    
       
   618  */
       
   619 void CTspaneContainer::AutoTestSwapL()
       
   620 	{
       
   621 	iControlNum = 0;
       
   622 
       
   623 	for (TInt ii=0; ii<4; ii++)
       
   624 		{
       
   625 		SwitchControlL(EFalse);
       
   626 		}
       
   627 
       
   628 	TRAPD(err, iStatusPane->SwapControlL(TUid::Uid(0x12345678), NULL));
       
   629 	if (err != KErrNotFound)
       
   630 		Panic(0);
       
   631 	}
       
   632 
       
   633 /**
       
   634    @SYMTestCaseID UIF-tspane-AutoTestContainerL
       
   635   
       
   636    @SYMPREQ
       
   637   
       
   638    @SYMTestCaseDesc Test CEikStatusPaneBase::ContainerControlL() API
       
   639   
       
   640    @SYMTestPriority High
       
   641   
       
   642    @SYMTestStatus Implemented
       
   643    
       
   644    @SYMTestActions The method tests whether CEikStatusPaneBase::ContainerControlL()
       
   645    returns a sub-pane container control represented by the uid specified.
       
   646    To do this the method changes the sub-pane container control properties
       
   647    such as visibilty, fading & dimness. Then it retreives container controls
       
   648    from the subpane by specifying their uids and checks the above mentioned
       
   649    properties against expected results. The test also verifies the scenario
       
   650    where an invalid subpane container control uid is specified.
       
   651   
       
   652    @SYMTestExpectedResults The properties of container control retreived from
       
   653    status pane should match the expected results. When an invalid container 
       
   654    control uid is specified the method should return leave error code
       
   655    KErrNotFound.
       
   656    
       
   657  */
       
   658 void CTspaneContainer::AutoTestContainerL()
       
   659 	{
       
   660 	CCoeControl* control;
       
   661 
       
   662 	for (TInt vis=0; vis<2; vis++)
       
   663 		{
       
   664 		iStatusPane->MakeVisible(vis);
       
   665 		for (TInt dim=1; dim>=0; dim--)
       
   666 			{
       
   667 			iStatusPane->SetDimmed(dim);
       
   668 			for (TInt fade=1; fade>=0; fade--)
       
   669 				{
       
   670 				iStatusPane->SetFaded(fade);
       
   671 				for (TInt ii = ETSpanePaneUid1; ii <= ETSpanePaneUid7; ii++)
       
   672 					{
       
   673 					control = iStatusPane->ContainerControlL(TUid::Uid(ii));
       
   674 					if (!COMPARE_BOOLS(dim, control->IsDimmed()) ||
       
   675 						!COMPARE_BOOLS(vis, control->IsVisible()))
       
   676 						Panic(0);
       
   677 					}
       
   678 				}
       
   679 			}
       
   680 		}
       
   681 
       
   682 	TRAPD(err, iStatusPane->ControlL(TUid::Uid(0x12345678)));
       
   683 	if (err != KErrNotFound)
       
   684 		Panic(0);
       
   685 	}
       
   686 
       
   687 
       
   688 class CEikTestLabel : public CEikLabel
       
   689 {
       
   690 	
       
   691 protected: // from CCoeControl
       
   692  void Draw(const TRect& aRect) const;	
       
   693 	
       
   694 };
       
   695 
       
   696 void CEikTestLabel::Draw(const TRect& /*aRect*/) const
       
   697 	{
       
   698 		
       
   699 	}
       
   700 
       
   701 class CEikTestTextButton : public CEikTextButton
       
   702 {
       
   703 	
       
   704  void Draw(const TRect& aRect) const;	
       
   705 };
       
   706 
       
   707 void CEikTestTextButton::Draw(const TRect& /*aRect*/) const
       
   708 	{
       
   709 		
       
   710 	}
       
   711 
       
   712 class CEikTestClock : public CEikClock
       
   713 {
       
   714 	
       
   715  void Draw(const TRect& aRect) const;	
       
   716 };
       
   717 
       
   718 void CEikTestClock::Draw(const TRect& /*aRect*/) const
       
   719 	{
       
   720 	}
       
   721 
       
   722  
       
   723  
       
   724 /**
       
   725   Auxiliary function for AutoTestBackGroundL
       
   726  
       
   727   The function creates different controls and set them in the status pane.
       
   728 */
       
   729 void CTspaneContainer::SwapBackgroundTestControlL(TInt aControlType)
       
   730 	{
       
   731 	
       
   732 
       
   733 	CCoeControl* newControl=0;
       
   734 	CCoeControl* container = iStatusPane->ContainerControlL(TUid::Uid(ETSpanePaneUid3));
       
   735 	
       
   736  
       
   737 	switch(aControlType)
       
   738 		{
       
   739 		 	case 0: 
       
   740 			// Pane 1 - normal label
       
   741 			newControl = new(ELeave) CEikLabel;
       
   742 		 	CleanupStack::PushL(newControl);
       
   743 			newControl->SetContainerWindowL(*container);
       
   744 		 
       
   745 			((CEikLabel*)newControl)->SetEmphasis(CEikLabel::EPartialEmphasis);
       
   746 			((CEikLabel*)newControl)->SetTextL(_L("Normal Label"));
       
   747 			break;
       
   748 	
       
   749 			case 1: 
       
   750 			// Pane 2 -  label not drawn
       
   751 			 
       
   752 			newControl = new(ELeave) CEikTestLabel;
       
   753 		 	CleanupStack::PushL(newControl);
       
   754 			newControl->SetContainerWindowL(*container);
       
   755 
       
   756 			((CEikLabel*)newControl)->SetEmphasis(CEikLabel::EPartialEmphasis);
       
   757 			((CEikLabel*)newControl)->SetTextL(_L("Test Label"));
       
   758 			break;
       
   759 			
       
   760 			case 2: 
       
   761 			// Pane 3 - normal text button	
       
   762 		 
       
   763 			newControl = new(ELeave) CEikTextButton;
       
   764 			CleanupStack::PushL(newControl);
       
   765 			newControl->SetContainerWindowL(*container);
       
   766 
       
   767 			((CEikTextButton*)newControl)->SetTextL(_L(" Normal Text Button"));	
       
   768 			 break;
       
   769 			 
       
   770 			case 3:
       
   771 			// Pane 4 - text button	not drawn
       
   772 		 
       
   773 			newControl = new(ELeave) CEikTestTextButton;
       
   774 			CleanupStack::PushL(newControl);
       
   775 			newControl->SetContainerWindowL(*container);
       
   776 
       
   777 			((CEikTextButton*)newControl)->SetTextL(_L("Test Text Button"));	
       
   778 			break;
       
   779 			
       
   780 			case 4:
       
   781 			// Pane 5 - normal clock
       
   782 			newControl = new(ELeave) CEikClock;
       
   783 			CleanupStack::PushL(newControl);
       
   784 			newControl->SetContainerWindowL(*container);
       
   785 			TResourceReader res;
       
   786 			iEikonEnv->CreateResourceReaderLC(res, R_TSPANE_CLOCK) ;
       
   787 			((CEikClock*)newControl)->ConstructFromResourceL(res);
       
   788 			CleanupStack::PopAndDestroy();	// res
       
   789 			break;
       
   790 			
       
   791 			case 5:
       
   792 			// Pane 6 - test clock
       
   793 			newControl = new(ELeave) CEikTestClock;
       
   794 			CleanupStack::PushL(newControl);
       
   795 			newControl->SetContainerWindowL(*container);
       
   796 			TResourceReader res1;
       
   797 			iEikonEnv->CreateResourceReaderLC(res1, R_TSPANE_CLOCK) ;
       
   798 			((CEikClock*)newControl)->ConstructFromResourceL(res1);
       
   799 			CleanupStack::PopAndDestroy();	// res1	    	    
       
   800 			break;
       
   801 		}
       
   802  
       
   803 	TRect rect = iStatusPane->PaneRectL(TUid::Uid(ETSpanePaneUid3));
       
   804 	newControl->SetRect(rect);
       
   805 	newControl->DrawNow();
       
   806 	newControl->ActivateL();
       
   807 
       
   808 	CCoeControl* oldControl= iStatusPane->SwapControlL(TUid::Uid(ETSpanePaneUid3), newControl); // iStatusPane takes ownership of newControl
       
   809 	iStatusPane->MakeVisible(ETrue); 
       
   810 	iStatusPane->ApplyCurrentSettingsL();
       
   811 
       
   812 	CleanupStack::Pop(); 
       
   813  
       
   814 	delete oldControl;
       
   815 	}
       
   816 
       
   817 /**
       
   818    @SYMTestCaseID UIF-tspane-AutoTestBackgroundL
       
   819   
       
   820    @SYMPREQ 852 part 2
       
   821   
       
   822    @SYMTestCaseDesc Tests the status pane gets a background
       
   823   
       
   824    @SYMTestPriority High
       
   825   
       
   826    @SYMTestStatus Implemented
       
   827    
       
   828    @SYMTestActions The method tests whether the background of the status pane
       
   829    is set when adding or changing the controls in the pane.
       
   830   
       
   831    @SYMTestExpectedResults The background is set to blue.
       
   832    
       
   833  */
       
   834 void CTspaneContainer::AutoTestBackgroundL()
       
   835 	{
       
   836  
       
   837 	for (TInt ii=0; ii<6; ii++)
       
   838 		{
       
   839 		SwapBackgroundTestControlL(ii);
       
   840 		}
       
   841 	}
       
   842 	
       
   843 /**
       
   844    @SYMTestCaseID UIF-tspane-AutoTestNewL
       
   845   
       
   846    @SYMPREQ
       
   847   
       
   848    @SYMTestCaseDesc Test CEikStatusPane::NewL()
       
   849   
       
   850    @SYMTestPriority High
       
   851   
       
   852    @SYMTestStatus Implemented
       
   853    
       
   854    @SYMTestActions This method intiates the following:
       
   855    (1)Tests on successful creation of status pane.
       
   856    (2)Test CEikStatusPane::NewL() when system status pane specifies an
       
   857    undefined default layout.
       
   858    (3)Test CEikStatusPane::NewL() when application status pane
       
   859    specifies an undefined layout.
       
   860    (4)Test CEikStatusPane::NewL() when application status pane
       
   861    specifies an undefined override pane.
       
   862   
       
   863    @SYMTestExpectedResults NA
       
   864    
       
   865  */
       
   866 void CTspaneContainer::AutoTestNewL()
       
   867 	{
       
   868 	AutoTestAppOverridesL();
       
   869 	AutoTestBadDefaultLayoutL();
       
   870 	AutoTestBadOverrideLayoutL();
       
   871 	AutoTestBadOverridePaneL();
       
   872 	}
       
   873 
       
   874 /**
       
   875    @SYMTestCaseID UIF-tspane-AutoTestAppOverridesL
       
   876   
       
   877    @SYMPREQ
       
   878   
       
   879    @SYMTestCaseDesc Test CEikStatusPane::NewL()
       
   880   
       
   881    @SYMTestPriority High
       
   882   
       
   883    @SYMTestStatus Implemented
       
   884    
       
   885    @SYMTestActions This method invokes CEikStatusPane::NewL() method by
       
   886    passing proper system status pane & application status pane to
       
   887    create a status pane. The method then tests the content & layout
       
   888    of the new status pane.
       
   889   
       
   890    @SYMTestExpectedResults The layout & content should match expected results.
       
   891    
       
   892  */
       
   893 void CTspaneContainer::AutoTestAppOverridesL()
       
   894 	{
       
   895 	CEikStatusPane* sp = CEikStatusPane::NewL(*iEikonEnv, &iEikonEnv->RootWin(), R_TSPANE_STATUS_PANE, R_TSPANE_APP_OVERRIDES);
       
   896 	CleanupStack::PushL(sp);
       
   897 
       
   898 	// Check Layout
       
   899 	const TRect spRect(TPoint(0,0), TSize(iEikonEnv->ScreenDevice()->SizeInPixels().iWidth, ETspaneTopHeight));
       
   900 	TRect rect = sp->PaneRectL(TUid::Uid(ETSpanePaneUid1));
       
   901 	if (rect != spRect)
       
   902 		Panic(0);
       
   903 
       
   904 	// Check Content
       
   905 	CCoeControl* label = sp->ControlL(TUid::Uid(ETSpanePaneUid1));
       
   906 	if (*((CEikLabel*)label)->Text() != _L("A"))
       
   907 		Panic(0);
       
   908 
       
   909 	CleanupStack::PopAndDestroy();	// sp
       
   910 	}
       
   911 
       
   912 /**
       
   913    @SYMTestCaseID UIF-tspane-AutoTestBadDefaultLayoutL
       
   914   
       
   915    @SYMPREQ
       
   916   
       
   917    @SYMTestCaseDesc Test CEikStatusPane::NewL() when system status pane
       
   918    specifies an undefined default layout.
       
   919   
       
   920    @SYMTestPriority High
       
   921   
       
   922    @SYMTestStatus Implemented
       
   923    
       
   924    @SYMTestActions This method invokes CEikStatusPane::NewL() method by
       
   925    passing a system status pane that specifies an undefined default 
       
   926    layout. The method then tests the error code returned.
       
   927   
       
   928    @SYMTestExpectedResults CEikStatusPane::NewL() should leave with
       
   929    KErrNotFound
       
   930    
       
   931  */
       
   932 void CTspaneContainer::AutoTestBadDefaultLayoutL()
       
   933 	{
       
   934 	TRAPD(err, CEikStatusPane::NewL(*iEikonEnv, &iEikonEnv->RootWin(), R_TSPANE_BAD_LAYOUT_STATUS_PANE));
       
   935 	if (err == KErrNone)
       
   936 		Panic(0);
       
   937 	if (err != KErrNotFound)
       
   938 		User::Leave(err);
       
   939 	}
       
   940 
       
   941 /**
       
   942    @SYMTestCaseID UIF-tspane-AutoTestBadOverrideLayoutL
       
   943   
       
   944    @SYMPREQ
       
   945   
       
   946    @SYMTestCaseDesc Test CEikStatusPane::NewL() when application status
       
   947    pane specifies an undefined layout.
       
   948   
       
   949    @SYMTestPriority High
       
   950   
       
   951    @SYMTestStatus Implemented
       
   952    
       
   953    @SYMTestActions This method invokes CEikStatusPane::NewL() method by
       
   954    passing a application status pane that specifies an undefined layout.
       
   955    The method then tests the error code returned.
       
   956   
       
   957    @SYMTestExpectedResults CEikStatusPane::NewL() should leave with
       
   958    KErrNotFound
       
   959    
       
   960  */
       
   961 void CTspaneContainer::AutoTestBadOverrideLayoutL()
       
   962 	{
       
   963 	TRAPD(err, CEikStatusPane::NewL(*iEikonEnv, &iEikonEnv->RootWin(), R_TSPANE_FLOATING_STATUS_PANE, R_TSPANE_APP_BAD_OVERRIDE_LAYOUT));
       
   964 	if (err == KErrNone)
       
   965 		Panic(0);
       
   966 	if (err != KErrNotFound)
       
   967 		User::Leave(err);
       
   968 	}
       
   969 
       
   970 /**
       
   971    @SYMTestCaseID UIF-tspane-AutoTestBadOverridePaneL
       
   972   
       
   973    @SYMPREQ
       
   974   
       
   975    @SYMTestCaseDesc Test CEikStatusPane::NewL() when the application status
       
   976    pane specifies an undefined override pane.
       
   977   
       
   978    @SYMTestPriority High
       
   979   
       
   980    @SYMTestStatus Implemented
       
   981    
       
   982    @SYMTestActions This method invokes CEikStatusPane::NewL() method by
       
   983    passing a application status pane that specifies an undefined override pane.
       
   984    The method then tests the error code returned.
       
   985   
       
   986    @SYMTestExpectedResults CEikStatusPane::NewL() should leave with
       
   987    KErrNotFound
       
   988    
       
   989  */
       
   990 void CTspaneContainer::AutoTestBadOverridePaneL()
       
   991 	{
       
   992 	TRAPD(err, CEikStatusPane::NewL(*iEikonEnv, &iEikonEnv->RootWin(), R_TSPANE_FLOATING_STATUS_PANE, R_TSPANE_APP_BAD_OVERRIDE_PANE));
       
   993 	if (err == KErrNone)
       
   994 		Panic(0);
       
   995 	if (err != KErrNotFound)
       
   996 		User::Leave(err);
       
   997 	}
       
   998 
       
   999 /**
       
  1000    Auxiliary function for all Test Cases
       
  1001   
       
  1002    This method creates a status pane control and sets it's observer.
       
  1003    
       
  1004  */
       
  1005 void CTspaneContainer::CreateStatusPaneL()
       
  1006 	{
       
  1007 	delete iStatusPane;
       
  1008 	iStatusPane = NULL;
       
  1009 	iStatusPane = CEikStatusPane::NewL(*iEikonEnv, &iEikonEnv->RootWin(), R_TSPANE_STATUS_PANE);
       
  1010 	//vm test(iStatusPane != NULL);
       
  1011 	iStatusPane->SetObserver(this);
       
  1012 	}
       
  1013 
       
  1014 /**
       
  1015    @SYMTestCaseID UIF-tspane-ReportState
       
  1016   
       
  1017    @SYMPREQ
       
  1018   
       
  1019    @SYMTestCaseDesc Test inquiry methods for visibility, fading and dimming
       
  1020   
       
  1021    @SYMTestPriority High
       
  1022   
       
  1023    @SYMTestStatus Implemented
       
  1024    
       
  1025    @SYMTestActions The method tests the following inquiry methods for visibility,
       
  1026    fading and dimming:
       
  1027    (1)TBool CEikStatusPaneBase::IsVisible()\n
       
  1028    (2)TBool CEikStatusPaneBase::IsDimmed()\n
       
  1029    (1)TBool CEikStatusPaneBase::IsFaded()\n
       
  1030    The test checks the visibility,dimming & fading parameters of the Status
       
  1031    pane & reports the state with the help of a information message.
       
  1032   
       
  1033    @SYMTestExpectedResults The test verifies results against expected values.
       
  1034    
       
  1035  */
       
  1036 void CTspaneContainer::ReportState()
       
  1037 	{
       
  1038 	TBuf<64> buf;
       
  1039 	if (!iStatusPane->IsVisible())
       
  1040 		buf += _L("!");
       
  1041 	buf += _L("vis ");
       
  1042 	if (!iStatusPane->IsDimmed())
       
  1043 		buf += _L("!");
       
  1044 	buf += _L("dim ");
       
  1045 	if (!iStatusPane->IsFaded())
       
  1046 		buf += _L("!");
       
  1047 	buf += _L("fade");
       
  1048 	iEikonEnv->InfoMsg(buf);
       
  1049 	}
       
  1050 
       
  1051 /**
       
  1052    @SYMTestCaseID UIF-tspane-SwitchVis
       
  1053   
       
  1054    @SYMPREQ
       
  1055   
       
  1056    @SYMTestCaseDesc Tests CEikStatusPane::MakeVisible(TBool aVisible) API.
       
  1057  
       
  1058    @SYMTestPriority High
       
  1059   
       
  1060    @SYMTestStatus Implemented
       
  1061    
       
  1062    @SYMTestActions The method tests making the controls on the status pane
       
  1063    visible and invisible by calling the method CEikStatusPane::MakeVisible().
       
  1064   
       
  1065    @SYMTestExpectedResults The controls on the status pane should be
       
  1066    invisible / visible when EFalse / ETrue is passed to
       
  1067    CEikStatusPane::MakeVisible() respectively.\n
       
  1068    
       
  1069  */
       
  1070 void CTspaneContainer::SwitchVis()
       
  1071 	{
       
  1072 	iStatusPane->MakeVisible(!iStatusPane->IsVisible());
       
  1073 	}
       
  1074 
       
  1075 /**
       
  1076    @SYMTestCaseID UIF-tspane-SwitchDim
       
  1077   
       
  1078    @SYMPREQ
       
  1079   
       
  1080    @SYMTestCaseDesc Tests CEikStatusPane::SetDimmed(TBool aDimmed) API.
       
  1081   
       
  1082    @SYMTestPriority High
       
  1083  
       
  1084    @SYMTestStatus Implemented
       
  1085    
       
  1086    @SYMTestActions The method tests capability to dim the controls on
       
  1087    status pane by calling method CEikStatusPane::SetDimmed().
       
  1088   
       
  1089    @SYMTestExpectedResults The controls on the status pane should be
       
  1090    dimmed / restored when ETrue / EFalse is passed to
       
  1091    CEikStatusPane::SetDimmed() respectively.\n
       
  1092    
       
  1093  */
       
  1094 void CTspaneContainer::SwitchDim()
       
  1095 	{
       
  1096 	iStatusPane->SetDimmed(!iStatusPane->IsDimmed());
       
  1097 	}
       
  1098 
       
  1099 /**
       
  1100    @SYMTestCaseID UIF-tspane-SwitchFade
       
  1101   
       
  1102    @SYMPREQ
       
  1103   
       
  1104    @SYMTestCaseDesc Tests CEikStatusPane::SetFaded(TBool aFaded) API.
       
  1105   
       
  1106    @SYMTestPriority High
       
  1107   
       
  1108    @SYMTestStatus Implemented
       
  1109    
       
  1110    @SYMTestActions The method tests capability to fade the controls on
       
  1111    status pane by calling method CEikStatusPane::SetFaded().
       
  1112   
       
  1113    @SYMTestExpectedResults The controls on the status pane should be
       
  1114    faded / unfaded when ETrue / EFalse is passed to
       
  1115    CEikStatusPane::SetFaded() respectively.\n
       
  1116   
       
  1117  */
       
  1118 void CTspaneContainer::SwitchFade()
       
  1119 	{
       
  1120 	iStatusPane->SetFaded(!iStatusPane->IsFaded());
       
  1121 	}
       
  1122 
       
  1123 /**
       
  1124   Auxiliary function for TestCaseID tspane-AutoTestL, tspane-AutoTestObserverL,
       
  1125   tspane_AutoTestSwitchL(), tspane_AutoTestCapsL
       
  1126   
       
  1127   This method changes the entire status pane layout to the one specified
       
  1128   by the resource file.
       
  1129   
       
  1130  */
       
  1131 void CTspaneContainer::SwitchLayoutL()
       
  1132 	{
       
  1133 	const TInt layouts[] = 
       
  1134 		{
       
  1135 		R_TSPANE_LAYOUT_COMPLEX, 
       
  1136 		R_TSPANE_LAYOUT_TOP, 
       
  1137 		R_TSPANE_LAYOUT_LEFT, 
       
  1138 		R_TSPANE_LAYOUT_BOTTOM, 
       
  1139 		R_TSPANE_LAYOUT_RIGHT, 
       
  1140 		R_TSPANE_LAYOUT_DIFSIZE,
       
  1141 		0x12345678
       
  1142 		};
       
  1143 
       
  1144 	iLayoutNum = (iLayoutNum+1)%(sizeof(layouts)/sizeof(TInt));
       
  1145 	iStatusPane->SwitchLayoutL(layouts[iLayoutNum]);
       
  1146 	}
       
  1147 	
       
  1148 	
       
  1149 /**
       
  1150    Auxiliary function for TestCaseID tspane-AutoTestSwapL
       
  1151   
       
  1152    This method switches the control present on the sub-pane represented by
       
  1153    uid ETSpanePaneUid1 on the current status pane with the following controls:
       
  1154    (1) Text Button
       
  1155    (2) Label
       
  1156    (3) Global Text Editor
       
  1157    (4) Clock Control
       
  1158    
       
  1159  */
       
  1160 void CTspaneContainer::SwitchControlL(TBool aFocus)
       
  1161 	{
       
  1162 	CCoeControl* newControl=0;
       
  1163 	CCoeControl* container = iStatusPane->ContainerControlL(TUid::Uid(ETSpanePaneUid1));
       
  1164 	
       
  1165 	iControlNum = (iControlNum+1)%4;
       
  1166 	switch(iControlNum)
       
  1167 		{
       
  1168 		case 0:
       
  1169 			newControl = new(ELeave) CEikTextButton;
       
  1170 			CleanupStack::PushL(newControl);
       
  1171 			newControl->SetContainerWindowL(*container);
       
  1172 			((CEikTextButton*)newControl)->SetTextL(_L("B"));
       
  1173 			break;
       
  1174 		case 1:
       
  1175 			newControl = new(ELeave) CEikLabel;
       
  1176 			CleanupStack::PushL(newControl);
       
  1177 			newControl->SetContainerWindowL(*container);
       
  1178 			((CEikLabel*)newControl)->SetEmphasis(CEikLabel::EPartialEmphasis);
       
  1179 			((CEikLabel*)newControl)->SetTextL(_L("Label which is long"));
       
  1180 			break;
       
  1181 		case 2:
       
  1182 			{
       
  1183 			newControl = new(ELeave) CControlStackedGlobalTextEditor(TGulBorder::ESingleGray);
       
  1184 			CleanupStack::PushL(newControl);
       
  1185 			newControl->SetContainerWindowL(*container);
       
  1186 			TBuf<1> temp = _L("E");
       
  1187 			((CEikGlobalTextEditor*)newControl)->ConstructL(container, 1, 64, CEikEdwin::ENoHorizScrolling, EGulFontControlAll, EGulAllFonts);
       
  1188 			((CEikGlobalTextEditor*)newControl)->SetTextL(&temp);
       
  1189 			if (aFocus)
       
  1190 				{
       
  1191 				iEikonEnv->EikAppUi()->AddToStackL(newControl);
       
  1192 				newControl->SetFocus(ETrue);
       
  1193 				}
       
  1194 			break;
       
  1195 			}
       
  1196 		default:
       
  1197 			newControl = new(ELeave) CEikClock;
       
  1198 			CleanupStack::PushL(newControl);
       
  1199 			newControl->SetContainerWindowL(*container);
       
  1200 			TResourceReader res;
       
  1201 			iEikonEnv->CreateResourceReaderLC(res, R_TSPANE_CLOCK) ;
       
  1202 			((CEikClock*)newControl)->ConstructFromResourceL(res);
       
  1203 			CleanupStack::PopAndDestroy();	// res
       
  1204 			break;
       
  1205 		}
       
  1206 
       
  1207 	TRect rect = iStatusPane->PaneRectL(TUid::Uid(ETSpanePaneUid1));
       
  1208 	newControl->SetRect(rect);
       
  1209 
       
  1210 	CCoeControl* oldControl = iStatusPane->SwapControlL(TUid::Uid(ETSpanePaneUid1), newControl);
       
  1211 	CleanupStack::Pop();	// newControl transferred to status pane
       
  1212 	if (aFocus && oldControl->IsFocused())
       
  1213 		{
       
  1214 		oldControl->SetFocus(EFalse);
       
  1215 		iEikonEnv->EikAppUi()->RemoveFromStack(oldControl);
       
  1216 		}
       
  1217 	delete oldControl;
       
  1218 
       
  1219 	newControl->ActivateL();
       
  1220 	newControl->DrawNow();
       
  1221 	}
       
  1222 
       
  1223 /**
       
  1224    @SYMTestCaseID UIF-tspane-BoundingRectOfRegionL
       
  1225   
       
  1226    @SYMPREQ
       
  1227   
       
  1228    @SYMTestCaseDesc Tests CEikStatusPaneBase::GetShapeL() API
       
  1229   
       
  1230    @SYMTestPriority High
       
  1231   
       
  1232    @SYMTestStatus Implemented
       
  1233    
       
  1234    @SYMTestActions The method tests whether GetShapeL() method selects the region
       
  1235    of screen containing the status pane. The method then reads the bounding
       
  1236    rectangle for the region to verify.
       
  1237   
       
  1238    @SYMTestExpectedResults The bounding rectangle co-ordinates of status pane
       
  1239    should be displayed.
       
  1240    
       
  1241  */
       
  1242 void CTspaneContainer::BoundingRectOfRegionL()
       
  1243 	{
       
  1244 	TRect boundingRect(0,0,0,0);
       
  1245 	if(iStatusPane)
       
  1246 		{
       
  1247 		TRegionFix<40> region;	
       
  1248 		iStatusPane->GetShapeL(region,ETrue,ETrue);
       
  1249 		boundingRect = region.BoundingRect();
       
  1250 		}
       
  1251 	TBuf<80> messageBuf;
       
  1252 	_LIT(KBoundingInfoBuf,"Status pane bounding rectangle = %d,%d,%d,%d");
       
  1253 	messageBuf.AppendFormat(KBoundingInfoBuf,boundingRect.iTl.iX,boundingRect.iTl.iY,boundingRect.iBr.iX,boundingRect.iBr.iY);
       
  1254 	iEikonEnv->InfoMsg(messageBuf);
       
  1255 	}
       
  1256 
       
  1257 //
       
  1258 // CFloatingSpaneKiller
       
  1259 //
       
  1260 CFloatingSpaneKiller::~CFloatingSpaneKiller()
       
  1261 /**
       
  1262    Destructor
       
  1263  */
       
  1264 	{
       
  1265 	delete iSpane;
       
  1266 	if (iWg)
       
  1267 		{
       
  1268 		iWg->Close();
       
  1269 		}
       
  1270 	delete iWg;
       
  1271 	}
       
  1272 	
       
  1273 /**
       
  1274    Auxiliary function for TestCaseID tspane-CreateNewWindowGroupL
       
  1275   
       
  1276    This method allocates and constructs a new text button control.
       
  1277   
       
  1278  */	
       
  1279 CFloatingSpaneKiller* CFloatingSpaneKiller::NewL(CEikStatusPane* aSpane, RWindowGroup* aWg)
       
  1280 	{
       
  1281 	CFloatingSpaneKiller* self = new(ELeave) CFloatingSpaneKiller(aSpane, aWg);
       
  1282 	CleanupStack::PushL(self);
       
  1283 	self->ConstructL();
       
  1284 	CleanupStack::Pop();
       
  1285 	return self;
       
  1286 	}
       
  1287 
       
  1288 /**
       
  1289    @SYMTestCaseID UIF-tspane-HandleControlEventL
       
  1290   
       
  1291    @SYMPREQ
       
  1292   
       
  1293    @SYMTestCaseDesc Test Killing the floating Status pane.
       
  1294   
       
  1295    @SYMTestPriority High
       
  1296   
       
  1297    @SYMTestStatus Implemented
       
  1298    
       
  1299    @SYMTestActions The method tests deletion of the floating status pane.
       
  1300   
       
  1301    @SYMTestExpectedResults The method should successfully delete the floating
       
  1302    status pane.
       
  1303    
       
  1304  */
       
  1305 void CFloatingSpaneKiller::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
       
  1306 	{
       
  1307 	if (aEventType == EEventStateChanged)
       
  1308 		{
       
  1309 		RWindowGroup* wg = iWg;
       
  1310 		iWg = NULL;
       
  1311 		if (wg)
       
  1312 			{
       
  1313 			wg->Close();
       
  1314 			}
       
  1315 		CEikStatusPane* spane = iSpane;
       
  1316 		iSpane = NULL;
       
  1317 		delete spane;
       
  1318 		delete wg;
       
  1319 		}
       
  1320 	}
       
  1321 
       
  1322 CFloatingSpaneKiller::CFloatingSpaneKiller(CEikStatusPane* aSpane, RWindowGroup* aWg)
       
  1323 : iSpane(aSpane), iWg(aWg)
       
  1324 /**
       
  1325    Constructor
       
  1326  */
       
  1327 	{
       
  1328 	}
       
  1329 
       
  1330 /**
       
  1331    Auxiliary function for TestCaseID tspane-CreateNewWindowGroupL
       
  1332   
       
  1333    This method completes construction of text button control and swaps the
       
  1334    control with sub-pane control on the floating status pane.
       
  1335   
       
  1336  */
       
  1337 void CFloatingSpaneKiller::ConstructL()
       
  1338 	{
       
  1339 	CCoeControl* container = iSpane->ContainerControlL(TUid::Uid(ETSpanePaneUid2));
       
  1340 	
       
  1341 	SetContainerWindowL(*container);
       
  1342 	SetTextL(_L("Kill"));
       
  1343 
       
  1344 	SetObserver(this);
       
  1345 
       
  1346 	SetRect(container->Rect());		// the fast way to set a controls rect when swapping into status pane
       
  1347 
       
  1348 	CCoeControl* oldControl = iSpane->SwapControlL(TUid::Uid(ETSpanePaneUid2), this);
       
  1349 	delete oldControl;
       
  1350 
       
  1351 	ActivateL();
       
  1352 	DrawNow();
       
  1353 	}
       
  1354 
       
  1355 
       
  1356 //
       
  1357 // CTspaneAppUi
       
  1358 //
       
  1359 CTspaneAppUi::CTspaneAppUi(CTmsTestStep*		aStep) :
       
  1360 	CTestAppUi(aStep,
       
  1361 		KTSpaneResourceFilePath, 
       
  1362 		R_TSPANE_HOTKEYS, 
       
  1363 		R_TSPANE_MENUBAR)
       
  1364 /**
       
  1365    Constructor
       
  1366  */
       
  1367 	{
       
  1368 	}
       
  1369 
       
  1370 
       
  1371 
       
  1372 CTspaneAppUi::~CTspaneAppUi()
       
  1373 /**
       
  1374    Destructor
       
  1375  */
       
  1376 	{
       
  1377 	RemoveFromStack(iAppView);
       
  1378 	delete iAppView;
       
  1379 
       
  1380 	}
       
  1381 
       
  1382 /**
       
  1383    Auxiliary function for all Test Cases
       
  1384   
       
  1385    This method prepares the test step's user interface and prepares it
       
  1386    to start the tests.
       
  1387    
       
  1388  */
       
  1389 void CTspaneAppUi::ConstructL()
       
  1390     {
       
  1391    	CTestAppUi::ConstructL();
       
  1392 	
       
  1393 	iAppView=new(ELeave) CTspaneContainer;
       
  1394     iAppView->ConstructL(ClientRect());
       
  1395 	AddToStackL(iAppView);
       
  1396 
       
  1397 	AutoTestManager().StartAutoTest();
       
  1398 	}
       
  1399 
       
  1400 /**
       
  1401    Auxiliary function for all Test Cases
       
  1402   
       
  1403    The method is an override from CTestAppUi. The method initiates all tests
       
  1404    by calling CTspaneAppUi::HandleCommandL().
       
  1405    
       
  1406  */
       
  1407 void CTspaneAppUi::RunTestStepL(TInt aNumStep)
       
  1408 	{
       
  1409 #ifdef FORCE_AUTO
       
  1410 	User::After(TTimeIntervalMicroSeconds32(1000000));
       
  1411 #endif	
       
  1412 	switch(aNumStep)
       
  1413 		{
       
  1414 		case 1:
       
  1415 		SetTestStepID(_L("UIF-tspane-AutoTestL"));
       
  1416 		INFO_PRINTF1(_L("Normal"));
       
  1417 		HandleCommandL(ETspaneCmdAutoNormal);
       
  1418 		RecordTestResultL();
       
  1419 		break;
       
  1420 		case 2:
       
  1421 		SetTestStepID(_L("UIF-tspane-AutoTestL"));
       
  1422 		INFO_PRINTF1(_L("Oom"));
       
  1423 		HandleCommandL(ETspaneCmdAutoOom);
       
  1424 		RecordTestResultL();
       
  1425 		break;
       
  1426 		case 3:
       
  1427 		SetTestStepID(_L("UIF-tspane-BoundingRectOfRegionL"));
       
  1428 		INFO_PRINTF1(_L("Display status pane bound rectangle"));
       
  1429 		HandleCommandL(ETspaneCmdBoundingRegion);
       
  1430 		RecordTestResultL();
       
  1431 		break;
       
  1432 		case 4:
       
  1433 		SetTestStepID(_L("UIF-tspane-ReportState"));
       
  1434 		INFO_PRINTF1(_L("Manual state report"));
       
  1435 		HandleCommandL(ETspaneCmdManualState);
       
  1436 		RecordTestResultL();
       
  1437 		break;
       
  1438 		case 5:
       
  1439 		SetTestStepID(_L("UIF-tspane-CreateNewWindowGroupL"));
       
  1440 		INFO_PRINTF1(_L("Create new window group"));
       
  1441 		HandleCommandL(ETspaneCmdManualWg);
       
  1442 		RecordTestResultL();
       
  1443 		break;
       
  1444 		case 6:
       
  1445 		if(iFloatingPanel)
       
  1446 			{	
       
  1447 			SetTestStepID(_L("UIF-tspane-HandleControlEventL"));
       
  1448 			INFO_PRINTF1(_L("Kill Floating panel"));
       
  1449 			iFloatingPanel->HandleControlEventL(NULL, CFloatingSpaneKiller::EEventStateChanged);
       
  1450 			iFloatingPanel = NULL;
       
  1451 			RecordTestResultL();
       
  1452 			}
       
  1453 		break;
       
  1454 		case 7:
       
  1455 		SetTestStepID(_L("UIF-tspane-SwitchVis"));
       
  1456 		// follow on...
       
  1457 		case 8:
       
  1458 		INFO_PRINTF1(_L("Switch Vis"));
       
  1459 		HandleCommandL(ETspaneCmdManualVis);
       
  1460 		if( aNumStep == 8 )
       
  1461 			{
       
  1462 			RecordTestResultL();
       
  1463 			}
       
  1464 		break;
       
  1465 		case 9:
       
  1466 		SetTestStepID(_L("UIF-tspane-SwitchDim"));
       
  1467 		// follow on...
       
  1468 		case 10:
       
  1469 		INFO_PRINTF1(_L("Switch Dim"));
       
  1470 		HandleCommandL(ETspaneCmdManualDim);
       
  1471 		if( aNumStep == 10 )
       
  1472 			{
       
  1473 			RecordTestResultL();
       
  1474 			}
       
  1475 		break;
       
  1476 		case 11:
       
  1477 		SetTestStepID(_L("UIF-tspane-AutoTestSwapL"));
       
  1478 		// follow on...
       
  1479 		case 12: case 13: case 14:
       
  1480 		INFO_PRINTF1(_L("Switch Control"));
       
  1481 		HandleCommandL(ETspaneCmdManualControl);
       
  1482 		if( aNumStep == 14 )
       
  1483 			{
       
  1484 			RecordTestResultL();
       
  1485 			}
       
  1486 		break;
       
  1487 		case 15:
       
  1488 		SetTestStepID(_L("UIF-tspane-AutoTestSwitchL"));
       
  1489 		// follow on...
       
  1490 		case 16: case 17: case 18: case 19:
       
  1491 		INFO_PRINTF1(_L("Switch Layout"));
       
  1492 		HandleCommandL(ETspaneCmdManualLayout);
       
  1493 		if( aNumStep == 19 )
       
  1494 			{
       
  1495 			RecordTestResultL();
       
  1496 			CloseTMSGraphicsStep();
       
  1497 			}
       
  1498 		break;
       
  1499 		case 20:
       
  1500 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
  1501 			break;
       
  1502 		}
       
  1503 	}
       
  1504 
       
  1505 /**
       
  1506    Auxiliary function for all Test Cases
       
  1507   
       
  1508    This method is called by CTspaneAppUi::RunTestStepL() to initiate the tests.
       
  1509    
       
  1510  */
       
  1511 void CTspaneAppUi::HandleCommandL(TInt aCommand)
       
  1512 	{
       
  1513 	switch (aCommand)
       
  1514 		{
       
  1515 		case EEikCmdExit:
       
  1516 			Exit();
       
  1517 			break;
       
  1518 		case ETspaneCmdAutoAll:
       
  1519 			iAppView->AutoTestL(CTspaneContainer::ETotal);
       
  1520 			iEikonEnv->InfoMsg(_L("Complete"));
       
  1521 			break;
       
  1522 		case ETspaneCmdAutoNormal:
       
  1523 			iAppView->AutoTestL(CTspaneContainer::EAllNormal);
       
  1524 			iEikonEnv->InfoMsg(_L("Complete"));
       
  1525 			break;
       
  1526 		case ETspaneCmdAutoOom:
       
  1527 			iAppView->AutoTestL(CTspaneContainer::EOOM);
       
  1528 			iEikonEnv->InfoMsg(_L("Complete"));
       
  1529 			break;
       
  1530 		case ETspaneCmdManualVis:
       
  1531 			iAppView->SwitchVis();
       
  1532 			break;
       
  1533 		case ETspaneCmdManualDim:
       
  1534 			iAppView->SwitchDim();
       
  1535 			break;
       
  1536 		case ETspaneCmdManualFade:
       
  1537 			iAppView->SwitchFade();
       
  1538 			break;
       
  1539 		case ETspaneCmdManualState:
       
  1540 			iAppView->ReportState();
       
  1541 			break;
       
  1542 		case ETspaneCmdManualLayout:
       
  1543 			iAppView->SwitchLayoutL();
       
  1544 			break;
       
  1545 		case ETspaneCmdManualControl:
       
  1546 			iAppView->SwitchControlL();
       
  1547 			break;
       
  1548 		case ETspaneCmdManualWg:
       
  1549 			CreateNewWindowGroupL();
       
  1550 			break;
       
  1551 		case ETspaneCmdBoundingRegion:
       
  1552 			iAppView->BoundingRectOfRegionL();
       
  1553 			break;
       
  1554 		default:
       
  1555 			Panic(0);
       
  1556 			break;
       
  1557 		}
       
  1558 	}
       
  1559 
       
  1560 /**
       
  1561    @SYMTestCaseID UIF-tspane-CreateNewWindowGroupL
       
  1562   
       
  1563    @SYMPREQ
       
  1564   
       
  1565    @SYMTestCaseDesc Test adding a floating status pane to a new window group.
       
  1566   
       
  1567    @SYMTestPriority High
       
  1568   
       
  1569    @SYMTestStatus Implemented
       
  1570    
       
  1571    @SYMTestActions The test method creates a new window group and adds a floating
       
  1572    status pane with two sub-panes that are strechable. Now a Text Button
       
  1573    control is created and swaped with second sub-pane label control.
       
  1574   
       
  1575    @SYMTestExpectedResults Floating status pane should display only sub-pane one
       
  1576    since it is strechable. Once the Text button control is created and swapped
       
  1577    with control on sub-pane two sub-pane one should reduce its size to also
       
  1578    accomodate the text button.
       
  1579    
       
  1580  */
       
  1581 void CTspaneAppUi::CreateNewWindowGroupL()
       
  1582 	{
       
  1583 	RWindowGroup* wg=new(ELeave) RWindowGroup(iEikonEnv->WsSession());
       
  1584 	User::LeaveIfError(wg->Construct((TUint32)this));
       
  1585 	wg->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
       
  1586 	wg->EnableReceiptOfFocus(EFalse); // disable key events
       
  1587 	CleanupStack::PushL(wg);
       
  1588 	CEikStatusPane* statusPane = CEikStatusPane::NewL(*iEikonEnv, wg, R_TSPANE_FLOATING_STATUS_PANE);
       
  1589 	CleanupStack::PushL(statusPane);
       
  1590 	iFloatingPanel = CFloatingSpaneKiller::NewL(statusPane, wg);	// transfers ownership to a killer button
       
  1591 	CleanupStack::Pop(2);	// statusPane and wg
       
  1592 	// We can loose track of the status pane, window group and killer, because they
       
  1593 	// are in a mutual suicide pact!
       
  1594 	}
       
  1595 
       
  1596 //--------
       
  1597 
       
  1598 CTestSpaneStep::CTestSpaneStep()
       
  1599 /**
       
  1600    Constructor
       
  1601  */
       
  1602 	{
       
  1603 	SetTestStepName(KTestSpaneStep);
       
  1604 	}
       
  1605 
       
  1606 CTestSpaneStep::~CTestSpaneStep()
       
  1607 /**
       
  1608    Destructor
       
  1609  */
       
  1610 	{
       
  1611 	}
       
  1612 
       
  1613 /**
       
  1614    Auxiliary function for all Test Cases
       
  1615   
       
  1616    The method creates & sets the application's user interface object.
       
  1617    
       
  1618  */
       
  1619 void CTestSpaneStep::ConstructAppL(CEikonEnv* aCoe)
       
  1620     { // runs inside a TRAP harness
       
  1621 	aCoe->ConstructL();
       
  1622 	CTspaneAppUi* appUi= new (ELeave) CTspaneAppUi(this);
       
  1623     aCoe->SetAppUi(appUi);
       
  1624     appUi->ConstructL();
       
  1625     }
       
  1626 
       
  1627 /**
       
  1628    Auxiliary function for all Test Cases
       
  1629   
       
  1630    The method creates & sets the test step's user interface object and
       
  1631    launches the test step.
       
  1632    
       
  1633  */
       
  1634 TVerdict CTestSpaneStep::doTestStepL() // main function called by E32
       
  1635 	{
       
  1636 	PreallocateHALBuffer();
       
  1637 	__UHEAP_MARK;
       
  1638 
       
  1639 	CEikonEnv* coe=new CEikonEnv;
       
  1640 	TRAPD(err,ConstructAppL(coe));
       
  1641 
       
  1642 	if (!err)
       
  1643 		coe->ExecuteD();
       
  1644 	
       
  1645 	REComSession::FinalClose();	
       
  1646 	__UHEAP_MARKEND;
       
  1647 
       
  1648 	return TestStepResult();
       
  1649 	}
       
  1650 	
       
  1651