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