|
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 #include <eikenv.h> |
|
23 #include <eikappui.h> |
|
24 #include <eikapp.h> |
|
25 #include <eikdoc.h> |
|
26 #include <ecom/ecom.h> |
|
27 #include <hal.h> |
|
28 |
|
29 #include "TDisableExitChecksStep.h" |
|
30 #include <apacmdln.h> |
|
31 |
|
32 |
|
33 _LIT(KTDisableExitChecksResourceFilePath,""); |
|
34 _LIT8(KETrue,"ETrue"); |
|
35 _LIT8(KEFalse,"EFalse"); |
|
36 |
|
37 /*AppUI*/ |
|
38 CTDisableExitChecksAppUi::CTDisableExitChecksAppUi(CTmsTestStep* aStep) : |
|
39 CTestAppUi(aStep, KTDisableExitChecksResourceFilePath) |
|
40 { |
|
41 } |
|
42 |
|
43 void CTDisableExitChecksAppUi::ConstructL() |
|
44 { |
|
45 CTestAppUi::ConstructL(); |
|
46 AutoTestManager().StartAutoTest(); |
|
47 } |
|
48 |
|
49 CTDisableExitChecksAppUi::~CTDisableExitChecksAppUi() |
|
50 { |
|
51 } |
|
52 |
|
53 /** |
|
54 @SYMTestCaseID UIF-TDisableExitChecksStep-TestDisableShutDownChecks |
|
55 |
|
56 @SYMDEF PDEF109432: Device does not shutdown properly |
|
57 |
|
58 @SYMTestCaseDesc Test triggers the launch of an app that leaks memory once with disabled and once |
|
59 with enabled shutdown checks. |
|
60 |
|
61 @SYMTestPriority High |
|
62 |
|
63 @SYMTestStatus Implemented |
|
64 |
|
65 @SYMTestActions Call StartProcessL with ETrue in order to disable the shutdown checks. |
|
66 Call StartProcessL with EFalse in order to disable the shutdown checks. |
|
67 Close the panic windows that have emerged. |
|
68 |
|
69 @SYMTestExpectedResults A panic window emerges, when the shutdown checks are enabled, since |
|
70 the app used (disableexitchecksapp) leaks memory. The panic window is followingly closed. |
|
71 */ |
|
72 |
|
73 void CTDisableExitChecksAppUi::TestDisableShutDownChecks() |
|
74 { |
|
75 INFO_PRINTF1(_L("Start Test TestDisableShutDownChecks...")); |
|
76 INFO_PRINTF1(_L("Disable shutdown checks...")); |
|
77 StartProcessL(KETrue); |
|
78 INFO_PRINTF1(_L("Enable shutdown checks...")); |
|
79 StartProcessL(KEFalse); |
|
80 CloseAllPanicWindowsL(); //closes the panic window that emerges, when the shutdown checks are enabled. |
|
81 } |
|
82 |
|
83 /** |
|
84 * This function creates a process to run disableexitchecksapp and launches this application. |
|
85 * |
|
86 * The trailing data in the launch information is set to the aTailEnd parameter (expected to |
|
87 * be ETrue or EFalse). |
|
88 * |
|
89 * Since disableexitchecksapp leaks memory, it panics, when shutdown checks are enabled. |
|
90 * However, it is expected to exit normally,when shutdown checks are disabled. |
|
91 * |
|
92 */ |
|
93 void CTDisableExitChecksAppUi::StartProcessL(const TDesC8& aTailEnd) |
|
94 { |
|
95 CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); |
|
96 RProcess process; |
|
97 INFO_PRINTF1(_L("Create process...")); |
|
98 User::LeaveIfError(process.Create(KExeName, KNullDesC)); |
|
99 INFO_PRINTF1(_L("Process created!")); |
|
100 CleanupClosePushL(process); |
|
101 INFO_PRINTF1(_L("Set commandline parameters...")); |
|
102 TRAPD(ret, |
|
103 { |
|
104 cmdLine->SetExecutableNameL(KExeName); |
|
105 cmdLine->SetTailEndL(aTailEnd); |
|
106 cmdLine->SetProcessEnvironmentL(process); |
|
107 }) |
|
108 TEST(ret==KErrNone); |
|
109 TRequestStatus status = KRequestPending; |
|
110 process.Logon(status); |
|
111 |
|
112 //Prevent emulator closing when a panic occurs |
|
113 User::SetJustInTime(EFalse); |
|
114 |
|
115 process.Resume(); |
|
116 User::WaitForRequest(status); |
|
117 INFO_PRINTF1(_L("Check process exit type...")); |
|
118 if (aTailEnd==KETrue) |
|
119 TEST(process.ExitType()==EExitKill); //disableexitchecksapp exits normally,when shutdown checks are disabled |
|
120 else if (aTailEnd==KEFalse) |
|
121 TEST(process.ExitType()==EExitPanic); //disableexitchecksapp panics at exit,when shutdown checks are enabled |
|
122 INFO_PRINTF1(_L("Check process exit reason...")); |
|
123 TEST(process.ExitReason()==KErrNone); |
|
124 |
|
125 User::SetJustInTime(ETrue); |
|
126 CleanupStack::PopAndDestroy(2, cmdLine); |
|
127 } |
|
128 |
|
129 void CTDisableExitChecksAppUi::RunTestStepL(TInt aStepNum) |
|
130 { |
|
131 switch(aStepNum) |
|
132 { |
|
133 case 1: |
|
134 SetTestStepID(_L("UIF-TDisableExitChecksStep-TestDisableShutDownChecks")); |
|
135 TRAPD(err,TestDisableShutDownChecks()); |
|
136 TEST(err==KErrNone); |
|
137 RecordTestResultL(); |
|
138 CloseTMSGraphicsStep(); |
|
139 break; |
|
140 case 2: |
|
141 INFO_PRINTF1(_L("All tests completed.\n")); |
|
142 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
143 break; |
|
144 default: |
|
145 INFO_PRINTF1(_L("CTDisableExitChecksAppUi::RunTestStepL default case\n")); |
|
146 break; |
|
147 } |
|
148 } |
|
149 |
|
150 /*Test step*/ |
|
151 CTDisableExitChecksStep::CTDisableExitChecksStep() |
|
152 { |
|
153 SetTestStepName(KTDisableExitChecksStep); |
|
154 } |
|
155 |
|
156 CTDisableExitChecksStep::~CTDisableExitChecksStep() |
|
157 { |
|
158 } |
|
159 |
|
160 void CTDisableExitChecksStep::ConstructAppL(CEikonEnv* aCoe) |
|
161 { |
|
162 aCoe->ConstructL(); |
|
163 CTDisableExitChecksAppUi* appUi=new(ELeave) CTDisableExitChecksAppUi(this); |
|
164 aCoe->SetAppUi(appUi); |
|
165 appUi->ConstructL(); |
|
166 } |
|
167 |
|
168 TVerdict CTDisableExitChecksStep::doTestStepL() // main function called by E32 |
|
169 { |
|
170 INFO_PRINTF1(_L("TDisableExitChecks Test Started")); |
|
171 PreallocateHALBuffer(); |
|
172 __UHEAP_MARK; // |
|
173 CEikonEnv* coe=new CEikonEnv; |
|
174 TRAPD(err,ConstructAppL(coe)); |
|
175 if (!err) |
|
176 { |
|
177 coe->ExecuteD(); |
|
178 } |
|
179 else |
|
180 { |
|
181 SetTestStepResult(EFail); |
|
182 delete coe; |
|
183 } |
|
184 |
|
185 REComSession::FinalClose(); |
|
186 __UHEAP_MARKEND; |
|
187 INFO_PRINTF1(_L("Test Finished")); |
|
188 return TestStepResult(); |
|
189 } |