|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Demonstration use of the TestExecuteUtils client API |
|
16 * Relies on test config files being exported to z:\SampleTest |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file SampleClient.cpp |
|
24 */ |
|
25 #include <TestExecuteClient.h> |
|
26 |
|
27 LOCAL_C void MainL() |
|
28 { |
|
29 // Create a root session with the SampleServer test server |
|
30 // User::After() 1/10th second delays between server calls because IPC calls fail with |
|
31 // KErrServerBusy if we bang them in to fast. |
|
32 RTestServ server; |
|
33 User::LeaveIfError(server.Connect(_L("SampleServer"))); |
|
34 CleanupClosePushL(server); |
|
35 |
|
36 RTestSession session1; |
|
37 User::LeaveIfError(session1.Open(server,_L("SampleStep1"))); |
|
38 CleanupClosePushL(session1); |
|
39 TRequestStatus status1; |
|
40 User::After(100000); |
|
41 // Run a test step then pick up completion |
|
42 TExitCategoryName panicString1; |
|
43 session1.RunTestStep(_L("z:\\Sampletest\\SampleTest.ini SectionOne"),panicString1,status1); |
|
44 User::WaitForRequest(status1); |
|
45 // Demonstration of another step run on the same session |
|
46 // We have to wait for the first step to complete otherwise we get KErrInUse |
|
47 // If we want to run multiple instances then we create another test session |
|
48 panicString1.Zero(); |
|
49 session1.RunTestStep(_L("z:\\Sampletest\\SampleTest.ini SectionTwo"),panicString1,status1); |
|
50 |
|
51 // Get another session whilst the other one is still running |
|
52 RTestSession session2; |
|
53 User::After(100000); |
|
54 User::LeaveIfError(session2.Open(server,_L("SampleStep1"))); |
|
55 CleanupClosePushL(session2); |
|
56 TRequestStatus status2; |
|
57 User::After(100000); |
|
58 TExitCategoryName panicString2; |
|
59 session2.RunTestStep(_L("z:\\Sampletest\\SampleTest.ini SectionTwo"),panicString2,status2); |
|
60 |
|
61 // Get another session whilst the other two are still running |
|
62 RTestSession session3; |
|
63 User::After(100000); |
|
64 User::LeaveIfError(session3.Open(server,_L("SampleStep1"))); |
|
65 CleanupClosePushL(session3); |
|
66 TRequestStatus status3; |
|
67 User::After(100000); |
|
68 TExitCategoryName panicString3; |
|
69 session3.RunTestStep(_L("z:\\Sampletest\\SampleTest.ini SectionTwo"),panicString3,status3); |
|
70 |
|
71 // The test steps all ran concurrently so pick up the completions |
|
72 User::WaitForRequest(status1); |
|
73 User::WaitForRequest(status2); |
|
74 User::WaitForRequest(status3); |
|
75 |
|
76 session1.Close(); |
|
77 session2.Close(); |
|
78 session3.Close(); |
|
79 |
|
80 CleanupStack::Pop(3); |
|
81 CleanupStack::Pop(&server); |
|
82 // Close the root server session |
|
83 server.Close(); |
|
84 // Wait for flogger to log |
|
85 User::After(5000000); |
|
86 } |
|
87 |
|
88 // Entry point for all Epoc32 executables |
|
89 // See PSP Chapter 2 Getting Started |
|
90 GLDEF_C TInt E32Main() |
|
91 { |
|
92 // Heap balance checking |
|
93 // See PSP Chapter 6 Error Handling |
|
94 __UHEAP_MARK; |
|
95 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
96 if(cleanup == NULL) |
|
97 { |
|
98 return KErrNoMemory; |
|
99 } |
|
100 TRAPD(err,MainL()); |
|
101 _LIT(KPanic,"SampleClient"); |
|
102 __ASSERT_ALWAYS(!err, User::Panic(KPanic,err)); |
|
103 delete cleanup; |
|
104 __UHEAP_MARKEND; |
|
105 return KErrNone; |
|
106 } |