|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // test for DEF043452 Memory leak in ecomserver |
|
15 // This file contains test for DEF043452 Memory leak in ecomserver |
|
16 // |
|
17 // |
|
18 |
|
19 #include <e32test.h> |
|
20 #include <f32file.h> |
|
21 #include <bautils.h> |
|
22 |
|
23 #include "Interface.h" // interface to Plugins |
|
24 #include "RegistryData.h" |
|
25 #include "DefaultResolver.h" |
|
26 #include "EComResolverParams.h" |
|
27 #include "DriveInfo.h" |
|
28 #include "RegistryResolveTransaction.h" |
|
29 |
|
30 LOCAL_D RTest test(_L("t_defaultresolver.exe")); |
|
31 |
|
32 /** |
|
33 @SYMTestCaseID SYSLIB-ECOM-CT-0700 |
|
34 @SYMTestCaseDesc Tests for defect number DEF043452 |
|
35 Tests for memory leak in ecom server |
|
36 @SYMTestPriority High |
|
37 @SYMTestActions Simulates a request to list implementation of unknown interface |
|
38 Checks for any memory leak in the CDefaultResolver class |
|
39 @SYMTestExpectedResults The test must not fail. |
|
40 @SYMREQ REQ0000 |
|
41 */ |
|
42 LOCAL_C void DoTestsL() |
|
43 { |
|
44 __UHEAP_MARK; |
|
45 |
|
46 CRegistryData* rd=NULL; |
|
47 /** CRegistryResolveTransaction */ |
|
48 CRegistryResolveTransaction* registryResolveTransaction = NULL; |
|
49 CDefaultResolver* dr=NULL; |
|
50 |
|
51 RFs TheFs; |
|
52 |
|
53 RImplInfoArray* ifArray=new(ELeave) RImplInfoArray; |
|
54 |
|
55 TEComResolverParams trp; |
|
56 |
|
57 //Connecting to file server |
|
58 TInt error=TheFs.Connect(); |
|
59 test(error==KErrNone); |
|
60 |
|
61 rd=CRegistryData::NewL(TheFs); |
|
62 // Set up client request and extended interfaces |
|
63 TClientRequest clientReq; |
|
64 RArray<TUid> extendedInterfaces; |
|
65 CleanupClosePushL(extendedInterfaces); |
|
66 // construct the registry resolve transaction object here |
|
67 TBool capability= ETrue; |
|
68 registryResolveTransaction = CRegistryResolveTransaction::NewL(*rd,extendedInterfaces,clientReq,capability); |
|
69 CleanupStack::PushL(registryResolveTransaction); |
|
70 |
|
71 dr=CDefaultResolver::NewL(*registryResolveTransaction); |
|
72 |
|
73 //Passing an unknown interface uid |
|
74 TUid ifUid = {0x10009DC3}; |
|
75 |
|
76 const TInt KNoOfFailure=2; |
|
77 //Simulating a request to list implementation of unknown interface |
|
78 //with no memory leak in the CDefaultResolver class |
|
79 for (TInt i=0;i<KNoOfFailure;i++) |
|
80 { |
|
81 TRAPD(err,ifArray=dr->ListAllL(ifUid,trp)); |
|
82 test(err==KEComErrNoInterfaceIdentified); |
|
83 test(ifArray->Count()==0); |
|
84 } |
|
85 |
|
86 CleanupStack::PopAndDestroy(registryResolveTransaction); |
|
87 CleanupStack::PopAndDestroy(&extendedInterfaces); |
|
88 |
|
89 delete ifArray; |
|
90 delete dr; |
|
91 delete rd; |
|
92 |
|
93 // TheFs.Close() is moved here because CRegistryData will |
|
94 // use the file server session to close the RFileReadStream. |
|
95 TheFs.Close(); |
|
96 |
|
97 __UHEAP_MARKEND; |
|
98 |
|
99 } |
|
100 |
|
101 |
|
102 |
|
103 GLDEF_C TInt E32Main() |
|
104 { |
|
105 __UHEAP_MARK; |
|
106 test.Title(); |
|
107 test.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0700 T_DEFAULTRESOLVER tests. ")); |
|
108 |
|
109 // get clean-up stack |
|
110 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
111 |
|
112 //install the scheduler |
|
113 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
114 CActiveScheduler::Install(scheduler); |
|
115 |
|
116 TRAPD(err,DoTestsL()); |
|
117 test(err==KErrNone); |
|
118 delete scheduler; |
|
119 delete cleanup; |
|
120 |
|
121 test.End(); |
|
122 test.Close(); |
|
123 |
|
124 __UHEAP_MARKEND; |
|
125 return(0); |
|
126 } |