|
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 <e32property.h> |
|
23 #include <e32debug.h> |
|
24 #include "gsatestappgood.h" |
|
25 #include "gtestapps.h" |
|
26 #include "gsatestprocgoodsession.h" |
|
27 #include <apacmdln.h> |
|
28 |
|
29 static void PublishPriority() |
|
30 { |
|
31 const TInt KMaxCommandLength = 256; |
|
32 CApaCommandLine* apaCmdLine = NULL; |
|
33 CApaCommandLine::GetCommandLineFromProcessEnvironment(apaCmdLine); |
|
34 TBuf8<KMaxCommandLength> commandLine(apaCmdLine->TailEnd()); |
|
35 TLex8 flagLex(commandLine); |
|
36 TInt priority = 0; |
|
37 while(!flagLex.Eos()) |
|
38 { |
|
39 TPtrC8 token(flagLex.NextToken()); |
|
40 TLex8 temp(token); |
|
41 temp.Val(priority); |
|
42 } |
|
43 RDebug::Printf("Priority of this application is : %d",priority); |
|
44 delete apaCmdLine; |
|
45 } |
|
46 |
|
47 static void MainL() |
|
48 { |
|
49 PublishPriority(); |
|
50 // Try and connect to ProcGoodSession. If it is successful, set a property. |
|
51 // Else dont set the property. |
|
52 RTestProcGoodSession session; |
|
53 TInt err = session.Connect(); |
|
54 if(KErrNone == err) |
|
55 { |
|
56 _LIT_SECURITY_POLICY_PASS(KTestReadPolicy); |
|
57 _LIT_SECURITY_POLICY_S0(KTestWritePolicy, RProcess().SecureId()); |
|
58 |
|
59 TInt err = RProperty::Define(KTestAppUidCategory, KTestPropertyKey, RProperty::EInt, KTestReadPolicy, KTestWritePolicy); |
|
60 err = RProperty::Set(KTestAppUidCategory, KTestPropertyKey, KPropertySetValue); |
|
61 } |
|
62 |
|
63 if (User::CommandLineLength() > 0) |
|
64 { |
|
65 TBuf<KTestCommandLineMaxLength> commandLine; |
|
66 if(User::CommandLineLength() > commandLine.MaxLength()) |
|
67 User::Leave(KErrTooBig); |
|
68 |
|
69 User::CommandLine(commandLine); |
|
70 |
|
71 TLex flagLex(commandLine); |
|
72 while(!flagLex.Eos()) |
|
73 { |
|
74 TPtrC token(flagLex.NextToken()); |
|
75 if(token == KLaunchProcessAndWait) |
|
76 { |
|
77 CActiveScheduler* sched = new(ELeave) CActiveScheduler; |
|
78 CActiveScheduler::Install(sched); |
|
79 |
|
80 RDebug::Printf("Rendezvous this application"); |
|
81 RProcess::Rendezvous(KErrNone); |
|
82 |
|
83 RSemaphore sem; |
|
84 TInt err = sem.OpenGlobal(KStartTestProcGoodSem); |
|
85 if(err == KErrNone) |
|
86 { |
|
87 sem.Signal(); |
|
88 sem.Close(); |
|
89 } |
|
90 |
|
91 // Start the active scheduler, so that the process would be running until the test case |
|
92 // sets up the monitoring and would kill the process explicitly. |
|
93 CActiveScheduler::Start(); |
|
94 delete sched; |
|
95 } |
|
96 } |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 /** |
|
102 Standard DLL entry point function. |
|
103 |
|
104 @return KErrNone |
|
105 */ |
|
106 TInt E32Main() |
|
107 { |
|
108 __UHEAP_MARK; |
|
109 |
|
110 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
111 TInt r=KErrNoMemory; |
|
112 if (cleanup) |
|
113 { |
|
114 TRAP(r, MainL()); |
|
115 delete cleanup; |
|
116 } |
|
117 |
|
118 __UHEAP_MARKEND; |
|
119 return r; |
|
120 } |