os/ossrv/lowlevellibsandfws/pluginfw/Framework/SimpleTests/t_language.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/SimpleTests/t_language.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,734 @@
     1.4 +// Copyright (c) 2002-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 +#include <ecom/ecom.h>
    1.20 +#include "../EcomTestUtils/EcomTestUtils.h"
    1.21 +
    1.22 +#define UNUSED_VAR(a) a = a
    1.23 +
    1.24 +LOCAL_D RTest TEST(_L("ECom Language Plugin Test"));
    1.25 +
    1.26 +// Files to copy
    1.27 +_LIT(KEComLangPluginDllOnC, "C:\\sys\\bin\\LanguagePlugin.dll");
    1.28 +_LIT(KEComLangPluginDllOnZ, "Z:\\RAMOnly\\LanguagePlugin.dll");
    1.29 +
    1.30 +_LIT(KEComLangPluginRscOnC, "C:\\resource\\plugins\\LanguagePlugin.rsc");
    1.31 +_LIT(KEComLangPluginRscOnZ, "Z:\\RAMOnly\\LanguagePlugin.rsc");
    1.32 +
    1.33 +_LIT(KEComLangPluginRsc1OnC, "C:\\resource\\plugins\\LanguagePlugin.r01");
    1.34 +_LIT(KEComLangPluginRsc1OnZ, "Z:\\RAMOnly\\LanguagePlugin.r01");
    1.35 +
    1.36 +_LIT(KEComLangPluginRsc2OnC, "C:\\resource\\plugins\\LanguagePlugin.r02");
    1.37 +_LIT(KEComLangPluginRsc2OnZ, "Z:\\RAMOnly\\LanguagePlugin.r02");
    1.38 +
    1.39 +_LIT(KEComLangPluginRsc3OnC, "C:\\resource\\plugins\\LanguagePlugin.r03");
    1.40 +_LIT(KEComLangPluginRsc3OnZ, "Z:\\RAMOnly\\LanguagePlugin.r03");
    1.41 +
    1.42 +#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
    1.43 +    // Language files used for locale settings
    1.44 +    _LIT(KEComEnglishLocale, "elocl.01");
    1.45 +    _LIT(KEComFrenchLocale, "elocl.02");
    1.46 +    _LIT(KEComGermanLocale, "elocl.03");
    1.47 +    _LIT(KEComSpanishLocale, "elocl.04");
    1.48 +#else
    1.49 +// refer base/os/kernelhwsrv/kernel/eka/euser/locmapping.cpp
    1.50 +// Language
    1.51 +    _LIT(KEComEnglishLang,"elocl_lan.001");
    1.52 +    _LIT(KEComFrenchLang,"elocl_lan.002");
    1.53 +    _LIT(KEComGermanLang,"elocl_lan.003");
    1.54 +    _LIT(KEComSpanishLang,"elocl_lan.004");
    1.55 +    // Region
    1.56 +    _LIT(KEComEnglishReg,"elocl_reg.826");
    1.57 +    _LIT(KEComFrenchReg,"elocl_reg.250");
    1.58 +    _LIT(KEComGermanReg,"elocl_reg.276");
    1.59 +    _LIT(KEComSpanishReg,"elocl_reg.724");
    1.60 +    // Collation
    1.61 +    _LIT(KEComEnglishColl,"elocl_col.001");
    1.62 +    _LIT(KEComFrenchColl,"elocl_col.002");
    1.63 +    _LIT(KEComGermanColl,"elocl_col.003");
    1.64 +    _LIT(KEComSpanishColl,"elocl_col.001");
    1.65 +#endif
    1.66 +
    1.67 +// Result strings saved in opaque_data of each plugin
    1.68 +_LIT8(KEComDefaultResult, "LANGUAGE_RSC");
    1.69 +_LIT8(KEComEnglishResult, "LANGUAGE_01");
    1.70 +_LIT8(KEComFrenchResult, "LANGUAGE_02");
    1.71 +_LIT8(KEComGermanResult, "LANGUAGE_03");
    1.72 +
    1.73 +// Test data for data driven tests.
    1.74 +#define MAX_LANGUAGE_TEST_FILES 5
    1.75 +struct TLangTestEntry
    1.76 +	{
    1.77 +	// Source and destination to copy necessary plugins
    1.78 +	struct FilesInfo
    1.79 +		{
    1.80 +		const TDesC* source;
    1.81 +		const TDesC* dest;
    1.82 +		};
    1.83 +	FilesInfo files[MAX_LANGUAGE_TEST_FILES];
    1.84 +#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
    1.85 +	// Locale file to load
    1.86 +	const TDesC* localeFile;
    1.87 +#else
    1.88 +	const TDesC* lang;
    1.89 +	const TDesC* region;
    1.90 +	const TDesC* collation;
    1.91 +#endif
    1.92 +	// Language downgrade path to set up
    1.93 +	TLanguage downgradePathSetup[3];
    1.94 +
    1.95 +	// Expected result - opaque_data of retrieved plugin
    1.96 +	const TDesC8* result;
    1.97 +	};
    1.98 +
    1.99 +// Test Data
   1.100 +LOCAL_D const TLangTestEntry LangTestData[] =
   1.101 +	{
   1.102 +		// Data Set 0
   1.103 +		{
   1.104 +			{
   1.105 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.106 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.107 +				{&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
   1.108 +				{&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
   1.109 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.110 +			},
   1.111 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.112 +			&KEComEnglishLocale,
   1.113 +            #else
   1.114 +			&KEComEnglishLang,
   1.115 +			&KEComEnglishReg,
   1.116 +			&KEComEnglishColl,
   1.117 +            #endif
   1.118 +			{ELangEnglish, ELangFrench, ELangGerman},
   1.119 +			&KEComEnglishResult
   1.120 +		},
   1.121 +		// Data Set 1
   1.122 +		{
   1.123 +			{
   1.124 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.125 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.126 +				{&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
   1.127 +				{&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
   1.128 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.129 +			},
   1.130 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.131 +            &KEComFrenchLocale,
   1.132 +            #else
   1.133 +            &KEComFrenchLang,
   1.134 +            &KEComFrenchReg,
   1.135 +            &KEComFrenchColl,
   1.136 +            #endif
   1.137 +			{ELangFrench, ELangEnglish, ELangGerman},
   1.138 +			&KEComFrenchResult
   1.139 +		},
   1.140 +		// Data Set 2
   1.141 +		{
   1.142 +			{
   1.143 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.144 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.145 +				{&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
   1.146 +				{&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
   1.147 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.148 +			},
   1.149 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.150 +            &KEComGermanLocale,
   1.151 +            #else
   1.152 +            &KEComGermanLang,
   1.153 +            &KEComGermanReg,
   1.154 +            &KEComGermanColl,
   1.155 +            #endif
   1.156 +			{ELangGerman, ELangEnglish, ELangFrench},
   1.157 +			&KEComGermanResult
   1.158 +		},
   1.159 +		// Data Set 3
   1.160 +		{
   1.161 +			{
   1.162 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.163 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.164 +				{&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
   1.165 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.166 +			},
   1.167 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.168 +            &KEComFrenchLocale,
   1.169 +            #else
   1.170 +            &KEComFrenchLang,
   1.171 +            &KEComFrenchReg,
   1.172 +            &KEComFrenchColl,
   1.173 +            #endif
   1.174 +			{ELangEnglish, ELangFrench, ELangGerman},
   1.175 +			&KEComFrenchResult
   1.176 +		},
   1.177 +		// Data Set 4
   1.178 +		{
   1.179 +			{
   1.180 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.181 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.182 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.183 +			},
   1.184 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.185 +            &KEComGermanLocale,
   1.186 +            #else
   1.187 +            &KEComGermanLang,
   1.188 +            &KEComGermanReg,
   1.189 +            &KEComGermanColl,
   1.190 +            #endif
   1.191 +			{ELangEnglish, ELangFrench, ELangGerman},
   1.192 +			&KEComGermanResult
   1.193 +		},
   1.194 +		// Data Set 5
   1.195 +		{
   1.196 +			{
   1.197 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.198 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.199 +				{&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
   1.200 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.201 +			},
   1.202 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.203 +            &KEComGermanLocale,
   1.204 +            #else
   1.205 +            &KEComGermanLang,
   1.206 +            &KEComGermanReg,
   1.207 +            &KEComGermanColl,
   1.208 +            #endif
   1.209 +			{ELangSpanish, ELangItalian, ELangGerman},
   1.210 +			&KEComGermanResult
   1.211 +		},
   1.212 +		// Data Set 6
   1.213 +		{
   1.214 +			{
   1.215 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.216 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.217 +				{&KEComLangPluginRsc2OnZ, &KEComLangPluginRsc2OnC},
   1.218 +				{&KEComLangPluginRsc3OnZ, &KEComLangPluginRsc3OnC}
   1.219 +			},
   1.220 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.221 +            &KEComEnglishLocale,
   1.222 +            #else
   1.223 +            &KEComEnglishLang,
   1.224 +            &KEComEnglishReg,
   1.225 +            &KEComEnglishColl,
   1.226 +            #endif
   1.227 +			{ELangSpanish, ELangItalian, ELangSwedish},
   1.228 +			&KEComDefaultResult
   1.229 +		},
   1.230 +		// Data Set 7
   1.231 +		{
   1.232 +			{
   1.233 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.234 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.235 +				{&KEComLangPluginRsc1OnZ, &KEComLangPluginRsc1OnC},
   1.236 +			},
   1.237 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.238 +            &KEComEnglishLocale,
   1.239 +            #else
   1.240 +            &KEComEnglishLang,
   1.241 +            &KEComEnglishReg,
   1.242 +            &KEComEnglishColl,
   1.243 +            #endif
   1.244 +			{ELangSpanish, ELangSwedish, ELangItalian},
   1.245 +			&KEComEnglishResult
   1.246 +		},
   1.247 +		// Data Set 8
   1.248 +		{
   1.249 +			{
   1.250 +				{&KEComLangPluginDllOnZ, &KEComLangPluginDllOnC},
   1.251 +				{&KEComLangPluginRscOnZ, &KEComLangPluginRscOnC},
   1.252 +			},
   1.253 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.254 +            &KEComEnglishLocale,
   1.255 +            #else
   1.256 +            &KEComEnglishLang,
   1.257 +            &KEComEnglishReg,
   1.258 +            &KEComEnglishColl,
   1.259 +            #endif
   1.260 +			{ELangItalian, ELangSwedish, ELangSpanish},
   1.261 +			&KEComDefaultResult
   1.262 +		},
   1.263 +	};
   1.264 +
   1.265 +struct TLangTestEntry2
   1.266 +	{
   1.267 +	// Locale file to load
   1.268 +    #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.269 +        // Locale file to load
   1.270 +        const TDesC* localeFile;
   1.271 +    #else
   1.272 +        const TDesC* lang;
   1.273 +        const TDesC* region;
   1.274 +        const TDesC* collation;
   1.275 +    #endif
   1.276 +	
   1.277 +	// Language downgrade path to set up
   1.278 +	TLanguage downgradePathSetup[3];
   1.279 +
   1.280 +	// Expected result - opaque_data of retrieved plugin
   1.281 +	const TDesC8* result;
   1.282 +	};
   1.283 +
   1.284 +LOCAL_D const TLangTestEntry2 LangTestData2[] =
   1.285 +	{
   1.286 +		//Data Set 0
   1.287 +		{
   1.288 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.289 +            &KEComEnglishLocale,
   1.290 +            #else
   1.291 +            &KEComEnglishLang,
   1.292 +            &KEComEnglishReg,
   1.293 +            &KEComEnglishColl,
   1.294 +            #endif
   1.295 +			{ELangEnglish, ELangFrench, ELangGerman},
   1.296 +			&KEComEnglishResult
   1.297 +
   1.298 +		},
   1.299 +
   1.300 +		//Data Set 1
   1.301 +		{
   1.302 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.303 +            &KEComFrenchLocale,
   1.304 +            #else
   1.305 +            &KEComFrenchLang,
   1.306 +            &KEComFrenchReg,
   1.307 +            &KEComFrenchColl,
   1.308 +            #endif
   1.309 +			{ELangFrench, ELangEnglish, ELangGerman},
   1.310 +			&KEComFrenchResult
   1.311 +		},
   1.312 +		//Data Set 2
   1.313 +		{
   1.314 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.315 +            &KEComGermanLocale,
   1.316 +            #else
   1.317 +            &KEComGermanLang,
   1.318 +            &KEComGermanReg,
   1.319 +            &KEComGermanColl,
   1.320 +            #endif
   1.321 +			{ELangGerman, ELangEnglish, ELangFrench},
   1.322 +			&KEComGermanResult
   1.323 +		},
   1.324 +		//Data Set 3
   1.325 +		{
   1.326 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.327 +            &KEComFrenchLocale,
   1.328 +            #else
   1.329 +            &KEComFrenchLang,
   1.330 +            &KEComFrenchReg,
   1.331 +            &KEComFrenchColl,
   1.332 +            #endif
   1.333 +			{ELangEnglish, ELangFrench, ELangGerman},
   1.334 +			&KEComFrenchResult
   1.335 +		},
   1.336 +		//Data Set 4
   1.337 +		{
   1.338 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.339 +            &KEComGermanLocale,
   1.340 +            #else
   1.341 +            &KEComGermanLang,
   1.342 +            &KEComGermanReg,
   1.343 +            &KEComGermanColl,
   1.344 +            #endif
   1.345 +			{ELangEnglish, ELangFrench, ELangGerman},
   1.346 +			&KEComGermanResult
   1.347 +		},
   1.348 +		//Data Set 5
   1.349 +		{
   1.350 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.351 +            &KEComGermanLocale,
   1.352 +            #else
   1.353 +            &KEComGermanLang,
   1.354 +            &KEComGermanReg,
   1.355 +            &KEComGermanColl,
   1.356 +            #endif
   1.357 +			{ELangSpanish, ELangItalian, ELangGerman},
   1.358 +			&KEComGermanResult
   1.359 +		},
   1.360 +		//Data Set 6
   1.361 +		{
   1.362 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.363 +            &KEComEnglishLocale,
   1.364 +            #else
   1.365 +            &KEComEnglishLang,
   1.366 +            &KEComEnglishReg,
   1.367 +            &KEComEnglishColl,
   1.368 +            #endif
   1.369 +			{ELangSpanish, ELangItalian, ELangSwedish},
   1.370 +			&KEComEnglishResult
   1.371 +
   1.372 +		},
   1.373 +		//Data Set 7
   1.374 +		{
   1.375 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.376 +            &KEComSpanishLocale,
   1.377 +            #else
   1.378 +            &KEComSpanishLang,
   1.379 +            &KEComSpanishReg,
   1.380 +            &KEComSpanishColl,
   1.381 +            #endif
   1.382 +			{ELangSpanish, ELangFrench, ELangEnglish},
   1.383 +			&KEComFrenchResult
   1.384 +
   1.385 +		},
   1.386 +		//Data Set 8
   1.387 +		{
   1.388 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.389 +            &KEComSpanishLocale,
   1.390 +            #else
   1.391 +            &KEComSpanishLang,
   1.392 +            &KEComSpanishReg,
   1.393 +            &KEComSpanishColl,
   1.394 +            #endif
   1.395 +			{ELangSpanish,ELangItalian, ELangSwedish},
   1.396 +			&KEComDefaultResult
   1.397 +		},
   1.398 +
   1.399 +		//Data Set 9
   1.400 +		{
   1.401 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.402 +            &KEComSpanishLocale,
   1.403 +            #else
   1.404 +            &KEComSpanishLang,
   1.405 +            &KEComSpanishReg,
   1.406 +            &KEComSpanishColl,
   1.407 +            #endif
   1.408 +			{ELangSpanish, ELangGerman, ELangItalian},
   1.409 +			&KEComGermanResult
   1.410 +		},
   1.411 +
   1.412 +		//Data Set 10
   1.413 +		{
   1.414 +            #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.415 +            &KEComSpanishLocale,
   1.416 +            #else
   1.417 +            &KEComSpanishLang,
   1.418 +            &KEComSpanishReg,
   1.419 +            &KEComSpanishColl,
   1.420 +            #endif
   1.421 +			{ELangSpanish, ELangItalian, ELangNone},
   1.422 +			&KEComDefaultResult
   1.423 +		}
   1.424 +	};
   1.425 +
   1.426 +class REComLanguagePluginTest
   1.427 +	{
   1.428 +public:
   1.429 +	void StaticRunTestsL();
   1.430 +	void DynamicRunTestsOnCL();
   1.431 +	void DynamicRunTestsOnZL();
   1.432 +    #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL	
   1.433 +        void SetLanguage(const TDesC& aLangFile,  const TLanguage aLang[3]);
   1.434 +    #else	
   1.435 +        void SetLanguage(const TDesC& aLanguage,const TDesC& aReg,const TDesC& aColl,const TLanguage aLang[3]);
   1.436 +    #endif
   1.437 +	void CopyFiles(TInt aIndex);
   1.438 +	static void DeleteFiles(TInt aIndex);
   1.439 +	void DoCheckL(TInt testDataId, TUid &aInterfaceId, TDriveUnit aDriveUnit);
   1.440 +	};
   1.441 +
   1.442 +/**
   1.443 +Copies plugins.
   1.444 +*/
   1.445 +void REComLanguagePluginTest::CopyFiles(TInt aIndex)
   1.446 +	{
   1.447 +	for (TInt i = 0; i < MAX_LANGUAGE_TEST_FILES && LangTestData[aIndex].files[i].source; i++)
   1.448 +		{
   1.449 +		TRAPD(err, EComTestUtils::FileManCopyFileL(	*(LangTestData[aIndex].files[i].source),
   1.450 +													*(LangTestData[aIndex].files[i].dest)) );
   1.451 + 		TEST(err==KErrNone, __LINE__);
   1.452 +		}
   1.453 +	}
   1.454 +
   1.455 +/**
   1.456 +Deletes plugins.
   1.457 +*/
   1.458 +void REComLanguagePluginTest::DeleteFiles(TInt aIndex)
   1.459 +	{
   1.460 +		for (TInt i = 0; i < MAX_LANGUAGE_TEST_FILES && LangTestData[aIndex].files[i].source != NULL; i++)
   1.461 +		{
   1.462 +		TRAPD(err, EComTestUtils::FileManDeleteFileL(*(LangTestData[aIndex].files[i].dest)) );
   1.463 +		UNUSED_VAR(err);
   1.464 +		}
   1.465 +	}
   1.466 +#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.467 +/**
   1.468 +Sets up the system-wide locale and language downgrade path.
   1.469 +*/
   1.470 +void REComLanguagePluginTest::SetLanguage(const TDesC& aLangFile, const TLanguage aLang[3])
   1.471 +	{
   1.472 +	TLocale locale;
   1.473 +	TInt loadval = 0;
   1.474 +	TExtendedLocale extendedLocale;
   1.475 +
   1.476 +	extendedLocale.LoadSystemSettings();
   1.477 +	loadval = extendedLocale.LoadLocale(aLangFile);
   1.478 +	TEST(loadval==KErrNone, __LINE__);
   1.479 +	extendedLocale.SaveSystemSettings();
   1.480 +
   1.481 +	locale.SetLanguageDowngrade(0, aLang[0]);
   1.482 +	locale.SetLanguageDowngrade(1, aLang[1]);
   1.483 +	locale.SetLanguageDowngrade(2, aLang[2]);
   1.484 +	locale.Set();
   1.485 +	}
   1.486 +#else
   1.487 +/**
   1.488 +Sets up the system-wide locale and language downgrade path for the new locale model.
   1.489 +*/
   1.490 +void REComLanguagePluginTest::SetLanguage(const TDesC& aLanguage,const TDesC& aReg,const TDesC& aColl,const TLanguage aLang[3])
   1.491 +    {
   1.492 +    TLocale locale;
   1.493 +    TExtendedLocale extendedLocale;
   1.494 +    TInt loadval = 0;
   1.495 +
   1.496 +    extendedLocale.LoadSystemSettings();
   1.497 +    loadval = extendedLocale.LoadLocale(aLanguage,aReg,aColl);
   1.498 +    TEST(loadval==KErrNone, __LINE__);
   1.499 +    extendedLocale.SaveSystemSettings();
   1.500 +
   1.501 +    locale.SetLanguageDowngrade(0, aLang[0]);
   1.502 +    locale.SetLanguageDowngrade(1, aLang[1]);
   1.503 +    locale.SetLanguageDowngrade(2, aLang[2]);
   1.504 +    locale.Set();
   1.505 +    }
   1.506 +#endif
   1.507 +
   1.508 +void REComLanguagePluginTest::DoCheckL(TInt testDataId, TUid &aInterfaceId, TDriveUnit aDriveUnit)
   1.509 +	{
   1.510 +	RImplInfoPtrArray implArray;
   1.511 +
   1.512 +	REComSession::ListImplementationsL(aInterfaceId, implArray);
   1.513 +
   1.514 +	// Verify results
   1.515 +	TBuf<100> buf;
   1.516 +	RDebug::Print(_L("\tArray Count = %d\n"), implArray.Count());
   1.517 +	buf.Copy(implArray[0]->OpaqueData());
   1.518 +	RDebug::Print(_L("\tOpaque Data = %S\n"), &buf);
   1.519 +	TInt drive = implArray[0]->Drive();
   1.520 +	RDebug::Print(_L("\tDrive = %d\n"), drive);
   1.521 +
   1.522 +	TEST(implArray.Count() == 1);
   1.523 +
   1.524 +	if(aDriveUnit == EDriveZ)
   1.525 +		{
   1.526 +		TEST(implArray[0]->OpaqueData() == *(LangTestData2[testDataId].result));
   1.527 +		}
   1.528 +	else
   1.529 +		{
   1.530 +		TEST(implArray[0]->OpaqueData() == *(LangTestData[testDataId].result));
   1.531 +		}
   1.532 +
   1.533 +	TEST(implArray[0]->Drive() == aDriveUnit);
   1.534 +
   1.535 +	// Post test clean up
   1.536 +	REComSession::FinalClose();
   1.537 +	implArray.ResetAndDestroy();
   1.538 +	}
   1.539 +
   1.540 +/**
   1.541 +Test case for DEF087773: ECOM ValidateRegistry checks for existence of RSC file only
   1.542 +
   1.543 +@SYMTestCaseID			SYSLIB-ECOM-CT-0655
   1.544 +@SYMTestCaseDesc		Checks for existence of resource files for different downgrade paths
   1.545 +@SYMTestPriority			high
   1.546 +@SYMTestActions			Data driven tests.
   1.547 +						Create different sets of language dependant resource file on "C"
   1.548 +						Drive and verify the ECom discovery process
   1.549 +@SYMTestExpectedResults The test must not fail.
   1.550 +@SYMDEF					DEF087773
   1.551 +*/
   1.552 +void REComLanguagePluginTest::StaticRunTestsL()
   1.553 +	{
   1.554 +	TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0655 "));
   1.555 +	TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);
   1.556 +
   1.557 +	TUid ifUid={0x10009DB9};
   1.558 +	for(TInt i = 0; i < numberOfElements; i++)
   1.559 +		{
   1.560 +		// kill ecom server so that language downgrade changes are picked up
   1.561 +		ECOMTU_KILL_SERVER_L(TEST);
   1.562 +
   1.563 +		// Prepare test
   1.564 +        #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.565 +		SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup);
   1.566 +        #else
   1.567 +		SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup);
   1.568 +        #endif
   1.569 +		
   1.570 +		CopyFiles(i);
   1.571 +
   1.572 +		// 1st boot
   1.573 +		TEST.Printf(_L("\tLanguage Plugin Test %d - 1st boot \n"), i);
   1.574 +		DoCheckL(i,ifUid, EDriveC );
   1.575 +
   1.576 +		// kill ecom server for second boot
   1.577 +		ECOMTU_KILL_SERVER_L(TEST);
   1.578 +
   1.579 +		// 2nd boot
   1.580 +		TEST.Printf(_L("\tLanguage Plugin Test %d - 2nd boot \n"), i);
   1.581 +		DoCheckL(i, ifUid, EDriveC);
   1.582 +
   1.583 +		DeleteFiles(i);
   1.584 +		WAIT_FOR3s;
   1.585 +		}
   1.586 +	}
   1.587 +
   1.588 +/**
   1.589 +Test case for CR0209: Enable Dynamic Language Switching in ECOM
   1.590 +
   1.591 +@SYMTestCaseID			SYSLIB-ECOM-CT-3169
   1.592 +@SYMTestCaseDesc		Checks for picking up correct resource files for different downgrade paths in running time
   1.593 +@SYMTestPriority		high
   1.594 +@SYMTestActions			Data driven tests.
   1.595 +						Start up Ecom server
   1.596 +						Create different sets of language dependant resource file on "C" on running time.
   1.597 +						Drive and verify the ECom discovery process
   1.598 +@SYMTestExpectedResults The test must not fail.
   1.599 +@SYMDEF					CR0209
   1.600 +*/
   1.601 +void REComLanguagePluginTest::DynamicRunTestsOnCL()
   1.602 +	{
   1.603 +	TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3169 "));
   1.604 +	TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);
   1.605 +
   1.606 +	RImplInfoPtrArray implArray;
   1.607 +	TUid ifUid={0x10009DB9};
   1.608 +
   1.609 +	//start up ecom server
   1.610 +	REComSession::ListImplementationsL(ifUid, implArray);
   1.611 +
   1.612 +	for(TInt i = 0; i < numberOfElements; i++)
   1.613 +		{
   1.614 +
   1.615 +		// Prepare test
   1.616 +		CopyFiles(i);
   1.617 +
   1.618 +        #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.619 +        SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup);
   1.620 +        #else
   1.621 +        SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup);
   1.622 +        #endif
   1.623 +		WAIT_FOR3s;
   1.624 +
   1.625 +		TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on C \n"), i);
   1.626 +		DoCheckL(i,ifUid, EDriveC);
   1.627 +
   1.628 +		DeleteFiles(i);
   1.629 +		WAIT_FOR3s;
   1.630 +		implArray.ResetAndDestroy();
   1.631 +
   1.632 +		}
   1.633 +
   1.634 +	// Post test clean up
   1.635 +	REComSession::FinalClose();
   1.636 +	implArray.ResetAndDestroy();
   1.637 +
   1.638 +	//kill ecomserver after finishing test
   1.639 +	ECOMTU_KILL_SERVER_L(TEST);
   1.640 +
   1.641 +	}
   1.642 +
   1.643 +/**
   1.644 +Test case for CR0209: Enable Dynamic Language Switching in ECOM on Z: drive
   1.645 +
   1.646 +@SYMTestCaseID			SYSLIB-ECOM-CT-3170
   1.647 +@SYMTestCaseDesc		Checks for picking up correct resource files for different downgrade paths in running time.
   1.648 +@SYMTestPriority		high
   1.649 +@SYMTestActions			Data driven tests.
   1.650 +						Start up Ecom server
   1.651 +						Change languae downgrade path on running time.
   1.652 +						Drive and verify the ECom discovery process.
   1.653 +@SYMTestExpectedResults The test must not fail.
   1.654 +@SYMDEF					CR0209
   1.655 +*/
   1.656 +void REComLanguagePluginTest::DynamicRunTestsOnZL()
   1.657 +	{
   1.658 +	TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3170 "));
   1.659 +	TInt numberOfElements = sizeof(LangTestData2)/sizeof(TLangTestEntry2);
   1.660 +
   1.661 +	//Interface ID in a DLL existing on Z: Drive
   1.662 +	TUid ifUid={0x10009DE1};
   1.663 +
   1.664 +	//start up ecom server
   1.665 +	RImplInfoPtrArray implArray;
   1.666 +	REComSession::ListImplementationsL(ifUid, implArray);
   1.667 +	WAIT_FOR3s;
   1.668 +
   1.669 +	for(TInt i = 0; i < numberOfElements; i++)
   1.670 +		{
   1.671 +
   1.672 +		// Prepare test
   1.673 +        #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.674 +        SetLanguage(*(LangTestData2[i].localeFile), LangTestData2[i].downgradePathSetup);
   1.675 +        #else
   1.676 +        SetLanguage(*(LangTestData2[i].lang),*(LangTestData2[i].region),*(LangTestData2[i].collation),LangTestData2[i].downgradePathSetup);
   1.677 +        #endif
   1.678 +		WAIT_FOR3s;
   1.679 +
   1.680 +		// Dynamic language downgrade path changing
   1.681 +		TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on Z \n"), i);
   1.682 +		DoCheckL(i,ifUid, EDriveZ);
   1.683 +		implArray.ResetAndDestroy();
   1.684 +
   1.685 +		}
   1.686 +
   1.687 +	// Post test clean up
   1.688 +	REComSession::FinalClose();
   1.689 +	implArray.ResetAndDestroy();
   1.690 +
   1.691 +	}
   1.692 +
   1.693 +LOCAL_C void RunTestL()
   1.694 +	{
   1.695 +	__UHEAP_MARK;
   1.696 +	REComLanguagePluginTest testSuite;
   1.697 +	testSuite.StaticRunTestsL();
   1.698 +	testSuite.DynamicRunTestsOnCL();
   1.699 +	testSuite.DynamicRunTestsOnZL();
   1.700 +
   1.701 +	__UHEAP_MARKEND;
   1.702 +	}
   1.703 +
   1.704 +GLDEF_C TInt E32Main()
   1.705 +	{
   1.706 +	__UHEAP_MARK;
   1.707 +
   1.708 +	TEST.Title();
   1.709 +	TEST.Start(_L("ECom Language Plugins tests."));
   1.710 +
   1.711 +	CTrapCleanup* cleanup = CTrapCleanup::New();
   1.712 +	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
   1.713 +	CActiveScheduler::Install(scheduler);
   1.714 +
   1.715 +	TRAPD(err,RunTestL());
   1.716 +
   1.717 +	// tidy up in case of leave
   1.718 +	if(err != KErrNone)
   1.719 +		{
   1.720 +		TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);
   1.721 +		for(TInt i = 0; i < numberOfElements; i++)
   1.722 +			{
   1.723 +			REComLanguagePluginTest::DeleteFiles(i);
   1.724 +			}
   1.725 +		}
   1.726 +
   1.727 +	TEST(err==KErrNone, __LINE__);
   1.728 +
   1.729 +	delete scheduler;
   1.730 +	delete cleanup;
   1.731 +
   1.732 +	TEST.End();
   1.733 +	TEST.Close();
   1.734 +
   1.735 +	__UHEAP_MARKEND;
   1.736 +	return(0);
   1.737 +	}