|
1 /* |
|
2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Base class for all test cases class member functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "SizeTests.h" |
|
20 |
|
21 // ============================ MEMBER FUNCTIONS =============================== |
|
22 |
|
23 CSizeTests* CSizeTests::NewL( CStifLogger* aLog ) |
|
24 { |
|
25 CSizeTests* self = new(ELeave) CSizeTests( aLog ); |
|
26 CleanupStack::PushL( self ); |
|
27 self->ConstructL(); |
|
28 CleanupStack::Pop( self ); |
|
29 return self; |
|
30 } |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // Constructor |
|
34 // ----------------------------------------------------------------------------- |
|
35 CSizeTests::CSizeTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // Destructor |
|
41 // ----------------------------------------------------------------------------- |
|
42 CSizeTests::~CSizeTests() |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // 2nd phase constructor |
|
48 // ----------------------------------------------------------------------------- |
|
49 void CSizeTests::ConstructL() |
|
50 { |
|
51 CAsyncTestCaseBase::ConstructL(); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // ExecuteL : start executing the test case |
|
56 // ----------------------------------------------------------------------------- |
|
57 TBool CSizeTests::ExecuteL() |
|
58 { |
|
59 LogHeader( _L("Size") ); |
|
60 |
|
61 CMsgStoreAccount* account = CMsgStoreAccount::NewLC( 1234, KNullDesC ); //+1 |
|
62 CMsgStoreMailBox* mailBox = iMsgStore->CreateAccountL( *account ); |
|
63 CleanupStack::PushL( mailBox ); //+2 |
|
64 |
|
65 CMsgStorePropertyContainer* bigProperties = CMsgStorePropertyContainer::NewL(); |
|
66 CleanupStack::PushL( bigProperties ); //+3 |
|
67 |
|
68 TBuf8<1000> buf; |
|
69 buf.Fill( 'X', 1000 ); |
|
70 |
|
71 // 100K properties |
|
72 for( TInt i = 0; i < 100; i++ ) |
|
73 { |
|
74 TBuf8<20> propertyName; |
|
75 propertyName.Format( _L8("property%i"), &propertyName ); |
|
76 |
|
77 bigProperties->AddPropertyL( propertyName, buf ); |
|
78 } |
|
79 |
|
80 iLog->Log( _L("Case %d: Create a folder with big properties"), iCaseId++ ); |
|
81 |
|
82 |
|
83 |
|
84 TMsgStoreId folderId = mailBox->CreateFolderL( mailBox->Id(), *bigProperties ); |
|
85 |
|
86 CMsgStoreFolder* folder = mailBox->FolderL( folderId ); |
|
87 ComparePropertiesL( *folder, *bigProperties ); |
|
88 delete folder; |
|
89 |
|
90 RPointerArray<CMsgStoreFolder> folders; |
|
91 mailBox->FoldersL( folders ); |
|
92 ComparePropertiesL( *folders[folders.Count()-1], *bigProperties ); |
|
93 folders.ResetAndDestroy(); |
|
94 |
|
95 iLog->Log( _L("Case %d: Create a message with big properties"), iCaseId++ ); |
|
96 |
|
97 CMsgStoreMessage* message = mailBox->CreateMessageL( folderId, *bigProperties ); |
|
98 CleanupStack::PushL( message ); //+4 |
|
99 message->CommitL(); |
|
100 |
|
101 CMsgStoreMessage* message2 = mailBox->FetchMessageL( message->Id(), folderId ); |
|
102 ComparePropertiesL( *message2, *bigProperties ); |
|
103 delete message2; |
|
104 |
|
105 iLog->Log( _L("Case %d: Create an attachment with big properties"), iCaseId++ ); |
|
106 |
|
107 CMsgStoreMessagePart* attachment = message->AddChildPartL( *bigProperties ); |
|
108 CleanupStack::PushL( attachment ); //+5 |
|
109 |
|
110 CMsgStoreMessagePart* attachment2 = message->AddChildPartL( *bigProperties ); |
|
111 ComparePropertiesL( *attachment2, *bigProperties ); |
|
112 delete attachment2; |
|
113 |
|
114 RPointerArray<CMsgStoreMessagePart> attachments; |
|
115 message->ChildPartsL( attachments ); |
|
116 ComparePropertiesL( *attachments[0], *bigProperties ); |
|
117 attachments.ResetAndDestroy(); |
|
118 |
|
119 iLog->Log( _L("Case %d: Add large content to message with Appends"), iCaseId++ ); |
|
120 |
|
121 buf.Fill( 'C', 1000 ); |
|
122 for( TInt i = 0; i < 100; i++ ) |
|
123 { |
|
124 message->AppendToContentL( buf ); |
|
125 } // end for |
|
126 |
|
127 buf.Copy( _L8("D") ); |
|
128 message->AppendToContentL( buf ); |
|
129 |
|
130 iLog->Log( _L("Case %d: Fetch large content to buffer"), iCaseId++ ); |
|
131 |
|
132 RBuf8 heapBuf; |
|
133 heapBuf.CleanupClosePushL(); //+6 |
|
134 heapBuf.CreateL( 100002 ); |
|
135 |
|
136 message->FetchContentToBufferL( heapBuf ); |
|
137 |
|
138 CheckCondition( _L( "content OK"), heapBuf.Length() == 100001 && heapBuf[0] == 'C' && |
|
139 heapBuf[99999] == 'C' && heapBuf[100000] == 'D' ); |
|
140 |
|
141 iLog->Log( _L("Case %d: Fetch large content to file"), iCaseId++ ); |
|
142 |
|
143 _LIT( KFilename, "c:\\content_test.txt" ); |
|
144 message->FetchContentToFileL( KFilename ); |
|
145 |
|
146 iLog->Log( _L("Case %d: Add large content to attachment with file"), iCaseId++ ); |
|
147 |
|
148 attachment->ReplaceContentWithFileL( KFilename ); |
|
149 |
|
150 iLog->Log( _L("Case %d: Fetch large content to buffer"), iCaseId++ ); |
|
151 |
|
152 heapBuf.FillZ(); |
|
153 |
|
154 message->FetchContentToBufferL( heapBuf ); |
|
155 |
|
156 CheckCondition( _L( "content OK"), heapBuf.Length() == 100001 && heapBuf[0] == 'C' && |
|
157 heapBuf[99999] == 'C' && heapBuf[100000] == 'D' ); |
|
158 |
|
159 |
|
160 CleanupStack::PopAndDestroy(6); |
|
161 |
|
162 //we are done |
|
163 return ETrue; |
|
164 } |
|
165 |
|
166 |
|
167 // End of File |