windowing/windowserver/test/tauto/TGWHANDLE.CPP
changeset 110 7f25ef56562d
child 136 62bb7c97884c
equal deleted inserted replaced
98:bf7481649c98 110:7f25ef56562d
       
     1 // Copyright (c) 1996-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 // GWHANDLE.CPP
       
    15 // Test group window handle functions
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @test
       
    22  @internalComponent - Internal Symbian test code
       
    23 */
       
    24 
       
    25 #include "TGWHANDLE.H"
       
    26 
       
    27 
       
    28 CTGwHandle::CTGwHandle(CTestStep* aStep):
       
    29 	CTWsGraphicsBase(aStep)
       
    30 	{
       
    31 	}
       
    32 
       
    33 void CTGwHandle::ConstructL()
       
    34 	{
       
    35 	}
       
    36 
       
    37 CTGwHandle::~CTGwHandle()
       
    38 	{
       
    39 	}
       
    40 
       
    41 TInt CTGwHandle::NumberOfWndGroupsWithZeroPriority(TInt aScreenNumber)
       
    42 	{
       
    43 	__ASSERT_ALWAYS(aScreenNumber <= 1, User::Invariant());
       
    44 	return TheClient->iWs.NumWindowGroups(aScreenNumber,0);
       
    45 	}
       
    46 
       
    47 void CTGwHandle::GetGwListL(CArrayFixFlat<TInt> *aWindowHandles)
       
    48 	{
       
    49 	User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles));
       
    50 	}
       
    51 
       
    52 void CTGwHandle::GetGwListL(CArrayFixFlat<TInt> *aWindowHandles, TInt aScreenNumber)
       
    53 	{
       
    54 	User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles, aScreenNumber));
       
    55 	}
       
    56 
       
    57 void CTGwHandle::GetGwListL(TInt aPriority, CArrayFixFlat<TInt> *aWindowHandles)
       
    58 	{
       
    59 	User::LeaveIfError(TheClient->iWs.WindowGroupList(aPriority,aWindowHandles));
       
    60 	}
       
    61 
       
    62 void CTGwHandle::GetGwListL(RArray<RWsSession::TWindowGroupChainInfo>* aWindowHandles)
       
    63 	{
       
    64 	User::LeaveIfError(TheClient->iWs.WindowGroupList(aWindowHandles));
       
    65 	}
       
    66 
       
    67 void CTGwHandle::GetGwListL(TInt aPriority, RArray<RWsSession::TWindowGroupChainInfo>* aWindowHandles)
       
    68 	{
       
    69 	User::LeaveIfError(TheClient->iWs.WindowGroupList(aPriority, aWindowHandles));
       
    70 	}
       
    71 
       
    72 void CTGwHandle::GwNamesL()
       
    73 	{
       
    74 	enum {EConnectHandle1=123456};
       
    75 	enum {EWindowGroupHandle1=234567};
       
    76 	enum {EWindowGroupHandle2=666666};
       
    77 //
       
    78 	TInt foreground;
       
    79 	User::LeaveIfError(foreground=TheClient->iWs.GetFocusWindowGroup());
       
    80 	RWsSession ws1;
       
    81 	User::LeaveIfError(ws1.Connect());
       
    82 
       
    83 	// assign to the correct screen
       
    84 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1);
       
    85 	CleanupStack::PushL(screen);
       
    86 	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
       
    87 
       
    88 	RWindowGroup gw1(ws1);
       
    89 	User::LeaveIfError(gw1.Construct(EWindowGroupHandle1));
       
    90 	gw1.SetOwningWindowGroup(foreground);
       
    91 	RWindowGroup gw2(ws1);
       
    92 	User::LeaveIfError(gw2.Construct(EWindowGroupHandle2));
       
    93 	gw2.SetOwningWindowGroup(foreground);
       
    94 //
       
    95 	TBuf<8> getName;
       
    96 //
       
    97 // Check default name is simply a null string
       
    98 //
       
    99 	TInt retVal = gw1.Name(getName);
       
   100 	TEST(retVal==KErrNone);
       
   101 	if (retVal!=KErrNone)
       
   102 		INFO_PRINTF3(_L("gw1.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   103 
       
   104 	TEST(getName==_L(""));
       
   105 	if (getName!=_L(""))
       
   106 		INFO_PRINTF3(_L("getName==_L() - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   107 //
       
   108 	TBuf<8> name1(_L("A_Name1"));
       
   109 	TBuf<8> name2(_L("A_Name2"));
       
   110 //
       
   111 	retVal = gw1.SetName(name1);
       
   112 	TEST(retVal==KErrNone);
       
   113 	if (retVal!=KErrNone)
       
   114 		INFO_PRINTF3(_L("gw1.SetName(name1) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   115 
       
   116 	retVal = gw2.SetName(name2);
       
   117 	TEST(retVal==KErrNone);
       
   118 	if (retVal!=KErrNone)
       
   119 		INFO_PRINTF3(_L("(gw2.SetName(name2) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   120 
       
   121 	retVal = gw1.Name(getName);
       
   122 	TEST(retVal==KErrNone);
       
   123 	if (retVal!=KErrNone)
       
   124 		INFO_PRINTF3(_L("(gw1.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   125 
       
   126 	TEST(getName==name1);
       
   127 	if (getName!=name1)
       
   128 		INFO_PRINTF3(_L("getName==name1 - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   129 //
       
   130 	retVal = gw2.Name(getName);
       
   131 	TEST(retVal==KErrNone);
       
   132 	if (retVal!=KErrNone)
       
   133 		INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   134 
       
   135 	TEST(getName==name2);
       
   136 	if (getName!=name2)
       
   137 		INFO_PRINTF3(_L("getName==name2 - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   138 
       
   139 //
       
   140 // A few weird characters in the name should work fine
       
   141 //
       
   142 	retVal = gw2.SetName(_L("xx*"));
       
   143 	TEST(retVal==KErrNone);
       
   144 	if (retVal!=KErrNone)
       
   145 		INFO_PRINTF3(_L("(gw2.SetName(_L(xx*)) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   146 
       
   147 	retVal = gw2.Name(getName);
       
   148 	TEST(retVal==KErrNone);
       
   149 	if (retVal!=KErrNone)
       
   150 		INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   151 
       
   152 	TEST(getName==_L("xx*"));
       
   153 	if (getName!=_L("xx*"))
       
   154 		INFO_PRINTF3(_L("getName==_L(xx*) - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   155 
       
   156 //
       
   157 	retVal = gw2.SetName(_L(":"));
       
   158 	TEST(retVal==KErrNone);
       
   159 	if (retVal!=KErrNone)
       
   160 		INFO_PRINTF3(_L("(gw2.SetName(_L(:)) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   161 
       
   162 	retVal = gw2.Name(getName);
       
   163 	TEST(retVal==KErrNone);
       
   164 	if (retVal!=KErrNone)
       
   165 		INFO_PRINTF3(_L("(gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   166 
       
   167 	TEST(getName==_L(":"));
       
   168 	if (getName!=_L(":"))
       
   169 		INFO_PRINTF3(_L("getName==_L(:) - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   170 
       
   171 //
       
   172 // Setting the name back to a null name
       
   173 //
       
   174 	retVal = gw2.SetName(_L(""));
       
   175 	TEST(retVal==KErrNone);
       
   176 	if (retVal!=KErrNone)
       
   177 		INFO_PRINTF3(_L("gw2.SetName(_L()) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   178 
       
   179 	retVal = gw2.Name(getName);
       
   180 	TEST(retVal==KErrNone);
       
   181 	if (retVal!=KErrNone)
       
   182 		INFO_PRINTF3(_L("gw2.Name(getName) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   183 
       
   184 	TEST(getName==_L(""));
       
   185 	if (getName!=_L(""))
       
   186 		INFO_PRINTF3(_L("getName==_L() - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   187 
       
   188 //
       
   189 // Getting a name into a too short buffer should fill thew whole buffer from the left hand part
       
   190 // of the window name and return KErrOverflow
       
   191 //
       
   192 	gw2.SetName(name2);
       
   193 	TBuf<4> shortBuf;
       
   194 	retVal = gw2.Name(shortBuf);
       
   195 	TEST(retVal==KErrOverflow);
       
   196 	if (retVal!=KErrOverflow)
       
   197 		INFO_PRINTF3(_L("gw2.Name(shortBuf) return value - Expected: %d, Actual: %d"), KErrOverflow, retVal);
       
   198 
       
   199 	TEST(shortBuf==name2.Left(4));
       
   200 	if (shortBuf!=name2.Left(4))
       
   201 		INFO_PRINTF3(_L("shortBuf==name2.Left(4) - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   202 
       
   203 //
       
   204 // passing a 0 length TPtr pointing to NULL should be safe, simply returning KErrOverflow
       
   205 //
       
   206 	TPtr nullPtr(NULL,0);
       
   207 	retVal = gw2.Name(nullPtr);
       
   208 	TEST(retVal==KErrOverflow);
       
   209 	if (retVal!=KErrOverflow)
       
   210 		INFO_PRINTF3(_L("gw2.Name(nullPtr) return value - Expected: %d, Actual: %d"), KErrOverflow, retVal);
       
   211 
       
   212 	TEST(nullPtr==_L(""));
       
   213 	if (nullPtr!=_L(""))
       
   214 		INFO_PRINTF3(_L("nullPtr==_L() - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   215 
       
   216 //
       
   217 // Getting a null name into a null descriptor
       
   218 //
       
   219 	gw2.SetName(_L(""));
       
   220 	TPtr nullPtr2(NULL,0);
       
   221 	retVal = gw2.Name(nullPtr);
       
   222 	TEST(retVal==KErrNone);
       
   223 	if (retVal!=KErrNone)
       
   224 		INFO_PRINTF3(_L("gw2.Name(nullPtr) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   225 
       
   226 	TEST(nullPtr2==_L(""));
       
   227 	if (nullPtr2!=_L(""))
       
   228 		INFO_PRINTF3(_L("nullPtr2==_L() - Expected: %d, Actual: %d"), ETrue, EFalse);
       
   229 //
       
   230 	gw1.Close();
       
   231 	gw2.Close();
       
   232 	CleanupStack::PopAndDestroy(screen);
       
   233 	ws1.Close();
       
   234 	}
       
   235 
       
   236 void CTGwHandle::GwIdentifierTestL()
       
   237 	{
       
   238 	enum {EWindowGroupHandle1=234567};
       
   239 	enum {EWindowGroupHandle2=666666};
       
   240 	enum {EWindowGroupHandle3=999};
       
   241 //
       
   242 	CArrayFixFlat<TInt>* windowHandles=new(ELeave) CArrayFixFlat<TInt>(5);
       
   243 	CleanupStack::PushL(windowHandles);
       
   244 	GetGwListL(0, windowHandles);
       
   245 	TInt retVal = TheClient->iWs.GetFocusWindowGroup();
       
   246 	TEST(retVal==(*windowHandles)[0]);
       
   247 	if (retVal!=(*windowHandles)[0])
       
   248 		INFO_PRINTF3(_L("TheClient->iWs.GetFocusWindowGroup() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal);
       
   249 
       
   250 //
       
   251 	RWsSession ws1;
       
   252 	User::LeaveIfError(ws1.Connect());
       
   253 	CleanupClosePushL(ws1);
       
   254 
       
   255 	// assign to the correct screen
       
   256 	CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1);
       
   257 	CleanupStack::PushL(screen1);
       
   258 	User::LeaveIfError(screen1->Construct(iTest->iScreenNumber));
       
   259 
       
   260 	RWindowGroup gw1(ws1);
       
   261 	User::LeaveIfError(gw1.Construct(EWindowGroupHandle1));
       
   262 	gw1.SetOwningWindowGroup((*windowHandles)[0]);
       
   263 	RWsSession ws2;
       
   264 	User::LeaveIfError(ws2.Connect());
       
   265 	CleanupClosePushL(ws2);
       
   266 
       
   267 	// assign to the correct screen
       
   268 	CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2);
       
   269 	CleanupStack::PushL(screen2);
       
   270 	User::LeaveIfError(screen2->Construct(iTest->iScreenNumber));
       
   271 
       
   272 	RWindowGroup gw2(ws2);
       
   273 	User::LeaveIfError(gw2.Construct(EWindowGroupHandle2));
       
   274 //
       
   275 	GetGwListL(0, windowHandles);
       
   276 //
       
   277 
       
   278 	retVal = gw2.Identifier();
       
   279 	TEST(retVal==(*windowHandles)[0]);
       
   280 	if (retVal!=(*windowHandles)[0])
       
   281 		INFO_PRINTF3(_L("gw2.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal);
       
   282 
       
   283 	retVal = gw1.Identifier();
       
   284 	TEST(retVal==(*windowHandles)[1]);
       
   285 	if (retVal!=(*windowHandles)[1])
       
   286 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   287 
       
   288 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]);
       
   289 	TEST(retVal==EWindowGroupHandle2);
       
   290 	if (retVal!=EWindowGroupHandle2)
       
   291 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle2, retVal);
       
   292 
       
   293 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]);
       
   294 	TEST(retVal==EWindowGroupHandle1);
       
   295 	if (retVal!=EWindowGroupHandle1)
       
   296 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal);
       
   297 //
       
   298 	retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]);
       
   299 	TEST(retVal==0);
       
   300 	if (retVal!=0)
       
   301 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), 0, retVal);
       
   302 
       
   303 	retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]);
       
   304 	TEST(retVal==0);
       
   305 	if (retVal!=0)
       
   306 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), 0, retVal);
       
   307 
       
   308 //
       
   309 	TThreadId threadId;
       
   310 	TheClient->iWs.GetWindowGroupClientThreadId((*windowHandles)[0],threadId);
       
   311 
       
   312 	TUint64 ret = RThread().Id();
       
   313 	TEST(ret==threadId);
       
   314 	if (ret!=threadId)
       
   315 		INFO_PRINTF3(_L("RThread().Id() return value - Expected: %d, Actual: %d"), (TInt)threadId, (TInt)ret);
       
   316 
       
   317 	TheClient->iWs.GetWindowGroupClientThreadId((*windowHandles)[1],threadId);
       
   318 
       
   319 	TUint64 retVal2 = RThread().Id();
       
   320 	TEST(retVal2==threadId);
       
   321 	if (retVal2!=threadId)
       
   322 		INFO_PRINTF3(_L("RThread().Id() return value - Expected: %d, Actual: %d"), (TInt)threadId, (TInt)retVal2);
       
   323 //
       
   324 	retVal = gw1.OrdinalPosition();
       
   325 	TEST(retVal==1);
       
   326 	if (retVal!=1)
       
   327 		INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal);
       
   328 
       
   329 	retVal = gw2.OrdinalPosition();
       
   330 	TEST(retVal==0);
       
   331 	if (retVal!=0)
       
   332 		INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal);
       
   333 
       
   334 	retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],0);
       
   335 	TEST(retVal==KErrNone);
       
   336 	if (retVal!=KErrNone)
       
   337 		INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],0) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   338 
       
   339 	retVal = gw1.OrdinalPosition();
       
   340 	TEST(retVal==0);
       
   341 	if (retVal!=0)
       
   342 		INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal);
       
   343 
       
   344 	retVal = gw2.OrdinalPosition();
       
   345 	TEST(retVal==1);
       
   346 	if (retVal!=1)
       
   347 		INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal);
       
   348 //
       
   349 	retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],1);
       
   350 	TEST(retVal==KErrNone);
       
   351 	if (retVal!=KErrNone)
       
   352 		INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[1],1) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   353 
       
   354 	retVal = gw1.OrdinalPosition();
       
   355 	TEST(retVal==1);
       
   356 	if (retVal!=1)
       
   357 		INFO_PRINTF3(_L("gw1.OrdinalPosition() return value - Expected: %d, Actual: %d"), 1, retVal);
       
   358 
       
   359 	retVal = gw2.OrdinalPosition();
       
   360 	TEST(retVal==0);
       
   361 	if (retVal!=0)
       
   362 		INFO_PRINTF3(_L("gw2.OrdinalPosition() return value - Expected: %d, Actual: %d"), 0, retVal);
       
   363 
       
   364 	retVal = TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],1);
       
   365 	TEST(retVal==KErrNone);
       
   366 	if (retVal!=KErrNone)
       
   367 		INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],1) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
   368 
       
   369 	GetGwListL(0, windowHandles);
       
   370 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]);
       
   371 	TEST(retVal==EWindowGroupHandle1);
       
   372 	if (retVal!=EWindowGroupHandle1)
       
   373 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal);
       
   374 
       
   375 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]);
       
   376 	TEST(retVal==EWindowGroupHandle2);
       
   377 	if (retVal!=EWindowGroupHandle2)
       
   378 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle2, retVal);
       
   379 //
       
   380 	RWindowGroup gw3(ws2);
       
   381 	User::LeaveIfError(gw3.Construct(EWindowGroupHandle3));
       
   382 	gw1.SetOrdinalPosition(0,100000);	// Assume nothing else in the system is higher, else test will fail
       
   383 	gw3.SetOrdinalPosition(0,100000);
       
   384 	ws1.Flush();
       
   385 	ws2.Flush();
       
   386 //
       
   387 	GetGwListL(100000, windowHandles);
       
   388 	retVal = windowHandles->Count();
       
   389 	TEST(retVal==2);
       
   390 	if (retVal!=2)
       
   391 		INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), 2, retVal);
       
   392 
       
   393 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]);
       
   394 	TEST(retVal==EWindowGroupHandle3);
       
   395 	if (retVal!=EWindowGroupHandle3)
       
   396 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle3, retVal);
       
   397 
       
   398 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]);
       
   399 	TEST(retVal==EWindowGroupHandle1);
       
   400 	if (retVal!=EWindowGroupHandle1)
       
   401 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal);
       
   402 
       
   403 //
       
   404 	retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]);
       
   405 	TEST(retVal==100000);
       
   406 	if (retVal!=100000)
       
   407 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), 100000, retVal);
       
   408 
       
   409 	retVal = TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]);
       
   410 	TEST(retVal==100000);
       
   411 	if (retVal!=100000)
       
   412 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupOrdinalPriority((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), 100000, retVal);
       
   413 //
       
   414 	GetGwListL(-12453, windowHandles);	// Test 0 count, Assumes no window with priority
       
   415 	retVal = windowHandles->Count();
       
   416 	TEST(retVal==0);
       
   417 	if (retVal!=0)
       
   418 		INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), 0, retVal);
       
   419 
       
   420 //
       
   421 	GetGwListL(windowHandles, iTest->iScreenNumber);
       
   422 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]);
       
   423 	TEST(retVal==EWindowGroupHandle3);
       
   424 	if (retVal!=EWindowGroupHandle3)
       
   425 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[0]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle3, retVal);
       
   426 
       
   427 	retVal = TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]);
       
   428 	TEST(retVal==EWindowGroupHandle1);
       
   429 	if (retVal!=EWindowGroupHandle1)
       
   430 		INFO_PRINTF3(_L("TheClient->iWs.GetWindowGroupHandle((*windowHandles)[1]) return value - Expected: %d, Actual: %d"), EWindowGroupHandle1, retVal);
       
   431 //
       
   432 // Check passing bad identifiers
       
   433 //
       
   434 	retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(-1,0);
       
   435 	TEST(retVal==KErrNotFound);
       
   436 	if (retVal!=KErrNotFound)
       
   437 		INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(-1,0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   438 
       
   439 	retVal = TheClient->iWs.GetWindowGroupHandle(-3);
       
   440 	TEST(retVal==KErrNotFound);
       
   441 	if (retVal!=KErrNotFound)
       
   442 		INFO_PRINTF3(_L("TTheClient->iWs.GetWindowGroupHandle(-3) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   443 
       
   444 //
       
   445 	gw1.Close();
       
   446 	gw2.Close();
       
   447 	gw3.Close();
       
   448 	
       
   449 	CleanupStack::PopAndDestroy(5, windowHandles);
       
   450 	}
       
   451 
       
   452 void CTGwHandle::OwnerToForegroundL()
       
   453 	{
       
   454 	enum {EWindowGroupHandle1=234567};
       
   455 	enum {EWindowGroupHandle2a=666666};
       
   456 	enum {EWindowGroupHandle2b=666667};
       
   457 //
       
   458 	CArrayFixFlat<TInt> *windowHandles=new(ELeave) CArrayFixFlat<TInt>(5);
       
   459 	CleanupStack::PushL(windowHandles);
       
   460 	GetGwListL(0, windowHandles);
       
   461 	TInt oldForeground=(*windowHandles)[0];
       
   462 //
       
   463 	RWsSession ws1;
       
   464 	User::LeaveIfError(ws1.Connect());
       
   465 	CleanupClosePushL(ws1);
       
   466 
       
   467 	// assign to the correct screen
       
   468 	CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1);
       
   469 	CleanupStack::PushL(screen1);
       
   470 	User::LeaveIfError(screen1->Construct(iTest->iScreenNumber));
       
   471 
       
   472 	RWindowGroup gw1(ws1);
       
   473 	User::LeaveIfError(gw1.Construct(EWindowGroupHandle1));
       
   474 	CleanupClosePushL(gw1);
       
   475 	RWsSession ws2;
       
   476 	User::LeaveIfError(ws2.Connect());
       
   477 	CleanupClosePushL(ws2);
       
   478 
       
   479 	// assign to the correct screen
       
   480 	CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2);
       
   481 	CleanupStack::PushL(screen2);
       
   482 	User::LeaveIfError(screen2->Construct(iTest->iScreenNumber));
       
   483 
       
   484 	RWindowGroup gw2a(ws2);
       
   485 	User::LeaveIfError(gw2a.Construct(EWindowGroupHandle2a));
       
   486 	CleanupClosePushL(gw2a);
       
   487 	RWindowGroup gw2b(ws2);
       
   488 	User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b));
       
   489 	CleanupClosePushL(gw2b);
       
   490 	gw1.SetOrdinalPosition(1);
       
   491 //
       
   492 // Turn auto flushing on as we're using multiple connections and it would be easy to forget to flush one
       
   493 //
       
   494 	ws1.SetAutoFlush(ETrue);
       
   495 	ws2.SetAutoFlush(ETrue);
       
   496 	TheClient->iWs.SetAutoFlush(ETrue);
       
   497 //
       
   498 	GetGwListL(0, windowHandles);
       
   499 //
       
   500 	TInt  retVal = gw2b.Identifier();
       
   501 	TEST(retVal==(*windowHandles)[0]);
       
   502 	if (retVal!=(*windowHandles)[0])
       
   503 		INFO_PRINTF3(_L("gw2b.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal);
       
   504 
       
   505 	retVal = gw1.Identifier();
       
   506 	TEST(retVal==(*windowHandles)[1]);
       
   507 	if (retVal!=(*windowHandles)[1])
       
   508 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   509 
       
   510 	retVal = gw2a.Identifier();
       
   511 	TEST(retVal==(*windowHandles)[2]);
       
   512 	if (retVal!=(*windowHandles)[2])
       
   513 		INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal);
       
   514 
       
   515 	retVal = oldForeground;
       
   516 	TEST(retVal==(*windowHandles)[3]);
       
   517 	if (retVal!=(*windowHandles)[3])
       
   518 		INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[3], oldForeground);
       
   519 //
       
   520 	CleanupStack::PopAndDestroy(&gw2b);
       
   521 	GetGwListL(0, windowHandles);
       
   522 
       
   523 	retVal = gw2a.Identifier();
       
   524 	TEST(retVal==(*windowHandles)[0]);
       
   525 	if (retVal!=(*windowHandles)[0])
       
   526 		INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal);
       
   527 	// Check 2a jumped over 1 in the ordinal list
       
   528 
       
   529 	retVal = gw1.Identifier();
       
   530 	TEST(retVal==(*windowHandles)[1]);
       
   531 	if (retVal!=(*windowHandles)[1])
       
   532 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   533 
       
   534 	retVal = oldForeground;
       
   535 	TEST(retVal==(*windowHandles)[2]);
       
   536 	if (retVal!=(*windowHandles)[2])
       
   537 		INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[2], oldForeground);
       
   538 
       
   539 //
       
   540 	User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b));
       
   541 	CleanupClosePushL(gw2b);
       
   542 	gw2b.SetOwningWindowGroup(oldForeground);
       
   543 	CleanupStack::PopAndDestroy(&gw2b);
       
   544 	GetGwListL(0, windowHandles);
       
   545 	retVal = oldForeground;
       
   546 	TEST(retVal==(*windowHandles)[0]);
       
   547 	if (retVal!=(*windowHandles)[0])
       
   548 		INFO_PRINTF3(_L("oldForeground - Expected: %d, Actual: %d"), (*windowHandles)[0], oldForeground);
       
   549 	// Check old foreground bought to foreground
       
   550 
       
   551 	retVal = gw2a.Identifier();
       
   552 	TEST(retVal==(*windowHandles)[1]);
       
   553 	if (retVal!=(*windowHandles)[1])
       
   554 		INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   555 
       
   556 	retVal = gw1.Identifier();
       
   557 	TEST(retVal==(*windowHandles)[2]);
       
   558 	if (retVal!=(*windowHandles)[2])
       
   559 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal);
       
   560 
       
   561 	TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],2);
       
   562 //
       
   563 	User::LeaveIfError(gw2b.Construct(EWindowGroupHandle2b));
       
   564 	CleanupClosePushL(gw2b);
       
   565 	gw2b.SetOwningWindowGroup((*windowHandles)[1]);
       
   566 	gw2b.SetOrdinalPosition(KOrdinalPositionSwitchToOwningWindow);	// Should bring 2a to foreground
       
   567 	GetGwListL(0, windowHandles);
       
   568 
       
   569 	retVal = gw2a.Identifier();
       
   570 	TEST(retVal==(*windowHandles)[0]);
       
   571 	if (retVal!=(*windowHandles)[0])
       
   572 		INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal);
       
   573 
       
   574 	retVal = gw2b.Identifier();
       
   575 	TEST(retVal==(*windowHandles)[1]);
       
   576 	if (retVal!=(*windowHandles)[1])
       
   577 		INFO_PRINTF3(_L("gw2b.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   578 
       
   579 	retVal = gw1.Identifier();
       
   580 	TEST(retVal==(*windowHandles)[2]);
       
   581 	if (retVal!=(*windowHandles)[2])
       
   582 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[2], retVal);
       
   583 //
       
   584 	CleanupStack::PopAndDestroy(&gw2b);
       
   585 	GetGwListL(0, windowHandles);
       
   586 	retVal = gw2a.Identifier();
       
   587 	TEST(retVal==(*windowHandles)[0]);
       
   588 	if (retVal!=(*windowHandles)[0])
       
   589 		INFO_PRINTF3(_L("gw2a.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[0], retVal);
       
   590 
       
   591 	retVal = gw1.Identifier();
       
   592 	TEST(retVal==(*windowHandles)[1]);
       
   593 	if (retVal!=(*windowHandles)[1])
       
   594 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   595 //
       
   596 	CleanupStack::PopAndDestroy(&gw2a);		// Should bring shell to foreground
       
   597 	GetGwListL(0, windowHandles);
       
   598 
       
   599 // check whether the shell is on
       
   600 	TThreadId threadId;
       
   601 	ws2.GetWindowGroupClientThreadId((*windowHandles)[0],threadId);
       
   602 	TBool shellRunning=ETrue;
       
   603 
       
   604 	TFullName shellName;
       
   605 	// apply to primary screen only where SHELL is running
       
   606 	TFindThread findThread(iTest->iScreenNumber==KDefaultScreen?_L("WSHELL*::*"):_L("WxSHELL*::*"));
       
   607 	if(findThread.Next(shellName)==KErrNone)
       
   608 		{
       
   609 		RThread shell;
       
   610 		User::LeaveIfError(shell.Open(shellName));
       
   611 		TEST(shell.Id()==threadId);
       
   612 		if (retVal!=(*windowHandles)[1])
       
   613 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[1], retVal);
       
   614 
       
   615 		shell.Close();
       
   616 		}
       
   617 	else
       
   618 		{
       
   619 		shellRunning=EFalse;
       
   620 		}
       
   621 
       
   622 
       
   623 	// Check gw1 second
       
   624 	retVal = gw1.Identifier();
       
   625 	TEST(retVal==(*windowHandles)[shellRunning ? 1 : 0]);
       
   626 	if (retVal!=(*windowHandles)[shellRunning ? 1 : 0])
       
   627 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[shellRunning ? 1 : 0], retVal);
       
   628 
       
   629 	retVal = oldForeground;
       
   630 	TEST(retVal==(*windowHandles)[shellRunning ? 2 : 1]);
       
   631 	if (retVal!=(*windowHandles)[shellRunning ? 2 : 1])
       
   632 		INFO_PRINTF3(_L("gw1.Identifier() return value - Expected: %d, Actual: %d"), (*windowHandles)[shellRunning ? 2 : 1], retVal);
       
   633 	// and oldforeground second
       
   634 
       
   635 //
       
   636 	CleanupStack::PopAndDestroy(5, &ws1);
       
   637 //
       
   638 // Kick shell back into background, 'cause that's where it belongs
       
   639 //
       
   640 	TheClient->iWs.SetWindowGroupOrdinalPosition((*windowHandles)[0],-1);
       
   641 	TheClient->iWs.SetAutoFlush(EFalse);
       
   642 //
       
   643 	CleanupStack::PopAndDestroy(windowHandles);
       
   644 	}
       
   645 
       
   646 void CTGwHandle::FindWindowGroupIdentifierTestL()
       
   647 	{
       
   648 	enum {EWindowGroupHandle1=234567};
       
   649 	enum {EWindowGroupHandle2=666666};
       
   650 	enum {EWindowGroupHandle3=123};
       
   651 	TInt foreground=TheClient->iWs.GetFocusWindowGroup();
       
   652 	RWsSession ws1;
       
   653 	User::LeaveIfError(ws1.Connect());
       
   654 
       
   655 	// assign to the correct screen
       
   656 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1);
       
   657 	CleanupStack::PushL(screen);
       
   658 	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
       
   659 	CleanupStack::Pop(screen);
       
   660 
       
   661 	CleanupClosePushL(ws1);
       
   662 //
       
   663 	RWindowGroup gw1(ws1);
       
   664 	User::LeaveIfError(gw1.Construct(EWindowGroupHandle1));
       
   665 	CleanupClosePushL(gw1);
       
   666 	gw1.SetOwningWindowGroup(foreground);
       
   667 	RWindowGroup gw2(ws1);
       
   668 	User::LeaveIfError(gw2.Construct(EWindowGroupHandle2));
       
   669 	CleanupClosePushL(gw2);
       
   670 	gw1.SetOwningWindowGroup(foreground);
       
   671 	RWindowGroup gw3(ws1);
       
   672 	User::LeaveIfError(gw3.Construct(EWindowGroupHandle3));
       
   673 	CleanupClosePushL(gw3);
       
   674 	gw3.SetOwningWindowGroup(foreground);
       
   675 //
       
   676 	TInt id1=gw1.Identifier();
       
   677 	TInt id2=gw2.Identifier();
       
   678 	TInt id3=gw3.Identifier();
       
   679 //
       
   680 	gw1.SetName(_L("qwerty123abcd"));
       
   681 	gw2.SetName(_L("123"));
       
   682 	gw3.SetName(_L("qqqabcdxxx123"));
       
   683 //
       
   684 	TInt retVal = ws1.FindWindowGroupIdentifier(0,_L("123"),0);
       
   685 	TEST(retVal==id2);
       
   686 	if (retVal!=id2)
       
   687 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(123),0) return value - Expected: %d, Actual: %d"), id2, retVal);
       
   688 
       
   689 //
       
   690 	retVal = ws1.FindWindowGroupIdentifier(0,_L("*123*"),0);
       
   691 	TEST(retVal==id3);
       
   692 	if (retVal!=id3)
       
   693 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*123*),0) return value - Expected: %d, Actual: %d"), id3, retVal);
       
   694 
       
   695 	retVal = ws1.FindWindowGroupIdentifier(id3,_L("*123*"),0);
       
   696 	TEST(retVal==id2);
       
   697 	if (retVal!=id2)
       
   698 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*123*),0) return value - Expected: %d, Actual: %d"), id2, retVal);
       
   699 
       
   700 	retVal = ws1.FindWindowGroupIdentifier(id2,_L("*123*"),0);
       
   701 	TEST(retVal==id1);
       
   702 	if (retVal!=id1)
       
   703 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id2,_L(*123*),0) return value - Expected: %d, Actual: %d"), id1, retVal);
       
   704 
       
   705 //
       
   706 	retVal = ws1.FindWindowGroupIdentifier(0,_L("*abcd*"),0);
       
   707 	TEST(retVal==id3);
       
   708 	if (retVal!=id3)
       
   709 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*abcd*),0) return value - Expected: %d, Actual: %d"), id3, retVal);
       
   710 
       
   711 	retVal = ws1.FindWindowGroupIdentifier(id3,_L("*abcd*"),0);
       
   712 	TEST(retVal==id1);
       
   713 	if (retVal!=id1)
       
   714 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*abcd*),0)return value - Expected: %d, Actual: %d"), id1, retVal);
       
   715 //
       
   716 	retVal = ws1.FindWindowGroupIdentifier(0,_L("*123*"),7);
       
   717 	TEST(retVal==id3);
       
   718 	if (retVal!=id3)
       
   719 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*123*),7)return value - Expected: %d, Actual: %d"), id3, retVal);
       
   720 
       
   721 	retVal = ws1.FindWindowGroupIdentifier(id3,_L("*123*"),7);
       
   722 	TEST(retVal==KErrNotFound);
       
   723 	if (retVal!=KErrNotFound)
       
   724 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id3,_L(*123*),7) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   725 
       
   726 	retVal = ws1.FindWindowGroupIdentifier(0,_L("*abc*"),4);
       
   727 	TEST(retVal==id1);
       
   728 	if (retVal!=id1)
       
   729 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(*abc*),4) return value - Expected: %d, Actual: %d"), id1, retVal);
       
   730 
       
   731 	retVal = ws1.FindWindowGroupIdentifier(id1,_L("*abc*"),4);
       
   732 	TEST(retVal==KErrNotFound);
       
   733 	if (retVal!=KErrNotFound)
       
   734 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(*abc*),4) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   735 
       
   736 	retVal = ws1.FindWindowGroupIdentifier(0,_L("xxx*"),7);
       
   737 	TEST(retVal==id3);
       
   738 	if (retVal!=id3)
       
   739 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(xxx*),7) return value - Expected: %d, Actual: %d"), id3, retVal);
       
   740 
       
   741 	retVal = ws1.FindWindowGroupIdentifier(0,_L("xxx*"),8);
       
   742 	TEST(retVal==KErrNotFound);
       
   743 	if (retVal!=KErrNotFound)
       
   744 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(0,_L(xxx*),8) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   745 //
       
   746 	retVal = ws1.FindWindowGroupIdentifier(id1,_L("12"),0);
       
   747 	TEST(retVal==KErrNotFound);
       
   748 	if (retVal!=KErrNotFound)
       
   749 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(12),0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   750 
       
   751 	retVal = ws1.FindWindowGroupIdentifier(id1,_L("qqq"),0);
       
   752 	TEST(retVal==KErrNotFound);
       
   753 	if (retVal!=KErrNotFound)
       
   754 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(qqq),0) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   755 
       
   756 	retVal = ws1.FindWindowGroupIdentifier(id1,_L("abcd"),3);
       
   757 	TEST(retVal==KErrNotFound);
       
   758 	if (retVal!=KErrNotFound)
       
   759 		INFO_PRINTF3(_L("ws1.FindWindowGroupIdentifier(id1,_L(abcd),3) return value - Expected: %d, Actual: %d"), KErrNotFound, retVal);
       
   760 //
       
   761 	delete screen;
       
   762 	CleanupStack::PopAndDestroy(4, &ws1);
       
   763 	}
       
   764 
       
   765 void CTGwHandle::DefaultOwningWindowL()
       
   766 	{
       
   767 	TInt foreground=TheClient->iWs.GetFocusWindowGroup();
       
   768 	RWsSession ws1;
       
   769 	User::LeaveIfError(ws1.Connect());
       
   770 
       
   771 	// assign to the correct screen
       
   772 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1);
       
   773 	CleanupStack::PushL(screen);
       
   774 	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
       
   775 
       
   776 //
       
   777 	INFO_PRINTF1(_L("DefaultOwningWindow1"));
       
   778 	RWindowGroup gw1(ws1);
       
   779 	User::LeaveIfError(gw1.Construct(1));
       
   780 	gw1.SetOwningWindowGroup(foreground);
       
   781 	RWindowGroup gw2(ws1);
       
   782 	User::LeaveIfError(gw2.Construct(2));
       
   783 	gw2.SetOwningWindowGroup(foreground);
       
   784 	RWindowGroup gw3(ws1);
       
   785 	User::LeaveIfError(gw3.Construct(3));
       
   786 	gw3.SetOwningWindowGroup(foreground);
       
   787 	RWindowGroup gw4(ws1);
       
   788 	User::LeaveIfError(gw4.Construct(4));
       
   789 	gw4.SetOwningWindowGroup(foreground);
       
   790 	INFO_PRINTF1(_L(" Created Group Window"));
       
   791 //
       
   792 	TInt prevOwningGroup=ws1.GetDefaultOwningWindow();
       
   793 	gw1.DefaultOwningWindow();
       
   794 	TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow());
       
   795 	if (gw1.Identifier()!=ws1.GetDefaultOwningWindow())
       
   796 		INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier());
       
   797 
       
   798 	gw2.DefaultOwningWindow();
       
   799 	TEST(gw2.Identifier()==ws1.GetDefaultOwningWindow());
       
   800 	if (gw2.Identifier()!=ws1.GetDefaultOwningWindow())
       
   801 		INFO_PRINTF3(_L("gw2.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw2.Identifier());
       
   802 
       
   803 	gw2.Close();
       
   804 	TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow());
       
   805 	if (gw1.Identifier()!=ws1.GetDefaultOwningWindow())
       
   806 		INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier());
       
   807 
       
   808 	gw3.DefaultOwningWindow();
       
   809 	gw4.DefaultOwningWindow();
       
   810 	gw3.Close();
       
   811 	TEST(gw4.Identifier()==ws1.GetDefaultOwningWindow());
       
   812 	if (gw4.Identifier()!=ws1.GetDefaultOwningWindow())
       
   813 		INFO_PRINTF3(_L("gw4.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw4.Identifier());
       
   814 
       
   815 	gw4.Close();
       
   816 	TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow());
       
   817 	if (gw1.Identifier()!=ws1.GetDefaultOwningWindow())
       
   818 		INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier());
       
   819 
       
   820 	gw1.Close();
       
   821 	TEST(prevOwningGroup==ws1.GetDefaultOwningWindow());
       
   822 	if (prevOwningGroup!=ws1.GetDefaultOwningWindow())
       
   823 		INFO_PRINTF3(_L("prevOwningGroup==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), prevOwningGroup);
       
   824 
       
   825 	INFO_PRINTF1(_L(" Closed Group Window"));
       
   826 
       
   827 	User::LeaveIfError(gw1.Construct(1));
       
   828 	gw1.SetOwningWindowGroup(foreground);
       
   829 	User::LeaveIfError(gw2.Construct(2));
       
   830 	gw2.SetOwningWindowGroup(foreground);
       
   831 	User::LeaveIfError(gw3.Construct(3));
       
   832 	gw3.SetOwningWindowGroup(foreground);
       
   833 	INFO_PRINTF1(_L(" ReCreated Group Window"));
       
   834 	gw1.DefaultOwningWindow();
       
   835 	gw1.DefaultOwningWindow();
       
   836  	gw1.Close();
       
   837 	gw2.DefaultOwningWindow();
       
   838 	gw2.DefaultOwningWindow();
       
   839 	gw3.Close();
       
   840 	gw2.Close();
       
   841 	INFO_PRINTF1(_L(" Re-Closed Group Window"));
       
   842 
       
   843 	User::LeaveIfError(gw1.Construct(1));
       
   844 	gw1.SetOwningWindowGroup(foreground);
       
   845 	User::LeaveIfError(gw2.Construct(2));
       
   846 	gw2.SetOwningWindowGroup(foreground);
       
   847 	User::LeaveIfError(gw3.Construct(3));
       
   848 	gw3.SetOwningWindowGroup(foreground);
       
   849 	User::LeaveIfError(gw4.Construct(4));
       
   850 	gw4.SetOwningWindowGroup(foreground);
       
   851 	INFO_PRINTF1(_L(" ReCreated Group Window Again"));
       
   852 	gw1.DefaultOwningWindow();
       
   853 	gw2.DefaultOwningWindow();
       
   854 	gw1.DefaultOwningWindow();
       
   855  	gw1.Close();
       
   856 	gw2.Close();
       
   857 	gw3.DefaultOwningWindow();
       
   858 	gw4.DefaultOwningWindow();
       
   859 	gw3.DefaultOwningWindow();
       
   860  	gw4.Close();
       
   861 	gw3.Close();
       
   862 	INFO_PRINTF1(_L(" Re-Closed Group Window Again"));
       
   863 
       
   864 	User::LeaveIfError(gw1.Construct(1));
       
   865 	gw1.DefaultOwningWindow();
       
   866 	TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow());
       
   867 	if (gw1.Identifier()!=ws1.GetDefaultOwningWindow())
       
   868 		INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier());
       
   869 
       
   870 	gw1.DefaultOwningWindow();
       
   871 	TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow());
       
   872 	if (gw1.Identifier()!=ws1.GetDefaultOwningWindow())
       
   873 		INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier());
       
   874 
       
   875 	User::LeaveIfError(gw2.Construct(2));
       
   876 	TEST(gw1.Identifier()==ws1.GetDefaultOwningWindow());
       
   877 	if (gw1.Identifier()!=ws1.GetDefaultOwningWindow())
       
   878 		INFO_PRINTF3(_L("gw1.Identifier()==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1.Identifier());
       
   879 
       
   880 	gw2.Close();
       
   881 	gw1.Close();
       
   882 
       
   883 	CleanupStack::PopAndDestroy(screen);
       
   884 	ws1.Close();
       
   885 	}
       
   886 
       
   887 void CTGwHandle::DefaultOwningWindow2L()
       
   888 //This test originally resulted in a crash, while the above test originally resulted in lockups.
       
   889 	{
       
   890 	RWsSession ws1;
       
   891 	User::LeaveIfError(ws1.Connect());
       
   892 
       
   893 	// assign to the correct screen
       
   894 	CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(ws1);
       
   895 	CleanupStack::PushL(screen1);
       
   896 	User::LeaveIfError(screen1->Construct(iTest->iScreenNumber));
       
   897 
       
   898 	RWsSession ws2;
       
   899 	User::LeaveIfError(ws2.Connect());
       
   900 
       
   901 	// assign to the correct screen
       
   902 	CWsScreenDevice* screen2 = new (ELeave) CWsScreenDevice(ws2);
       
   903 	CleanupStack::PushL(screen2);
       
   904 	User::LeaveIfError(screen2->Construct(iTest->iScreenNumber));
       
   905 
       
   906 //
       
   907 	RWindowGroup gw1(ws1);
       
   908 	User::LeaveIfError(gw1.Construct(1));
       
   909 	RWindowGroup gw2(ws2);
       
   910 	User::LeaveIfError(gw2.Construct(2));
       
   911 	RWindowGroup gw3(ws1);
       
   912 	User::LeaveIfError(gw3.Construct(3));
       
   913 //
       
   914 	const TInt gw1Id=gw1.Identifier();
       
   915 	gw1.DefaultOwningWindow();
       
   916 	gw2.DefaultOwningWindow();
       
   917 	/*const TInt gw2Id=*/gw2.Identifier();
       
   918 	gw1.DefaultOwningWindow();
       
   919 	TEST(gw1Id==ws1.GetDefaultOwningWindow());
       
   920 	if (gw1Id!=ws1.GetDefaultOwningWindow())
       
   921 		INFO_PRINTF3(_L("gw1Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1Id);
       
   922 
       
   923 	gw3.DefaultOwningWindow();
       
   924 	gw3.Close();
       
   925 	TEST(gw1Id==ws1.GetDefaultOwningWindow());
       
   926 	if (gw1Id!=ws1.GetDefaultOwningWindow())
       
   927 		INFO_PRINTF3(_L("gw1Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw1Id);
       
   928 
       
   929 	gw1.Close();
       
   930 	TInt gw2Id=gw2.Identifier();
       
   931 	TEST(gw2Id==ws1.GetDefaultOwningWindow());
       
   932 	if (gw2Id!=ws1.GetDefaultOwningWindow())
       
   933 		INFO_PRINTF3(_L("gw2Id==ws1.GetDefaultOwningWindow() - Expected: %d, Actual: %d"), ws1.GetDefaultOwningWindow(), gw2Id);
       
   934 
       
   935 	gw2.SetOrdinalPosition(0);
       
   936 	gw2.Close();
       
   937 	ws2.Flush();
       
   938 	TRawEvent rawEvent;
       
   939 	rawEvent.Set(TRawEvent::EKeyDown,32);
       
   940 	TheClient->iWs.SimulateRawEvent(rawEvent);
       
   941 	TheClient->iWs.Flush();
       
   942 //
       
   943 	CleanupStack::PopAndDestroy(2,screen1);
       
   944 	ws1.Close();
       
   945 	ws2.Close();
       
   946 	}
       
   947 
       
   948 #define FREQ 500
       
   949 void CTGwHandle::IdentifierWrapAroundTestL()
       
   950 	{
       
   951 	TInt report=-1;
       
   952 	RWsSession ws1;
       
   953 	User::LeaveIfError(ws1.Connect());
       
   954 
       
   955 	// assign to the correct screen
       
   956 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1);
       
   957 	CleanupStack::PushL(screen);
       
   958 	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
       
   959 
       
   960 	RWindowGroup gw1(ws1);
       
   961 	User::LeaveIfError(gw1.Construct(1));
       
   962 	gw1.EnableReceiptOfFocus(EFalse);
       
   963 	TInt id1=gw1.Identifier();
       
   964 	RWindowGroup gw2(ws1);
       
   965 	User::LeaveIfError(gw2.Construct(2));
       
   966 	gw2.EnableReceiptOfFocus(EFalse);
       
   967 	TInt id2=gw2.Identifier();
       
   968 	gw2.Close();	// Allow gw2 id to be re-used
       
   969 	TInt id3;
       
   970 
       
   971 	do
       
   972 		{
       
   973 		RWindowGroup gw3(ws1);
       
   974 		User::LeaveIfError(gw3.Construct(2));
       
   975 		gw3.EnableReceiptOfFocus(EFalse);
       
   976 		id3=gw3.Identifier();
       
   977 		if ((id3/FREQ)!=(report/FREQ))	// || id3<=10)
       
   978 			{
       
   979 			report=id3;
       
   980 			iTest->LogMessage(id3);
       
   981 			}
       
   982 		TEST(id3!=id1);	// Check id1 is not re-used as the window hasn't been freed yet
       
   983 		if (id3==id1)
       
   984 			{
       
   985 			_LIT(KErr,"Window Group Id Reused!");
       
   986 			LOG_MESSAGE(KErr);
       
   987 			}
       
   988 		gw3.Close();
       
   989 		} while(id3!=id2);
       
   990 
       
   991 	CleanupStack::PopAndDestroy(screen);
       
   992 	ws1.Close();
       
   993 	}
       
   994 
       
   995 void GwHandleDestroyWindow(TAny* aWindow)
       
   996 	{
       
   997 	static_cast<RWindowTreeNode*>(aWindow)->Destroy();
       
   998 	}
       
   999 
       
  1000 RWindowGroup* CTGwHandle::CreateWindowGroupLC(RWsSession& aWs,TUint32 aClientHandle,TInt aParentId/*=0*/)
       
  1001 	{
       
  1002 	RWindowGroup* gw=new(ELeave) RWindowGroup(aWs);
       
  1003 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,gw));
       
  1004 	if (aParentId>0)
       
  1005 		{
       
  1006 		User::LeaveIfError(gw->ConstructChildApp(aParentId,aClientHandle,EFalse));
       
  1007 		}
       
  1008 	else
       
  1009 		{
       
  1010 		User::LeaveIfError(gw->Construct(aClientHandle,EFalse));
       
  1011 		}
       
  1012 	return gw;
       
  1013 	}
       
  1014 
       
  1015 void CTGwHandle::CreateGroupWindowsLC(RWsSession& aWs)
       
  1016 	{
       
  1017 	for(TInt ii=ENumGroups-1;ii>=0;--ii)
       
  1018 		iGroups[ii]=CreateWindowGroupLC(aWs,ii);
       
  1019 	}
       
  1020 
       
  1021 void CTGwHandle::CreateChainedGroupWindowsLC(RWsSession& aWs,TBool aSecondChain)
       
  1022 	{
       
  1023 	TInt parentId=0;
       
  1024 	for(TInt ii=ENumChained-1;ii>=0;--ii)
       
  1025 		{
       
  1026 		iChained[ii]=CreateWindowGroupLC(aWs,ENumGroups+ii,parentId);
       
  1027 		parentId=iChained[ii]->Identifier();
       
  1028 		}
       
  1029 	if(aSecondChain)
       
  1030 		{
       
  1031 		parentId =0;
       
  1032 		for(TInt ii=ENumChained-1;ii>=0;--ii)
       
  1033 			{
       
  1034 			iChained2[ii]=CreateWindowGroupLC(aWs,ENumGroups+ENumGroups+ii,parentId);
       
  1035 			parentId=iChained2[ii]->Identifier();
       
  1036 			}
       
  1037 		}
       
  1038 	}
       
  1039 
       
  1040 void CTGwHandle::MoveGroups(RWindowGroup** aGroups,TInt aGp,TInt aNum,TInt aPos,TInt aInc/*=2*/)
       
  1041 	{
       
  1042 	TInt ii;
       
  1043 	for(ii=aNum;ii>0;--ii)
       
  1044 		{
       
  1045 		aGroups[aGp]->SetOrdinalPosition(aPos);
       
  1046 		aGp+=(aInc>0?1:-1);
       
  1047 		aPos+=aInc;
       
  1048 		}
       
  1049 	}
       
  1050 
       
  1051 void CTGwHandle::TestGroups(TInt aPos)
       
  1052 	{
       
  1053 	TInt retVal;
       
  1054 	TInt ii = 0;
       
  1055 	for(ii=0;ii<ENumChained;++ii)
       
  1056 		{
       
  1057 		retVal = iChained[ii]->OrdinalPosition();
       
  1058 		TEST(retVal==aPos+ii);
       
  1059 		if (retVal!=aPos+ii)
       
  1060 			INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+ii, retVal);
       
  1061 		}
       
  1062 
       
  1063 	for(ii=0;ii<ENumGroups;++ii)
       
  1064 		{
       
  1065 		retVal = iGroups[ii]->OrdinalPosition();
       
  1066 		TInt ret = (ii<aPos?ii:ii+ENumChained);
       
  1067 		TEST(retVal==ret);
       
  1068 		if (retVal!=ret)
       
  1069 			INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ret, retVal);
       
  1070 		}
       
  1071 	}
       
  1072 
       
  1073 void CTGwHandle::TestGroupsBefore(TInt aPos)
       
  1074 	{
       
  1075 	TInt ii;
       
  1076 	TInt retVal;
       
  1077 	if (aPos>0)
       
  1078 		{
       
  1079 		for (ii=0;ii<aPos;++ii)
       
  1080 			{
       
  1081 			retVal = iGroups[ii]->OrdinalPosition();
       
  1082 			TEST(retVal==ii);
       
  1083 			if (retVal!=ii)
       
  1084 				INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ii, retVal);
       
  1085 			}
       
  1086 		}
       
  1087 	for (ii=0;ii<ENumChained;++ii)
       
  1088 		{
       
  1089 		retVal = iChained[ii]->OrdinalPosition();
       
  1090 		TEST(retVal==aPos+2*ii);
       
  1091 		if (retVal!=aPos+2*ii)
       
  1092 			INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+2*ii, retVal);
       
  1093 		}
       
  1094 	for (ii=0;ii<ENumChained-1;++ii)
       
  1095 		{
       
  1096 		retVal = iGroups[aPos+ii]->OrdinalPosition();
       
  1097 		TEST(retVal==aPos+1+2*ii);
       
  1098 		if (retVal!=aPos+1+2*ii)
       
  1099 			INFO_PRINTF3(_L("iGroups[aPos+ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos+1+2*ii, retVal);
       
  1100 		}
       
  1101 	for (ii=aPos+ENumChained-1;ii<ENumGroups;++ii)
       
  1102 		{
       
  1103 		retVal = iGroups[ii]->OrdinalPosition();
       
  1104 		TEST(retVal==ii+ENumChained);
       
  1105 		if (retVal!=ii+ENumChained)
       
  1106 			INFO_PRINTF3(_L("iGroups[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), ii+ENumChained, retVal);
       
  1107 		}
       
  1108 	}
       
  1109 
       
  1110 void CTGwHandle::WindowGroupChaining()
       
  1111 	{
       
  1112 	RWsSession& ws=TheClient->iWs;
       
  1113 	CreateGroupWindowsLC(ws);
       
  1114 	CreateChainedGroupWindowsLC(ws);
       
  1115 	TestGroups(0);
       
  1116 	TInt start,target,moveGp;
       
  1117 	for(moveGp=0;moveGp<ENumChained;++moveGp)
       
  1118 		{
       
  1119 		for(target=0;target<ENumGroups+1;++target)
       
  1120 			{
       
  1121 			for(start=0;start<ENumGroups-ENumChained+2;++start)
       
  1122 				{
       
  1123 				if (target>start+1)
       
  1124 					MoveGroups(iGroups,target-1,target-start-1,ENumChained+target-1,-1);
       
  1125 				if (target<start && start>0)
       
  1126 					MoveGroups(iGroups,0,start,0,1);
       
  1127 				MoveGroups(iGroups,start,ENumChained-1,start+1);
       
  1128 				TestGroupsBefore(start);
       
  1129 				iChained[moveGp]->SetOrdinalPosition(target+moveGp);
       
  1130 				TestGroups(target);
       
  1131 				}
       
  1132 			}
       
  1133 		iChained[0]->SetOrdinalPosition(0);
       
  1134 		TestGroups(0);
       
  1135 		}
       
  1136 	CleanupStack::PopAndDestroy(ENumGroups+ENumChained,iGroups[ENumGroups-1]);
       
  1137 	}
       
  1138 
       
  1139 void CTGwHandle::WindowGroupChaining2()
       
  1140 	{
       
  1141 	RWsSession& ws=TheClient->iWs;
       
  1142 	RWindowGroup* chain1=CreateWindowGroupLC(ws,1);
       
  1143 	chain1->SetOrdinalPosition(0,1);
       
  1144 	RWindowGroup* chain2=CreateWindowGroupLC(ws,2,chain1->Identifier());
       
  1145 	TInt retVal = chain2->OrdinalPriority();
       
  1146 	TEST(retVal==1);
       
  1147 	if (retVal!=1)
       
  1148 			INFO_PRINTF3(_L("chain2->OrdinalPriority() return value - Expected: %d, Actual: %d"), 1, retVal);
       
  1149 
       
  1150 	chain1->SetOrdinalPosition(0,2);
       
  1151 	retVal = chain2->OrdinalPriority();
       
  1152 	TEST(retVal==2);
       
  1153 	if (retVal!=2)
       
  1154 			INFO_PRINTF3(_L("chain2->OrdinalPriority() return value - Expected: %d, Actual: %d"), 2, retVal);
       
  1155 
       
  1156 	chain2->SetOrdinalPosition(0,3);
       
  1157 	retVal = chain1->OrdinalPriority();
       
  1158 	TEST(retVal==3);
       
  1159 	if (retVal!=3)
       
  1160 			INFO_PRINTF3(_L("chain1->OrdinalPriority() return value - Expected: %d, Actual: %d"), 3, retVal);
       
  1161 
       
  1162 	CleanupStack::PopAndDestroy(2,chain1);
       
  1163 	
       
  1164 	//Test that two different sessions can't chain window-groups without permisson.
       
  1165 	//Both sessions must use the same screen.
       
  1166 	RWsSession ws2;
       
  1167 	User::LeaveIfError(ws2.Connect());
       
  1168 	CleanupClosePushL(ws2);
       
  1169 	chain1=CreateWindowGroupLC(ws2,1);
       
  1170 	TInt id1=chain1->Identifier();
       
  1171 	
       
  1172 	RWsSession ws3;
       
  1173 	User::LeaveIfError(ws3.Connect());
       
  1174 	CleanupClosePushL(ws3);
       
  1175 	RWindowGroup chain(ws3);
       
  1176 	
       
  1177 	RDebug::Print(KPlatsecBegin);
       
  1178 	retVal = chain.ConstructChildApp(id1,2);
       
  1179 	TEST(retVal==KErrPermissionDenied);
       
  1180 	if (retVal!=KErrPermissionDenied)
       
  1181 			INFO_PRINTF3(_L("chain.ConstructChildApp(id1,2) return value - Expected: %d, Actual: %d"), KErrPermissionDenied, retVal);
       
  1182 
       
  1183 	RDebug::Print(KPlatsecEnd);
       
  1184 	chain1->AllowProcessToCreateChildWindowGroups(TUid::Uid(0x10205152));	//Secure ID
       
  1185 	retVal = chain.ConstructChildApp(id1,2);
       
  1186 	TEST(retVal==KErrNone);
       
  1187 	if (retVal!=KErrNone)
       
  1188 			INFO_PRINTF3(_L("chain.ConstructChildApp(id1,2) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
  1189 
       
  1190 	chain.Close();
       
  1191 	CleanupStack::PopAndDestroy(3,&ws2);
       
  1192 	}
       
  1193 
       
  1194 void CTGwHandle::UnchainWindowGroupsL()
       
  1195 	{
       
  1196 	RArray<RWsSession::TWindowGroupChainInfo>* windowHandles=new(ELeave) RArray<RWsSession::TWindowGroupChainInfo>;
       
  1197 	CleanupStack::PushL(windowHandles);
       
  1198 	GetGwListL(0,windowHandles);
       
  1199 	TInt shellWindow=windowHandles->Count();
       
  1200 	//Creating chained window groups.
       
  1201 	CreateChainedGroupWindowsLC(TheClient->iWs);
       
  1202 	GetGwListL(0,windowHandles);
       
  1203 	//Test total window groups in the list
       
  1204 	TInt retVal = windowHandles->Count();
       
  1205 	TEST(retVal==ENumChained+shellWindow);
       
  1206 	if (retVal!=ENumChained+shellWindow)
       
  1207 			INFO_PRINTF3(_L("windowHandles->Count() return value - Expected: %d, Actual: %d"), ENumChained+shellWindow, retVal);
       
  1208 	//Two unchained group windows
       
  1209 
       
  1210 	//Test Parent Id
       
  1211 	TInt parentId=0;
       
  1212 	for(TInt ii=ENumChained-1;ii>=0;ii--)
       
  1213 		{
       
  1214 		RWsSession::TWindowGroupChainInfo window;
       
  1215 		window.iId=iChained[ii]->Identifier();
       
  1216 		TInt loc=windowHandles->Find(window);
       
  1217 		TEST(loc!=KErrNotFound);
       
  1218 		if (loc==KErrNotFound)
       
  1219 			INFO_PRINTF3(_L("windowHandles->Find(window) return value - Expected: %d, Actual: %d"), KErrNotFound, loc);
       
  1220 
       
  1221 		if(loc!=KErrNotFound)
       
  1222 			{
       
  1223 			TEST((*windowHandles)[loc].iParentId==parentId);
       
  1224 			if ((*windowHandles)[loc].iParentId!=parentId)
       
  1225 				INFO_PRINTF3(_L("(*windowHandles)[loc].iParentId==parentId - Expected: %d, Actual: %d"), parentId, (*windowHandles)[loc].iParentId);
       
  1226 
       
  1227 			parentId=window.iId;
       
  1228 			}
       
  1229 		}
       
  1230 	//Test unchaining of chained window groups
       
  1231 	for(TInt count=ENumChained-1;count>=0;count--)
       
  1232 		{
       
  1233 		iChained[count]->Close();
       
  1234 		GetGwListL(0,windowHandles);
       
  1235 		TEST(windowHandles->Count()== count+shellWindow);
       
  1236 		if (windowHandles->Count()!= count+shellWindow)
       
  1237 				INFO_PRINTF3(_L("windowHandles->Count()==count+shellWindow - Expected: %d, Actual: %d"), count+shellWindow, windowHandles->Count());
       
  1238 
       
  1239 		}
       
  1240 	CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]);
       
  1241 
       
  1242 	//delete middle windowgroup of chain which should kill all the child windows
       
  1243 	CreateChainedGroupWindowsLC(TheClient->iWs);
       
  1244 	TInt windowPos=2;
       
  1245 	CleanupStack::Pop(2,iChained[1]);	//Pop first 2 items iChained[0] and iChained[1]
       
  1246 	iChained[windowPos]->Close();//Close the 3rd WindowGroup in the chain.should unchain 4 and 5 window group.
       
  1247 	CleanupStack::PopAndDestroy(iChained[windowPos]);
       
  1248 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1]));
       
  1249 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0]));
       
  1250 	GetGwListL(0,windowHandles);
       
  1251 	retVal = ChainedWindowCount(windowHandles);
       
  1252 	TEST(retVal==ENumChained-windowPos-1);
       
  1253 	if (retVal!=ENumChained-windowPos-1)
       
  1254 				INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-1, retVal);
       
  1255 
       
  1256 //	CleanupStack::PopAndDestroy(ENumChained-1,iChained[ENumChained-1]);
       
  1257 
       
  1258 	windowPos=3;
       
  1259 	CleanupStack::Pop(2,iChained[1]);
       
  1260 	iChained[windowPos]->Close();//Close the 2nd WindowGroup in the chain.
       
  1261 								//should unchain all .
       
  1262 	CleanupStack::PopAndDestroy(iChained[windowPos]);
       
  1263 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1]));
       
  1264 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0]));
       
  1265 	GetGwListL(0,windowHandles);
       
  1266 	retVal = ChainedWindowCount(windowHandles);
       
  1267 	TEST(retVal==ENumChained-windowPos-2);
       
  1268 	if (retVal!=ENumChained-windowPos-2)
       
  1269 				INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-2, retVal);
       
  1270 
       
  1271 	windowPos=4;
       
  1272 	CleanupStack::Pop(2,iChained[1]);
       
  1273 	iChained[windowPos]->Close();//Closing parent window group in chain. There should be no chain
       
  1274 	CleanupStack::PopAndDestroy(iChained[windowPos]);
       
  1275 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[1]));
       
  1276 	CleanupStack::PushL(TCleanupItem(&GwHandleDestroyWindow,iChained[0]));
       
  1277 	GetGwListL(0,windowHandles);
       
  1278 	retVal = ChainedWindowCount(windowHandles);
       
  1279 	TEST(retVal==ENumChained-windowPos-1);
       
  1280 	if (retVal!=ENumChained-windowPos-1)
       
  1281 				INFO_PRINTF3(_L("ChainedWindowCount(windowHandles) return value - Expected: %d, Actual: %d"), ENumChained-windowPos-1, retVal);
       
  1282 
       
  1283 	CleanupStack::PopAndDestroy(ENumChained-3,iChained[ENumChained-4]);
       
  1284 	windowHandles->Close();
       
  1285 	CleanupStack::PopAndDestroy(windowHandles);
       
  1286 	}
       
  1287 
       
  1288 TInt CTGwHandle::ChainedWindowCount(RArray<RWsSession::TWindowGroupChainInfo>* aWindowHandles)
       
  1289 	{
       
  1290 	TInt wndGrpCount=0;
       
  1291 	for(TInt ii=0;ii<aWindowHandles->Count();ii++)
       
  1292 		{
       
  1293 		if((*aWindowHandles)[ii].iParentId!=-1)
       
  1294 			wndGrpCount++;
       
  1295 		}
       
  1296 	return wndGrpCount;
       
  1297 	}
       
  1298 
       
  1299 void CTGwHandle::TestOrdinalPositionL()
       
  1300 	{
       
  1301 	TInt noOfGroupWnds = NumberOfWndGroupsWithZeroPriority(iTest->iScreenNumber);
       
  1302 	//Creating the chained window groups
       
  1303 	CreateChainedGroupWindowsLC(TheClient->iWs);
       
  1304 	TestOrdinalPos(0);
       
  1305 	//Test the ordinal position of all chained windows by setting the WndPos window
       
  1306 	//to chainPos position
       
  1307 	for(TInt wndPos=0;wndPos<ENumChained;wndPos++)
       
  1308 		{
       
  1309 		for(TInt chainPos=0;chainPos<15;chainPos++)
       
  1310 			{
       
  1311 			iChained[wndPos]->SetOrdinalPosition(chainPos);
       
  1312 			TInt dung = chainPos-wndPos;
       
  1313 			if(dung > noOfGroupWnds)
       
  1314 				{
       
  1315 				dung = noOfGroupWnds;
       
  1316 				}
       
  1317 			dung = Max(dung, 0);
       
  1318 			TestOrdinalPos(chainPos - wndPos > noOfGroupWnds ? noOfGroupWnds : Max(chainPos - wndPos, 0));
       
  1319 			}
       
  1320 		}
       
  1321 	//Test for negative ordinal number
       
  1322 	iChained[0]->SetOrdinalPosition(-2);
       
  1323 	TestOrdinalPos(noOfGroupWnds);
       
  1324 	CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]);
       
  1325 	}
       
  1326 
       
  1327 void CTGwHandle::TestOrdinalPositionNoDebugL()
       
  1328 	{
       
  1329 	TInt noOfGroupWnds = NumberOfWndGroupsWithZeroPriority(iTest->iScreenNumber);
       
  1330 	//Creating the chained window groups
       
  1331 	CreateChainedGroupWindowsLC(TheClient->iWs);
       
  1332 	//Test the ordinal position of all chained windows
       
  1333 	TestOrdinalPosNoDebug(0);
       
  1334 	//Test the ordinal position of all chained windows by setting the WndPos window
       
  1335 	//to chainPos position
       
  1336 	for(TInt wndPos=0;wndPos<ENumChained;wndPos++)
       
  1337 		{
       
  1338 		for(TInt chainPos=0;chainPos<15;chainPos++)
       
  1339 			{
       
  1340 			iChained[wndPos]->SetOrdinalPosition(chainPos);
       
  1341 			TestOrdinalPosNoDebug(chainPos - wndPos > noOfGroupWnds ? noOfGroupWnds : Max(chainPos - wndPos, 0));
       
  1342 			}
       
  1343 		}
       
  1344 	//Test for negative ordinal number
       
  1345 	iChained[0]->SetOrdinalPosition(-2);
       
  1346 	TestOrdinalPosNoDebug(noOfGroupWnds);
       
  1347 	CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]);
       
  1348 	}
       
  1349 
       
  1350 void CTGwHandle::TestOrdinalPos(TInt aPos)
       
  1351 	{
       
  1352 	for(TInt ii=0;ii<ENumChained;ii++)
       
  1353 		{
       
  1354 		TInt iCha = iChained[ii]->OrdinalPosition();
       
  1355 		TEST(iCha==aPos++);
       
  1356 		if (iCha!=aPos-1)
       
  1357 			{
       
  1358 			INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos-1, iCha);
       
  1359 			}
       
  1360 		}
       
  1361 	}
       
  1362 
       
  1363 void CTGwHandle::TestOrdinalPosNoDebug(TInt aPos)
       
  1364 	{
       
  1365 	for(TInt ii=0;ii<ENumChained;ii++)
       
  1366 		{
       
  1367 		TInt iCha = iChained[ii]->OrdinalPosition();
       
  1368 		TEST(iCha==aPos++);
       
  1369 		if (iCha!=aPos-1)
       
  1370 			INFO_PRINTF3(_L("iChained[ii]->OrdinalPosition() return value - Expected: %d, Actual: %d"), aPos-1, iCha);
       
  1371 
       
  1372 		}
       
  1373 	}
       
  1374 
       
  1375 void CTGwHandle:: TestclosingclientL()
       
  1376 	{
       
  1377 	RWsSession ws1;
       
  1378 	User::LeaveIfError(ws1.Connect());
       
  1379 	CleanupClosePushL(ws1);
       
  1380 
       
  1381 	// assign to the correct screen
       
  1382 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws1);
       
  1383 	CleanupStack::PushL(screen);
       
  1384 	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
       
  1385 
       
  1386 	// Creating first Window Group
       
  1387 	RWindowGroup gw1(ws1);
       
  1388 	User::LeaveIfError(gw1.Construct(ENullWsHandle));
       
  1389 	ws1.SetWindowGroupOrdinalPosition(gw1.Identifier(),0);
       
  1390 
       
  1391 	// Creating second Window Group
       
  1392 	RWindowGroup gw2(ws1);
       
  1393 	User::LeaveIfError(gw2.Construct(ENullWsHandle));
       
  1394 	gw2.SetOwningWindowGroup(gw1.Identifier());
       
  1395 	gw2.SetOrdinalPosition(1);
       
  1396 	CleanupStack::PopAndDestroy(screen);
       
  1397 	CleanupStack::PopAndDestroy(&ws1);
       
  1398 	}
       
  1399 
       
  1400 void CTGwHandle::TestClearingAndSettingChildGroupsL()
       
  1401 	{
       
  1402 	RArray<RWsSession::TWindowGroupChainInfo> windowHandles;
       
  1403 	CleanupClosePushL(windowHandles);
       
  1404 	//Creating a chain of 5 window groups.
       
  1405 	CreateChainedGroupWindowsLC(TheClient->iWs);
       
  1406 	TInt ret=KErrNone;
       
  1407 	// Want to test clearing and setting of window groups for chain lengths of 5 down to 2
       
  1408 	for(TInt jj=ENumChained-1;jj>0;jj--)
       
  1409 		{
       
  1410 		// For each window group in the chain, test clearing and setting a child group
       
  1411 		for(TInt ii=jj;ii>0;ii--)
       
  1412 			{
       
  1413 			RWsSession::TWindowGroupChainInfo window1;
       
  1414 			window1.iId=iChained[ii]->Identifier();
       
  1415 			GetGwListL(0,&windowHandles);
       
  1416 			TInt loc=windowHandles.Find(window1);
       
  1417 			TEST(loc!=KErrNotFound);
       
  1418 			if(loc!=KErrNotFound)
       
  1419 				{
       
  1420 				RWsSession::TWindowGroupChainInfo window2;
       
  1421 				window2.iId=iChained[ii-1]->Identifier();
       
  1422 				loc = windowHandles.Find(window2);
       
  1423 				TEST(loc!=KErrNotFound);
       
  1424 				// First test that the parent of the next window in the chain is the previous in the chain
       
  1425 				if(loc!=KErrNotFound)
       
  1426 					{
       
  1427 					TEST(windowHandles[loc].iParentId==window1.iId);
       
  1428 					}
       
  1429 				// Then clear and test that the parent of the next window in the chain
       
  1430 				// is no longer the previous window in the chain
       
  1431 				ret=iChained[ii]->ClearChildGroup();
       
  1432 				TEST(ret==KErrNone);
       
  1433 				// Try to clear a child group when it's already cleared - should return KErrArgument
       
  1434 				ret=iChained[ii]->ClearChildGroup();
       
  1435 				TEST(ret==KErrArgument);
       
  1436 				GetGwListL(0,&windowHandles);
       
  1437 				loc = windowHandles.Find(window2);
       
  1438 				TEST(loc!=KErrNotFound);
       
  1439 				// Test that it has no parent (0) or is unchained (-1)
       
  1440 				if(loc!=KErrNotFound)
       
  1441 					{
       
  1442 					if(ii==1) // last in chain therefore unchained, should return -1
       
  1443 						TEST(windowHandles[loc].iParentId==-1);
       
  1444 					else // otherwise should return 0 signifying in a chain but with no parent
       
  1445 						TEST(windowHandles[loc].iParentId==0);
       
  1446 					}
       
  1447 				// Reset the former child group as a child to the current group
       
  1448 				ret=iChained[ii]->SetChildGroup(window2.iId);
       
  1449 				TEST(ret==KErrNone);
       
  1450 				// Test that it has now got it's parent back
       
  1451 				GetGwListL(0,&windowHandles);
       
  1452 				loc = windowHandles.Find(window2);
       
  1453 				TEST(loc!=KErrNotFound);
       
  1454 				if(loc!=KErrNotFound)
       
  1455 					{
       
  1456 					TEST(windowHandles[loc].iParentId==window1.iId);
       
  1457 					}
       
  1458 				}
       
  1459 			}
       
  1460 			// Reduce chain length by 1
       
  1461 			ret=iChained[jj]->ClearChildGroup();
       
  1462 			TEST(ret==KErrNone);
       
  1463 		}
       
  1464 	// Try to clear the child group of a window that's not in a queue - returns KErrArgument
       
  1465 	ret=iChained[0]->ClearChildGroup();
       
  1466 	TEST(ret==KErrArgument);
       
  1467 	// Test calling set on a non-existent window group - fictional id, larger than what exists
       
  1468 	ret=iChained[0]->SetChildGroup(9999);
       
  1469 	TEST(ret==KErrArgument);
       
  1470 	// Cleanup
       
  1471 	CleanupStack::PopAndDestroy(ENumChained,iChained[ENumChained-1]);
       
  1472 	CleanupStack::PopAndDestroy(&windowHandles);
       
  1473 	}
       
  1474 
       
  1475 void CTGwHandle::TestAgainstLoopsWhenAddingChildGroupsL()
       
  1476 	{
       
  1477 	//Creating two chains of 5 window groups.
       
  1478 	CreateChainedGroupWindowsLC(TheClient->iWs,ETrue);
       
  1479 	TInt ret=KErrNone;
       
  1480 	
       
  1481 	//Try to append any of element of this chain to the lastone (itself included)
       
  1482 	//All these attempts should fail (otherwise a infinite loop will be set up)
       
  1483 	for(TInt ii=ENumChained-1;ii>=0;ii--)
       
  1484 		{
       
  1485 		TInt windowId = iChained[ii]->Identifier();
       
  1486 		// Try to append it to the last one
       
  1487 		ret=iChained[0]->SetChildGroup(windowId);
       
  1488 		TEST(ret==KErrArgument);
       
  1489 		if(ret!=KErrArgument)
       
  1490 			{
       
  1491 			_LIT(KLog,"Error: SetChildGroup with a GpWin belonging to the same queue succeeded, return value :%d");
       
  1492 			LOG_MESSAGE2(KLog,ret);
       
  1493 			}
       
  1494 		}
       
  1495 	//Try to append any elements belonging to another chain to the last one of this chain
       
  1496 	//All these trials should fail (otherwise a infinite loop will be set up)
       
  1497 	//Except for the parent of the second chain.
       
  1498 	for(TInt ii=0;ii<ENumChained;ii++)
       
  1499 		{
       
  1500 		TInt windowId = iChained2[ii]->Identifier();
       
  1501 		// Try to append it to the last one
       
  1502 		ret=iChained[0]->SetChildGroup(windowId);
       
  1503 		if(ii != ENumChained-1)
       
  1504 			{
       
  1505 			TEST(ret==KErrArgument);
       
  1506 			if(ret!=KErrArgument)
       
  1507 				{
       
  1508 				_LIT(KLog,"Error: SetChildGroup with a GpWin which already has a parent succeeded, return value :%d");
       
  1509 				LOG_MESSAGE2(KLog,ret);
       
  1510 				}
       
  1511 			iChained[0]->ClearChildGroup();
       
  1512 			}
       
  1513 		else
       
  1514 			{
       
  1515 			TEST(ret==KErrNone);
       
  1516 			if(ret!=KErrNone)
       
  1517 				{
       
  1518 				_LIT(KLog,"Error: SetChildGroup with a GpWin with no parent failed, return value :%d");
       
  1519 				LOG_MESSAGE2(KLog,ret);
       
  1520 				}
       
  1521 			}
       
  1522 		}
       
  1523 	TInt windowId = iChained2[ENumChained-1]->Identifier();
       
  1524 	ret=iChained[ENumChained-1]->SetChildGroup(windowId);
       
  1525 	TEST(ret==KErrArgument);
       
  1526 	if(ret!=KErrArgument)
       
  1527 		{
       
  1528 		_LIT(KLog,"Error: SetChildGroup successful on a GpWin which already has a child, return value :%d");
       
  1529 		LOG_MESSAGE2(KLog,ret);
       
  1530 		}
       
  1531 	//Now take a window group not belonging to any queue
       
  1532 	//just take the parent's chain and pop it 
       
  1533 	//and try to append it to itself
       
  1534 	ret=iChained[ENumChained-1]->ClearChildGroup();
       
  1535 	TEST(ret==KErrNone);
       
  1536 	ret=iChained[ENumChained-1]->SetChildGroup(iChained[ENumChained-1]->Identifier());
       
  1537 	TEST(ret==KErrArgument);
       
  1538 	if(ret!=KErrArgument)
       
  1539 		{
       
  1540 		_LIT(KLog,"Error: Setting GpWin as a child of itself succeeded, return value :%d");
       
  1541 		LOG_MESSAGE2(KLog,ret);
       
  1542 		}
       
  1543     CleanupStack::PopAndDestroy(ENumChained+ENumChained,iChained[ENumChained-1]);
       
  1544 	}
       
  1545 void CTGwHandle::RunTestCaseL(TInt /*aCurTestCase*/)
       
  1546 	{
       
  1547 	_LIT(KTest0,"Window group names");
       
  1548 	_LIT(KTest1,"Window group identifiers");
       
  1549 	_LIT(KTest2,"Owner to foreground");
       
  1550 	_LIT(KTest3,"FindWindowGroupIdentifier test");
       
  1551 	_LIT(KTest4,"IdentifierWrapAround test");
       
  1552 	_LIT(KTest5,"DefaultOwningWindow test");
       
  1553 	_LIT(KTest6,"DefaultOwningWindow2 test");
       
  1554 	_LIT(KTest7,"Window Group Chaining");
       
  1555 	_LIT(KTest8,"Window Group Chaining2");
       
  1556 	_LIT(KTest9,"Unchaining window group");
       
  1557 	_LIT(KTest10,"Ordinal Postion Test");
       
  1558 	_LIT(KTest11,"CrashTest on closing client");
       
  1559 	_LIT(KTest12,"Setting and Clearing Child Groups");
       
  1560 	_LIT(KTest13,"No Infinite Loops in Setting Child Groups");
       
  1561 	((CTGwHandleStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  1562 	switch(++iTest->iState)
       
  1563 		{
       
  1564 /**
       
  1565 
       
  1566   @SYMTestCaseID GRAPHICS-WSERV-0316
       
  1567 
       
  1568   @SYMDEF             DEF081259
       
  1569 
       
  1570   @SYMTestCaseDesc Test setting window group names
       
  1571 
       
  1572   @SYMTestPriority High
       
  1573 
       
  1574   @SYMTestStatus Implemented
       
  1575 
       
  1576   @SYMTestActions Set the name of a window group to different values and check the
       
  1577   					value is set correctly
       
  1578 
       
  1579   @SYMTestExpectedResults The window group name is set correctly
       
  1580 
       
  1581 */
       
  1582 		case 1:
       
  1583 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0316"));
       
  1584 			//iState=9; break;
       
  1585 			iTest->LogSubTest(KTest0);
       
  1586 			GwNamesL();
       
  1587 			break;
       
  1588 /**
       
  1589 
       
  1590   @SYMTestCaseID GRAPHICS-WSERV-0317
       
  1591 
       
  1592   @SYMDEF             DEF081259
       
  1593 
       
  1594   @SYMTestCaseDesc Test setting window group identifiers
       
  1595 
       
  1596   @SYMTestPriority High
       
  1597 
       
  1598   @SYMTestStatus Implemented
       
  1599 
       
  1600   @SYMTestActions Set the identifiers of a window groups. manipulate the window groups and
       
  1601   					check the identifiers remain correct
       
  1602 
       
  1603   @SYMTestExpectedResults The identifiers are correct for each window group after
       
  1604   							manipulation
       
  1605 
       
  1606 */
       
  1607 		case 2:
       
  1608 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0317"));
       
  1609 			iTest->LogSubTest(KTest1);
       
  1610 			GwIdentifierTestL();
       
  1611 			break;
       
  1612 /**
       
  1613 
       
  1614   @SYMTestCaseID GRAPHICS-WSERV-0318
       
  1615 
       
  1616   @SYMDEF             DEF081259
       
  1617 
       
  1618   @SYMTestCaseDesc Test moving different window groups to the foreground and bringing
       
  1619   					back the backgorund
       
  1620 
       
  1621   @SYMTestPriority High
       
  1622 
       
  1623   @SYMTestStatus Implemented
       
  1624 
       
  1625   @SYMTestActions Create some window groups and move them in turn to the foreground before
       
  1626   					restoring the background
       
  1627 
       
  1628   @SYMTestExpectedResults Window groups move to and from the foreground with error
       
  1629 
       
  1630 */
       
  1631 		case 3:
       
  1632 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0318"));
       
  1633 			iTest->LogSubTest(KTest2);
       
  1634 			OwnerToForegroundL();
       
  1635 			break;
       
  1636 /**
       
  1637 
       
  1638   @SYMTestCaseID GRAPHICS-WSERV-0319
       
  1639 
       
  1640   @SYMDEF             DEF081259
       
  1641 
       
  1642   @SYMTestCaseDesc Test returning different window groups identifiers by searching
       
  1643   					on the name
       
  1644 
       
  1645   @SYMTestPriority High
       
  1646 
       
  1647   @SYMTestStatus Implemented
       
  1648 
       
  1649   @SYMTestActions Create some window groups and return their identifiers by searching on
       
  1650   					their names
       
  1651 
       
  1652   @SYMTestExpectedResults The correct identifiers are returned for each name
       
  1653 
       
  1654 */
       
  1655 		case 4:
       
  1656 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0319"));
       
  1657 			iTest->LogSubTest(KTest3);
       
  1658 			FindWindowGroupIdentifierTestL();
       
  1659 			break;
       
  1660 /**
       
  1661 
       
  1662   @SYMTestCaseID GRAPHICS-WSERV-0320
       
  1663 
       
  1664   @SYMDEF             DEF081259
       
  1665 
       
  1666   @SYMTestCaseDesc Test that a windows group identifier is not used twice
       
  1667 
       
  1668   @SYMTestPriority High
       
  1669 
       
  1670   @SYMTestStatus Implemented
       
  1671 
       
  1672   @SYMTestActions Assign a window group identifier to one window group and check
       
  1673   					the same identifier can not be used for a second group
       
  1674 
       
  1675   @SYMTestExpectedResults Window group identifier can not be reused
       
  1676 
       
  1677 */
       
  1678 		case 5:
       
  1679 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0320"));
       
  1680 			iTest->LogSubTest(KTest4);
       
  1681 			IdentifierWrapAroundTestL();
       
  1682 			break;
       
  1683 /**
       
  1684 
       
  1685   @SYMTestCaseID GRAPHICS-WSERV-0321
       
  1686 
       
  1687   @SYMDEF             DEF081259
       
  1688 
       
  1689   @SYMTestCaseDesc Test that the default owning window for window groups is set
       
  1690   					correctly
       
  1691 
       
  1692   @SYMTestPriority High
       
  1693 
       
  1694   @SYMTestStatus Implemented
       
  1695 
       
  1696   @SYMTestActions Set different default owning windows for different window groups.
       
  1697   					Check the windows have been set correctly.
       
  1698 
       
  1699   @SYMTestExpectedResults The default owning windows for the groups are set correctly
       
  1700 
       
  1701 */
       
  1702 		case 6:
       
  1703 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0321"));
       
  1704 			iTest->LogSubTest(KTest5);
       
  1705 			DefaultOwningWindowL();
       
  1706 			break;
       
  1707 /**
       
  1708 
       
  1709   @SYMTestCaseID GRAPHICS-WSERV-0322
       
  1710 
       
  1711   @SYMDEF             DEF081259
       
  1712 
       
  1713   @SYMTestCaseDesc Test that the default owning window for window groups is set
       
  1714   					correctly
       
  1715 
       
  1716   @SYMTestPriority High
       
  1717 
       
  1718   @SYMTestStatus Implemented
       
  1719 
       
  1720   @SYMTestActions Set different default owning windows for different window groups.
       
  1721   					Check the windows have been set correctly.
       
  1722 
       
  1723   @SYMTestExpectedResults The default owning windows for the groups are set correctly
       
  1724 
       
  1725 */
       
  1726 		case 7:
       
  1727 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0322"));
       
  1728 			iTest->LogSubTest(KTest6);
       
  1729 			DefaultOwningWindow2L();
       
  1730 			TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0);
       
  1731 			break;
       
  1732 /**
       
  1733 
       
  1734   @SYMTestCaseID GRAPHICS-WSERV-0323
       
  1735 
       
  1736   @SYMDEF             DEF081259
       
  1737 
       
  1738   @SYMTestCaseDesc Test that window groups can be chained correctly
       
  1739 
       
  1740   @SYMTestPriority High
       
  1741 
       
  1742   @SYMTestStatus Implemented
       
  1743 
       
  1744   @SYMTestActions Create a chain of window groups and check that the chain of groups
       
  1745   					can be manipluated correctly
       
  1746 
       
  1747   @SYMTestExpectedResults The chain can be manipulated correctly
       
  1748 
       
  1749 */
       
  1750 		case 8:
       
  1751 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0323"));
       
  1752 			iTest->LogSubTest(KTest7);
       
  1753 			WindowGroupChaining();
       
  1754 			break;
       
  1755 /**
       
  1756 
       
  1757   @SYMTestCaseID GRAPHICS-WSERV-0324
       
  1758 
       
  1759   @SYMDEF             DEF081259
       
  1760 
       
  1761   @SYMTestCaseDesc Test that window groups can be chained correctly
       
  1762 
       
  1763   @SYMTestPriority High
       
  1764 
       
  1765   @SYMTestStatus Implemented
       
  1766 
       
  1767   @SYMTestActions Create a chain of window groups and check that the chain of groups
       
  1768   					can be manipluated correctly
       
  1769 
       
  1770   @SYMTestExpectedResults The chain can be manipulated correctly
       
  1771 
       
  1772 */
       
  1773 		case 9:
       
  1774 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0324"));
       
  1775 			iTest->LogSubTest(KTest8);
       
  1776 			WindowGroupChaining2();
       
  1777 			break;
       
  1778 /**
       
  1779 
       
  1780   @SYMTestCaseID GRAPHICS-WSERV-0325
       
  1781 
       
  1782   @SYMDEF             DEF081259
       
  1783 
       
  1784   @SYMTestCaseDesc Test that window groups can be unchained correctly
       
  1785 
       
  1786   @SYMTestPriority High
       
  1787 
       
  1788   @SYMTestStatus Implemented
       
  1789 
       
  1790   @SYMTestActions Create chains of window groups and check that the window groups can be
       
  1791   					unchained correctly
       
  1792 
       
  1793   @SYMTestExpectedResults The chain can be unchained correctly
       
  1794 
       
  1795 */
       
  1796 		case 10:
       
  1797 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0325"));
       
  1798 			iTest->LogSubTest(KTest9);
       
  1799 			UnchainWindowGroupsL();
       
  1800 			break;
       
  1801 /**
       
  1802 
       
  1803   @SYMTestCaseID GRAPHICS-WSERV-0326
       
  1804 
       
  1805   @SYMDEF             DEF081259
       
  1806 
       
  1807   @SYMTestCaseDesc Test the ordinal position of chained window groups
       
  1808 
       
  1809   @SYMTestPriority High
       
  1810 
       
  1811   @SYMTestStatus Implemented
       
  1812 
       
  1813   @SYMTestActions Create chains of window groups and check their ordinal position is correct
       
  1814   					for different scenarios
       
  1815 
       
  1816   @SYMTestExpectedResults Ordinal position of chained window group is correct
       
  1817 
       
  1818 */
       
  1819 		case 11:
       
  1820 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0326"));
       
  1821 			iTest->LogSubTest(KTest10);
       
  1822 			TestOrdinalPositionL();
       
  1823 			break;
       
  1824 		case 12:
       
  1825 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0326"));
       
  1826 			iTest->LogSubTest(KTest10);
       
  1827 			TestOrdinalPositionNoDebugL();
       
  1828 			break;
       
  1829 /**
       
  1830 
       
  1831   @SYMTestCaseID GRAPHICS-WSERV-0327
       
  1832 
       
  1833   @SYMDEF             DEF081259
       
  1834 
       
  1835   @SYMTestCaseDesc Test that window groups are dealt with correctly if their client is closed
       
  1836 
       
  1837   @SYMTestPriority High
       
  1838 
       
  1839   @SYMTestStatus Implemented
       
  1840 
       
  1841   @SYMTestActions Create window groups and then close there client.
       
  1842 
       
  1843   @SYMTestExpectedResults The window groups of the closed client are handled without error
       
  1844 
       
  1845 */
       
  1846 		case 13:
       
  1847 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327"));
       
  1848 			iTest->LogSubTest(KTest11);
       
  1849 			TestclosingclientL();
       
  1850 			break;
       
  1851 		case 14:
       
  1852 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327"));
       
  1853 			iTest->LogSubTest(KTest12);
       
  1854 			TestClearingAndSettingChildGroupsL();
       
  1855 			break;
       
  1856 		case 15:
       
  1857 			((CTGwHandleStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0327"));
       
  1858 			iTest->LogSubTest(KTest13);
       
  1859 			TestAgainstLoopsWhenAddingChildGroupsL();
       
  1860 			break;
       
  1861 		default:
       
  1862 			((CTGwHandleStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1863 			((CTGwHandleStep*)iStep)->CloseTMSGraphicsStep();
       
  1864 			TestComplete();
       
  1865 			break;
       
  1866 		}
       
  1867 	((CTGwHandleStep*)iStep)->RecordTestResultL();
       
  1868 	}
       
  1869 
       
  1870 __WS_CONSTRUCT_STEP__(GwHandle)