windowing/windowserver/test/tauto/tdevicerotation.cpp
changeset 188 1b081cb0800b
equal deleted inserted replaced
187:9f66f99ee56f 188:1b081cb0800b
       
     1 // Copyright (c) 2010 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 // Set of tests for Tracing Device Rotation. These tests generally test
       
    15 // RWsSession::IndicateAppOrientation(...).
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Nokia test code
       
    22 */
       
    23 
       
    24 #include "tdevicerotation.h"
       
    25 #include "themeserverpropertydefine.h"
       
    26 #include "..\..\nga\server\renderorientationtracker.h" 
       
    27 #include <hal.h>
       
    28 #include <hal_data.h>
       
    29 #include <w32std.h>
       
    30 
       
    31 const TInt KPublishTimeout = 1000000; // 1 second in microseconds
       
    32 
       
    33 //
       
    34 // CTDeviceRotation Definition
       
    35 //
       
    36 
       
    37 CTDeviceRotation::CTDeviceRotation(CTestStep* aStep):
       
    38 	CTGraphicsBase(aStep), iWaitForPublishOnNextTest(ETrue)
       
    39 	{
       
    40 	}
       
    41 
       
    42 CTDeviceRotation::~CTDeviceRotation()
       
    43 	{
       
    44     iPublishTimer.Close();
       
    45     
       
    46     iChildWindow.Close();
       
    47     iWindowGroup.Close();
       
    48     iWs.Close();    
       
    49     
       
    50     iSecondChildWindow.Close();
       
    51     iSecondWindowGroup.Close();    
       
    52     iSecondWs.Close();
       
    53    
       
    54     /* This Process called with the argument KThemeServerPropertyDefineCmdDelete, deletes 
       
    55        the theme server RProperty. This is because an RProperty can only be defined and 
       
    56        deleted from within a process with the same UID3 as the RProperty catogory you are 
       
    57        trying to define/delete.*/
       
    58     RProcess themeServerPropertyDefine;
       
    59     TInt err = themeServerPropertyDefine.Create(KThemeServerPropertyDefine,
       
    60             KThemeServerPropertyDefineCmdDelete);
       
    61     if (KErrNone != err)
       
    62         {
       
    63         _LIT(KLog, "themeServerPropertyDefine.Create() failed with error: %d");
       
    64         INFO_PRINTF2(KLog, err);
       
    65         TEST(EFalse);        
       
    66         }
       
    67     //wait for themeServerPropertyDefine process to terminate
       
    68     TRequestStatus themeServerPropertyDefineLogonStatus;
       
    69     themeServerPropertyDefine.Logon(themeServerPropertyDefineLogonStatus);
       
    70     themeServerPropertyDefine.Resume();
       
    71     User::WaitForRequest(themeServerPropertyDefineLogonStatus);
       
    72     if (themeServerPropertyDefineLogonStatus != KErrNone)
       
    73         {
       
    74         _LIT(KLog, "themeServerPropertyDefine.Logon() failed with error: %d");
       
    75         INFO_PRINTF2(KLog, themeServerPropertyDefineLogonStatus);
       
    76         TEST(EFalse);        
       
    77         }
       
    78     themeServerPropertyDefine.Close();
       
    79     
       
    80     iRenderOrientationProperty.Delete(KRenderOrientationCategory, KRenderOrientationKey);
       
    81     iRenderOrientationProperty.Close();
       
    82     iThemeServerOrientationProperty.Close();
       
    83     }
       
    84 
       
    85 void CTDeviceRotation::ConstructL()
       
    86     {
       
    87     TInt err = iWs.Connect();
       
    88     TESTL(err == KErrNone);
       
    89             
       
    90     err = iSecondWs.Connect();
       
    91     TESTL(KErrNone == err);
       
    92     
       
    93     iWs.SetAutoFlush(ETrue);
       
    94     iSecondWs.SetAutoFlush(ETrue);
       
    95     
       
    96     iWindowGroup = RWindowGroup(iWs);
       
    97     err = iWindowGroup.Construct(iWs.Handle());
       
    98     TESTL(KErrNone == err);
       
    99     iWindowGroup.SetOrdinalPosition(0,1);
       
   100     
       
   101     iChildWindow = RWindow(iWs);
       
   102     err = iChildWindow.Construct(iWindowGroup, reinterpret_cast<TUint32>(&iChildWindow));
       
   103     TESTL(KErrNone == err);    
       
   104 
       
   105     iSecondWindowGroup = RWindowGroup(iSecondWs);
       
   106     err = iSecondWindowGroup.Construct(iSecondWs.Handle());
       
   107     TESTL(KErrNone == err);
       
   108     iSecondWindowGroup.SetOrdinalPosition(1,1);
       
   109     
       
   110     iSecondChildWindow = RWindow(iSecondWs);
       
   111     err = iSecondChildWindow.Construct(iSecondWindowGroup, reinterpret_cast<TUint32>(&iSecondChildWindow));
       
   112     TESTL(KErrNone == err);    
       
   113     
       
   114     err= iRenderOrientationProperty.Attach(KRenderOrientationCategory, KRenderOrientationKey, EOwnerThread);
       
   115     TESTL(KErrNone == err);
       
   116     iRenderOrientationProperty.Subscribe(iRenderOrientationStatus);
       
   117     
       
   118     /* This Process called with the argument KThemeServerPropertyDefineCmdDefine, defines
       
   119        the theme server catagory to be the same as the theme servers process ID. This is 
       
   120        because an RProperty can only be defined and deleted from within a process with the 
       
   121        same UID3 as the RProperty catogory you are trying to define/delete.*/
       
   122     RProcess themeServerPropertyDefine;
       
   123     err = themeServerPropertyDefine.Create(KThemeServerPropertyDefine,KThemeServerPropertyDefineCmdDefine);
       
   124     TESTL(KErrNone == err);
       
   125     TRequestStatus themeServerPropertyDefineLogonStatus;
       
   126     themeServerPropertyDefine.Logon(themeServerPropertyDefineLogonStatus);
       
   127     themeServerPropertyDefine.Resume();
       
   128     User::WaitForRequest(themeServerPropertyDefineLogonStatus);
       
   129     TESTL(KErrNone == themeServerPropertyDefineLogonStatus.Int()); 
       
   130     themeServerPropertyDefine.Close(); 
       
   131 
       
   132     err = iThemeServerOrientationProperty.Attach(KThemeOrientationCategory, KThemeOrientationKey, EOwnerThread);
       
   133     TESTL(KErrNone == err);
       
   134     
       
   135     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   136     
       
   137     iPublishTimer.CreateLocal();
       
   138     }
       
   139 
       
   140 void CTDeviceRotation::SimulateThemeServerOrientation(TRenderOrientation aOrientation)
       
   141     {
       
   142     _LIT(KFunctionInfo, "SimulateThemeServerOrientation(aOrientation = %d)");
       
   143     INFO_PRINTF2(KFunctionInfo, aOrientation);
       
   144     TInt err = iThemeServerOrientationProperty.Set(aOrientation);
       
   145     if (KErrNone != err)
       
   146         {
       
   147         _LIT(KLog,"iThemeServerOrientationProperty.Set(%d) failed with err %d");
       
   148         INFO_PRINTF3(KLog,aOrientation,err);
       
   149         TEST(EFalse);
       
   150         }
       
   151     switch(aOrientation)
       
   152         {
       
   153         case EDisplayOrientationNormal:
       
   154         case EDisplayOrientation90CW:
       
   155         case EDisplayOrientation180:
       
   156         case EDisplayOrientation270CW:
       
   157             {
       
   158             if(KErrNone == err)
       
   159                 {
       
   160                 iCurrentThemeServerOrientation = aOrientation;            
       
   161                 }                
       
   162             break;
       
   163             }
       
   164         default:
       
   165             _LIT(KLog, "This orientation is not supported by theme server.");
       
   166         	INFO_PRINTF1(KLog);
       
   167         }
       
   168     }
       
   169 
       
   170 void CTDeviceRotation::IsOrientationCorrect(TRenderOrientation aExpectedOrientation)
       
   171     {
       
   172     // timer to timeout when nothing is published
       
   173     iPublishTimer.After(iPublishTimerStatus, KPublishTimeout);
       
   174     
       
   175     // wait for either
       
   176     User::WaitForRequest(iRenderOrientationStatus, iPublishTimerStatus);
       
   177     
       
   178     // check that the orientation was published or not, as expected
       
   179     if(iWaitForPublishOnNextTest)
       
   180         {
       
   181         // Check that it really has published
       
   182         if(iRenderOrientationStatus.Int()==KErrNone && iPublishTimerStatus.Int()==KRequestPending)
       
   183             {
       
   184             iPublishTimer.Cancel();
       
   185             // re-subscribe
       
   186             iRenderOrientationProperty.Subscribe(iRenderOrientationStatus);            
       
   187             }
       
   188         else
       
   189             {
       
   190             _LIT(KLog,"Timed out (%d) while waiting for render orientation %d to be published");
       
   191             INFO_PRINTF3(KLog,iRenderOrientationStatus.Int(),aExpectedOrientation);        
       
   192             TEST(EFalse);
       
   193             }
       
   194         }
       
   195     else
       
   196         {
       
   197         // Check that it really hasn't published    
       
   198         if(iRenderOrientationStatus.Int()!=KRequestPending)
       
   199             {
       
   200             _LIT(KLog,"Render Orientation %d was published (%d) when not expected (timeout = %d)");
       
   201             INFO_PRINTF4(KLog,aExpectedOrientation, iRenderOrientationStatus.Int(),iPublishTimerStatus.Int());
       
   202             iPublishTimer.Cancel();
       
   203             TEST(EFalse);
       
   204             }
       
   205         else if(iPublishTimerStatus.Int()!=KErrNone)
       
   206             {
       
   207             _LIT(KLog,"Timeout failure %d");
       
   208             INFO_PRINTF2(KLog,iPublishTimerStatus.Int());           
       
   209             TEST(EFalse);        
       
   210             }
       
   211         
       
   212         // reset to default
       
   213         iWaitForPublishOnNextTest = ETrue;
       
   214         }
       
   215     
       
   216     // Retrieve the value.
       
   217     TInt orientation;
       
   218     TInt err = iRenderOrientationProperty.Get(orientation);
       
   219     if(KErrNone != err)
       
   220            {
       
   221            _LIT(KLog,"iThemeServerOrientationProperty.Get(...) failed with err %d");
       
   222            INFO_PRINTF2(KLog,err);
       
   223            TEST(EFalse);
       
   224            }
       
   225     else if(aExpectedOrientation == EDisplayOrientationAuto)
       
   226         {
       
   227         TEST(orientation == iCurrentThemeServerOrientation);
       
   228         CheckHalSetting(iCurrentThemeServerOrientation);
       
   229         }
       
   230     else
       
   231         {
       
   232         TEST(orientation == aExpectedOrientation);
       
   233         CheckHalSetting(static_cast<TRenderOrientation>(orientation));
       
   234         }
       
   235     }
       
   236 
       
   237 void CTDeviceRotation::CheckHalSetting(TRenderOrientation aOrientation)
       
   238     {
       
   239     HALData::TDigitiserOrientation halOrientationExp = static_cast<HALData::TDigitiserOrientation>
       
   240             (HALData::EDigitiserOrientation_000 + (aOrientation - EDisplayOrientationNormal));
       
   241     TInt halOrientation;
       
   242     TInt err = HAL::Get(iWs.GetFocusScreen(), HALData::EDigitiserOrientation, halOrientation);
       
   243     if (err != KErrNotSupported)
       
   244         {
       
   245         if (err != KErrNone)
       
   246             {
       
   247             _LIT(KLog,"Getting HAL orientation attribute returned error %d when no error expected");
       
   248             INFO_PRINTF2(KLog,err);
       
   249             }
       
   250         TEST(err==KErrNone);
       
   251         if (halOrientationExp != halOrientation)
       
   252             {
       
   253             _LIT(KLog,"HAL orientation is %d when expected to be %d");
       
   254             INFO_PRINTF3(KLog, halOrientation, halOrientationExp);
       
   255             }
       
   256         TEST(halOrientationExp==halOrientation);
       
   257         }
       
   258     else
       
   259         {
       
   260         _LIT(KLog,"HAL-Orientation HALData::EDigitiserOrientation isn't supported by Driver");
       
   261         INFO_PRINTF1(KLog);
       
   262         }
       
   263     }
       
   264 
       
   265 void CTDeviceRotation::TestIndicateAppOrientation(TRenderOrientation aOrientation)
       
   266 	{
       
   267     _LIT(KTestInfo, "TestIndicateAppOrientation(aOrientation = %d)");
       
   268     INFO_PRINTF2(KTestInfo, aOrientation);
       
   269 	if (EDisplayOrientationIgnore == aOrientation)
       
   270 	    {
       
   271         TEST(EFalse);
       
   272         _LIT(KLog, "TestIndicateAppOrientation(TRenderOrientation aOrientation) cannot be used with EDisplayOrientationIgnore");
       
   273         INFO_PRINTF1(KLog);
       
   274 	    }
       
   275 	iWs.IndicateAppOrientation(aOrientation);
       
   276 	iWindowGroup.SetOrdinalPosition(0);
       
   277 	IsOrientationCorrect(aOrientation);
       
   278 	}
       
   279 
       
   280 void CTDeviceRotation::TestIndicateAppOrientation(TRenderOrientation aOrientation, TRenderOrientation aSecondOrientation)
       
   281     {
       
   282     _LIT(KTestInfo, "TestIndicateAppOrientation(aOrientation = %d, aSecondOrientation = %d)");
       
   283     INFO_PRINTF3(KTestInfo, aOrientation, aSecondOrientation);
       
   284     //Inform window serve the orientation status
       
   285     iWs.IndicateAppOrientation(aOrientation);
       
   286     iSecondWs.IndicateAppOrientation(aSecondOrientation);
       
   287     
       
   288     iWindowGroup.SetOrdinalPosition(0,1);
       
   289     iSecondWindowGroup.SetOrdinalPosition(1,1);
       
   290 
       
   291     if(aOrientation != EDisplayOrientationIgnore)
       
   292         {
       
   293         IsOrientationCorrect(aOrientation);
       
   294         }
       
   295     else
       
   296         {
       
   297         IsOrientationCorrect(aSecondOrientation);
       
   298         }
       
   299     }
       
   300 
       
   301 void CTDeviceRotation::TestAppOrientationOnSwap(TRenderOrientation aOrientation, TRenderOrientation aSecondOrientation)
       
   302     {    
       
   303     _LIT(KTestInfo, "TestAppOrientationOnSwap(aOrientation = %d, aSecondOrientation = %d)");
       
   304     INFO_PRINTF3(KTestInfo, aOrientation, aSecondOrientation);
       
   305     
       
   306     iWs.IndicateAppOrientation(aOrientation);
       
   307     iSecondWs.IndicateAppOrientation(aSecondOrientation);
       
   308     
       
   309     iSecondWindowGroup.SetOrdinalPosition(0);
       
   310     if (aSecondOrientation != EDisplayOrientationIgnore)
       
   311         {
       
   312         IsOrientationCorrect(aSecondOrientation);
       
   313         }
       
   314     else
       
   315         {
       
   316         IsOrientationCorrect(aOrientation);
       
   317         }
       
   318     }
       
   319 
       
   320 void CTDeviceRotation::RunTestCaseL(TInt aCurTestCase)
       
   321 	{
       
   322     _LIT(KNewLine, "\n");
       
   323     (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KUnknownSYMTestCaseIDName);
       
   324 	switch(aCurTestCase)
       
   325 		{
       
   326 	    case 1:
       
   327             _LIT(KTestStepID1,"Test Initial Orientations");
       
   328             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID1);
       
   329             INFO_PRINTF1(KNewLine);
       
   330             INFO_PRINTF1(KTestStepID1);
       
   331             TestInitialOrientation();
       
   332             break;
       
   333 		case 2:
       
   334     	    _LIT(KTestStepID2,"Test Fixed Orientations");
       
   335             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID2);
       
   336             INFO_PRINTF1(KNewLine);
       
   337             INFO_PRINTF1(KTestStepID2);
       
   338             TestFixedOrientations();
       
   339 			break;
       
   340 		case 3:
       
   341     	    _LIT(KTestStepID3,"Test Auto Orientation");
       
   342 		    (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID3);
       
   343 		    INFO_PRINTF1(KNewLine);
       
   344 		    INFO_PRINTF1(KTestStepID3);
       
   345 		    TestAutoOrientation();
       
   346 			break;
       
   347 		case 4:
       
   348             _LIT(KTestStepID4,"Test Ignore Orientation");
       
   349             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID4);
       
   350             INFO_PRINTF1(KNewLine);
       
   351             INFO_PRINTF1(KTestStepID4);
       
   352             TestIgnoreOrientation();
       
   353 			break;
       
   354         case 5:
       
   355             _LIT(KTestStepID5,"Test Swap Orientations");
       
   356             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID5);
       
   357             INFO_PRINTF1(KNewLine);
       
   358             INFO_PRINTF1(KTestStepID5);
       
   359             TestFixedOrientationsOnWindowSwap();
       
   360 			break;
       
   361         case 6:
       
   362             _LIT(KTestStepID6,"Test Auto Swap Orientations");
       
   363             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID6);
       
   364             INFO_PRINTF1(KNewLine);
       
   365             INFO_PRINTF1(KTestStepID6);
       
   366             TestAutoOrientationOnWindowSwap();
       
   367             break;
       
   368         case 7:
       
   369             _LIT(KTestStepID7,"Test Ignore Swap Orientations");
       
   370             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID7);
       
   371             INFO_PRINTF1(KNewLine);
       
   372             INFO_PRINTF1(KTestStepID7);
       
   373             TestIgnoreOrientationOnWindowSwap();
       
   374 			break;
       
   375         case 8:
       
   376             _LIT(KTestStepID8,"Test Auto Swap Orientations");
       
   377             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID8);
       
   378             INFO_PRINTF1(KNewLine);
       
   379             INFO_PRINTF1(KTestStepID8);
       
   380             TestIgnoreAutoOrientationOnWindowSwap();
       
   381             break;
       
   382         case 9:
       
   383             _LIT(KTestStepID9,"Test Invalid App Orientations");
       
   384             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID9);
       
   385             INFO_PRINTF1(KNewLine);
       
   386             INFO_PRINTF1(KTestStepID9);
       
   387             TestInvalidAppOrientation();
       
   388             break;
       
   389         case 10:
       
   390             _LIT(KTestStepID10,"Test Invalid Theme Server Orientations");
       
   391             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KTestStepID10);
       
   392             INFO_PRINTF1(KNewLine);
       
   393             INFO_PRINTF1(KTestStepID10);
       
   394             TestInvalidThemeServerOrientation();
       
   395             break;
       
   396 		default:
       
   397             (reinterpret_cast<CTDeviceRotationStep*>(iStep))->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   398 			(reinterpret_cast<CTDeviceRotationStep*>(iStep))->CloseTMSGraphicsStep();
       
   399 			TestComplete();
       
   400 		}
       
   401 	(reinterpret_cast<CTDeviceRotationStep*>(iStep))->RecordTestResultL();
       
   402 	}
       
   403 
       
   404 
       
   405 /**
       
   406  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0001
       
   407  @SYMTestCaseDesc           Test Auto Orientation
       
   408  @SYMPREQ                   460936 Tracking Device Rotation
       
   409  @SYMTestPriority           1
       
   410  @SYMTestPurpose            To test that we can return the correct initial orientation value from 
       
   411                             the windwoserver.
       
   412  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   413                             windowserver orientation changes.
       
   414                             We have set up an RWindowGroup at the foreground and not altered its
       
   415                             indicated orientation.
       
   416  @SYMTestActions            1) Get the value of the orientation as published by window server.
       
   417 
       
   418  @SYMTestExpectedResults    The windowserver should return EDisplayOrientationNormal
       
   419  */
       
   420 void CTDeviceRotation::TestInitialOrientation()
       
   421     {
       
   422     iWaitForPublishOnNextTest = EFalse;
       
   423     IsOrientationCorrect(EDisplayOrientationNormal);
       
   424     }
       
   425 
       
   426 /**
       
   427  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0002
       
   428  @SYMTestCaseDesc           Test Fixed Orientations
       
   429  @SYMPREQ                   460936 Tracking Device Rotation
       
   430  @SYMTestPriority           1
       
   431  @SYMTestPurpose            To test that we can return the correct orientation value from 
       
   432                             the windwoserver after we indicate the application orientation
       
   433                             as fixed values using RWsSession::IndicateAppOrientation. Any 
       
   434                             theme server orientations should be ignored.
       
   435  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   436                             windowserver orientation changes.
       
   437                             An RProperty is set up to publish Theme server Orientation changes. 
       
   438                             We have set up an RWindowGroup in the foreground.
       
   439                             Windowserver orientation currently set to EDisplayOrientationNormal.
       
   440 
       
   441  @SYMTestActions            1) Set Theme Server orientation to EDisplayOrientation90CW.
       
   442                             2) Set the RWindowgroup in ordinal position 0 to a fixed orientation.
       
   443                             3) Check the published orinetation value in windowserver.
       
   444                             4) Repeat steps 2) and 3) for all fixed orientations
       
   445                             3) Set Theme Server orientation to EDisplayOrientationNormal.
       
   446                             4) Repeat Steps 2-4).
       
   447 
       
   448  @SYMTestExpectedResults    The orientation set in step 2) should always be the same as the 
       
   449                             orientation set in step 2)
       
   450  */
       
   451 void CTDeviceRotation::TestFixedOrientations()
       
   452     {
       
   453     iWaitForPublishOnNextTest = EFalse;
       
   454     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   455     TestIndicateAppOrientation(EDisplayOrientationNormal);
       
   456     TestIndicateAppOrientation(EDisplayOrientation90CW);
       
   457     TestIndicateAppOrientation(EDisplayOrientation180);
       
   458     TestIndicateAppOrientation(EDisplayOrientation270CW);
       
   459     
       
   460     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   461     TestIndicateAppOrientation(EDisplayOrientationNormal);
       
   462     TestIndicateAppOrientation(EDisplayOrientation90CW);
       
   463     TestIndicateAppOrientation(EDisplayOrientation180);
       
   464     TestIndicateAppOrientation(EDisplayOrientation270CW);
       
   465     
       
   466     SimulateThemeServerOrientation(EDisplayOrientation180);
       
   467     TestIndicateAppOrientation(EDisplayOrientationNormal);
       
   468     TestIndicateAppOrientation(EDisplayOrientation90CW);
       
   469     TestIndicateAppOrientation(EDisplayOrientation180);
       
   470     TestIndicateAppOrientation(EDisplayOrientation270CW);
       
   471     
       
   472     SimulateThemeServerOrientation(EDisplayOrientation270CW);
       
   473     TestIndicateAppOrientation(EDisplayOrientationNormal);
       
   474     TestIndicateAppOrientation(EDisplayOrientation90CW);
       
   475     TestIndicateAppOrientation(EDisplayOrientation180);
       
   476     TestIndicateAppOrientation(EDisplayOrientation270CW);    
       
   477     }
       
   478 
       
   479 /**
       
   480  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0003
       
   481  @SYMTestCaseDesc           Test Auto Orientation
       
   482  @SYMPREQ                   460936 Tracking Device Rotation
       
   483  @SYMTestPriority           1
       
   484  @SYMTestPurpose            To test that we can return the correct orientation value from 
       
   485                             the windwoserver after we indicate the application orientation
       
   486                             as auto values using RWsSession::IndicateAppOrientation. The wserv
       
   487                             should publish the theme server orientation changes only.
       
   488  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   489                             windowserver orientation changes.
       
   490                             An RProperty is set up to publish Theme server Orientation changes.
       
   491                             We have set up an RWindowGroup in the foreground.
       
   492                             WindowServer orinetation is not set to EDisplayOrientation90CW.
       
   493 
       
   494  @SYMTestActions            1) Set Theme Server orientation to EDisplayOrientation90CW.
       
   495                             2) Set the RWindowgroup in ordinal position 0 to auto orientation.
       
   496                             3) Check the published orinetation value in windowserver.
       
   497                             4) Set Theme Server orientation to EDisplayOrientationNormal.
       
   498                             5) Check the value of the orientation as published by window server.
       
   499                             6) Repeat 4) and 5) for EDisplayOrientation180 and 
       
   500                                EDisplayOrientation270CW
       
   501                             7) repeat 4) and 5) again for EDisplayOrientation270CW
       
   502 
       
   503  @SYMTestExpectedResults    We should get expected notifications where orientations have changed.
       
   504                             The orientation checked in step 3) should be the theme server 
       
   505                             orientation set in step 1).
       
   506                             The orientations checked in step 5) should be the theme server 
       
   507                             orientations set in step 4).
       
   508                             We should recieve no notification for step 7).
       
   509  */
       
   510 void CTDeviceRotation::TestAutoOrientation()
       
   511     {
       
   512     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   513     TestIndicateAppOrientation(EDisplayOrientationAuto);
       
   514     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   515     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   516     // Now flip it upside down to ensure that nothing assumes this will only be updated incrementally
       
   517     SimulateThemeServerOrientation(EDisplayOrientation180);
       
   518     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   519     SimulateThemeServerOrientation(EDisplayOrientation270CW);
       
   520     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   521     
       
   522     // And check that wserv doesn't publish if the theme server publishes the existing orientation
       
   523     SimulateThemeServerOrientation(EDisplayOrientation270CW);
       
   524     iWaitForPublishOnNextTest = EFalse;    
       
   525     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   526     }
       
   527 
       
   528 /**
       
   529  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0004
       
   530  @SYMTestCaseDesc           Test Ignore Orientation
       
   531  @SYMPREQ                   460936 Tracking Device Rotation
       
   532  @SYMTestPriority           1
       
   533  @SYMTestPurpose            To test that we can return the correct orientation value from 
       
   534                             the windwoserver after we indicate the front applications 
       
   535                             orientation as ignore.  
       
   536  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   537                             windowserver orientation changes.
       
   538                             An RProperty is set up to publish Theme server Orientation changes.
       
   539                             We have set up two RWindowGroups in the ordinal positions 0 and 1. 
       
   540                             WindowServer orinetation is not set to EDisplayOrientationNormal.
       
   541 
       
   542  @SYMTestActions            1) Set Theme Server orientation to EDisplayOrientation90CW.
       
   543                             2) Set the RWindowGroup in ordinal position 0 to a ignore orientation.
       
   544                             3) Set the RWindowgroup in ordinal position 1 to a fixed orientation.
       
   545                             4) Check the published orinetation value in windowserver.
       
   546                             5) Repeat steps 2-4) varying the fixed orientation set in step 2).
       
   547                             6) Set Theme Server orientation to EDisplayOrientation90CW.
       
   548                             7) Set the RWindowGroup in ordinal position 0 to a ignore orientation.
       
   549                             8) Set the RWindowgroup in ordinal position 1 to a fixed orientation.
       
   550                             9) Check the published orinetation value in windowserver.
       
   551                             10) Set Theme Server orientation to EDisplayOrientationNormal.
       
   552                             11) Check the published orinetation value in windowserver.
       
   553 
       
   554  @SYMTestExpectedResults    We should get expected notifications where orientations have changed.
       
   555                             All orientations checked in step 4) should be the fixed orientations 
       
   556                             of the windows in ordinal position 1, as set in step 3).
       
   557                             The orientation checked in step 9) should be the theme server 
       
   558                             orientation set in step 6).
       
   559                             The orientation checked in step 11) should be the theme server 
       
   560                             orientation set in step 10).
       
   561  */
       
   562 void CTDeviceRotation::TestIgnoreOrientation()
       
   563     {
       
   564     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   565     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientationNormal);
       
   566     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientation90CW);
       
   567     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientation180);
       
   568     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientation270CW);
       
   569     
       
   570     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   571     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientationAuto);
       
   572     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   573     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   574     }
       
   575 
       
   576 /**
       
   577  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0005
       
   578  @SYMTestCaseDesc           Test Fixed Orientations On Swap
       
   579  @SYMPREQ                   460936 Tracking Device Rotation
       
   580  @SYMTestPriority           1
       
   581  @SYMTestPurpose            To test that we get notifactation of a change in orientation and can 
       
   582                             return the correct orientation value from the windwoserver after we 
       
   583                             swap windows with varying fixed orienations.  
       
   584  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   585                             windowserver orientation changes.
       
   586                             We have set up two RWindowGroups in the ordinal positions 0 and 1. 
       
   587 
       
   588  @SYMTestActions            1) Set the RWindowGroup in ordinal position 0 to a fixed orientation.
       
   589                             2) Set the RWindowgroup in ordinal position 1 to a fixed orientation.
       
   590                             3) Check the published orinetation value in windowserver.
       
   591                             4) Move the RWindowGroup ordinal position 1 to the ordinal position 0.
       
   592                             5) Check the published orinetation value in windowserver.
       
   593                             6) Repeat steps 1-5 but vary the values the fixed orientation of the 
       
   594                                RWindows set in steps 1) and 2)
       
   595 
       
   596  @SYMTestExpectedResults    We should get expected notifications where orientations have changed.
       
   597                             All orientations checked in step 3) should be the fixed orientations 
       
   598                             of the windows in ordinal position 0, as set in step 1).
       
   599                             The orientations checked in step 5) should be the fixed orientations 
       
   600                             of the windows which was in ordinal position 1 before each swap, as 
       
   601                             set in step 2).
       
   602  */
       
   603 void CTDeviceRotation::TestFixedOrientationsOnWindowSwap()
       
   604     {
       
   605     iWaitForPublishOnNextTest = EFalse;
       
   606     TestIndicateAppOrientation(EDisplayOrientationNormal, EDisplayOrientationNormal);
       
   607     iWaitForPublishOnNextTest = EFalse;
       
   608     TestAppOrientationOnSwap(EDisplayOrientationNormal, EDisplayOrientationNormal);
       
   609     TestIndicateAppOrientation(EDisplayOrientationNormal, EDisplayOrientation90CW);
       
   610     TestAppOrientationOnSwap(EDisplayOrientationNormal, EDisplayOrientation90CW);
       
   611     TestIndicateAppOrientation(EDisplayOrientation90CW, EDisplayOrientationNormal);
       
   612     TestAppOrientationOnSwap(EDisplayOrientation90CW, EDisplayOrientationNormal);
       
   613     }
       
   614 
       
   615 /**
       
   616  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0006
       
   617  @SYMTestCaseDesc           Test Auto Orientations On Swap
       
   618  @SYMPREQ                   460936 Tracking Device Rotation
       
   619  @SYMTestPriority           1
       
   620  @SYMTestPurpose            To test that we get notifactation of a change in orientation and can 
       
   621                             return the correct orientation value from the windwoserver after we 
       
   622                             swap windows with auto orienations.  
       
   623  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   624                             windowserver orientation changes.
       
   625                             An RProperty is set up to publish Theme server Orientation changes.
       
   626                             We have set up two RWindowGroups in the ordinal positions 0 and 1.
       
   627                             WindowServer orinetation is not set to EDisplayOrientation270CW. 
       
   628 
       
   629  @SYMTestActions            1) Set the theme server orientation.
       
   630                             2) Set the RWindowGroup in ordinal position 0 to a fixed orientation.
       
   631                             3) Set the RWindowGroup in ordinal position 1 to auto orientation.
       
   632                             4) Check the published orinetation value in windowserver.
       
   633                             5) Move the RWindowGroup ordinal position 1 to the ordinal position 0. 
       
   634                             6) Check the published orinetation value in windowserver.
       
   635                             7) Repeat steps 1-6 but vary the values of the theme server 
       
   636                                orientation in step 1) and the fixed orientation of the frontwindow
       
   637                                in 2)
       
   638  @SYMTestExpectedResults    We should get expected notifications where orientations have changed.
       
   639                             All orientations checked in step 4) should be the fixed orientations 
       
   640                             of the front windows, which have been set in step 2).
       
   641                             All orientations checked in step 6) should be the theme server 
       
   642                             orientations set in step 1)
       
   643  */
       
   644 void CTDeviceRotation::TestAutoOrientationOnWindowSwap()
       
   645     {
       
   646     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   647     TestIndicateAppOrientation(EDisplayOrientation270CW, EDisplayOrientationAuto);
       
   648     TestAppOrientationOnSwap(EDisplayOrientation270CW, EDisplayOrientationAuto);
       
   649     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   650     TestIndicateAppOrientation(EDisplayOrientationAuto, EDisplayOrientation180);
       
   651     TestAppOrientationOnSwap(EDisplayOrientationAuto, EDisplayOrientation180);
       
   652     
       
   653     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   654     TestIndicateAppOrientation(EDisplayOrientation90CW, EDisplayOrientationAuto);
       
   655     iWaitForPublishOnNextTest = EFalse;
       
   656     TestAppOrientationOnSwap(EDisplayOrientation90CW, EDisplayOrientationAuto);
       
   657     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   658     TestIndicateAppOrientation(EDisplayOrientationAuto, EDisplayOrientationNormal);
       
   659     iWaitForPublishOnNextTest = EFalse;
       
   660     TestAppOrientationOnSwap(EDisplayOrientationAuto, EDisplayOrientationNormal);
       
   661     }
       
   662 
       
   663 /**
       
   664  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0007
       
   665  @SYMTestCaseDesc           Test Swap Orientations with Ignore Orientation
       
   666  @SYMPREQ                   460936 Tracking Device Rotation
       
   667  @SYMTestPriority           1
       
   668  @SYMTestPurpose            To test that we get notifactation of a change in orientation and can 
       
   669                             return the correct orientation value from the windwoserver after we 
       
   670                             swap windows with ignore orienations.  
       
   671  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   672                             windowserver orientation changes.
       
   673                             An RProperty is set up to publish Theme server Orientation changes.
       
   674                             We have set up two RWindowGroups in the ordinal positions 0 and 1. 
       
   675 
       
   676  @SYMTestActions            1) Set the theme server orientation.
       
   677                             2) Set the RWindowGroup in ordinal position 0 to ignore orientation.
       
   678                             3) Set the RWindowGroup in ordinal position 1 to a fixed orientation.
       
   679                             4) Check the published orinetation value in windowserver.
       
   680                             5) Move the RWindowGroup ordinal position 1 to the ordinal position 0. 
       
   681                             6) Check the published orinetation value in windowserver.
       
   682                             7) Repeat steps 1-6 but vary the values of the theme server 
       
   683                                orientation in step 1) and the fixed orientation of the frontwindow
       
   684                                in 3)
       
   685                             8) Set the theme server orientation.
       
   686                             9) Set the RWindowGroup in ordinal position 0 to a fixedorientation.
       
   687                             10) Set the RWindowGroup in ordinal position 1 to ignore orienation.
       
   688                             11) Repeat steps 4-6) 
       
   689                             12) Repeat steps 8-11) but vary the values of the theme server 
       
   690                                orientation in step 8) and the fixed orientation of the 
       
   691                                RwindowGroup in 9)                            
       
   692                                
       
   693  @SYMTestExpectedResults    We should get expected notifications where orientations have changed.
       
   694                             All orientations checked in step 4) and 6) should be the fixed 
       
   695                             orientations RWindowGroups which have been set in step 3).
       
   696                             All orientations checked in step 11) should be the fixed orientations 
       
   697                             of the front RWindowGroups which have been set in step 9).
       
   698 */
       
   699 void CTDeviceRotation::TestIgnoreOrientationOnWindowSwap()
       
   700     {
       
   701     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   702     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientation270CW);
       
   703     TestAppOrientationOnSwap(EDisplayOrientationIgnore, EDisplayOrientation180);
       
   704     
       
   705     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   706     TestIndicateAppOrientation(EDisplayOrientationIgnore, EDisplayOrientationNormal);
       
   707     TestAppOrientationOnSwap(EDisplayOrientationIgnore, EDisplayOrientation90CW);
       
   708     
       
   709     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   710     TestIndicateAppOrientation(EDisplayOrientation270CW, EDisplayOrientationIgnore);
       
   711     TestAppOrientationOnSwap(EDisplayOrientation180, EDisplayOrientationIgnore);    
       
   712     
       
   713     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   714     TestIndicateAppOrientation(EDisplayOrientationNormal, EDisplayOrientationIgnore);
       
   715     TestAppOrientationOnSwap(EDisplayOrientation90CW, EDisplayOrientationIgnore);
       
   716     }
       
   717 
       
   718 /**
       
   719  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0008
       
   720  @SYMTestCaseDesc           Test Swap Orientations with Auto and Ignore Orientations
       
   721  @SYMPREQ                   460936 Tracking Device Rotation
       
   722  @SYMTestPriority           1
       
   723  @SYMTestPurpose            To test that we get notifactation of a change in orientation and can 
       
   724                             return the correct orientation value from the windwoserver after we 
       
   725                             swap windows with auto and ignore orienations.  
       
   726  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   727                             windowserver orientation changes.
       
   728                             An RProperty is set up to publish Theme server Orientation changes.
       
   729                             We have set up two RWindowGroups in the ordinal positions 0 and 1. 
       
   730  @SYMTestActions            1) Set the theme server orientation to EDisplayOrientationNormal.
       
   731                             2) Set the RWindowGroup in ordinal position 0 to auto orientation.
       
   732                             3) Set the RWindowGroup in ordinal position 1 to ignore orientation.
       
   733                             4) Check the published orinetation value in windowserver.
       
   734                             5) Set the theme server orientation to EDisplayOrientation90CW.
       
   735                             6) Check the published orinetation value in windowserver.
       
   736                             7) Set the theme server orientation to EDisplayOrientationNormal.
       
   737                             8) Move the RWindowGroup in ordinal position 1 to ordinal position 0.
       
   738                             9) Check the published orinetation value in windowserver.
       
   739                             10) Set the theme server orientation to EDisplayOrientation90CW.
       
   740                             11) Check the published orinetation value in windowserver.
       
   741 
       
   742  @SYMTestExpectedResults    We should get expected notifications where orientations have changed.
       
   743                             The orientations checked in step 4), 6), 9) and  11) should all be 
       
   744                             the orientations set to the themeserver in steps 1), 5), 8) and 10)
       
   745                             respecvtively. 
       
   746 */
       
   747 void CTDeviceRotation::TestIgnoreAutoOrientationOnWindowSwap()
       
   748     {
       
   749     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   750     TestIndicateAppOrientation(EDisplayOrientationAuto, EDisplayOrientationIgnore);
       
   751     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   752     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   753     
       
   754     SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   755     iSecondWindowGroup.SetOrdinalPosition(0);
       
   756     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   757     SimulateThemeServerOrientation(EDisplayOrientation90CW);
       
   758     IsOrientationCorrect(iCurrentThemeServerOrientation);
       
   759     }
       
   760 
       
   761 /**
       
   762  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0009
       
   763  @SYMTestCaseDesc           Test Invalid App Orientation
       
   764  @SYMPREQ                   ###TrackingDeviceRotation### TODO replace me
       
   765  @SYMTestPriority           1
       
   766  @SYMTestPurpose            To test that an invalid orientation is ignored.
       
   767  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   768                             windowserver orientation changes.
       
   769                             An RProperty is set up to publish Theme server Orientation changes.
       
   770                             We have set up an RWindowGroup in ordinal position 0.
       
   771  @SYMTestActions            1) Set the theme server orientation to EDisplayOrientationNormal.
       
   772                             2) Set the RWindowGroup in ordinal position 0 to 
       
   773                                EDisplayOrientation90CW.
       
   774                             4) Check the published orinetation value in windowserver.
       
   775                             5) Set the RWindowGroup in ordinal position 0 to an invalid 
       
   776                                orientation.
       
   777                             6) Check the published orinetation value in windowserver.
       
   778 
       
   779  @SYMTestExpectedResults    Wserv should publish an orientation change for 2) but not for 5).
       
   780                             The orientations checked in steps 4) and 6) should both be the 
       
   781                             orientation set in step 2).
       
   782 */
       
   783 void CTDeviceRotation::TestInvalidAppOrientation()
       
   784 	{
       
   785 	SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   786 	TestIndicateAppOrientation(EDisplayOrientation90CW);
       
   787 	iWs.IndicateAppOrientation(static_cast<TRenderOrientation>(1000));
       
   788 	iWaitForPublishOnNextTest = EFalse;
       
   789 	IsOrientationCorrect(EDisplayOrientation90CW);
       
   790 	}
       
   791 
       
   792 /**
       
   793  @SYMTestCaseID             GRAPHICS-WSERV-DEVICEROTATION-0010
       
   794  @SYMTestCaseDesc           Test Invalid Theme Server Orientation
       
   795  @SYMPREQ                   ###TrackingDeviceRotation### TODO replace me
       
   796  @SYMTestPriority           1
       
   797  @SYMTestPurpose            To test that an invalid theme server orientation is ignored when
       
   798                             the app orientation has been set to auto.
       
   799  @SYMPrerequisites          An RProperty is set up to subscribe to notifications of 
       
   800                             windowserver orientation changes.
       
   801                             An RProperty is set up to publish Theme server Orientation changes.
       
   802                             We have set up an RWindowGroup in ordinal position 0.
       
   803  @SYMTestActions            1) Set the theme server orientation to EDisplayOrientationNormal.
       
   804                             2) Set the RWindowGroup in ordinal position 0 to 
       
   805                                EDisplayOrientationAuto.
       
   806                             4) Check the published orinetation value in windowserver.
       
   807                             5) Set the theme server orientation to an invalid orientation.
       
   808                             6) Check the published orinetation value in windowserver.
       
   809 
       
   810  @SYMTestExpectedResults    Wserv should publish an orientation change for 2) but not for 5).
       
   811                             The orientations checked in steps 4) and 6) should both be the 
       
   812                             theme server orientation set in step 1).
       
   813 */
       
   814 void CTDeviceRotation::TestInvalidThemeServerOrientation()
       
   815 	{
       
   816 	SimulateThemeServerOrientation(EDisplayOrientationNormal);
       
   817 	TestIndicateAppOrientation(EDisplayOrientationAuto);
       
   818 	SimulateThemeServerOrientation(static_cast<TRenderOrientation>(5000));
       
   819 	iWaitForPublishOnNextTest = EFalse;
       
   820 	IsOrientationCorrect(EDisplayOrientationNormal);
       
   821 	}
       
   822 
       
   823 __CONSTRUCT_STEP__(DeviceRotation)