os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_NewLocaleModel.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 #include "T_CheckLocale.h"
    18 #include <e32reg.h>
    19 
    20 RTest test(_L("T_NewLocaleModel"));
    21 
    22 
    23 //new locale API should work in the new locale model
    24 void TestNewLocaleAPI()
    25     {
    26     TExtendedLocale firstExtendLocale;
    27     
    28     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4022 new LoadLocale() interface"));
    29     firstExtendLocale.LoadSystemSettings();
    30     test( KErrNone == firstExtendLocale.LoadLocale(KGermanLanguage(), KGERegion(), KGECollation()) );
    31     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    32     TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
    33     TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
    34 	test( ERegDEU == User::RegionCode() );
    35 
    36     firstExtendLocale.LoadSystemSettings();
    37     test( KErrNone == firstExtendLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation()) );
    38     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    39     TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
    40     TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
    41     
    42     //becasue TestLocaleContent() naturally check the system locale content, we mark this test case here.
    43     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4025 publish locale content to the system"));
    44     test.End();
    45 
    46     firstExtendLocale.LoadSystemSettings();
    47     test( KErrNone == firstExtendLocale.LoadLocale(KUSLanguage(), KCNRegion(), KGECollation()) );
    48     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    49     TestLocaleDLLName(test, KUSLanguage(), KCNRegion(), KGECollation() );
    50     TestLocaleContent(test, KUSLanguageID, KCNCurrencySymbol, KGETCollationMethodID);
    51     test.End();
    52     
    53     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4023 new LoadLocaleAspect() interface"));  
    54     firstExtendLocale.LoadSystemSettings();    
    55     test( KErrNone == firstExtendLocale.LoadLocaleAspect(KCNLanguage));
    56     test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUSRegion));
    57     test( KErrNone == firstExtendLocale.LoadLocaleAspect(KGECollation));
    58     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    59     TestLocaleDLLName(test, KCNLanguage(), KUSRegion(), KGECollation() );
    60     TestLocaleContent(test, KCNLanguageID, KUSCurrencySymbol, KGETCollationMethodID);
    61 
    62     firstExtendLocale.LoadSystemSettings();
    63     test( KErrNone == firstExtendLocale.LoadLocaleAspect(KEnglishLanguage));
    64     test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUKRegion));
    65     test( KErrNone == firstExtendLocale.LoadLocaleAspect(KStandardCollation));
    66     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    67     TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
    68     TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
    69     test.End();
    70 
    71     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4020 new LoadLocale() should not work with old locale DLL"));  
    72     firstExtendLocale.LoadSystemSettings();
    73     test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldUKLocaleName(), KOldUKLocaleName()) );
    74     firstExtendLocale.LoadSystemSettings();
    75     test( KErrNotFound == firstExtendLocale.LoadLocale(KOldCNLocaleName(), KOldCNLocaleName(), KOldCNLocaleName()) );
    76     firstExtendLocale.LoadSystemSettings();
    77     test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldCNLocaleName(), KOldGELocaleName()) );
    78     test.End();
    79 
    80     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4021 new LoadLocaleAspect() should not work with old locale DLL"));  
    81     firstExtendLocale.LoadSystemSettings();
    82     test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldUKLocaleName()));
    83     firstExtendLocale.LoadSystemSettings();
    84     test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldCNLocaleName()));
    85     firstExtendLocale.LoadSystemSettings();
    86     test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldGELocaleName()));
    87     test.End();
    88     
    89     
    90     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4024 check DLL naming convention"));  
    91     firstExtendLocale.LoadSystemSettings();
    92     test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KUKRegion(), KGECollation()) );
    93     firstExtendLocale.LoadSystemSettings();
    94     test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KInvalidNameRegion(), KGECollation()) );
    95     firstExtendLocale.LoadSystemSettings();
    96     test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KUKRegion(), KInvalidNameCollation()) );
    97     firstExtendLocale.LoadSystemSettings();
    98     test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KInvalidNameRegion(), KInvalidNameCollation()) );
    99 
   100     firstExtendLocale.LoadSystemSettings();
   101     test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameLanguage()));
   102     firstExtendLocale.LoadSystemSettings();
   103     test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameRegion()));
   104     firstExtendLocale.LoadSystemSettings();
   105     test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameCollation()));
   106     test.End();
   107     }
   108 
   109 //Old locale API should work with the legacy old locale DLL name in the new locale model
   110 void TestOldLocaleAPI()
   111     {
   112     TExtendedLocale firstExtendLocale;
   113     
   114     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CIT-4018 old LoadLocale() API should work with the legacy old locale DLL name in the new locale model"));  
   115     firstExtendLocale.LoadSystemSettings();
   116     test( KErrNone == firstExtendLocale.LoadLocale(KOldUKLocaleName()) );
   117     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   118     TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
   119     TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
   120    
   121     firstExtendLocale.LoadSystemSettings();
   122     test( KErrNone == firstExtendLocale.LoadLocale(KOldCNLocaleName()) );
   123     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   124     TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
   125     TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
   126     test.End();
   127     
   128     test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CIT-4017 old LoadLocaleAspect() API should work with the legacy old locale DLL name in the new locale model"));  
   129     firstExtendLocale.LoadSystemSettings();
   130     test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldGELocaleName()));
   131     test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldGELocaleName()));
   132     test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldGELocaleName()));
   133     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   134     TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
   135     TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
   136     
   137     firstExtendLocale.LoadSystemSettings();
   138     test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldUKLocaleName()));
   139     test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldCNLocaleName()));
   140     test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldUSLocaleName()));
   141     test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   142     TestLocaleDLLName(test, KEnglishLanguage(), KUSRegion(), KCNCollation() );
   143     TestLocaleContent(test, KEnglishLanguageID, KUSCurrencySymbol, KCNTCollationMethodID);
   144     test.End();
   145     }
   146 
   147 
   148 void TestNewLocaleModel()
   149     {   
   150     TestOldLocaleAPI();   
   151     TestNewLocaleAPI();
   152     }
   153 
   154 TInt E32Main()
   155     {
   156     CTrapCleanup* tc = CTrapCleanup::New();
   157     test(tc != NULL);
   158 
   159     __UHEAP_MARK;
   160 
   161     test.Start(_L("The test for check old API and new API behavior in new locale model"));
   162     test.Title();
   163     TRAPD(err, ::TestNewLocaleModel())
   164     test(err == KErrNone);
   165 
   166     test.End();
   167     test.Close();
   168 
   169     __UHEAP_MARKEND;
   170 
   171     delete tc;
   172 
   173     return(KErrNone);
   174     }