68
|
1 |
// Copyright (c) 2002-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 |
// Contain the implementation of the class for generic CSD agent test
|
|
15 |
//
|
|
16 |
//
|
|
17 |
#include <f32file.h>
|
|
18 |
#include "CsdAgentTestSteps.h"
|
|
19 |
|
|
20 |
CsdAgentTestStep::CsdAgentTestStep()
|
|
21 |
{
|
|
22 |
|
|
23 |
}
|
|
24 |
|
|
25 |
CsdAgentTestStep::~CsdAgentTestStep()
|
|
26 |
{
|
|
27 |
|
|
28 |
}
|
|
29 |
|
|
30 |
enum TVerdict CsdAgentTestStep::doTestStepPreambleL()
|
|
31 |
{
|
|
32 |
enum TVerdict result = EPass;
|
|
33 |
|
|
34 |
RSocketServ ss;
|
|
35 |
ss.Connect();
|
|
36 |
CleanupClosePushL(ss);
|
|
37 |
|
|
38 |
if(KErrNone == WaitForAllInterfacesToCloseL(ss))
|
|
39 |
result = EPass;
|
|
40 |
else
|
|
41 |
result = EFail;
|
|
42 |
|
|
43 |
ss.Close();
|
|
44 |
CleanupStack::Pop();
|
|
45 |
return result;
|
|
46 |
}
|
|
47 |
|
|
48 |
TInt CsdAgentTestStep::WaitForAllInterfacesToCloseL(RSocketServ& ss)
|
|
49 |
{
|
|
50 |
TInt err;
|
|
51 |
TUint numOfConnections;
|
|
52 |
TUint count =0;
|
|
53 |
|
|
54 |
RConnection conn;
|
|
55 |
|
|
56 |
err = OpenConnection(conn,ss);
|
|
57 |
TESTEL(KErrNone == err,err);
|
|
58 |
CleanupClosePushL(conn);
|
|
59 |
|
|
60 |
err = EnumerateConnections(conn,numOfConnections);
|
|
61 |
TESTEL(KErrNone == err,err);
|
|
62 |
|
|
63 |
while((0 !=numOfConnections) && (count <60))
|
|
64 |
{
|
|
65 |
count++;
|
|
66 |
User::After(1000000);
|
|
67 |
err = EnumerateConnections(conn,numOfConnections);
|
|
68 |
}
|
|
69 |
|
|
70 |
CloseConnection(conn);
|
|
71 |
|
|
72 |
CleanupStack::Pop();
|
|
73 |
|
|
74 |
if(numOfConnections !=0)
|
|
75 |
{
|
|
76 |
return KErrTimedOut;
|
|
77 |
}
|
|
78 |
return KErrNone;
|
|
79 |
}
|
|
80 |
|
|
81 |
TInt CsdAgentTestStep::OpenConnection(RConnection& conn, RSocketServ& ss)
|
|
82 |
/*
|
|
83 |
* Open the connection using the socket server too
|
|
84 |
* @param conn the connection to open
|
|
85 |
* @param ss the socket server within which the connection is to be opened
|
|
86 |
* @return system wide error code
|
|
87 |
*/
|
|
88 |
{
|
|
89 |
return (conn.Open(ss));
|
|
90 |
}
|
|
91 |
|
|
92 |
TInt CsdAgentTestStep::EnumerateConnections(RConnection& conn, TUint& num)
|
|
93 |
/*
|
|
94 |
* Read how many connections (==interfaces?) exist at the moment
|
|
95 |
* @param conn - to be used to read the count
|
|
96 |
* @param num - on completion holds the number of connections
|
|
97 |
* @return system wide error code
|
|
98 |
*/
|
|
99 |
{
|
|
100 |
return (conn.EnumerateConnections(num));
|
|
101 |
}
|
|
102 |
|
|
103 |
void CsdAgentTestStep::CloseConnection(RConnection& conn)
|
|
104 |
/*
|
|
105 |
* Close a connection
|
|
106 |
* @param conn the connection to close
|
|
107 |
* @return system wide error code
|
|
108 |
*/
|
|
109 |
{
|
|
110 |
conn.Close();
|
|
111 |
}
|