First public contribution.
1 // Copyright (c) 2002-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <ecom/ecom.h>
17 #include "../EcomTestUtils/EcomTestUtils.h"
19 #define UNUSED_VAR(a) a = a
21 LOCAL_D RTest TEST(_L("ECom Language Plugin Test"));
24 _LIT(KEComLangPluginDllOnC, "C:\\sys\\bin\\LanguagePlugin.dll");
25 _LIT(KEComLangPluginDllOnZ, "Z:\\RAMOnly\\LanguagePlugin.dll");
27 _LIT(KEComLangPluginRscOnC, "C:\\resource\\plugins\\LanguagePlugin.rsc");
28 _LIT(KEComLangPluginRscOnZ, "Z:\\RAMOnly\\LanguagePlugin.rsc");
30 _LIT(KEComLangPluginRsc1OnC, "C:\\resource\\plugins\\LanguagePlugin.r01");
31 _LIT(KEComLangPluginRsc1OnZ, "Z:\\RAMOnly\\LanguagePlugin.r01");
33 _LIT(KEComLangPluginRsc2OnC, "C:\\resource\\plugins\\LanguagePlugin.r02");
34 _LIT(KEComLangPluginRsc2OnZ, "Z:\\RAMOnly\\LanguagePlugin.r02");
36 _LIT(KEComLangPluginRsc3OnC, "C:\\resource\\plugins\\LanguagePlugin.r03");
37 _LIT(KEComLangPluginRsc3OnZ, "Z:\\RAMOnly\\LanguagePlugin.r03");
39 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
40 // Language files used for locale settings
41 _LIT(KEComEnglishLocale, "elocl.01");
42 _LIT(KEComFrenchLocale, "elocl.02");
43 _LIT(KEComGermanLocale, "elocl.03");
44 _LIT(KEComSpanishLocale, "elocl.04");
46 // refer base/os/kernelhwsrv/kernel/eka/euser/locmapping.cpp
48 _LIT(KEComEnglishLang,"elocl_lan.001");
49 _LIT(KEComFrenchLang,"elocl_lan.002");
50 _LIT(KEComGermanLang,"elocl_lan.003");
51 _LIT(KEComSpanishLang,"elocl_lan.004");
53 _LIT(KEComEnglishReg,"elocl_reg.826");
54 _LIT(KEComFrenchReg,"elocl_reg.250");
55 _LIT(KEComGermanReg,"elocl_reg.276");
56 _LIT(KEComSpanishReg,"elocl_reg.724");
58 _LIT(KEComEnglishColl,"elocl_col.001");
59 _LIT(KEComFrenchColl,"elocl_col.002");
60 _LIT(KEComGermanColl,"elocl_col.003");
61 _LIT(KEComSpanishColl,"elocl_col.001");
64 // Result strings saved in opaque_data of each plugin
65 _LIT8(KEComDefaultResult, "LANGUAGE_RSC");
66 _LIT8(KEComEnglishResult, "LANGUAGE_01");
67 _LIT8(KEComFrenchResult, "LANGUAGE_02");
68 _LIT8(KEComGermanResult, "LANGUAGE_03");
70 // Test data for data driven tests.
71 #define MAX_LANGUAGE_TEST_FILES 5
74 // Source and destination to copy necessary plugins
80 FilesInfo files[MAX_LANGUAGE_TEST_FILES];
81 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
82 // Locale file to load
83 const TDesC* localeFile;
87 const TDesC* collation;
89 // Language downgrade path to set up
90 TLanguage downgradePathSetup[3];
92 // Expected result - opaque_data of retrieved plugin
97 LOCAL_D const TLangTestEntry LangTestData[] =
102 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
103 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
104 {&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
105 {&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
106 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
108 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
115 {ELangEnglish, ELangFrench, ELangGerman},
121 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
122 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
123 {&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
124 {&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
125 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
127 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
134 {ELangFrench, ELangEnglish, ELangGerman},
140 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
141 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
142 {&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
143 {&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
144 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
146 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
153 {ELangGerman, ELangEnglish, ELangFrench},
159 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
160 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
161 {&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
162 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
164 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
171 {ELangEnglish, ELangFrench, ELangGerman},
177 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
178 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
179 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
181 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
188 {ELangEnglish, ELangFrench, ELangGerman},
194 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
195 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
196 {&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
197 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
199 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
206 {ELangSpanish, ELangItalian, ELangGerman},
212 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
213 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
214 {&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
215 {&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
217 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
224 {ELangSpanish, ELangItalian, ELangSwedish},
230 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
231 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
232 {&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
234 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
241 {ELangSpanish, ELangSwedish, ELangItalian},
247 {&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
248 {&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
250 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
257 {ELangItalian, ELangSwedish, ELangSpanish},
262 struct TLangTestEntry2
264 // Locale file to load
265 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
266 // Locale file to load
267 const TDesC* localeFile;
271 const TDesC* collation;
274 // Language downgrade path to set up
275 TLanguage downgradePathSetup[3];
277 // Expected result - opaque_data of retrieved plugin
278 const TDesC8* result;
281 LOCAL_D const TLangTestEntry2 LangTestData2[] =
285 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
292 {ELangEnglish, ELangFrench, ELangGerman},
299 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
306 {ELangFrench, ELangEnglish, ELangGerman},
311 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
318 {ELangGerman, ELangEnglish, ELangFrench},
323 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
330 {ELangEnglish, ELangFrench, ELangGerman},
335 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
342 {ELangEnglish, ELangFrench, ELangGerman},
347 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
354 {ELangSpanish, ELangItalian, ELangGerman},
359 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
366 {ELangSpanish, ELangItalian, ELangSwedish},
372 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
379 {ELangSpanish, ELangFrench, ELangEnglish},
385 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
392 {ELangSpanish,ELangItalian, ELangSwedish},
398 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
405 {ELangSpanish, ELangGerman, ELangItalian},
411 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
418 {ELangSpanish, ELangItalian, ELangNone},
423 class REComLanguagePluginTest
426 void StaticRunTestsL();
427 void DynamicRunTestsOnCL();
428 void DynamicRunTestsOnZL();
429 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
430 void SetLanguage(const TDesC& aLangFile, const TLanguage aLang[3]);
432 void SetLanguage(const TDesC& aLanguage,const TDesC& aReg,const TDesC& aColl,const TLanguage aLang[3]);
434 void CopyFiles(TInt aIndex);
435 static void DeleteFiles(TInt aIndex);
436 void DoCheckL(TInt testDataId, TUid &aInterfaceId, TDriveUnit aDriveUnit);
442 void REComLanguagePluginTest::CopyFiles(TInt aIndex)
444 for (TInt i = 0; i < MAX_LANGUAGE_TEST_FILES && LangTestData[aIndex].files[i].source; i++)
446 TRAPD(err, EComTestUtils::FileManCopyFileL( *(LangTestData[aIndex].files[i].source),
447 *(LangTestData[aIndex].files[i].dest)) );
448 TEST(err==KErrNone, __LINE__);
455 void REComLanguagePluginTest::DeleteFiles(TInt aIndex)
457 for (TInt i = 0; i < MAX_LANGUAGE_TEST_FILES && LangTestData[aIndex].files[i].source != NULL; i++)
459 TRAPD(err, EComTestUtils::FileManDeleteFileL(*(LangTestData[aIndex].files[i].dest)) );
463 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
465 Sets up the system-wide locale and language downgrade path.
467 void REComLanguagePluginTest::SetLanguage(const TDesC& aLangFile, const TLanguage aLang[3])
471 TExtendedLocale extendedLocale;
473 extendedLocale.LoadSystemSettings();
474 loadval = extendedLocale.LoadLocale(aLangFile);
475 TEST(loadval==KErrNone, __LINE__);
476 extendedLocale.SaveSystemSettings();
478 locale.SetLanguageDowngrade(0, aLang[0]);
479 locale.SetLanguageDowngrade(1, aLang[1]);
480 locale.SetLanguageDowngrade(2, aLang[2]);
485 Sets up the system-wide locale and language downgrade path for the new locale model.
487 void REComLanguagePluginTest::SetLanguage(const TDesC& aLanguage,const TDesC& aReg,const TDesC& aColl,const TLanguage aLang[3])
490 TExtendedLocale extendedLocale;
493 extendedLocale.LoadSystemSettings();
494 loadval = extendedLocale.LoadLocale(aLanguage,aReg,aColl);
495 TEST(loadval==KErrNone, __LINE__);
496 extendedLocale.SaveSystemSettings();
498 locale.SetLanguageDowngrade(0, aLang[0]);
499 locale.SetLanguageDowngrade(1, aLang[1]);
500 locale.SetLanguageDowngrade(2, aLang[2]);
505 void REComLanguagePluginTest::DoCheckL(TInt testDataId, TUid &aInterfaceId, TDriveUnit aDriveUnit)
507 RImplInfoPtrArray implArray;
509 REComSession::ListImplementationsL(aInterfaceId, implArray);
513 RDebug::Print(_L("\tArray Count = %d\n"), implArray.Count());
514 buf.Copy(implArray[0]->OpaqueData());
515 RDebug::Print(_L("\tOpaque Data = %S\n"), &buf);
516 TInt drive = implArray[0]->Drive();
517 RDebug::Print(_L("\tDrive = %d\n"), drive);
519 TEST(implArray.Count() == 1);
521 if(aDriveUnit == EDriveZ)
523 TEST(implArray[0]->OpaqueData() == *(LangTestData2[testDataId].result));
527 TEST(implArray[0]->OpaqueData() == *(LangTestData[testDataId].result));
530 TEST(implArray[0]->Drive() == aDriveUnit);
532 // Post test clean up
533 REComSession::FinalClose();
534 implArray.ResetAndDestroy();
538 Test case for DEF087773: ECOM ValidateRegistry checks for existence of RSC file only
540 @SYMTestCaseID SYSLIB-ECOM-CT-0655
541 @SYMTestCaseDesc Checks for existence of resource files for different downgrade paths
542 @SYMTestPriority high
543 @SYMTestActions Data driven tests.
544 Create different sets of language dependant resource file on "C"
545 Drive and verify the ECom discovery process
546 @SYMTestExpectedResults The test must not fail.
549 void REComLanguagePluginTest::StaticRunTestsL()
551 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0655 "));
552 TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);
554 TUid ifUid={0x10009DB9};
555 for(TInt i = 0; i < numberOfElements; i++)
557 // kill ecom server so that language downgrade changes are picked up
558 ECOMTU_KILL_SERVER_L(TEST);
561 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
562 SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup);
564 SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup);
570 TEST.Printf(_L("\tLanguage Plugin Test %d - 1st boot \n"), i);
571 DoCheckL(i,ifUid, EDriveC );
573 // kill ecom server for second boot
574 ECOMTU_KILL_SERVER_L(TEST);
577 TEST.Printf(_L("\tLanguage Plugin Test %d - 2nd boot \n"), i);
578 DoCheckL(i, ifUid, EDriveC);
586 Test case for CR0209: Enable Dynamic Language Switching in ECOM
588 @SYMTestCaseID SYSLIB-ECOM-CT-3169
589 @SYMTestCaseDesc Checks for picking up correct resource files for different downgrade paths in running time
590 @SYMTestPriority high
591 @SYMTestActions Data driven tests.
593 Create different sets of language dependant resource file on "C" on running time.
594 Drive and verify the ECom discovery process
595 @SYMTestExpectedResults The test must not fail.
598 void REComLanguagePluginTest::DynamicRunTestsOnCL()
600 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3169 "));
601 TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);
603 RImplInfoPtrArray implArray;
604 TUid ifUid={0x10009DB9};
606 //start up ecom server
607 REComSession::ListImplementationsL(ifUid, implArray);
609 for(TInt i = 0; i < numberOfElements; i++)
615 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
616 SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup);
618 SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup);
622 TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on C \n"), i);
623 DoCheckL(i,ifUid, EDriveC);
627 implArray.ResetAndDestroy();
631 // Post test clean up
632 REComSession::FinalClose();
633 implArray.ResetAndDestroy();
635 //kill ecomserver after finishing test
636 ECOMTU_KILL_SERVER_L(TEST);
641 Test case for CR0209: Enable Dynamic Language Switching in ECOM on Z: drive
643 @SYMTestCaseID SYSLIB-ECOM-CT-3170
644 @SYMTestCaseDesc Checks for picking up correct resource files for different downgrade paths in running time.
645 @SYMTestPriority high
646 @SYMTestActions Data driven tests.
648 Change languae downgrade path on running time.
649 Drive and verify the ECom discovery process.
650 @SYMTestExpectedResults The test must not fail.
653 void REComLanguagePluginTest::DynamicRunTestsOnZL()
655 TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3170 "));
656 TInt numberOfElements = sizeof(LangTestData2)/sizeof(TLangTestEntry2);
658 //Interface ID in a DLL existing on Z: Drive
659 TUid ifUid={0x10009DE1};
661 //start up ecom server
662 RImplInfoPtrArray implArray;
663 REComSession::ListImplementationsL(ifUid, implArray);
666 for(TInt i = 0; i < numberOfElements; i++)
670 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
671 SetLanguage(*(LangTestData2[i].localeFile), LangTestData2[i].downgradePathSetup);
673 SetLanguage(*(LangTestData2[i].lang),*(LangTestData2[i].region),*(LangTestData2[i].collation),LangTestData2[i].downgradePathSetup);
677 // Dynamic language downgrade path changing
678 TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on Z \n"), i);
679 DoCheckL(i,ifUid, EDriveZ);
680 implArray.ResetAndDestroy();
684 // Post test clean up
685 REComSession::FinalClose();
686 implArray.ResetAndDestroy();
690 LOCAL_C void RunTestL()
693 REComLanguagePluginTest testSuite;
694 testSuite.StaticRunTestsL();
695 testSuite.DynamicRunTestsOnCL();
696 testSuite.DynamicRunTestsOnZL();
701 GLDEF_C TInt E32Main()
706 TEST.Start(_L("ECom Language Plugins tests."));
708 CTrapCleanup* cleanup = CTrapCleanup::New();
709 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
710 CActiveScheduler::Install(scheduler);
712 TRAPD(err,RunTestL());
714 // tidy up in case of leave
717 TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);
718 for(TInt i = 0; i < numberOfElements; i++)
720 REComLanguagePluginTest::DeleteFiles(i);
724 TEST(err==KErrNone, __LINE__);