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