classicui_pub/tsrc/bc/apps/S60_SDK3.0/bctestserverapp/src/bctestserverappcase.cpp
changeset 0 2f259fa3e83a
child 10 3d340a0166ff
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:         test case
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #include <w32std.h>
       
    27 #include <coecntrl.h>
       
    28 #include <aknserverapp.h>
       
    29 #include <avkon.hrh>
       
    30 #include <aknwseventobserver.h>
       
    31 #include <aknBitmapAnimation.h>
       
    32 #include <barsread.h>
       
    33 #include <aknsitemid.h>
       
    34 #include <bctestserverapp.rsg>
       
    35 #include <AknsConstants.h>
       
    36 #include <AknsItemData.h>
       
    37 #include <AknsSkinInstance.h>
       
    38 #include <AknsUtils.h>
       
    39 #include <avkon.rsg>
       
    40 
       
    41 #include "bctestserverappcase.h"
       
    42 #include "bctestserverappcontainer.h"
       
    43 #include "bctestserverapp.hrh"
       
    44 #include "bctestserverappappui.h"
       
    45 
       
    46 
       
    47 // ======== MEMBER FUNCTIONS ========
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // Symbian 2nd static Constructor
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CBCTestServerappCase* CBCTestServerappCase::NewL(
       
    54     CBCTestServerappContainer* aContainer )
       
    55     {
       
    56     CBCTestServerappCase* self = new( ELeave ) CBCTestServerappCase(
       
    57         aContainer );
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // C++ default constructor
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CBCTestServerappCase::CBCTestServerappCase(
       
    69     CBCTestServerappContainer* aContainer )
       
    70     : iContainer( aContainer )
       
    71     {
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Destructor
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CBCTestServerappCase::~CBCTestServerappCase()
       
    79     {
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Symbian 2nd Constructor
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CBCTestServerappCase::ConstructL()
       
    87     {
       
    88     BuildScriptL();
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CBCTestServerappCase::BuildScriptL
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CBCTestServerappCase::BuildScriptL()
       
    96     {
       
    97     AddTestL( LeftCBA, KeyOK, TEND );
       
    98     AddTestL( LeftCBA, Down, KeyOK, TEND );
       
    99     AddTestL( LeftCBA, Down, Down, KeyOK, TEND );
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CBCTestServerappCase::RunL
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 void CBCTestServerappCase::RunL( TInt aCmd )
       
   107     {
       
   108     if ( aCmd < EBCTestCmdOutline1 || aCmd > EBCTestCmdOutline3 )
       
   109         {
       
   110         return;
       
   111         }
       
   112     ReleaseCaseL();
       
   113     PrepareCaseL( aCmd );
       
   114     switch ( aCmd )
       
   115         {
       
   116         case EBCTestCmdOutline1:
       
   117             TestFunctionL();
       
   118             break;
       
   119         case EBCTestCmdOutline2:
       
   120             TestFunctionOneL();
       
   121             break;
       
   122         case EBCTestCmdOutline3:
       
   123             TestFunctionTwoL();
       
   124             break;
       
   125         default:
       
   126             break;
       
   127         }
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CBCTestServerappCase::PrepareCaseL
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CBCTestServerappCase::PrepareCaseL( TInt aCmd )
       
   135     {
       
   136     switch ( aCmd )
       
   137         {
       
   138         case EBCTestCmdOutline1:
       
   139             iControl = new( ELeave ) CCoeControl();
       
   140             iControl->SetContainerWindowL( *iContainer );
       
   141             iControl->MakeVisible( ETrue );
       
   142             break;
       
   143 
       
   144         default:
       
   145             break;
       
   146         }
       
   147     iContainer->SetControl( iControl );
       
   148     }
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // CBCTestServerappCase::ReleaseCaseL
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 void CBCTestServerappCase::ReleaseCaseL()
       
   155     {
       
   156     iContainer->ResetControl();
       
   157     iControl = NULL;
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CBCTestServerappCase::TestLayoutDecorator
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CBCTestServerappCase::TestFunctionL()
       
   165     {
       
   166     _LIT( strAddObserverL,"Class CAknWsEventMonitor Function AddObserverL tested" );
       
   167     _LIT( strHandleWsEventL,"Class CAknWsEventMonitor Function HandleWsEventL tested" );
       
   168     _LIT( strRemoveObserver,"Class CAknWsEventMonitor Function RemoveObserver tested" );
       
   169 
       
   170     CAknAppUi* base = static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi());
       
   171     CAknWsEventMonitor* monitor = base->EventMonitor();
       
   172     CSubMonitor* wsevent = CSubMonitor::NewL(); 
       
   173 
       
   174     CleanupStack::PushL(monitor);
       
   175 
       
   176     TWsEvent event;
       
   177     monitor->AddObserverL(wsevent);
       
   178     AssertTrueL( ETrue, strAddObserverL);
       
   179 
       
   180     monitor->HandleWsEventL(event, iContainer);
       
   181     AssertTrueL( ETrue, strHandleWsEventL);
       
   182 
       
   183     monitor->RemoveObserver(wsevent);
       
   184     AssertTrueL( ETrue, strRemoveObserver);
       
   185 
       
   186     CleanupStack::Pop(monitor);
       
   187     delete wsevent;
       
   188     monitor = NULL;
       
   189     base = NULL;
       
   190 
       
   191     }
       
   192 
       
   193 void CBCTestServerappCase::TestFunctionOneL()
       
   194     {
       
   195     _LIT( strConstructL,"Class CAknAppServer Function ConstructL tested" );
       
   196     _LIT( strdelCAknAppServer,"Class CAknAppServer Function ~CAknAppServer tested" );
       
   197 
       
   198 
       
   199     CAknAppServer *appserver = new ( ELeave ) CAknAppServer();
       
   200     CleanupStack::PushL( appserver );
       
   201 
       
   202     _LIT( serverName, "my server app");
       
   203     appserver->ConstructL(serverName);
       
   204     AssertTrueL( ETrue, strConstructL);
       
   205 
       
   206     CleanupStack::PopAndDestroy(appserver);
       
   207     AssertTrueL( ETrue, strdelCAknAppServer);
       
   208 
       
   209     }
       
   210 
       
   211 void CBCTestServerappCase::TestFunctionTwoL()
       
   212     {
       
   213 
       
   214     _LIT( strAnimation,"Class CAknBitmapAnimation Function Animation tested" );
       
   215     _LIT( strBitmapAnimData,"Class CAknBitmapAnimation Function BitmapAnimData tested" );
       
   216     _LIT( strCancelAnimation,"Class CAknBitmapAnimation Function CancelAnimation tested" );
       
   217     _LIT( strConstructFromResourceL,"Class CAknBitmapAnimation Function ConstructFromResourceL tested" );
       
   218     _LIT( strConstructFromSkinL,"Class CAknBitmapAnimation Function ConstructFromSkinL tested" );
       
   219     _LIT( strMinimumSize,"Class CAknBitmapAnimation Function MinimumSize tested" );
       
   220     _LIT( strNewL,"Class CAknBitmapAnimation Function NewL tested" );
       
   221     _LIT( strSetFrameIndexL,"Class CAknBitmapAnimation Function SetFrameIndexL tested" );
       
   222     _LIT( strSetFrameIntervalL,"Class CAknBitmapAnimation Function SetFrameIntervalL tested" );
       
   223     _LIT( strStartAnimationL,"Class CAknBitmapAnimation Function StartAnimationL tested" );
       
   224     _LIT( strdelCAknBitmapAnimation,"Class CAknBitmapAnimation Function ~CAknBitmapAnimation tested" );
       
   225 
       
   226     CAknBitmapAnimation *ani= CAknBitmapAnimation::NewL();
       
   227     AssertTrueL( ETrue, strNewL);
       
   228     CleanupStack::PushL(ani);
       
   229 
       
   230     ani->SetContainerWindowL(*iContainer);
       
   231     
       
   232     TBool flag = ani->ConstructFromSkinL(KAknsIIDQsnBgScreen);
       
   233     AssertTrueL( ETrue, strConstructFromSkinL);
       
   234 
       
   235     TResourceReader reader;
       
   236     CCoeEnv::Static()->CreateResourceReaderLC(reader, 
       
   237         R_BCTEST_BMPANIM_DATA_ORG);
       
   238     ani->ConstructFromResourceL(reader);
       
   239     AssertTrueL( ETrue, strConstructFromResourceL);
       
   240     CleanupStack::PopAndDestroy();
       
   241 
       
   242     TRAP_IGNORE( ani->SetFrameIndexL( 1 ) );
       
   243     AssertTrueL( ETrue, strSetFrameIndexL );
       
   244 
       
   245     ani->MinimumSize();
       
   246     AssertTrueL( ETrue, strMinimumSize);
       
   247 
       
   248     RBitmapAnim rani = ani->Animation();
       
   249     AssertTrueL( ETrue, strAnimation);
       
   250 
       
   251     CBitmapAnimClientData* clientData = ani->BitmapAnimData();
       
   252     AssertTrueL(ETrue, strBitmapAnimData);
       
   253     
       
   254     TInt i = 1500;
       
   255     ani->SetFrameIntervalL(i);
       
   256     AssertTrueL( ETrue, strSetFrameIntervalL);
       
   257     
       
   258     ani->StartAnimationL();
       
   259     AssertTrueL(ETrue, strStartAnimationL);
       
   260     
       
   261     CleanupStack::PopAndDestroy(ani);
       
   262     AssertTrueL(ETrue, strCancelAnimation);
       
   263     AssertTrueL( ETrue, strdelCAknBitmapAnimation);
       
   264     }
       
   265 CSubMonitor *CSubMonitor::NewL()
       
   266  {
       
   267   	CSubMonitor * self=new(ELeave) CSubMonitor();
       
   268 	CleanupStack::PushL(self);
       
   269 	self->ConstructL();
       
   270 	CleanupStack::Pop();
       
   271 	return self;
       
   272  }
       
   273 
       
   274 CSubMonitor::~CSubMonitor()
       
   275  {
       
   276  }
       
   277 
       
   278 void CSubMonitor::ConstructL()
       
   279   {
       
   280   }
       
   281 
       
   282 EXPORT_C void CSubMonitor::HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination)
       
   283  {
       
   284  }