os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_NewLocaleModel.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
#include "T_CheckLocale.h"
sl@0
    18
#include <e32reg.h>
sl@0
    19
sl@0
    20
RTest test(_L("T_NewLocaleModel"));
sl@0
    21
sl@0
    22
sl@0
    23
//new locale API should work in the new locale model
sl@0
    24
void TestNewLocaleAPI()
sl@0
    25
    {
sl@0
    26
    TExtendedLocale firstExtendLocale;
sl@0
    27
    
sl@0
    28
    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4022 new LoadLocale() interface"));
sl@0
    29
    firstExtendLocale.LoadSystemSettings();
sl@0
    30
    test( KErrNone == firstExtendLocale.LoadLocale(KGermanLanguage(), KGERegion(), KGECollation()) );
sl@0
    31
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
    32
    TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
sl@0
    33
    TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
sl@0
    34
	test( ERegDEU == User::RegionCode() );
sl@0
    35
sl@0
    36
    firstExtendLocale.LoadSystemSettings();
sl@0
    37
    test( KErrNone == firstExtendLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation()) );
sl@0
    38
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
    39
    TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
sl@0
    40
    TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
sl@0
    41
    
sl@0
    42
    //becasue TestLocaleContent() naturally check the system locale content, we mark this test case here.
sl@0
    43
    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4025 publish locale content to the system"));
sl@0
    44
    test.End();
sl@0
    45
sl@0
    46
    firstExtendLocale.LoadSystemSettings();
sl@0
    47
    test( KErrNone == firstExtendLocale.LoadLocale(KUSLanguage(), KCNRegion(), KGECollation()) );
sl@0
    48
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
    49
    TestLocaleDLLName(test, KUSLanguage(), KCNRegion(), KGECollation() );
sl@0
    50
    TestLocaleContent(test, KUSLanguageID, KCNCurrencySymbol, KGETCollationMethodID);
sl@0
    51
    test.End();
sl@0
    52
    
sl@0
    53
    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4023 new LoadLocaleAspect() interface"));  
sl@0
    54
    firstExtendLocale.LoadSystemSettings();    
sl@0
    55
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KCNLanguage));
sl@0
    56
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUSRegion));
sl@0
    57
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KGECollation));
sl@0
    58
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
    59
    TestLocaleDLLName(test, KCNLanguage(), KUSRegion(), KGECollation() );
sl@0
    60
    TestLocaleContent(test, KCNLanguageID, KUSCurrencySymbol, KGETCollationMethodID);
sl@0
    61
sl@0
    62
    firstExtendLocale.LoadSystemSettings();
sl@0
    63
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KEnglishLanguage));
sl@0
    64
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUKRegion));
sl@0
    65
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(KStandardCollation));
sl@0
    66
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
    67
    TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
sl@0
    68
    TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
sl@0
    69
    test.End();
sl@0
    70
sl@0
    71
    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4020 new LoadLocale() should not work with old locale DLL"));  
sl@0
    72
    firstExtendLocale.LoadSystemSettings();
sl@0
    73
    test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldUKLocaleName(), KOldUKLocaleName()) );
sl@0
    74
    firstExtendLocale.LoadSystemSettings();
sl@0
    75
    test( KErrNotFound == firstExtendLocale.LoadLocale(KOldCNLocaleName(), KOldCNLocaleName(), KOldCNLocaleName()) );
sl@0
    76
    firstExtendLocale.LoadSystemSettings();
sl@0
    77
    test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldCNLocaleName(), KOldGELocaleName()) );
sl@0
    78
    test.End();
sl@0
    79
sl@0
    80
    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4021 new LoadLocaleAspect() should not work with old locale DLL"));  
sl@0
    81
    firstExtendLocale.LoadSystemSettings();
sl@0
    82
    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldUKLocaleName()));
sl@0
    83
    firstExtendLocale.LoadSystemSettings();
sl@0
    84
    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldCNLocaleName()));
sl@0
    85
    firstExtendLocale.LoadSystemSettings();
sl@0
    86
    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldGELocaleName()));
sl@0
    87
    test.End();
sl@0
    88
    
sl@0
    89
    
sl@0
    90
    test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4024 check DLL naming convention"));  
