os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_RebootNewLocaleModel.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 // This file contains RTest based test which checks behaviour of InitialiseLocale.exe
    15 // when persisted locale is corrrupt/damaged
    16 // 
    17 //
    18 
    19 #include <bautils.h>
    20 #include <f32file.h>
    21 #include <e32cmn.h>
    22 #include <e32test.h>
    23 #include <e32std.h>
    24 #include <e32const.h>
    25 #include <babackup.h>
    26 #include <hal.h>
    27 #include <centralrepository.h>
    28 #include "LocaleRepository.h"
    29 #include "InitialiseLocale.h"
    30 #include "T_CheckLocale.h"
    31 
    32 
    33 // Name of the exe to be called explicitly
    34 _LIT(KInitPersistLocaleExeName, "InitialiseLocale.exe");
    35 
    36 LOCAL_D RTest test(_L("T_RebootLocaleNewLocaleModel"));
    37 
    38 
    39 // Central Repository Data cage file-path
    40 _LIT(KPersistLocale, "C:\\private\\10202be9\\persists\\1020E4D3.*");
    41 
    42 RFs TheFs;
    43 
    44 /*
    45 This function prepares for next test i.e, tests InitialiseLocale behaves
    46 when persisted file is damaged/corrupt.
    47 */
    48 void SetUpTestCorruptLocale()
    49     {
    50     TExtendedLocale myExtendedLocale;
    51     myExtendedLocale.LoadSystemSettings() ;
    52 
    53     test.Printf(_L("\n Changing Locale to Chinese Locale(31) so that default values are evident"));
    54 
    55     // Change the locale to Default Locale, all settings from single Dll
    56     myExtendedLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation());
    57 
    58     // Save the changes to system settings
    59     myExtendedLocale.SaveSystemSettings();
    60 
    61     // Wait so that it persists to repository
    62     User::After(1000000);
    63 
    64     User::LeaveIfError(TheFs.Connect());
    65     // Delete/damage the persisted file so that InitialiseLocale.exe
    66     // detects the damage and loads default locale
    67     BaflUtils::DeleteFile(TheFs, KPersistLocale);
    68     TheFs.Close();
    69     test.Printf(_L("\n Deleted persist file from C: \n"));
    70     }
    71 /**
    72 @SYMTestCaseID		SYSLIB-BAFL-CIT-0142
    73 @SYMTestCaseDesc 	Check that InitialiseLocale can get the correct locale information after reboot in the new locale model.
    74 @SYMTestPriority 	High
    75 @SYMTestActions  	Ensure that InitialiseLocale can get the correct locale information after reboot in the new locale model.
    76 @SYMTestExpectedResults The test must not fail.
    77 @SYMREQ PREQ1924
    78 */
    79 LOCAL_D void TestRebootLocale()
    80 	{
    81     test.Start(_L(" @SYMTestCaseID:TI18N-INITLOCALE-CT-4006 after rebooting check the locale content"));
    82     TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation());
    83     TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
    84     test.End();
    85     
    86 	}
    87 
    88 
    89 /** Tests behavior of Initialisation mechanism after system reboots
    90 This test requires that,
    91 1. The T_LocaleFlexiNewLocaleModel is executed
    92 2. Epoc be shut down
    93 3. Epoc restarted (so that InitialisationLocale.exe is called)
    94 4. Then this test be run
    95 */
    96 void TestRebootLocaleBehavior()
    97 	{
    98 	RProcess process;
    99 	// Kick-in InitialiseLocale.exe once again explicitly, This will be
   100 	// done as part of system start in actual release code.
   101 	TInt r = process.Create(KInitPersistLocaleExeName, KNullDesC);
   102 	if(r == KErrNone)
   103 		{
   104 		process.Resume(); // Start the process going
   105 		User::After(1000000);
   106 
   107 		TestRebootLocale();
   108 
   109 		User::After(1000000);
   110 		process.Close();
   111 		User::After(1000000);
   112 		}
   113 	}
   114 
   115 
   116 TInt E32Main()
   117 	{
   118 	CTrapCleanup* cleanup = CTrapCleanup::New();
   119 	test(cleanup != NULL);
   120 
   121 	__UHEAP_MARK;
   122 	test.Start(_L("Test to test reboot system"));
   123 	test.Title();
   124 
   125 	TRAPD(err, ::TestRebootLocaleBehavior());
   126 
   127 	test(err == KErrNone);
   128 	
   129 	TRAPD(err1, ::SetUpTestCorruptLocale());
   130 	test(err1 == KErrNone);
   131 
   132 	test.End();
   133 	test.Close();
   134 
   135 	__UHEAP_MARKEND;
   136 	delete cleanup;
   137 
   138 	return(KErrNone);
   139 	}