|
1 // Copyright (c) 2005-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 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 #include <e32svr.h> |
|
22 #include <e32std.h> |
|
23 #include <ecom/ecom.h> |
|
24 #include "TCnfStep.h" |
|
25 |
|
26 void CTCnfStep::ChangeLocaleL(TLanguage aLanguage) |
|
27 { |
|
28 TBuf<50> libraryName; |
|
29 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
30 libraryName.Format(_L("elocl_lan.%03d"), aLanguage); |
|
31 TExtendedLocale myExtendedLocale; |
|
32 TInt err = myExtendedLocale.LoadLocaleAspect(libraryName); |
|
33 TEST(err == KErrNone); |
|
34 User::LeaveIfError(err); |
|
35 err = myExtendedLocale.SaveSystemSettings(); |
|
36 TEST(err == KErrNone); |
|
37 User::LeaveIfError(err); |
|
38 |
|
39 #else |
|
40 libraryName.Format(_L("ELOCL.%02d"), aLanguage); |
|
41 TInt err = UserSvr::ChangeLocale(libraryName); |
|
42 User::LeaveIfError(err); |
|
43 TEST(err == KErrNone); |
|
44 #endif |
|
45 } |
|
46 |
|
47 void CTCnfStep::CreateConv1L() |
|
48 { |
|
49 _LIT(KEnglishabc,"english_abc"); |
|
50 _LIT(KEnglishdef,"english_def"); |
|
51 _LIT(KFrenchabc,"french_abc"); |
|
52 _LIT(KFrenchdef,"french_def"); |
|
53 |
|
54 TInt ret = 0; |
|
55 |
|
56 CMimeInfo* mime = CMimeInfo::NewLC(mimeWord_Tcnf); |
|
57 mime->AddLanguageL(TLanguageInfo(ELangEnglish,engword_Tcnf)); |
|
58 mime->AddLanguageL(TLanguageInfo(ELangFrench,frword_Tcnf)); |
|
59 |
|
60 CleanupStack::PopAndDestroy(); //mime |
|
61 |
|
62 _LIT(KPath,"z:\\resource\\convert\\10004c41.RSC"); |
|
63 TFileName resourceFile; |
|
64 resourceFile.Copy(KPath); |
|
65 CCnaConvInfoFileReader2* readConverter=CCnaConvInfoFileReader2::NewL(resourceFile); |
|
66 CleanupStack::PushL(readConverter); |
|
67 readConverter->RestoreL(); |
|
68 CCnaConverter* con2 = readConverter->AtL(0); |
|
69 CleanupStack::PushL(con2); |
|
70 |
|
71 TLanguage originalLanguage = User::Language(); |
|
72 TRAP(ret,ChangeLocaleL(ELangEnglish)); |
|
73 TEST(ret == KErrNone); |
|
74 TEST(User::Language() == ELangEnglish); |
|
75 TDataType dt1(_L8("text/abc")); |
|
76 TTranslation trans = con2->MimeFromText(dt1); |
|
77 TEST(trans == KEnglishabc); |
|
78 |
|
79 TDataType dt2(_L8("text/def")); |
|
80 trans = con2->MimeToText(dt2); |
|
81 TEST(trans == KEnglishdef); |
|
82 |
|
83 TRAP(ret,ChangeLocaleL(ELangFrench)); |
|
84 TEST(ret == KErrNone); |
|
85 TEST(User::Language() == ELangFrench); |
|
86 if(User::Language() == ELangFrench) |
|
87 { |
|
88 trans = con2->MimeFromText(dt1); |
|
89 TEST(trans == KFrenchabc); |
|
90 |
|
91 trans = con2->MimeToText(dt2); |
|
92 TEST(trans == KFrenchdef); |
|
93 } |
|
94 TRAP(ret,ChangeLocaleL(originalLanguage)); |
|
95 TEST(ret == KErrNone); |
|
96 |
|
97 CleanupStack::PopAndDestroy(2); //con2 and readConverter |
|
98 } |
|
99 |
|
100 void CTCnfStep::testConverterCNFWriterL() |
|
101 { |
|
102 TUid uid; |
|
103 uid.iUid=123; |
|
104 CCnaConverter* con1=CCnaConverter::NewL(uid); |
|
105 CleanupStack::PushL(con1); |
|
106 TEST(con1->Uid()==uid); |
|
107 uid.iUid=1234; |
|
108 con1->SetUid(uid); |
|
109 TEST(con1->Uid()==uid); |
|
110 CleanupStack::PopAndDestroy(); //con1 |
|
111 |
|
112 CreateConv1L(); |
|
113 } |
|
114 |
|
115 CTCnfStep::~CTCnfStep() |
|
116 /** |
|
117 Destructor |
|
118 */ |
|
119 { |
|
120 } |
|
121 |
|
122 CTCnfStep::CTCnfStep() |
|
123 /** |
|
124 Constructor |
|
125 */ |
|
126 { |
|
127 // Call base class method to set up the human readable name for logging |
|
128 SetTestStepName(KTCnfStep); |
|
129 } |
|
130 |
|
131 TVerdict CTCnfStep::doTestStepL() |
|
132 { |
|
133 INFO_PRINTF1(_L("Testing the Conarc dll...")); |
|
134 |
|
135 // run the testcode (inside an alloc heaven harness) |
|
136 |
|
137 __UHEAP_MARK; |
|
138 INFO_PRINTF1(_L("About to test the Converter CNF")); |
|
139 |
|
140 mimeWord_Tcnf = TDataType(_L8("mime/msword")); |
|
141 engword_Tcnf = (_L("englishword")); |
|
142 frword_Tcnf = (_L("frenchword")); |
|
143 |
|
144 TRAPD(r,CTCnfStep::testConverterCNFWriterL()); |
|
145 TEST(r==KErrNone); |
|
146 INFO_PRINTF1(_L("test finished\n")); |
|
147 |
|
148 REComSession::FinalClose(); |
|
149 __UHEAP_MARKEND; |
|
150 |
|
151 return TestStepResult(); |
|
152 } |