sl@0
    91
    firstExtendLocale.LoadSystemSettings();
sl@0
    92
    test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KUKRegion(), KGECollation()) );
sl@0
    93
    firstExtendLocale.LoadSystemSettings();
sl@0
    94
    test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KInvalidNameRegion(), KGECollation()) );
sl@0
    95
    firstExtendLocale.LoadSystemSettings();
sl@0
    96
    test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KUKRegion(), KInvalidNameCollation()) );
sl@0
    97
    firstExtendLocale.LoadSystemSettings();
sl@0
    98
    test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KInvalidNameRegion(), KInvalidNameCollation()) );
sl@0
    99
sl@0
   100
    firstExtendLocale.LoadSystemSettings();
sl@0
   101
    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameLanguage()));
sl@0
   102
    firstExtendLocale.LoadSystemSettings();
sl@0
   103
    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameRegion()));
sl@0
   104
    firstExtendLocale.LoadSystemSettings();
sl@0
   105
    test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameCollation()));
sl@0
   106
    test.End();
sl@0
   107
    }
sl@0
   108
sl@0
   109
//Old locale API should work with the legacy old locale DLL name in the new locale model
sl@0
   110
void TestOldLocaleAPI()
sl@0
   111
    {
sl@0
   112
    TExtendedLocale firstExtendLocale;
sl@0
   113
    
sl@0
   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"));  
sl@0
   115
    firstExtendLocale.LoadSystemSettings();
sl@0
   116
    test( KErrNone == firstExtendLocale.LoadLocale(KOldUKLocaleName()) );
sl@0
   117
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
   118
    TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
sl@0
   119
    TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
sl@0
   120
   
sl@0
   121
    firstExtendLocale.LoadSystemSettings();
sl@0
   122
    test( KErrNone == firstExtendLocale.LoadLocale(KOldCNLocaleName()) );
sl@0
   123
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
   124
    TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
sl@0
   125
    TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
sl@0
   126
    test.End();
sl@0
   127
    
sl@0
   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"));  
sl@0
   129
    firstExtendLocale.LoadSystemSettings();
sl@0
   130
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldGELocaleName()));
sl@0
   131
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldGELocaleName()));
sl@0
   132
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldGELocaleName()));
sl@0
   133
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
   134
    TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
sl@0
   135
    TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
sl@0
   136
    
sl@0
   137
    firstExtendLocale.LoadSystemSettings();
sl@0
   138
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldUKLocaleName()));
sl@0
   139
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldCNLocaleName()));
sl@0
   140
    test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldUSLocaleName()));
sl@0
   141
    test( KErrNone == firstExtendLocale.SaveSystemSettings() );
sl@0
   142
    TestLocaleDLLName(test, KEnglishLanguage(), KUSRegion(), KCNCollation() );
sl@0
   143
    TestLocaleContent(test, KEnglishLanguageID, KUSCurrencySymbol, KCNTCollationMethodID);
sl@0
   144
    test.End();
sl@0
   145
    }
sl@0
   146
sl@0
   147
sl@0
   148
void TestNewLocaleModel()
sl@0
   149
    {   
sl@0
   150
    TestOldLocaleAPI();   
sl@0
   151
    TestNewLocaleAPI();
sl@0
   152
    }
sl@0
   153
sl@0
   154
TInt E32Main()
sl@0
   155
    {
sl@0
   156
    CTrapCleanup* tc = CTrapCleanup::New();
sl@0
   157
    test(tc != NULL);
sl@0
   158
sl@0
   159
    __UHEAP_MARK;
sl@0
   160
sl@0
   161
    test.Start(_L("The test for check old API and new API behavior in new locale model"));
sl@0
   162
    test.Title();
sl@0
   163
    TRAPD(err, ::TestNewLocaleModel())
sl@0
   164
    test(err == KErrNone);
sl@0
   165
sl@0
   166
    test.End();
sl@0
   167
    test.Close();
sl@0
   168
sl@0
   169
    __UHEAP_MARKEND;
sl@0
   170
sl@0
   171
    delete tc;
sl@0
   172
sl@0
   173
    return(KErrNone);
sl@0
   174
    }