sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
#include <f32file.h>
|
sl@0
|
22 |
#include <charconv.h>
|
sl@0
|
23 |
#include "t_imap.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#define test(cond) \
|
sl@0
|
27 |
{ \
|
sl@0
|
28 |
TBool __bb = (cond); \
|
sl@0
|
29 |
TEST(__bb); \
|
sl@0
|
30 |
if (!__bb) \
|
sl@0
|
31 |
{ \
|
sl@0
|
32 |
ERR_PRINTF1(_L("ERROR: Test Failed")); \
|
sl@0
|
33 |
User::Leave(1); \
|
sl@0
|
34 |
} \
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
39 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
40 |
/**
|
sl@0
|
41 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0574
|
sl@0
|
42 |
@SYMTestCaseDesc Tests for converting to Unicode from UTF- 7, from UTF-7 to Unicode
|
sl@0
|
43 |
@SYMTestPriority Medium
|
sl@0
|
44 |
@SYMTestActions Tests for CCnvCharacterSetConverter::ConvertToUnicode(),
|
sl@0
|
45 |
CCnvCharacterSetConverter::ConvertFromUnicode() function
|
sl@0
|
46 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
47 |
@SYMREQ REQ0000
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
void CT_IMAP::TestIMAP()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
RFs fileServerSession;
|
sl@0
|
52 |
CleanupClosePushL(fileServerSession);
|
sl@0
|
53 |
User::LeaveIfError(fileServerSession.Connect());
|
sl@0
|
54 |
CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
|
sl@0
|
55 |
TInt state=CCnvCharacterSetConverter::KStateDefault;
|
sl@0
|
56 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0574 Testing IMAP UTF-7 "));
|
sl@0
|
57 |
test(characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierImapUtf7, fileServerSession)==CCnvCharacterSetConverter::EAvailable);
|
sl@0
|
58 |
TBuf16<256> originalUnicode;
|
sl@0
|
59 |
TBuf8<256> generatedUtf7;
|
sl@0
|
60 |
TBuf16<256> generatedUnicode;
|
sl@0
|
61 |
//
|
sl@0
|
62 |
INFO_PRINTF1(_L("Empty descriptor"));
|
sl@0
|
63 |
originalUnicode=_L16("");
|
sl@0
|
64 |
test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0);
|
sl@0
|
65 |
test(generatedUtf7==_L8(""));
|
sl@0
|
66 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
67 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
68 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
69 |
INFO_PRINTF1(_L("Characters \" +&-~\\\""));
|
sl@0
|
70 |
originalUnicode=_L16(" +&-~\\");
|
sl@0
|
71 |
test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0);
|
sl@0
|
72 |
test(generatedUtf7==_L8(" +&--~\\"));
|
sl@0
|
73 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
74 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
75 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
76 |
INFO_PRINTF1(_L("Example quoted in RFC 2060 (Section 5.1.3)"));
|
sl@0
|
77 |
originalUnicode.Format(_L16("~peter/mail/%c%c%c/%c%c"), 0x65e5, 0x672c, 0x8a9e, 0x53f0, 0x5317);
|
sl@0
|
78 |
test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0);
|
sl@0
|
79 |
test(generatedUtf7==_L8("~peter/mail/&ZeVnLIqe-/&U,BTFw-"));
|
sl@0
|
80 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
81 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
82 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
83 |
INFO_PRINTF1(_L("Testing fix for defect EDNDSEF-4KMEUH in \"Symbian Defect Tracking v3.0\""));
|
sl@0
|
84 |
originalUnicode.Format(_L16("%c%c%c%c%c%c%c%c%c"), 0x30ad, 0x30e3, 0x30d3, 0x30cd, 0x30c3, 0x30c8, 0x3068, 0x306f, 0xff1f);
|
sl@0
|
85 |
test(characterSetConverter->ConvertFromUnicode(generatedUtf7, originalUnicode)==0);
|
sl@0
|
86 |
test(generatedUtf7==_L8("&MK0w4zDTMM0wwzDIMGgwb,8f-"));
|
sl@0
|
87 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7, state)==0);
|
sl@0
|
88 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
89 |
test(generatedUnicode==originalUnicode);
|
sl@0
|
90 |
TBuf8<0x14> generatedUtf7_0x14;
|
sl@0
|
91 |
test(characterSetConverter->ConvertFromUnicode(generatedUtf7_0x14, originalUnicode)==3);
|
sl@0
|
92 |
test(generatedUtf7_0x14==_L8("&MK0w4zDTMM0wwzDI-"));
|
sl@0
|
93 |
test(characterSetConverter->ConvertToUnicode(generatedUnicode, generatedUtf7_0x14, state)==0);
|
sl@0
|
94 |
test(state==CCnvCharacterSetConverter::KStateDefault);
|
sl@0
|
95 |
test(generatedUnicode==originalUnicode.Left(6));
|
sl@0
|
96 |
CleanupStack::PopAndDestroy(2); // characterSetConverter and fileServerSession
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
CT_IMAP::CT_IMAP()
|
sl@0
|
100 |
{
|
sl@0
|
101 |
SetTestStepName(KTestStep_T_IMAP);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
TVerdict CT_IMAP::doTestStepL()
|
sl@0
|
105 |
{
|
sl@0
|
106 |
SetTestStepResult(EFail);
|
sl@0
|
107 |
|
sl@0
|
108 |
__UHEAP_MARK;
|
sl@0
|
109 |
|
sl@0
|
110 |
TRAPD(error1, TestIMAP());
|
sl@0
|
111 |
|
sl@0
|
112 |
__UHEAP_MARKEND;
|
sl@0
|
113 |
|
sl@0
|
114 |
if(error1 == KErrNone )
|
sl@0
|
115 |
{
|
sl@0
|
116 |
SetTestStepResult(EPass);
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
return TestStepResult();
|
sl@0
|
120 |
}
|