os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_NewLocaleModel.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_NewLocaleModel.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,174 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +#include "T_CheckLocale.h"
    1.21 +#include <e32reg.h>
    1.22 +
    1.23 +RTest test(_L("T_NewLocaleModel"));
    1.24 +
    1.25 +
    1.26 +//new locale API should work in the new locale model
    1.27 +void TestNewLocaleAPI()
    1.28 +    {
    1.29 +    TExtendedLocale firstExtendLocale;
    1.30 +    
    1.31 +    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4022 new LoadLocale() interface"));
    1.32 +    firstExtendLocale.LoadSystemSettings();
    1.33 +    test( KErrNone == firstExtendLocale.LoadLocale(KGermanLanguage(), KGERegion(), KGECollation()) );
    1.34 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    1.35 +    TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
    1.36 +    TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
    1.37 +	test( ERegDEU == User::RegionCode() );
    1.38 +
    1.39 +    firstExtendLocale.LoadSystemSettings();
    1.40 +    test( KErrNone == firstExtendLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation()) );
    1.41 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    1.42 +    TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
    1.43 +    TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
    1.44 +    
    1.45 +    //becasue TestLocaleContent() naturally check the system locale content, we mark this test case here.
    1.46 +    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4025 publish locale content to the system"));
    1.47 +    test.End();
    1.48 +
    1.49 +    firstExtendLocale.LoadSystemSettings();
    1.50 +    test( KErrNone == firstExtendLocale.LoadLocale(KUSLanguage(), KCNRegion(), KGECollation()) );
    1.51 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    1.52 +    TestLocaleDLLName(test, KUSLanguage(), KCNRegion(), KGECollation() );
    1.53 +    TestLocaleContent(test, KUSLanguageID, KCNCurrencySymbol, KGETCollationMethodID);
    1.54 +    test.End();
    1.55 +    
    1.56 +    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4023 new LoadLocaleAspect() interface"));  
    1.57 +    firstExtendLocale.LoadSystemSettings();    
    1.58 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KCNLanguage));
    1.59 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUSRegion));
    1.60 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KGECollation));
    1.61 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    1.62 +    TestLocaleDLLName(test, KCNLanguage(), KUSRegion(), KGECollation() );
    1.63 +    TestLocaleContent(test, KCNLanguageID, KUSCurrencySymbol, KGETCollationMethodID);
    1.64 +
    1.65 +    firstExtendLocale.LoadSystemSettings();
    1.66 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KEnglishLanguage));
    1.67 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUKRegion));
    1.68 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KStandardCollation));
    1.69 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
    1.70 +    TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
    1.71 +    TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
    1.72 +    test.End();
    1.73 +
    1.74 +    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4020 new LoadLocale() should not work with old locale DLL"));  
    1.75 +    firstExtendLocale.LoadSystemSettings();
    1.76 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldUKLocaleName(), KOldUKLocaleName()) );
    1.77 +    firstExtendLocale.LoadSystemSettings();
    1.78 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KOldCNLocaleName(), KOldCNLocaleName(), KOldCNLocaleName()) );
    1.79 +    firstExtendLocale.LoadSystemSettings();
    1.80 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldCNLocaleName(), KOldGELocaleName()) );
    1.81 +    test.End();
    1.82 +
    1.83 +    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4021 new LoadLocaleAspect() should not work with old locale DLL"));  
    1.84 +    firstExtendLocale.LoadSystemSettings();
    1.85 +    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldUKLocaleName()));
    1.86 +    firstExtendLocale.LoadSystemSettings();
    1.87 +    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldCNLocaleName()));
    1.88 +    firstExtendLocale.LoadSystemSettings();
    1.89 +    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldGELocaleName()));
    1.90 +    test.End();
    1.91 +    
    1.92 +    
    1.93 +    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4024 check DLL naming convention"));  
    1.94 +    firstExtendLocale.LoadSystemSettings();
    1.95 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KUKRegion(), KGECollation()) );
    1.96 +    firstExtendLocale.LoadSystemSettings();
    1.97 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KInvalidNameRegion(), KGECollation()) );
    1.98 +    firstExtendLocale.LoadSystemSettings();
    1.99 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KUKRegion(), KInvalidNameCollation()) );
   1.100 +    firstExtendLocale.LoadSystemSettings();
   1.101 +    test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KInvalidNameRegion(), KInvalidNameCollation()) );
   1.102 +
   1.103 +    firstExtendLocale.LoadSystemSettings();
   1.104 +    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameLanguage()));
   1.105 +    firstExtendLocale.LoadSystemSettings();
   1.106 +    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameRegion()));
   1.107 +    firstExtendLocale.LoadSystemSettings();
   1.108 +    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameCollation()));
   1.109 +    test.End();
   1.110 +    }
   1.111 +
   1.112 +//Old locale API should work with the legacy old locale DLL name in the new locale model
   1.113 +void TestOldLocaleAPI()
   1.114 +    {
   1.115 +    TExtendedLocale firstExtendLocale;
   1.116 +    
   1.117 +    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"));  
   1.118 +    firstExtendLocale.LoadSystemSettings();
   1.119 +    test( KErrNone == firstExtendLocale.LoadLocale(KOldUKLocaleName()) );
   1.120 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   1.121 +    TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
   1.122 +    TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
   1.123 +   
   1.124 +    firstExtendLocale.LoadSystemSettings();
   1.125 +    test( KErrNone == firstExtendLocale.LoadLocale(KOldCNLocaleName()) );
   1.126 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   1.127 +    TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
   1.128 +    TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
   1.129 +    test.End();
   1.130 +    
   1.131 +    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"));  
   1.132 +    firstExtendLocale.LoadSystemSettings();
   1.133 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldGELocaleName()));
   1.134 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldGELocaleName()));
   1.135 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldGELocaleName()));
   1.136 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   1.137 +    TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
   1.138 +    TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
   1.139 +    
   1.140 +    firstExtendLocale.LoadSystemSettings();
   1.141 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldUKLocaleName()));
   1.142 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldCNLocaleName()));
   1.143 +    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldUSLocaleName()));
   1.144 +    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
   1.145 +    TestLocaleDLLName(test, KEnglishLanguage(), KUSRegion(), KCNCollation() );
   1.146 +    TestLocaleContent(test, KEnglishLanguageID, KUSCurrencySymbol, KCNTCollationMethodID);
   1.147 +    test.End();
   1.148 +    }
   1.149 +
   1.150 +
   1.151 +void TestNewLocaleModel()
   1.152 +    {   
   1.153 +    TestOldLocaleAPI();   
   1.154 +    TestNewLocaleAPI();
   1.155 +    }
   1.156 +
   1.157 +TInt E32Main()
   1.158 +    {
   1.159 +    CTrapCleanup* tc = CTrapCleanup::New();
   1.160 +    test(tc != NULL);
   1.161 +
   1.162 +    __UHEAP_MARK;
   1.163 +
   1.164 +    test.Start(_L("The test for check old API and new API behavior in new locale model"));
   1.165 +    test.Title();
   1.166 +    TRAPD(err, ::TestNewLocaleModel())
   1.167 +    test(err == KErrNone);
   1.168 +
   1.169 +    test.End();
   1.170 +    test.Close();
   1.171 +
   1.172 +    __UHEAP_MARKEND;
   1.173 +
   1.174 +    delete tc;
   1.175 +
   1.176 +    return(KErrNone);
   1.177 +    }