|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 #include "T_LongSql.h" |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <cntfield.h> |
|
20 |
|
21 RTest TheTest(_L("Building a long SQL query")); |
|
22 |
|
23 // |
|
24 // CSqlSearch class definition |
|
25 // |
|
26 CSqlSearcher::CSqlSearcher() |
|
27 { |
|
28 } |
|
29 |
|
30 CSqlSearcher::~CSqlSearcher() |
|
31 { |
|
32 delete iDb; |
|
33 } |
|
34 |
|
35 void CSqlSearcher::ConstructL() |
|
36 { |
|
37 iDb = CContactDatabase::ReplaceL(); |
|
38 } |
|
39 |
|
40 CSqlSearcher* CSqlSearcher::NewLC() |
|
41 { |
|
42 CSqlSearcher* self = new(ELeave) CSqlSearcher; |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(); |
|
45 return(self); |
|
46 } |
|
47 |
|
48 void CSqlSearcher::IdleFindCallback() |
|
49 { |
|
50 CActiveScheduler::Stop(); |
|
51 } |
|
52 |
|
53 void CSqlSearcher::DoSearchL(const TDesC& aString, TUid aFieldId) |
|
54 { |
|
55 CContactItemFieldDef* fieldsToSearch = new (ELeave) CContactItemFieldDef; |
|
56 CleanupStack::PushL(fieldsToSearch); |
|
57 |
|
58 fieldsToSearch->AppendL(aFieldId); |
|
59 |
|
60 CIdleFinder* idleFinder = iDb->FindAsyncL(aString, fieldsToSearch, this); |
|
61 CleanupStack::PushL(idleFinder); |
|
62 |
|
63 CActiveScheduler::Start(); |
|
64 |
|
65 CleanupStack::PopAndDestroy(idleFinder); |
|
66 |
|
67 CleanupStack::PopAndDestroy(fieldsToSearch); |
|
68 } |
|
69 |
|
70 // |
|
71 // Main test: |
|
72 // |
|
73 |
|
74 static void doMainL() |
|
75 { |
|
76 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
|
77 CleanupStack::PushL(scheduler); |
|
78 CActiveScheduler::Install(scheduler); |
|
79 |
|
80 CSqlSearcher* searcher = CSqlSearcher::NewLC(); |
|
81 HBufC* buff = HBufC::NewLC(1024); |
|
82 TPtr ptr = buff->Des(); |
|
83 |
|
84 TheTest.Next(_L("A very short search string")); |
|
85 |
|
86 ptr.Zero(); |
|
87 ptr.AppendFill(TChar('x'), 3); |
|
88 searcher->DoSearchL(*buff, KUidContactFieldFamilyName); |
|
89 |
|
90 TheTest.Next(_L("A fairly long search string")); |
|
91 |
|
92 ptr.Zero(); |
|
93 ptr.AppendFill(TChar('x'), 233); |
|
94 searcher->DoSearchL(*buff, KUidContactFieldFamilyName); |
|
95 |
|
96 TheTest.Next(_L("A very slightly longer search string")); |
|
97 |
|
98 ptr.Zero(); |
|
99 ptr.AppendFill(TChar('x'), 234); |
|
100 searcher->DoSearchL(*buff, KUidContactFieldFamilyName); |
|
101 |
|
102 TheTest.Next(_L("A very long search string")); |
|
103 |
|
104 ptr.Zero(); |
|
105 ptr.AppendFill(TChar('x'), 600); |
|
106 searcher->DoSearchL(*buff, KUidContactFieldFamilyName); |
|
107 |
|
108 CleanupStack::PopAndDestroy(buff); |
|
109 CleanupStack::PopAndDestroy(searcher); |
|
110 CleanupStack::PopAndDestroy(scheduler); |
|
111 } |
|
112 |
|
113 /** |
|
114 |
|
115 @SYMTestCaseID PIM-T-LONGSQL-0001 |
|
116 |
|
117 */ |
|
118 |
|
119 GLDEF_C TInt E32Main() |
|
120 { |
|
121 __UHEAP_MARK; |
|
122 TheTest.Start(_L("@SYMTESTCaseID:PIM-T-LONGSQL-0001 Initialising")); |
|
123 |
|
124 |
|
125 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
126 |
|
127 TRAPD(error, doMainL()); |
|
128 TheTest(error == KErrNone); |
|
129 |
|
130 // Cleanup & close |
|
131 delete cleanup; |
|
132 |
|
133 TheTest.End(); |
|
134 TheTest.Close(); |
|
135 |
|
136 __UHEAP_MARKEND; |
|
137 return KErrNone; |
|
138 } |