common/tools/ats/smoketest/localisation/apparchitecture/tef/T_WgnamStep.CPP
changeset 793 0c32c669a39d
child 872 17498133d9ad
equal deleted inserted replaced
792:893b85cda81b 793:0c32c669a39d
       
     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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test accessing window group name.\n
       
    15 // Tests accessing & modifier functionality of CApaWindowGroupName API.\n
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalComponent - Internal Symbian test code 
       
    24 */
       
    25 
       
    26 #include <e32test.h>
       
    27 #include <apgwgnam.h>
       
    28 #include <w32std.h>
       
    29 #include "T_WgnamStep.h"
       
    30 
       
    31 /**
       
    32   Auxiliary Fn for Test Case ID T-WgnamStep-testWgNamesL
       
    33  
       
    34   This function accepts current window group name as descriptor and prints it.\n
       
    35   
       
    36 */
       
    37 void CT_WgnamStep::PrintWindowGroupName(const TPtrC& aWndGroupName)
       
    38 	{
       
    39 	_LIT(KWindowGroupName, "Current name=\"%S\"\n");
       
    40 	TFileName buffer;
       
    41 	buffer.Format(KWindowGroupName, &aWndGroupName);
       
    42 	INFO_PRINTF1(buffer);
       
    43 	}
       
    44 
       
    45 
       
    46 /**
       
    47    @SYMTestCaseID T-WgnamStep-testWgNamesL
       
    48   
       
    49    @SYMPREQ
       
    50   
       
    51    @SYMTestCaseDesc Test setting and accessing functionality of Window group name. 
       
    52    
       
    53    @SYMTestPriority High 
       
    54   
       
    55    @SYMTestStatus Implemented
       
    56    
       
    57    @SYMTestActions The test checks the following functionality of CApaWindowGroupName\n
       
    58    (1) Creation of window group name object.\n
       
    59    (2) Setting the task to be a System task.\n
       
    60    (3) Setting the task to be Busy.\n
       
    61    (4) Setting document name as filename.\n
       
    62    (5) Setting the task's capability to shutdown.\n
       
    63    (6) Setting the task's capability to switch between files.\n
       
    64    (7) Setting the tasks Uid.\n
       
    65    (8) Setting the tasks caption.\n
       
    66    (9) Setting the tasks Document name.\n
       
    67    (10) Setting the task to be ready.\n
       
    68    (11) Setting a name to a window group name.\n
       
    69    \n
       
    70    In each of the cases the setter function is called to set a particular
       
    71    attribute. The attribute is cross checked by verifying with its 
       
    72    corresponding getter / accessor function. After setting each of the attributes
       
    73    the test tries to analyze the impact of the attribute changed, on the windows
       
    74    group name.\n
       
    75    API Calls:\n	
       
    76    CApaWindowGroupName::NewL(const RWsSession& aWsSession)\n
       
    77    CApaWindowGroupName::SetSystem(TBool aSystem)\n
       
    78    CApaWindowGroupName::IsSystem() const\n
       
    79    CApaWindowGroupName::SetBusy(TBool aBusy)\n
       
    80    CApaWindowGroupName::IsBusy() const\n
       
    81    CApaWindowGroupName::SetDocNameIsAFile(TBool aDocNameIsAFile)\n
       
    82    CApaWindowGroupName::DocNameIsAFile() const\n
       
    83    CApaWindowGroupName::SetRespondsToShutdownEvent(TBool aRespondsToShutdownEvent)\n
       
    84    CApaWindowGroupName::RespondsToShutdownEvent() const\n
       
    85    CApaWindowGroupName::SetRespondsToSwitchFilesEvent(TBool aRespondsToSwitchFilesEvent)\n
       
    86    CApaWindowGroupName::RespondsToSwitchFilesEvent() const\n
       
    87    CApaWindowGroupName::SetAppUid(TUid aAppUid);\n
       
    88    CApaWindowGroupName::AppUid() const\n
       
    89    CApaWindowGroupName::SetCaptionL(const TDesC& aCaption)\n
       
    90    CApaWindowGroupName::Caption() const\n
       
    91    CApaWindowGroupName::SetDocNameL(const TDesC& aDocName);\n
       
    92    CApaWindowGroupName::DocName() const\n
       
    93    CApaWindowGroupName::SetAppReady(TBool aIsReady)\n
       
    94    CApaWindowGroupName::IsAppReady()\n
       
    95    CApaWindowGroupName::SetWindowGroupName(HBufC* aWgName)\n
       
    96    CApaWindowGroupName::WindowGroupName() const\n
       
    97    CApaWindowGroupName::FindByCaption(const TDesC& aCaption, RWsSession& aWsSession, TInt& aPrevWgId) const\n
       
    98    
       
    99    @SYMTestExpectedResults Test checks results against expected values.
       
   100     
       
   101  */
       
   102 void CT_WgnamStep::testWgNamesL()
       
   103 	{
       
   104 	_LIT(KWindowGroupName1, "WindowGroupName 1");
       
   105 	_LIT(KWindowGroupName2, "WindowGroupName 2");
       
   106 	_LIT(KBadName,"00\x00\x31\x31\x31\x31\x31\x31\x31\x31x31\x0\x0");
       
   107 	
       
   108 	INFO_PRINTF1(_L("Starting testWgNamesL()"));
       
   109 	//
       
   110 	// Instantiate a blank name
       
   111 	CApaWindowGroupName* apaWindowGroupName=NULL;
       
   112 	TRAPD(ret, apaWindowGroupName=CApaWindowGroupName::NewL(iWsSession));
       
   113 	TEST(ret==KErrNone);
       
   114 	User::LeaveIfError(iWsSession.Connect());
       
   115 	TEST(apaWindowGroupName!=NULL);
       
   116 
       
   117 	// test setting system
       
   118 	INFO_PRINTF1(_L("Block 1"));
       
   119 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   120 	TEST(!apaWindowGroupName->IsSystem());
       
   121 	INFO_PRINTF1(_L("Setting system\n"));
       
   122 	apaWindowGroupName->SetSystem(ETrue);
       
   123 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   124 	TEST(apaWindowGroupName->IsSystem());
       
   125 	INFO_PRINTF1(_L("Setting not system\n"));
       
   126 	apaWindowGroupName->SetSystem(EFalse);
       
   127 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   128 	TEST(!apaWindowGroupName->IsSystem());
       
   129 	INFO_PRINTF1(_L("\n"));
       
   130 	// User::After(2000000);
       
   131 
       
   132 	// test setting busy
       
   133 	INFO_PRINTF1(_L("Block 2"));
       
   134 	INFO_PRINTF1(_L("Test setting busy"));
       
   135 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   136 	TEST(!apaWindowGroupName->IsBusy());
       
   137 	INFO_PRINTF1(_L("Setting busy\n"));
       
   138 	apaWindowGroupName->SetBusy(ETrue);
       
   139 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   140 	TEST(apaWindowGroupName->IsBusy());
       
   141 	INFO_PRINTF1(_L("Setting not busy\n"));
       
   142 	apaWindowGroupName->SetBusy(EFalse);
       
   143 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   144 	TEST(!apaWindowGroupName->IsBusy());
       
   145 	INFO_PRINTF1(_L("\n"));
       
   146 	// User::After(2000000);
       
   147 
       
   148 	// test setting docname not a file
       
   149 	INFO_PRINTF1(_L("Block 3"));
       
   150 	INFO_PRINTF1(_L("Test setting doc name is not a file"));
       
   151 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   152 	TEST(apaWindowGroupName->DocNameIsAFile());
       
   153 	INFO_PRINTF1(_L("Setting doc name not a file\n"));
       
   154 	apaWindowGroupName->SetDocNameIsAFile(EFalse);
       
   155 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   156 	TEST(!apaWindowGroupName->DocNameIsAFile());
       
   157 	INFO_PRINTF1(_L("Setting doc name is a file\n"));
       
   158 	apaWindowGroupName->SetDocNameIsAFile(ETrue);
       
   159 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   160 	TEST(apaWindowGroupName->DocNameIsAFile());
       
   161 	INFO_PRINTF1(_L("\n"));
       
   162 	// User::After(2000000);
       
   163 
       
   164 	// RDebug::Print(_L("Block 3"));
       
   165 	INFO_PRINTF1(_L("Test setting does not respond to shutdown event"));
       
   166 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   167 	TEST(apaWindowGroupName->RespondsToShutdownEvent());
       
   168 	INFO_PRINTF1(_L("Setting does not respond to shutdown event\n"));
       
   169 	apaWindowGroupName->SetRespondsToShutdownEvent(EFalse);
       
   170 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   171 	TEST(!apaWindowGroupName->RespondsToShutdownEvent());
       
   172 	INFO_PRINTF1(_L("Setting does respond to shutdown event\n"));
       
   173 	apaWindowGroupName->SetRespondsToShutdownEvent(ETrue);
       
   174 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   175 	TEST(apaWindowGroupName->RespondsToShutdownEvent());
       
   176 	INFO_PRINTF1(_L("\n"));
       
   177 	// User::After(2000000);
       
   178 
       
   179 	// test setting does not respond to switch files event
       
   180 	// RDebug::Print(_L("Block 3"));
       
   181 	INFO_PRINTF1(_L("Test setting does not respond to switch files event"));
       
   182 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   183 	TEST(apaWindowGroupName->RespondsToSwitchFilesEvent());
       
   184 	INFO_PRINTF1(_L("Setting does not respond to switch files event\n"));
       
   185 	apaWindowGroupName->SetRespondsToSwitchFilesEvent(EFalse);
       
   186 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   187 	TEST(!apaWindowGroupName->RespondsToSwitchFilesEvent());
       
   188 	INFO_PRINTF1(_L("Setting does respond to switch files event\n"));
       
   189 	apaWindowGroupName->SetRespondsToSwitchFilesEvent(ETrue);
       
   190 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   191 	TEST(apaWindowGroupName->RespondsToSwitchFilesEvent());
       
   192 	INFO_PRINTF1(_L("\n"));
       
   193 	// User::After(2000000);
       
   194 
       
   195 	// test setting app uid
       
   196 	// RDebug::Print(_L("Block 5"));
       
   197 	INFO_PRINTF1(_L("Test setting appUid"));
       
   198 	const TUid uid={ 0x10000111 };
       
   199 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   200 	INFO_PRINTF2(_L("Setting app uid to %x\n"), uid.iUid);
       
   201 	apaWindowGroupName->SetAppUid(uid);
       
   202 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   203 	TEST(apaWindowGroupName->AppUid()==uid);
       
   204 	INFO_PRINTF1(_L("\n"));
       
   205 	// User::After(2000000);
       
   206 
       
   207 	// test setting caption
       
   208 	// RDebug::Print(_L("Block 6"));
       
   209 	INFO_PRINTF1(_L("Test setting caption"));
       
   210 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   211 	TPtrC caption=_L("App caption");
       
   212 	INFO_PRINTF2(_L("Setting app caption to %S\n"), &caption);
       
   213 	apaWindowGroupName->SetCaptionL(caption);
       
   214 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   215 	TEST(!(apaWindowGroupName->Caption().Compare(caption)));
       
   216 	INFO_PRINTF1(_L("\n"));
       
   217 	// User::After(2000000);
       
   218 	
       
   219 	// testing FindByCaption
       
   220 	INFO_PRINTF1(_L("Test Window group ID"));
       
   221 	_LIT(KCaption, "App caption");
       
   222 	TInt aWgId=0;
       
   223 	apaWindowGroupName->FindByCaption(KCaption, iWsSession, aWgId);
       
   224 	TEST(aWgId==KErrNotFound);
       
   225 	INFO_PRINTF3(_L("Expected value is KErrNotfound : %d ,Value Obtained is   : %d \n"),KErrNotFound, aWgId);
       
   226 
       
   227 	// test setting document name
       
   228 	// RDebug::Print(_L("Block 7"));
       
   229 	INFO_PRINTF1(_L("Test setting document name"));
       
   230 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   231 	TPtrC docName=_L("Doc name");
       
   232 	INFO_PRINTF2(_L("Setting doc name to %S\n"), &docName);
       
   233 	apaWindowGroupName->SetDocNameL(docName);
       
   234 	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
       
   235 	TEST(!(apaWindowGroupName->DocName().Compare(docName)));
       
   236 	INFO_PRINTF1(_L("\n"));
       
   237 
       
   238 	// test AppReady flag
       
   239 	INFO_PRINTF1(_L("Testing AppReady flag"));
       
   240 	INFO_PRINTF1(_L("Setting AppReady flag to false"));
       
   241 	apaWindowGroupName->SetAppReady(EFalse);
       
   242 	TEST(apaWindowGroupName->IsAppReady()==EFalse);
       
   243 	INFO_PRINTF1(_L("Setting AppReady flag to true"));
       
   244 	apaWindowGroupName->SetAppReady(ETrue);
       
   245 	TEST(!apaWindowGroupName->IsAppReady()==EFalse);
       
   246 	INFO_PRINTF1(_L("\n"));
       
   247 
       
   248 
       
   249 	// Testing SetWindowGroup Name
       
   250 	INFO_PRINTF1(_L("Testing SetWindowGroupName"));
       
   251 	CApaWindowGroupName* apaWindGroupName = NULL;
       
   252 	
       
   253 	TRAP(ret, apaWindGroupName=CApaWindowGroupName::NewL(iWsSession, apaWindowGroupName->WindowGroupName()));
       
   254 	TEST(ret==KErrNone);
       
   255 	apaWindGroupName->SetWindowGroupNameL(KWindowGroupName1);
       
   256 	TEST(apaWindGroupName->WindowGroupName().Compare(KWindowGroupName1)==0);
       
   257 	HBufC* windGroupName = KWindowGroupName2().AllocLC();
       
   258 	apaWindGroupName->SetWindowGroupName(windGroupName);
       
   259 	TEST(apaWindGroupName->WindowGroupName().Compare(KWindowGroupName2)==0);
       
   260 	
       
   261 	apaWindGroupName->SetWindowGroupNameL(KBadName);
       
   262 	const TUid retUid = apaWindGroupName->AppUid();
       
   263 	TEST(retUid == KNullUid);
       
   264 	INFO_PRINTF2(_L("Expected Uid: 0, Actual uid = %d\n"), retUid);
       
   265 	delete apaWindGroupName;
       
   266 
       
   267 	INFO_PRINTF1(_L("Cleaning up"));
       
   268 	delete apaWindowGroupName; // apaWindowGroupName
       
   269 
       
   270 	CleanupStack::Pop();	// windGroupName
       
   271 	iWsSession.Close();
       
   272 
       
   273 	INFO_PRINTF1(_L("Finished testWgNamesL()"));
       
   274 	}
       
   275 
       
   276 
       
   277 
       
   278 CT_WgnamStep::~CT_WgnamStep()
       
   279 /**
       
   280    Destructor
       
   281  */
       
   282 	{
       
   283 	}
       
   284 
       
   285 CT_WgnamStep::CT_WgnamStep()
       
   286 /**
       
   287    Constructor
       
   288  */
       
   289 	{
       
   290 	// Call base class method to set up the human readable name for logging
       
   291 	SetTestStepName(KT_WgnamStep);
       
   292 	}
       
   293 
       
   294 TVerdict CT_WgnamStep::doTestStepPreambleL()
       
   295 /**
       
   296    @return - TVerdict code
       
   297    Override of base class virtual
       
   298  */
       
   299 	{
       
   300 	SetTestStepResult(EPass);
       
   301 	return TestStepResult();
       
   302 	}
       
   303 
       
   304 TVerdict CT_WgnamStep::doTestStepPostambleL()
       
   305 /**
       
   306    @return - TVerdict code
       
   307    Override of base class virtual
       
   308  */
       
   309 	{
       
   310 	return TestStepResult();
       
   311 	}
       
   312 
       
   313 
       
   314 TVerdict CT_WgnamStep::doTestStepL()
       
   315 /**
       
   316    @return - TVerdict code
       
   317    Override of base class virtual
       
   318  */
       
   319 {
       
   320 	INFO_PRINTF1(_L("Testing window group names"));
       
   321 	//
       
   322 	// run the testcode (inside an alloc heaven harness)
       
   323 
       
   324 	__UHEAP_MARK;
       
   325 	TRAPD(r,testWgNamesL());
       
   326 		TEST(r==KErrNone);
       
   327 	__UHEAP_MARKEND;
       
   328 
       
   329 	return TestStepResult();
       
   330 }