appfw/apparchitecture/tef/t_winchainChild_Application.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 // Source file for the implementation of the 
       
    15 // application class - CChainChildApplication
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent - Internal Symbian test code 
       
    22 */
       
    23 
       
    24 #include "t_winchainChild.h"
       
    25 
       
    26 
       
    27 /**   The function is called by the UI framework to ask for the
       
    28       application's UID. The returned value is defined by the
       
    29       constant KUidTChainChildApp and must match the second value
       
    30       defined in the project definition file.
       
    31 */ 
       
    32 TUid CChainChildApplication::AppDllUid() const
       
    33 	{
       
    34 	return KUidTChainChildApp;
       
    35 	}
       
    36 
       
    37 /**  This function is called by the UI framework at
       
    38      application start-up. It creates an instance of the
       
    39      document class.
       
    40 */
       
    41 CApaDocument* CChainChildApplication::CreateDocumentL()
       
    42 	{
       
    43 	return new (ELeave) CChainChildDocument(*this);
       
    44 	}
       
    45 	
       
    46 	LOCAL_C CApaApplication* NewApplication()
       
    47 	{
       
    48 	return new CChainChildApplication;
       
    49 	}
       
    50 
       
    51 TFileName CChainChildApplication::BitmapStoreName() const
       
    52 	{
       
    53 	return KNullDesC();
       
    54 	}
       
    55 
       
    56 TFileName CChainChildApplication::ResourceFileName() const
       
    57 	{
       
    58 	return KNullDesC();
       
    59 	}
       
    60 
       
    61 
       
    62 GLDEF_C TInt E32Main()
       
    63 	{
       
    64 	return EikStart::RunApplication( NewApplication );
       
    65 	}
       
    66 
       
    67 
       
    68 
       
    69 /**       The constructor of the document class just passes the
       
    70           supplied reference to the constructor initialisation list.
       
    71           The document has no real work to do in this application.
       
    72 */
       
    73 CChainChildDocument::CChainChildDocument(CEikApplication& aApp)
       
    74 		: CEikDocument(aApp)
       
    75 	{
       
    76 	}
       
    77 
       
    78 
       
    79 /**     This is called by the UI framework as soon as the 
       
    80         document has been created. It creates an instance
       
    81         of the ApplicationUI. The Application UI class is
       
    82         an instance of a CEikAppUi derived class.
       
    83 */
       
    84 CEikAppUi* CChainChildDocument::CreateAppUiL()
       
    85 	{
       
    86     return new(ELeave) CChainChildAppUi;
       
    87 	}
       
    88 
       
    89 #include <eikserverapp.h>
       
    90 /**  The second phase constructor of the application UI class.
       
    91      The application UI creates and owns the one and only view.
       
    92 */ 
       
    93 void CChainChildAppUi::ConstructL()
       
    94     {
       
    95     //CEikAppUi::ConstructL();	
       
    96     CEikAppUi::BaseConstructL(ENoAppResourceFile|ENoScreenFurniture);
       
    97 	}
       
    98 
       
    99 // Check if parent ID is the KExoticOrdinalPriority	
       
   100 TInt CMyAppService::TestL(TInt aParentWindowGroupID)
       
   101 	{
       
   102 	CCoeEnv* coeEnv = CCoeEnv::Static();
       
   103 		
       
   104 	
       
   105 	TInt wgCount=coeEnv->WsSession().NumWindowGroups(KExoticOrdinalPriority);
       
   106 		
       
   107 	RDebug::Print(_L("Child - TestL: wgCount = %d"), wgCount);
       
   108 	
       
   109     RArray<RWsSession::TWindowGroupChainInfo>* wgIds=new(ELeave) RArray<RWsSession::TWindowGroupChainInfo>(wgCount);
       
   110     CleanupStack::PushL(wgIds);
       
   111     User::LeaveIfError(coeEnv->WsSession().WindowGroupList(KExoticOrdinalPriority,wgIds));
       
   112         
       
   113     TBool testPassed=EFalse;
       
   114 
       
   115     // The root identifier of this window
       
   116     TInt rootIdentifier = coeEnv->RootWin().Identifier();
       
   117     
       
   118     RDebug::Print(_L("Child - TestL: rootIdentifier = %d"), rootIdentifier);
       
   119     
       
   120     RDebug::Print(_L("Child - TestL: Entering loop.."));
       
   121     // Go through all window group IDs looking for the current one
       
   122     for (TInt i=0;i<wgCount;i++)
       
   123         {
       
   124         RWsSession::TWindowGroupChainInfo wgId=(*wgIds)[i];
       
   125         
       
   126         RDebug::Print(_L("Child - TestL: wgId[%d].iId = %d"), i, wgId.iId);
       
   127         RDebug::Print(_L("Child - TestL: wgId[%d].iParentId = %d"), i, wgId.iParentId);
       
   128         
       
   129         // If this is the current window group ID
       
   130         if (wgId.iId == rootIdentifier)
       
   131         	{
       
   132         	RDebug::Print(_L("Child - TestL: Root Identifier = wgId.Id on %d"),i);
       
   133         	testPassed=(wgId.iParentId == aParentWindowGroupID);
       
   134         	RDebug::Print(_L("Child - TestL: TestPassed = %d"), testPassed);
       
   135         	break;
       
   136         	}
       
   137         }
       
   138         
       
   139 	CleanupStack::PopAndDestroy();  // wgids
       
   140 	
       
   141 	return testPassed;
       
   142 	}
       
   143 	
       
   144 //
       
   145 // CMyAppService
       
   146 //
       
   147 void CMyAppService::ServiceL(const RMessage2& aMessage)
       
   148 	{
       
   149 	RDebug::Print(_L("Child - ServiceL: message function = %d"),aMessage.Function());
       
   150 	
       
   151 	switch (aMessage.Function())
       
   152 	{
       
   153 	case KQueryChainChild1:
       
   154 		if (TestL(aMessage.Int0())) 
       
   155 			{
       
   156 			aMessage.Complete(KChainPass);
       
   157 			}
       
   158 		else
       
   159 			{
       
   160 			aMessage.Complete(KChainFail);	
       
   161 			}
       
   162 			User::Exit(-1);
       
   163 		break;
       
   164 	case KQueryChainChild2:
       
   165 		aMessage.Complete(KErrNone);
       
   166 		User::Exit(-1);
       
   167 		break;
       
   168 	default:
       
   169 		aMessage.Complete(KErrNotSupported);
       
   170 		User::Leave(KErrNotSupported);
       
   171 		break;
       
   172 		}
       
   173 	}
       
   174 	
       
   175 //
       
   176 // CMyEikAppServer
       
   177 //
       
   178 CApaAppServiceBase* CMyEikAppServer::CreateServiceL(TUid aServiceType) const
       
   179 	{
       
   180 	RDebug::Print(_L("Child - CreateServiceL: Creating Service Type %d"),aServiceType);
       
   181 	if (aServiceType==KUidTChainServerApp)
       
   182 		{
       
   183 		return new(ELeave) CMyAppService;
       
   184 		}
       
   185 	return CEikAppServer::CreateServiceL(aServiceType);
       
   186 	}	
       
   187 	
       
   188 	
       
   189 CChainChildAppUi::~CChainChildAppUi()
       
   190 	{
       
   191 
       
   192 	}
       
   193 
       
   194 void CChainChildAppUi::HandleCommandL(TInt /*aCommand*/)
       
   195 	{
       
   196 	
       
   197 	}
       
   198 
       
   199 void CChainChildAppUi::RunTestStepL(TInt /*aNextStep*/)
       
   200 	{
       
   201 	}
       
   202 	
       
   203 
       
   204 
       
   205     
       
   206