|
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 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include <apgcli.h> |
|
18 #include <ecom/ecom.h> |
|
19 #include <apmrec.h> |
|
20 |
|
21 // Type definitions |
|
22 #define UNUSED_VAR(a) a = a |
|
23 |
|
24 CConsoleBase* console; |
|
25 LOCAL_D RTest test(_L("TEST_RECOGNIZER")); |
|
26 |
|
27 _LIT(KVCalFilePath, "z:\\testfiles\\cTestVcal.vcs"); |
|
28 _LIT8(KDataTypevCalendarPlain,"text/X-vCalendar"); |
|
29 _LIT8(KvCalMagicString,"BEGIN:VCALENDAR"); |
|
30 |
|
31 _LIT(KVCardFilePath, "z:\\testfiles\\cTestVcard.vcf"); |
|
32 _LIT8(KDataTypevCardPlain,"text/X-vCard"); |
|
33 _LIT8(KvCardMagicString,"BEGIN:VCARD"); |
|
34 |
|
35 const TUid KUidVersitRecognizer={0x100047EB}; |
|
36 |
|
37 void doTestL() |
|
38 { |
|
39 // TInt ret; |
|
40 |
|
41 CApaDataRecognizerType* dataRecType = NULL; |
|
42 TUid tempDtorKey = KNullUid; |
|
43 dataRecType = static_cast <CApaDataRecognizerType*>(REComSession::CreateImplementationL(KUidVersitRecognizer, tempDtorKey)); |
|
44 CleanupStack::PushL(dataRecType); |
|
45 |
|
46 _LIT(KSupportedTypes, "Test Supported Types"); |
|
47 |
|
48 test.Next(KSupportedTypes); |
|
49 test(dataRecType->SupportedDataTypeL(0) == TDataType(KDataTypevCardPlain)); |
|
50 test(dataRecType->SupportedDataTypeL(1) == TDataType(KDataTypevCalendarPlain)); |
|
51 |
|
52 _LIT(KRecognisevCal, "Test Recognise vCalendar"); |
|
53 |
|
54 test.Next(KRecognisevCal); |
|
55 TDataRecognitionResult result; |
|
56 result = dataRecType->RecognizeL(KVCalFilePath, KvCalMagicString); |
|
57 test(result.iDataType==TDataType(KDataTypevCalendarPlain)); |
|
58 test(result.iConfidence==CApaDataRecognizerType::ECertain); |
|
59 |
|
60 _LIT(KRecognisevCard, "Test Recognise vCard"); |
|
61 |
|
62 test.Next(KRecognisevCard); |
|
63 result = dataRecType->RecognizeL(KVCardFilePath, KvCardMagicString); |
|
64 test(result.iDataType==TDataType(KDataTypevCardPlain)); |
|
65 test(result.iConfidence==CApaDataRecognizerType::ECertain); |
|
66 |
|
67 CleanupStack::PopAndDestroy(dataRecType); |
|
68 REComSession::DestroyedImplementation(tempDtorKey); |
|
69 REComSession::FinalClose(); |
|
70 } |
|
71 |
|
72 /** |
|
73 @SYMTestCaseID PIM-TESTRECOGNIZER-0001 |
|
74 */ |
|
75 TInt E32Main() |
|
76 { |
|
77 __UHEAP_MARK; |
|
78 test.Start(_L("@SYMTestCaseID PIM-TESTRECOGNIZER-0001 TEST_RECOGNIZER")); |
|
79 test.Title(); |
|
80 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
81 TRAPD(error,doTestL()); |
|
82 UNUSED_VAR(error); //Used to supress build warnings |
|
83 |
|
84 ASSERT(error == KErrNone); |
|
85 delete cleanup; |
|
86 test.End(); |
|
87 test.Close(); |
|
88 __UHEAP_MARKEND; |
|
89 return (KErrNone); |
|
90 } |