|
1 // Copyright (c) 2003-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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // CloseServer |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // [Action Description] |
|
20 // Closes the messaging server and deletes the session. |
|
21 // [APIs Used] |
|
22 // CMsvSession::CloseMessageServer |
|
23 // __ACTION_INFO_END__ |
|
24 // |
|
25 // |
|
26 |
|
27 /** |
|
28 @file |
|
29 */ |
|
30 |
|
31 |
|
32 #include "CMtfTestActionCloseServer.h" |
|
33 #include "CMtfTestCase.h" |
|
34 #include "CMtfTestActionParameters.h" |
|
35 |
|
36 _LIT(KMsvServerPattern, "!MsvServer*"); |
|
37 |
|
38 CMtfTestAction* CMtfTestActionCloseServer::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
39 { |
|
40 CMtfTestActionCloseServer* self = new (ELeave) CMtfTestActionCloseServer(aTestCase); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(aActionParameters); |
|
43 CleanupStack::Pop(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 CMtfTestActionCloseServer::CMtfTestActionCloseServer(CMtfTestCase& aTestCase) |
|
49 : CMtfSynchronousTestAction(aTestCase) |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 CMtfTestActionCloseServer::~CMtfTestActionCloseServer() |
|
55 { |
|
56 } |
|
57 |
|
58 void CMtfTestActionCloseServer::ExecuteActionL() |
|
59 { |
|
60 TestCase().INFO_PRINTF2(_L("Test Action %S started."), &KTestActionCloseServer ); |
|
61 |
|
62 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
63 |
|
64 // Close the messaging server |
|
65 paramSession->CloseMessageServer(); |
|
66 |
|
67 // Delete the session |
|
68 DeleteParameterL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
69 |
|
70 // Wait for the messaging server to close |
|
71 WaitForServerClose(); |
|
72 |
|
73 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCloseServer ); |
|
74 TestCase().ActionCompletedL(*this); |
|
75 } |
|
76 |
|
77 void CMtfTestActionCloseServer::WaitForServerClose() |
|
78 { |
|
79 |
|
80 FOREVER |
|
81 { |
|
82 #if defined(__WINS__) && !defined(EKA2) |
|
83 TFileName name; |
|
84 TFindThread find(KMsvServerName); |
|
85 if (find.Next(name) != KErrNone) |
|
86 break; |
|
87 #endif |
|
88 #if defined (__EPOC32__) && !defined(EKA2) |
|
89 TFullName name; |
|
90 TFindProcess find(_L("MSEXE*")); |
|
91 if (find.Next(name) != KErrNone) |
|
92 break; |
|
93 #endif |
|
94 #if defined(EKA2) |
|
95 TFullName name; |
|
96 TFindServer find(KMsvServerPattern); |
|
97 if (find.Next(name) != KErrNone) |
|
98 break; |
|
99 #endif |
|
100 User::After(100000); |
|
101 } |
|
102 } |