sysstatemgmt/systemstateplugins/test/tunitadptplugin/src/tmisc_adaptationplugin_step.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code  
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #include <s32mem.h>
       
    25 #include "tmisc_adaptationplugin_step.h"
       
    26 
       
    27 //
       
    28 // Run the tests
       
    29 //
       
    30 
       
    31 CTestMiscAdaptationPlugin::CTestMiscAdaptationPlugin()
       
    32 	:CAdaptationTestBase(KTCTestMiscAdaptationPlugin)
       
    33 	{
       
    34 	
       
    35 	}
       
    36 
       
    37 CTestMiscAdaptationPlugin::~CTestMiscAdaptationPlugin()
       
    38 	{
       
    39 
       
    40 	}
       
    41 
       
    42 
       
    43 
       
    44 void CTestMiscAdaptationPlugin::TestSecurityStateChange()
       
    45 	{
       
    46 	INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::TestSecurityStateChange"));
       
    47 
       
    48 	TRequestStatus status;
       
    49 	TPckgBuf <TInt> responsePckg;
       
    50 	TInt state = 0;
       
    51 	iSsmMiscAdaptation.SecurityStateChange(state, responsePckg, status);
       
    52 	User::WaitForRequest(status);
       
    53 
       
    54 	if(iSsmMiscAdaptation.Handle())
       
    55 		{
       
    56 		TEST(KErrNone == status.Int());	
       
    57 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestSecurityStateChange completed with %d error : expected %d>"),status.Int(),KErrNone);	
       
    58 		}
       
    59 	else
       
    60 		{
       
    61 		TEST(KErrDisconnected == status.Int());	
       
    62 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestSecurityStateChange completed with %d error : expected %d>"),status.Int(),KErrDisconnected);	
       
    63 		}
       
    64 	}
       
    65 
       
    66 void CTestMiscAdaptationPlugin::TestGetGlobalStartupMode()
       
    67 	{
       
    68 	INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::TestGetGlobalStartupMode"));
       
    69 
       
    70 	TRequestStatus status;
       
    71 	TPckgBuf <TInt> modePckg;
       
    72 	iSsmMiscAdaptation.GetGlobalStartupMode(modePckg, status);
       
    73 	User::WaitForRequest(status);
       
    74 
       
    75 	if(iSsmMiscAdaptation.Handle())
       
    76 		{
       
    77 		TEST(KErrNone == status.Int());	
       
    78 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestGetGlobalStartupMode completed with %d error : expected %d>"),status.Int(),KErrNone);	
       
    79 		}
       
    80 	else
       
    81 		{
       
    82 		TEST(KErrDisconnected == status.Int());	
       
    83 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestGetGlobalStartupMode completed with %d error : expected %d>"),status.Int(),KErrDisconnected);	
       
    84 		}
       
    85 	}
       
    86 
       
    87 void CTestMiscAdaptationPlugin::DoTestPrepareSimLanguages(TSsmLanguageListPriority aPriority)
       
    88     {
       
    89     INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::DoTestPrepareSimLanguages"));
       
    90 
       
    91     TRequestStatus status;
       
    92     TPckgBuf <TInt> sizePckg;
       
    93 
       
    94     iSsmMiscAdaptation.PrepareSimLanguages(aPriority, sizePckg, status);
       
    95     User::WaitForRequest(status);
       
    96     
       
    97     if(iSsmMiscAdaptation.Handle())
       
    98         {
       
    99         TEST(KErrNotSupported == status.Int()); 
       
   100         INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::DoTestPrepareSimLanguages completed with %d error : expected %d>"),status.Int(),KErrNotSupported);    
       
   101         }
       
   102     else
       
   103         {
       
   104         TEST(KErrDisconnected == status.Int()); 
       
   105         INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::DoTestPrepareSimLanguages completed with %d error : expected %d>"),status.Int(),KErrDisconnected);    
       
   106         }
       
   107 
       
   108     }
       
   109 
       
   110 void CTestMiscAdaptationPlugin::TestPrepareSimLanguages()
       
   111 	{
       
   112 	INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::TestPrepareSimLanguages"));
       
   113 
       
   114 	DoTestPrepareSimLanguages(EPrimaryLanguages);
       
   115 
       
   116 	DoTestPrepareSimLanguages(ESecondaryLanguages);
       
   117 	
       
   118 	DoTestPrepareSimLanguages(ETertiaryLanguages);
       
   119 	}
       
   120 
       
   121 void CTestMiscAdaptationPlugin::TestGetSimLanguages()
       
   122 	{
       
   123 	INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::TestGetSimLanguages"));
       
   124 
       
   125 	//Testing PrepareSimLaguages 
       
   126 	DoTestPrepareSimLanguages(EPrimaryLanguages);
       
   127 
       
   128 	TInt simLanguageCount = 2; //Setting simLanguageCount to dummy value '2' for testing as the server would not have written any response in sizePckg and hence it will contain garbage value
       
   129 	TRAPD(res,iSsmMiscAdaptation.SimLanguagesArrayL(simLanguageCount));
       
   130 	
       
   131 	if(iSsmMiscAdaptation.Handle())
       
   132 		{
       
   133 		TEST(KErrNotSupported == res);	
       
   134 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestGetSimLanguages completed with %d error : expected %d>"),res,KErrNotSupported);	
       
   135 		}
       
   136 	else
       
   137 		{
       
   138 		TEST(KErrDisconnected == res);	
       
   139 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestGetSimLanguages completed with %d error : expected %d>"),res,KErrDisconnected);	
       
   140 		}
       
   141 	}
       
   142 
       
   143 void CTestMiscAdaptationPlugin::TestGetHiddenReset()
       
   144 	{
       
   145 	INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::TestGetHiddenReset"));
       
   146 
       
   147 	TRequestStatus status;
       
   148 	TPckgBuf<TBool> hiddenResetPckg;
       
   149 	iSsmMiscAdaptation.GetHiddenReset(hiddenResetPckg, status);
       
   150 	User::WaitForRequest(status);
       
   151 
       
   152 	if(iSsmMiscAdaptation.Handle())
       
   153 		{
       
   154 		TEST(KErrNotSupported == status.Int());	
       
   155 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestGetHiddenReset completed with %d error : expected %d>"),status.Int(),KErrNotSupported);	
       
   156 		}
       
   157 	else
       
   158 		{
       
   159 		TEST(KErrDisconnected == status.Int());	
       
   160 		INFO_PRINTF3(_L("CTestMiscAdaptationPlugin::TestGetHiddenReset completed with %d error : expected %d>"),status.Int(),KErrDisconnected);	
       
   161 		}
       
   162 	}
       
   163 
       
   164 void CTestMiscAdaptationPlugin::TestCancel()
       
   165 	{
       
   166 	INFO_PRINTF1(_L(" >CTestMiscAdaptationPlugin::TestCancel"));
       
   167 	iSsmMiscAdaptation.Cancel();
       
   168 	INFO_PRINTF1(_L(" CTestMiscAdaptationPlugin::TestCancel>"));	
       
   169 	}
       
   170 
       
   171 
       
   172 //from CAdaptationTestBase
       
   173 TVerdict CTestMiscAdaptationPlugin::doTestStepL()
       
   174 	{
       
   175 	__UHEAP_MARK;
       
   176 	
       
   177 	TestSecurityStateChange();
       
   178 
       
   179 	TestGetGlobalStartupMode();
       
   180 	
       
   181 	TestPrepareSimLanguages();
       
   182 
       
   183 	TestGetSimLanguages();
       
   184 	
       
   185 	TestGetHiddenReset();
       
   186 
       
   187 	TestCancel();
       
   188 	
       
   189 	User::LeaveIfError(iSsmMiscAdaptation.Connect());
       
   190 
       
   191 	TestSecurityStateChange();
       
   192 
       
   193 	TestGetGlobalStartupMode();
       
   194 	
       
   195 	TestPrepareSimLanguages();
       
   196 
       
   197 	TestGetSimLanguages();
       
   198 	
       
   199 	TestGetHiddenReset();
       
   200 
       
   201 	TestCancel();
       
   202 	//TestRelease();			// have to test this part too ...
       
   203 
       
   204 	__UHEAP_MARKEND;
       
   205 
       
   206 	return TestStepResult();
       
   207 	}