199
|
1 |
// Copyright (c) 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 the License "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 |
// e32test\resourceman\t_rescontrolclisync.cpp
|
|
15 |
// TestCase Description:
|
|
16 |
// This test harness is to test the unsafe setup of power request call back object
|
|
17 |
// inside resourcecontrol.cpp. The memeber variable of TPowerRequestCb should not
|
|
18 |
// be corrupted when a second ChangeResourceState is execute during the call back
|
|
19 |
// function is running.
|
|
20 |
//
|
|
21 |
//
|
|
22 |
|
|
23 |
#include <e32test.h>
|
|
24 |
#include <e32hal.h>
|
|
25 |
#include <e32math.h>
|
|
26 |
#include <e32def.h>
|
|
27 |
#include <e32def_private.h>
|
|
28 |
#include "d_rescontrolclisync.h"
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
LOCAL_D RTest test(_L("T_RESCONTROLCLISYNC"));
|
|
33 |
RTestResMan lddChan;
|
|
34 |
RTestResMan lddChan2;
|
|
35 |
|
|
36 |
#define TESTANDCLEAN(x) TestAndClean(x,__LINE__)
|
|
37 |
|
|
38 |
void TestAndClean(TBool aTestValid, TInt aLine)
|
|
39 |
{
|
|
40 |
if(!aTestValid)
|
|
41 |
{
|
|
42 |
lddChan.DeRegisterClient();
|
|
43 |
lddChan2.DeRegisterClient();
|
|
44 |
lddChan.Close();
|
|
45 |
lddChan2.Close();
|
|
46 |
User::FreeLogicalDevice(KLddFileName);
|
|
47 |
User::FreePhysicalDevice(KPddFileName);
|
|
48 |
RDebug::Printf("Test fail at line %d", aLine);
|
|
49 |
test.HandleError(EFalse, aLine, (TText *)__FILE__);
|
|
50 |
}
|
|
51 |
}
|
|
52 |
|
|
53 |
GLDEF_C TInt E32Main()
|
|
54 |
{
|
|
55 |
test.Title();
|
|
56 |
test.Start(_L("Testing Resource Manager...\n"));
|
|
57 |
|
|
58 |
test.Next(_L("Load Physical device"));
|
|
59 |
TInt r = User::LoadPhysicalDevice(KPddFileName);
|
|
60 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
61 |
test.Next(_L("Load Logical Device"));
|
|
62 |
r=User::LoadLogicalDevice(KLddFileName);
|
|
63 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
64 |
test.Next(_L("Open Logical Channel 1"));
|
|
65 |
r = lddChan.Open();
|
|
66 |
test(r==KErrNone);
|
|
67 |
test.Next(_L("Open Logical Channel 2"));
|
|
68 |
r = lddChan2.Open();
|
|
69 |
test(r==KErrNone);
|
|
70 |
|
|
71 |
test.Next(_L("Register client 1"));
|
|
72 |
r = lddChan.RegisterClient();
|
|
73 |
RDebug::Printf("Register client 1 return r = %d", r);
|
|
74 |
TESTANDCLEAN(r==KErrNone);
|
|
75 |
|
|
76 |
test.Next(_L("Register client 2"));
|
|
77 |
r = lddChan2.RegisterClient();
|
|
78 |
RDebug::Printf("Register client 2 return r = %d", r);
|
|
79 |
TESTANDCLEAN(r==KErrNone);
|
|
80 |
|
|
81 |
test.Next(_L("Print resource info"));
|
|
82 |
r = lddChan.PrintResourceInfo();
|
|
83 |
RDebug::Printf("Print resource info return r = %d", r);
|
|
84 |
TESTANDCLEAN(r==KErrNone);
|
|
85 |
|
|
86 |
TRequestStatus RequestStatus;
|
|
87 |
TRequestStatus RequestStatus2;
|
|
88 |
|
|
89 |
test.Next(_L("WaitAndChangeResource"));
|
|
90 |
lddChan.WaitAndChangeResource(RequestStatus);
|
|
91 |
|
|
92 |
test.Next(_L("ChangeResourceAndSignal"));
|
|
93 |
lddChan2.ChangeResourceAndSignal(RequestStatus2);
|
|
94 |
|
|
95 |
User::WaitForRequest(RequestStatus);
|
|
96 |
TESTANDCLEAN(RequestStatus.Int()==KErrNone);
|
|
97 |
User::WaitForRequest(RequestStatus2);
|
|
98 |
TESTANDCLEAN(RequestStatus2.Int()==KErrNone);
|
|
99 |
|
|
100 |
test.Next(_L("De-register client 1"));
|
|
101 |
r = lddChan.DeRegisterClient();
|
|
102 |
test(r==KErrNone);
|
|
103 |
|
|
104 |
test.Next(_L("De-register client 2"));
|
|
105 |
r = lddChan2.DeRegisterClient();
|
|
106 |
test(r==KErrNone);
|
|
107 |
|
|
108 |
test.Printf(_L("Closing the channel\n"));
|
|
109 |
lddChan.Close();
|
|
110 |
lddChan2.Close();
|
|
111 |
test.Printf(_L("Freeing logical device\n"));
|
|
112 |
r = User::FreeLogicalDevice(KLddFileName);
|
|
113 |
test(r==KErrNone);
|
|
114 |
r = User::FreePhysicalDevice(KPddFileName);
|
|
115 |
test(r==KErrNone);
|
|
116 |
test.End();
|
|
117 |
test.Close();
|
|
118 |
return KErrNone;
|
|
119 |
}
|
|
120 |
|