71 test.Printf(_L("Test default key data\n")); |
71 test.Printf(_L("Test default key data\n")); |
72 testConv(_L("\nFirst Special key down"),KEY_DOWN,EXPECT_KEY_PRESS,ESpecialKeyBase,ESpecialKeyBase,0); |
72 testConv(_L("\nFirst Special key down"),KEY_DOWN,EXPECT_KEY_PRESS,ESpecialKeyBase,ESpecialKeyBase,0); |
73 |
73 |
74 RLibrary testLib; |
74 RLibrary testLib; |
75 TInt res=testLib.Load(EKDATA); |
75 TInt res=testLib.Load(EKDATA); |
76 test_KErrNone(res); |
76 test(res==KErrNone); |
77 THandleInfo handleInfo; |
77 THandleInfo handleInfo; |
78 testLib.HandleInfo(&handleInfo); |
78 testLib.HandleInfo(&handleInfo); |
79 test(handleInfo.iNumOpenInThread==2); |
79 test(handleInfo.iNumOpenInThread==2); |
80 testLib.Close(); |
80 testLib.Close(); |
81 |
81 |
82 test.Printf(_L("Change to unknown dll \n")); // Test with non keydata type dll |
82 test.Printf(_L("Change to unknown dll \n")); // Test with non keydata type dll |
83 res=KeyTranslator->ChangeKeyData(DUMMYDLL); |
83 res=KeyTranslator->ChangeKeyData(DUMMYDLL); |
84 test_Value(res, res == KErrArgument); |
84 test(res==KErrArgument); |
85 |
85 |
86 res=testLib.Load(EKDATA); |
86 res=testLib.Load(EKDATA); |
87 test_KErrNone(res); |
87 test(res==KErrNone); |
88 testLib.HandleInfo(&handleInfo); |
88 testLib.HandleInfo(&handleInfo); |
89 test(handleInfo.iNumOpenInThread==2); |
89 test(handleInfo.iNumOpenInThread==2); |
90 testLib.Close(); |
90 testLib.Close(); |
91 |
91 |
92 res=testLib.Load(DUMMYDLL); |
92 res=testLib.Load(DUMMYDLL); |
93 test_KErrNone(res); |
93 test(res==KErrNone); |
94 testLib.HandleInfo(&handleInfo); |
94 testLib.HandleInfo(&handleInfo); |
95 test(handleInfo.iNumOpenInThread==1); |
95 test(handleInfo.iNumOpenInThread==1); |
96 testLib.Close(); |
96 testLib.Close(); |
97 |
97 |
98 fLib.Find(_L("*")); |
98 fLib.Find(_L("*")); |
104 test(n.FindF(findname) == KErrNotFound); |
104 test(n.FindF(findname) == KErrNotFound); |
105 } |
105 } |
106 // |
106 // |
107 test.Printf(_L("Change to EKDATA.dll\n")); |
107 test.Printf(_L("Change to EKDATA.dll\n")); |
108 res=KeyTranslator->ChangeKeyData(EKDATA); |
108 res=KeyTranslator->ChangeKeyData(EKDATA); |
109 test_KErrNone(res); |
109 test(res==KErrNone); |
110 |
110 |
111 res=testLib.Load(EKDATA); |
111 res=testLib.Load(EKDATA); |
112 test_KErrNone(res); |
112 test(res==KErrNone); |
113 testLib.HandleInfo(&handleInfo); |
113 testLib.HandleInfo(&handleInfo); |
114 test(handleInfo.iNumOpenInThread==2); |
114 test(handleInfo.iNumOpenInThread==2); |
115 testLib.Close(); |
115 testLib.Close(); |
116 res=testLib.Load(DUMMYDLL); |
116 res=testLib.Load(DUMMYDLL); |
117 test_KErrNone(res); |
117 test(res==KErrNone); |
118 testLib.HandleInfo(&handleInfo); |
118 testLib.HandleInfo(&handleInfo); |
119 test(handleInfo.iNumOpenInThread==1); |
119 test(handleInfo.iNumOpenInThread==1); |
120 testLib.Close(); |
120 testLib.Close(); |
121 |
121 |
122 fLib.Find(_L("*")); |
122 fLib.Find(_L("*")); |
132 //test(n.FindF(EKDATA) == KErrNotSupported); |
132 //test(n.FindF(EKDATA) == KErrNotSupported); |
133 testConv(_L("\nFirst Special key down"),KEY_DOWN,EXPECT_KEY_PRESS,ESpecialKeyBase,ESpecialKeyBase,0); |
133 testConv(_L("\nFirst Special key down"),KEY_DOWN,EXPECT_KEY_PRESS,ESpecialKeyBase,ESpecialKeyBase,0); |
134 |
134 |
135 test.Printf(_L("Change back to Default KeyData\n")); |
135 test.Printf(_L("Change back to Default KeyData\n")); |
136 res=KeyTranslator->ChangeKeyData(_L("")); |
136 res=KeyTranslator->ChangeKeyData(_L("")); |
137 test_KErrNone(res); |
137 test(res==KErrNone); |
138 |
138 |
139 res=testLib.Load(EKDATA); |
139 res=testLib.Load(EKDATA); |
140 test_KErrNone(res); |
140 test(res==KErrNone); |
141 testLib.HandleInfo(&handleInfo); |
141 testLib.HandleInfo(&handleInfo); |
142 test(handleInfo.iNumOpenInThread==2); |
142 test(handleInfo.iNumOpenInThread==2); |
143 testLib.Close(); |
143 testLib.Close(); |
144 |
144 |
145 res=testLib.Load(DUMMYDLL); |
145 res=testLib.Load(DUMMYDLL); |
146 test_KErrNone(res); |
146 test(res==KErrNone); |
147 testLib.HandleInfo(&handleInfo); |
147 testLib.HandleInfo(&handleInfo); |
148 test(handleInfo.iNumOpenInThread==1); |
148 test(handleInfo.iNumOpenInThread==1); |
149 testLib.Close(); |
149 testLib.Close(); |
150 |
150 |
151 fLib.Find(_L("*")); |
151 fLib.Find(_L("*")); |
278 for(i=0; i<KMaxAttempts; ++i) |
278 for(i=0; i<KMaxAttempts; ++i) |
279 { |
279 { |
280 test.Printf(_L("SubscribeToSystemChangeNotification(0x%x), attempt:%d\n"), aEventMask, i); |
280 test.Printf(_L("SubscribeToSystemChangeNotification(0x%x), attempt:%d\n"), aEventMask, i); |
281 |
281 |
282 TInt nRes = aNotifier.Logon(aStatus); |
282 TInt nRes = aNotifier.Logon(aStatus); |
283 test_KErrNone(nRes); |
283 test(nRes==KErrNone); |
284 |
284 |
285 if(aStatus.Int() == KRequestPending) |
285 if(aStatus.Int() == KRequestPending) |
286 break; |
286 break; |
287 |
287 |
288 //-- some other system-wide event can just happen; re-subscribe |
288 //-- some other system-wide event can just happen; re-subscribe |
320 { |
320 { |
321 TLocale locale; |
321 TLocale locale; |
322 |
322 |
323 RChangeNotifier notifier; |
323 RChangeNotifier notifier; |
324 TInt res=notifier.Create(); |
324 TInt res=notifier.Create(); |
325 test_KErrNone(res); |
325 test(res==KErrNone); |
326 TRequestStatus stat; |
326 TRequestStatus stat; |
327 |
327 |
328 res=notifier.Logon(stat); |
328 res=notifier.Logon(stat); |
329 test_KErrNone(res); |
329 test(res==KErrNone); |
330 // initial value of stat already tested by t_chnot |
330 // initial value of stat already tested by t_chnot |
331 |
331 |
332 SubscribeToSystemChangeNotification(notifier, stat, EChangesLocale); |
332 SubscribeToSystemChangeNotification(notifier, stat, EChangesLocale); |
333 |
333 |
334 test.Printf(_L("Change to US Locale\n")); |
334 test.Printf(_L("Change to US Locale\n")); |
335 res=UserSvr::ChangeLocale(ELOCLUS); |
335 res=UserSvr::ChangeLocale(ELOCLUS); |
336 test.Printf(_L("res=%d\n"),res); |
336 test.Printf(_L("res=%d\n"),res); |
337 test_KErrNone(res); |
337 test(res==KErrNone); |
338 |
338 |
339 WaitForSystemChange(notifier, stat, EChangesLocale); |
339 WaitForSystemChange(notifier, stat, EChangesLocale); |
340 test(stat.Int() & EChangesLocale); |
340 test(stat.Int() & EChangesLocale); |
341 |
341 |
342 //------------------- |
342 //------------------- |
348 testUS(locale); |
348 testUS(locale); |
349 |
349 |
350 test.Printf(_L("Change to GE Locale\n")); |
350 test.Printf(_L("Change to GE Locale\n")); |
351 res=UserSvr::ChangeLocale(ELOCLGE); |
351 res=UserSvr::ChangeLocale(ELOCLGE); |
352 test.Printf(_L("res=%d\n"),res); |
352 test.Printf(_L("res=%d\n"),res); |
353 test_KErrNone(res); |
353 test(res==KErrNone); |
354 |
354 |
355 WaitForSystemChange(notifier, stat, EChangesLocale); |
355 WaitForSystemChange(notifier, stat, EChangesLocale); |
356 test(stat.Int() & EChangesLocale); |
356 test(stat.Int() & EChangesLocale); |
357 |
357 |
358 //------------------- |
358 //------------------- |
365 testGE(locale); |
365 testGE(locale); |
366 |
366 |
367 test.Printf(_L("Load non ELOCL type DLL\n")); |
367 test.Printf(_L("Load non ELOCL type DLL\n")); |
368 res=UserSvr::ChangeLocale(DUMMYDLL); |
368 res=UserSvr::ChangeLocale(DUMMYDLL); |
369 test.Printf(_L("res=%d\n"),res); |
369 test.Printf(_L("res=%d\n"),res); |
370 test_Value(res, res == KErrNotSupported); |
370 test(res == KErrNotSupported); |
371 |
371 |
372 //-- ensure that there wasn't locale change |
372 //-- ensure that there wasn't locale change |
373 const TInt KMaxAttempts = 100; |
373 const TInt KMaxAttempts = 100; |
374 TInt i; |
374 TInt i; |
375 for(i=0; i<KMaxAttempts; ++i) |
375 for(i=0; i<KMaxAttempts; ++i) |
394 //matching we just need to add the TCollationTable::EMatchingTable flag |
394 //matching we just need to add the TCollationTable::EMatchingTable flag |
395 //inside the TCollationMethods::iFlags |
395 //inside the TCollationMethods::iFlags |
396 test.Printf(_L("Change to US1 Locale\n")); |
396 test.Printf(_L("Change to US1 Locale\n")); |
397 res=UserSvr::ChangeLocale(ELOCLUS1); |
397 res=UserSvr::ChangeLocale(ELOCLUS1); |
398 test.Printf(_L("res=%d\n"),res); |
398 test.Printf(_L("res=%d\n"),res); |
399 test_KErrNone(res); |
399 test(res==KErrNone); |
400 |
400 |
401 WaitForSystemChange(notifier, stat, EChangesLocale); |
401 WaitForSystemChange(notifier, stat, EChangesLocale); |
402 test(stat.Int() & EChangesLocale); |
402 test(stat.Int() & EChangesLocale); |
403 |
403 |
404 |
404 |
435 test(a_small.MatchC(_L("b"))==0); |
435 test(a_small.MatchC(_L("b"))==0); |
436 */ |
436 */ |
437 test.Printf(_L("Back to default UK Locale\n")); |
437 test.Printf(_L("Back to default UK Locale\n")); |
438 res=UserSvr::ChangeLocale(ELOCL_DEFAULT); |
438 res=UserSvr::ChangeLocale(ELOCL_DEFAULT); |
439 test.Printf(_L("res=%d\n"),res); |
439 test.Printf(_L("res=%d\n"),res); |
440 test_KErrNone(res); |
440 test(res==KErrNone); |
441 |
441 |
442 WaitForSystemChange(notifier, stat, EChangesLocale); |
442 WaitForSystemChange(notifier, stat, EChangesLocale); |
443 test(stat.Int() & EChangesLocale); |
443 test(stat.Int() & EChangesLocale); |
444 |
444 |
445 //------------------- |
445 //------------------- |
457 test.Printf(_L("Change to US Locale with file open on drive\n")); |
457 test.Printf(_L("Change to US Locale with file open on drive\n")); |
458 |
458 |
459 _LIT(KTestFile, "TEST.TXT"); |
459 _LIT(KTestFile, "TEST.TXT"); |
460 RFile file; |
460 RFile file; |
461 res = file.Replace(TheFs, KTestFile, 0); |
461 res = file.Replace(TheFs, KTestFile, 0); |
462 test_KErrNone(res); |
462 test(res == KErrNone); |
463 |
463 |
464 |
464 |
465 res=UserSvr::ChangeLocale(ELOCLUS); |
465 res=UserSvr::ChangeLocale(ELOCLUS); |
466 test.Printf(_L("res=%d\n"),res); |
466 test.Printf(_L("res=%d\n"),res); |
467 test_KErrNone(res); |
467 test(res==KErrNone); |
468 |
468 |
469 |
469 |
470 WaitForSystemChange(notifier, stat, EChangesLocale); |
470 WaitForSystemChange(notifier, stat, EChangesLocale); |
471 test(stat.Int() & EChangesLocale); |
471 test(stat.Int() & EChangesLocale); |
472 |
472 |
475 SubscribeToSystemChangeNotification(notifier, stat, EChangesLocale); |
475 SubscribeToSystemChangeNotification(notifier, stat, EChangesLocale); |
476 |
476 |
477 |
477 |
478 _LIT8(KTestData, "Arsenal"); |
478 _LIT8(KTestData, "Arsenal"); |
479 res = file.Write(KTestData); |
479 res = file.Write(KTestData); |
480 test_KErrNone(res); |
480 test(res==KErrNone); |
481 file.Close(); |
481 file.Close(); |
482 |
482 |
483 res = file.Open(TheFs, KTestFile, 0); |
483 res = file.Open(TheFs, KTestFile, 0); |
484 test_KErrNone(res); |
484 test(res == KErrNone); |
485 file.Close(); |
485 file.Close(); |
486 res = TheFs.Delete(KTestFile); |
486 res = TheFs.Delete(KTestFile); |
487 test_KErrNone(res); |
487 test(res==KErrNone); |
488 |
488 |
489 //************************************************ |
489 //************************************************ |
490 |
490 |
491 //-- close the notifier |
491 //-- close the notifier |
492 notifier.Close(); |
492 notifier.Close(); |
648 void testExtendedLocale() |
648 void testExtendedLocale() |
649 { |
649 { |
650 TExtendedLocale locale; |
650 TExtendedLocale locale; |
651 locale.LoadLocale(ELOCLUS); |
651 locale.LoadLocale(ELOCLUS); |
652 TInt r = locale.SaveSystemSettings(); |
652 TInt r = locale.SaveSystemSettings(); |
653 test_KErrNone(r); |
653 test(r == KErrNone); |
654 testExtendedUS(ELocaleLanguageSettings | ELocaleCollateSetting | ELocaleLocaleSettings | ELocaleTimeDateSettings, locale); |
654 testExtendedUS(ELocaleLanguageSettings | ELocaleCollateSetting | ELocaleLocaleSettings | ELocaleTimeDateSettings, locale); |
655 |
655 |
656 r = locale.SetCurrencySymbol(TPtrC(_S("Leu"))); |
656 r = locale.SetCurrencySymbol(TPtrC(_S("Leu"))); |
657 test_KErrNone(r); |
657 test(r == KErrNone); |
658 TCurrencySymbol symbol; |
658 TCurrencySymbol symbol; |
659 symbol.Set(); |
659 symbol.Set(); |
660 test(symbol.Compare(TPtrC(_S("Leu"))) == 0); |
660 test(symbol.Compare(TPtrC(_S("Leu"))) == 0); |
661 |
661 |
662 User::SetCurrencySymbol(TPtrC(_S("Le"))); |
662 User::SetCurrencySymbol(TPtrC(_S("Le"))); |
666 TFileName dllName; |
666 TFileName dllName; |
667 TFileName eloclus; |
667 TFileName eloclus; |
668 eloclus.Copy(ELOCLUS); |
668 eloclus.Copy(ELOCLUS); |
669 eloclus.Append(TPtrC(KDLLExtension)); |
669 eloclus.Append(TPtrC(KDLLExtension)); |
670 r = locale.GetLocaleDllName(ELocaleLanguageSettings, dllName); |
670 r = locale.GetLocaleDllName(ELocaleLanguageSettings, dllName); |
671 test_KErrNone(r); |
671 test(r == KErrNone); |
672 dllName.UpperCase(); |
|
673 test.Printf(_L("dllName looking for %s (%s)\n"), dllName.Ptr(), eloclus.Ptr()); |
672 test.Printf(_L("dllName looking for %s (%s)\n"), dllName.Ptr(), eloclus.Ptr()); |
674 test(dllName.Find(eloclus) != KErrNotFound); |
673 test(dllName.Find(eloclus) != KErrNotFound); |
675 |
674 |
676 dllName.FillZ(); |
675 dllName.FillZ(); |
677 |
676 |
678 r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName); |
677 r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName); |
679 test_KErrNone(r); |
678 test(r == KErrNone); |
680 dllName.UpperCase(); |
|
681 test(dllName.Find(eloclus) != KErrNotFound); |
679 test(dllName.Find(eloclus) != KErrNotFound); |
682 |
680 |
683 dllName.FillZ(); |
681 dllName.FillZ(); |
684 |
682 |
685 r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName); |
683 r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName); |
686 test_KErrNone(r); |
684 test(r == KErrNone); |
687 dllName.UpperCase(); |
|
688 test(dllName.Find(eloclus) != KErrNotFound); |
685 test(dllName.Find(eloclus) != KErrNotFound); |
689 |
686 |
690 dllName.FillZ(); |
687 dllName.FillZ(); |
691 |
688 |
692 r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName); |
689 r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName); |
693 test_KErrNone(r); |
690 test(r == KErrNone); |
694 dllName.UpperCase(); |
|
695 test(dllName.Find(eloclus) != KErrNotFound); |
691 test(dllName.Find(eloclus) != KErrNotFound); |
696 |
692 |
697 dllName.FillZ(); |
693 dllName.FillZ(); |
698 |
694 |
699 r = locale.LoadLocaleAspect(ELocaleLocaleSettings | ELocaleTimeDateSettings, ELOCLGE); |
695 r = locale.LoadLocaleAspect(ELocaleLocaleSettings | ELocaleTimeDateSettings, ELOCLGE); |
700 test_KErrNone(r); |
696 test(r == KErrNone); |
701 |
697 |
702 r = locale.SaveSystemSettings(); |
698 r = locale.SaveSystemSettings(); |
703 test_KErrNone(r); |
699 test(r == KErrNone); |
704 |
700 |
705 testExtendedUS(ELocaleLanguageSettings | ELocaleCollateSetting, locale); |
701 testExtendedUS(ELocaleLanguageSettings | ELocaleCollateSetting, locale); |
706 |
702 |
707 symbol.Set(); |
703 symbol.Set(); |
708 test(symbol.Compare(TPtrC(_S("DM"))) == 0); |
704 test(symbol.Compare(TPtrC(_S("DM"))) == 0); |
721 |
717 |
722 TFileName eloclge; |
718 TFileName eloclge; |
723 eloclge.Copy(ELOCLGE); |
719 eloclge.Copy(ELOCLGE); |
724 eloclge.Append(KDLLExtension); |
720 eloclge.Append(KDLLExtension); |
725 r = locale.GetLocaleDllName(ELocaleLanguageSettings, dllName); |
721 r = locale.GetLocaleDllName(ELocaleLanguageSettings, dllName); |
726 test_KErrNone(r); |
722 test(r == KErrNone); |
727 dllName.UpperCase(); |
|
728 test(dllName.Find(eloclus) != KErrNotFound); |
723 test(dllName.Find(eloclus) != KErrNotFound); |
729 |
724 |
730 dllName.FillZ(); |
725 dllName.FillZ(); |
731 |
726 |
732 r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName); |
727 r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName); |
733 test_KErrNone(r); |
728 test(r == KErrNone); |
734 dllName.UpperCase(); |
|
735 test(dllName.Find(eloclus) != KErrNotFound); |
729 test(dllName.Find(eloclus) != KErrNotFound); |
736 |
730 |
737 dllName.FillZ(); |
731 dllName.FillZ(); |
738 |
732 |
739 r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName); |
733 r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName); |
740 test_KErrNone(r); |
734 test(r == KErrNone); |
741 dllName.UpperCase(); |
|
742 test(dllName.Find(eloclge) != KErrNotFound); |
735 test(dllName.Find(eloclge) != KErrNotFound); |
743 |
736 |
744 dllName.FillZ(); |
737 dllName.FillZ(); |
745 |
738 |
746 r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName); |
739 r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName); |
747 test_KErrNone(r); |
740 test(r == KErrNone); |
748 dllName.UpperCase(); |
|
749 test(dllName.Find(eloclge) != KErrNotFound); |
741 test(dllName.Find(eloclge) != KErrNotFound); |
750 |
742 |
751 dllName.FillZ(); |
743 dllName.FillZ(); |
752 |
744 |
753 } |
745 } |