sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Implementation of the RTestServ and RTestSession API's
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file TestClient.cpp
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
//#include "..\..\SampleServer\src\SampleServer.h"
|
sl@0
|
22 |
#include <simulprocserver.h>
|
sl@0
|
23 |
#include <simulprocclient.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
TVersion RTestServ::Version() const
|
sl@0
|
27 |
{
|
sl@0
|
28 |
return(TVersion(1,0,1));
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
EXPORT_C TInt RTestServ::Connect(const TDesC& aServerName)
|
sl@0
|
32 |
/**
|
sl@0
|
33 |
* @param aServerName - Human readable name of the test server
|
sl@0
|
34 |
* @param aDebugMode - Set to true for just in time debugging
|
sl@0
|
35 |
* @return int - Standard error codes
|
sl@0
|
36 |
* Secure version of the API call. Expects the server binary to be
|
sl@0
|
37 |
* ServerXXX.exe
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
{
|
sl@0
|
40 |
if(aServerName.Length() > iServerName.MaxLength())
|
sl@0
|
41 |
return KErrTooBig;
|
sl@0
|
42 |
iServerName = aServerName;
|
sl@0
|
43 |
// Assume the server is already running and attempt to create a session
|
sl@0
|
44 |
// 4 message slots
|
sl@0
|
45 |
TInt err = CreateSession(aServerName,Version(),4);
|
sl@0
|
46 |
if(err == KErrNotFound)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
// Server not running
|
sl@0
|
49 |
// Construct the server binary name
|
sl@0
|
50 |
TBuf<KMaxServerNameLength> serverFile;
|
sl@0
|
51 |
RProcess server;
|
sl@0
|
52 |
_LIT(KEmpty,"");
|
sl@0
|
53 |
_LIT(KExe,".exe");
|
sl@0
|
54 |
|
sl@0
|
55 |
serverFile.Copy(aServerName);
|
sl@0
|
56 |
serverFile.Append(KExe);
|
sl@0
|
57 |
err = server.Create(serverFile,KEmpty);
|
sl@0
|
58 |
if(err != KErrNone)
|
sl@0
|
59 |
return err;
|
sl@0
|
60 |
// Synchronise with the server
|
sl@0
|
61 |
TRequestStatus reqStatus;
|
sl@0
|
62 |
server.Rendezvous(reqStatus);
|
sl@0
|
63 |
|
sl@0
|
64 |
if (reqStatus!=KRequestPending)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
server.Kill(0);
|
sl@0
|
67 |
}
|
sl@0
|
68 |
else
|
sl@0
|
69 |
{
|
sl@0
|
70 |
// Start the test harness
|
sl@0
|
71 |
server.Resume();
|
sl@0
|
72 |
// Server will call the reciprocal static synchronise call
|
sl@0
|
73 |
}
|
sl@0
|
74 |
User::WaitForRequest(reqStatus); // wait for start or death
|
sl@0
|
75 |
server.Close();
|
sl@0
|
76 |
if(reqStatus.Int() != KErrNone)
|
sl@0
|
77 |
return reqStatus.Int();
|
sl@0
|
78 |
|
sl@0
|
79 |
// Create the root server session
|
sl@0
|
80 |
err = CreateSession(aServerName,Version(),4);
|
sl@0
|
81 |
}
|
sl@0
|
82 |
return err;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
EXPORT_C const TDesC& RTestServ::ServerName() const
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
* @return - The human readable server name
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
{
|
sl@0
|
90 |
return iServerName;
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
//
|
sl@0
|
94 |
EXPORT_C TInt RTestSession::Open(RTestServ& aServ, const TDesC& aStepName, TBool aSharedData)
|
sl@0
|
95 |
/**
|
sl@0
|
96 |
* @param aServ - Reference to the root server session
|
sl@0
|
97 |
* @param aStepName - Reference to the name of the test step owned by the server
|
sl@0
|
98 |
* @return Standard error codes
|
sl@0
|
99 |
* Secure and Non-secure variants
|
sl@0
|
100 |
* Synchronously open a server test step session
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
{
|
sl@0
|
103 |
if(aStepName.Length() > KMaxServerNameLength)
|
sl@0
|
104 |
return KErrTooBig;
|
sl@0
|
105 |
TIpcArgs args;
|
sl@0
|
106 |
args.Set(0,&aStepName);
|
sl@0
|
107 |
args.Set(1,aSharedData);
|
sl@0
|
108 |
return CreateSubSession(aServ,EMMTSOpenTestStep,args);
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
EXPORT_C void RTestSession::StartProcessing(TRequestStatus& aStatus)
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
*
|
sl@0
|
114 |
* @param aCommandString - The arguments to the RUN_TEST_STEP command
|
sl@0
|
115 |
* @return aPanicString - If the test step panics, this member is set up with the panic string
|
sl@0
|
116 |
* @param aStatus - For completion to the caller
|
sl@0
|
117 |
* Secure and Non-secure variants
|
sl@0
|
118 |
* Send the RUN_TEST_STEP arguments to the test server
|
sl@0
|
119 |
*/
|
sl@0
|
120 |
{
|
sl@0
|
121 |
SendReceive(EMMTSStartProcessing,aStatus);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
EXPORT_C TVerdict RTestSession::EndProcessingAndReturnResult(TDes8& aMessage)
|
sl@0
|
125 |
/**
|
sl@0
|
126 |
*
|
sl@0
|
127 |
* @return - Standard Epoc error codes
|
sl@0
|
128 |
* Secure and Non-secure variants
|
sl@0
|
129 |
* Synchronous abort of the the test step
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
{
|
sl@0
|
132 |
|
sl@0
|
133 |
TPckgBuf<TVerdict> v;
|
sl@0
|
134 |
TIpcArgs args;
|
sl@0
|
135 |
args.Set(0,&v);
|
sl@0
|
136 |
args.Set(1,&aMessage);
|
sl@0
|
137 |
SendReceive(EMMTSStopProcessing, args);
|
sl@0
|
138 |
return v();
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
EXPORT_C void RTestSession::Close()
|
sl@0
|
142 |
{
|
sl@0
|
143 |
CloseSubSession(EMMTSClose);
|
sl@0
|
144 |
}
|