|
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 <startupproperties.h> |
|
23 #include <hal.h> |
|
24 |
|
25 #include "startsafe.h" |
|
26 #include "tstartsafe_proctimesucc.h" |
|
27 #include "testappslow.h" |
|
28 #include "testapps.h" |
|
29 |
|
30 |
|
31 const TInt KProcTimeSuccTimeoutMargin = 1600; //400; // milliseconds |
|
32 const TInt KProcTimeSuccWaitTime = KTestAppSlowTimeoutInMilliSeconds + KProcTimeSuccTimeoutMargin; |
|
33 |
|
34 /** |
|
35 Old Test CaseID APPFWK-STARTSAFE-0005 |
|
36 New Test CaseID DEVSRVS-SHMA-STARTSAFE-0005 |
|
37 */ |
|
38 |
|
39 TVerdict CAppFwkStartSafeTestStepProcTimeSucc::doTestStepL() |
|
40 { |
|
41 |
|
42 CStartSafe *startSafe = CStartSafe::NewL(); |
|
43 CleanupStack::PushL( startSafe ); |
|
44 |
|
45 CStartupProperties *prop = CStartupProperties::NewL(); |
|
46 CleanupStack::PushL( prop ); |
|
47 |
|
48 RProcess proc; |
|
49 CleanupClosePushL( proc ); |
|
50 |
|
51 prop->SetFileParamsL( KTestAppSlow, KNullDesC ); |
|
52 prop->SetStartupType( EStartProcess ); |
|
53 prop->SetStartMethod( EWaitForStart ); |
|
54 prop->SetNoOfRetries( 0 ); |
|
55 prop->SetTimeout( KProcTimeSuccWaitTime ); |
|
56 |
|
57 |
|
58 INFO_PRINTF1( _L("Invoke StartSafe on the test-app") ); |
|
59 |
|
60 TInt tried = 0; |
|
61 TInt nTicksInMicroseconds = 0; |
|
62 HAL::Get( HAL::ENanoTickPeriod, nTicksInMicroseconds ); |
|
63 INFO_PRINTF2( _L("System nano-ticks in uSec = %d"), nTicksInMicroseconds ); |
|
64 |
|
65 TUint nTicks = User::NTickCount(); |
|
66 |
|
67 TRAPD( err, startSafe->StartL(*prop, proc, tried) ); |
|
68 |
|
69 nTicks = ( User::NTickCount() - nTicks ); |
|
70 INFO_PRINTF2( _L("milliseconds after = %d"), nTicks * (nTicksInMicroseconds / 1000) ); |
|
71 INFO_PRINTF2( _L("Of which test-app tardiness accounts for = %dms"), KTestAppSlowTimeoutInMilliSeconds ); |
|
72 |
|
73 // Prepare to check that the process is the app we think it is. |
|
74 TPtrC procNamePtr = proc.FileName().Right( KTestAppSlow().Length() ); |
|
75 TInt nameComparison = procNamePtr.Compare( KTestAppSlow() ); |
|
76 |
|
77 if( (KErrNone == err) && (0 == nameComparison) ) |
|
78 { |
|
79 SetTestStepResult( EPass ); |
|
80 INFO_PRINTF2( _L("Process \"%S\" started correctly"), &procNamePtr ); |
|
81 INFO_PRINTF1( _L("Test passed") ); |
|
82 } |
|
83 else |
|
84 { |
|
85 ERR_PRINTF2( _L("Test Failed StartSafe returned %d"), err ); |
|
86 INFO_PRINTF2( _L("Process name returned \"%S\""), &procNamePtr ); |
|
87 |
|
88 SetTestStepResult( EFail ); |
|
89 } |
|
90 |
|
91 // Dispose of the test-app. |
|
92 if( 0 == nameComparison ) |
|
93 { |
|
94 proc.Kill( KErrNone ); |
|
95 } |
|
96 |
|
97 |
|
98 CleanupStack::PopAndDestroy( 3, startSafe ); |
|
99 |
|
100 return TestStepResult(); |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 CAppFwkStartSafeTestStepProcTimeSucc::CAppFwkStartSafeTestStepProcTimeSucc() |
|
106 { |
|
107 SetTestStepName(KCTestCaseProcTimeSucc); |
|
108 } |