kerneltest/f32test/server/t_dlocl.cpp
changeset 109 b3a1d9898418
parent 0 a41df078684a
child 152 657f875b013e
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
    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(res==KErrNone);
    76     test_KErrNone(res);
    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(res==KErrArgument);
    84     test_Value(res, res == KErrArgument);
    85     
    85     
    86     res=testLib.Load(EKDATA);
    86     res=testLib.Load(EKDATA);
    87     test(res==KErrNone);
    87     test_KErrNone(res);
    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(res==KErrNone);
    93     test_KErrNone(res);
    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(res==KErrNone);
   109     test_KErrNone(res);
   110     
   110     
   111     res=testLib.Load(EKDATA);
   111     res=testLib.Load(EKDATA);
   112     test(res==KErrNone);
   112     test_KErrNone(res);
   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(res==KErrNone);
   117     test_KErrNone(res);
   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(res==KErrNone);
   137     test_KErrNone(res);
   138     
   138     
   139     res=testLib.Load(EKDATA);
   139     res=testLib.Load(EKDATA);
   140     test(res==KErrNone);
   140     test_KErrNone(res);
   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(res==KErrNone);
   146     test_KErrNone(res);
   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(nRes==KErrNone);
   283         test_KErrNone(nRes);
   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(res==KErrNone);
   325     test_KErrNone(res);
   326     TRequestStatus stat;
   326     TRequestStatus stat;
   327     
   327     
   328     res=notifier.Logon(stat);
   328     res=notifier.Logon(stat);
   329     test(res==KErrNone);
   329     test_KErrNone(res);
   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(res==KErrNone);
   337         test_KErrNone(res);
   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(res==KErrNone);
   353         test_KErrNone(res);
   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(res == KErrNotSupported);
   370         test_Value(res, 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(res==KErrNone);
   399         test_KErrNone(res);
   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(res==KErrNone);
   440         test_KErrNone(res);
   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(res == KErrNone);
   462         test_KErrNone(res);
   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(res==KErrNone);
   467         test_KErrNone(res);
   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(res==KErrNone);
   480         test_KErrNone(res);
   481         file.Close();
   481         file.Close();
   482 
   482 
   483         res = file.Open(TheFs, KTestFile, 0);
   483         res = file.Open(TheFs, KTestFile, 0);
   484         test(res == KErrNone);
   484         test_KErrNone(res);
   485         file.Close();
   485         file.Close();
   486         res = TheFs.Delete(KTestFile);
   486         res = TheFs.Delete(KTestFile);
   487         test(res==KErrNone);
   487         test_KErrNone(res);
   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(r == KErrNone);
   653     test_KErrNone(r);
   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(r == KErrNone);
   657     test_KErrNone(r);
   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(r == KErrNone);
   671     test_KErrNone(r);
   672     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());
   673     test(dllName.Find(eloclus) != KErrNotFound);
   673     test(dllName.Find(eloclus) != KErrNotFound);
   674     
   674     
   675     dllName.FillZ();
   675     dllName.FillZ();
   676 
   676 
   677     r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName);
   677     r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName);
   678     test(r == KErrNone);
   678     test_KErrNone(r);
   679     test(dllName.Find(eloclus) != KErrNotFound);
   679     test(dllName.Find(eloclus) != KErrNotFound);
   680     
   680     
   681     dllName.FillZ();
   681     dllName.FillZ();
   682 
   682 
   683     r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName);
   683     r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName);
   684     test(r == KErrNone);
   684     test_KErrNone(r);
   685     test(dllName.Find(eloclus) != KErrNotFound);
   685     test(dllName.Find(eloclus) != KErrNotFound);
   686     
   686     
   687     dllName.FillZ();
   687     dllName.FillZ();
   688 
   688 
   689     r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName);
   689     r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName);
   690     test(r == KErrNone);
   690     test_KErrNone(r);
   691     test(dllName.Find(eloclus) != KErrNotFound);
   691     test(dllName.Find(eloclus) != KErrNotFound);
   692     
   692     
   693     dllName.FillZ();
   693     dllName.FillZ();
   694 
   694 
   695     r = locale.LoadLocaleAspect(ELocaleLocaleSettings | ELocaleTimeDateSettings, ELOCLGE);
   695     r = locale.LoadLocaleAspect(ELocaleLocaleSettings | ELocaleTimeDateSettings, ELOCLGE);
   696     test(r == KErrNone);
   696     test_KErrNone(r);
   697 
   697 
   698     r = locale.SaveSystemSettings();
   698     r = locale.SaveSystemSettings();
   699     test(r == KErrNone);
   699     test_KErrNone(r);
   700 
   700 
   701     testExtendedUS(ELocaleLanguageSettings | ELocaleCollateSetting, locale);
   701     testExtendedUS(ELocaleLanguageSettings | ELocaleCollateSetting, locale);
   702 
   702 
   703     symbol.Set();
   703     symbol.Set();
   704     test(symbol.Compare(TPtrC(_S("DM"))) == 0);
   704     test(symbol.Compare(TPtrC(_S("DM"))) == 0);
   717 
   717 
   718     TFileName eloclge;
   718     TFileName eloclge;
   719     eloclge.Copy(ELOCLGE);
   719     eloclge.Copy(ELOCLGE);
   720     eloclge.Append(KDLLExtension);
   720     eloclge.Append(KDLLExtension);
   721     r = locale.GetLocaleDllName(ELocaleLanguageSettings, dllName);
   721     r = locale.GetLocaleDllName(ELocaleLanguageSettings, dllName);
   722     test(r == KErrNone);
   722     test_KErrNone(r);
   723     test(dllName.Find(eloclus) != KErrNotFound);
   723     test(dllName.Find(eloclus) != KErrNotFound);
   724     
   724     
   725     dllName.FillZ();
   725     dllName.FillZ();
   726 
   726 
   727     r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName);
   727     r = locale.GetLocaleDllName(ELocaleCollateSetting, dllName);
   728     test(r == KErrNone);
   728     test_KErrNone(r);
   729     test(dllName.Find(eloclus) != KErrNotFound);
   729     test(dllName.Find(eloclus) != KErrNotFound);
   730     
   730     
   731     dllName.FillZ();
   731     dllName.FillZ();
   732 
   732 
   733     r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName);
   733     r = locale.GetLocaleDllName(ELocaleLocaleSettings, dllName);
   734     test(r == KErrNone);
   734     test_KErrNone(r);
   735     test(dllName.Find(eloclge) != KErrNotFound);
   735     test(dllName.Find(eloclge) != KErrNotFound);
   736     
   736     
   737     dllName.FillZ();
   737     dllName.FillZ();
   738 
   738 
   739     r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName);
   739     r = locale.GetLocaleDllName(ELocaleTimeDateSettings, dllName);
   740     test(r == KErrNone);
   740     test_KErrNone(r);
   741     test(dllName.Find(eloclge) != KErrNotFound);
   741     test(dllName.Find(eloclge) != KErrNotFound);
   742     
   742     
   743     dllName.FillZ();
   743     dllName.FillZ();
   744 
   744 
   745     }
   745     }