|
1 // Copyright (c) 2004-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 #include <mtmuids.h> |
|
17 #include "sendas2test.h" |
|
18 |
|
19 RTest test(_L("SendAs2 - Add/Remove MTM testing")); |
|
20 |
|
21 // |
|
22 |
|
23 void TestMTMRemoveL() |
|
24 { |
|
25 CDummyObserver* ob1 = new(ELeave) CDummyObserver; |
|
26 CleanupStack::PushL(ob1); |
|
27 |
|
28 CMsvSession* session = CMsvSession::OpenSyncL(*ob1); |
|
29 CleanupStack::PushL(session); |
|
30 |
|
31 RSendAs sendAs; |
|
32 CleanupClosePushL(sendAs); |
|
33 |
|
34 theUtils->WriteComment(_L("\nEstablishing a connection with the server...")); |
|
35 test(sendAs.Connect() == KErrNone); // Establish a connection |
|
36 theUtils->WriteComment(_L("\tsuccess.")); |
|
37 |
|
38 CSendAsMessageTypes* messageTypes = CSendAsMessageTypes::NewL(); |
|
39 CleanupStack::PushL(messageTypes); |
|
40 |
|
41 theUtils->WriteComment(_L("\nRetrieving message types.")); |
|
42 sendAs.FilteredMessageTypesL(*messageTypes); |
|
43 |
|
44 TInt typeCount = messageTypes->Count(); |
|
45 test(typeCount > 0); |
|
46 |
|
47 // Remove sendas test mtm |
|
48 User::LeaveIfError(session->DeInstallMtmGroup(_L("z:\\resource\\messaging\\mtm\\SENDASTESTMTM.RSC"))); |
|
49 // Wait one second. Allows the active scheduler to run and update the mtm list. |
|
50 User::After(1000000); |
|
51 |
|
52 // Repopulate sendas list. |
|
53 messageTypes->Reset(); |
|
54 sendAs.FilteredMessageTypesL(*messageTypes); |
|
55 |
|
56 // Check the sendAs mtm list count is one lower |
|
57 theUtils->WriteComment(_L("\nChecking mtm count is one lower.")); |
|
58 test(messageTypes->Count() == (typeCount - 1)); |
|
59 |
|
60 CleanupStack::PopAndDestroy(4, ob1); // messageTypes, sendAs, session, ob1 |
|
61 theUtils->WriteComment(_L("\nClosing session.")); |
|
62 } |
|
63 |
|
64 void TestMTMAddL() |
|
65 { |
|
66 CDummyObserver* ob1 = new(ELeave) CDummyObserver; |
|
67 CleanupStack::PushL(ob1); |
|
68 |
|
69 CMsvSession* session = CMsvSession::OpenSyncL(*ob1); |
|
70 CleanupStack::PushL(session); |
|
71 |
|
72 RSendAs sendAs; |
|
73 CleanupClosePushL(sendAs); |
|
74 |
|
75 theUtils->WriteComment(_L("\nEstablishing a connection with the server...")); |
|
76 test(sendAs.Connect() == KErrNone); // Establish a connection |
|
77 theUtils->WriteComment(_L("\tsuccess.")); |
|
78 |
|
79 CSendAsMessageTypes* messageTypes = CSendAsMessageTypes::NewL(); |
|
80 CleanupStack::PushL(messageTypes); |
|
81 |
|
82 theUtils->WriteComment(_L("\nRetrieving message types.")); |
|
83 sendAs.FilteredMessageTypesL(*messageTypes); |
|
84 |
|
85 TInt typeCount = messageTypes->Count(); |
|
86 test(typeCount > 0); |
|
87 |
|
88 // Add sendas test mtm |
|
89 User::LeaveIfError(session->InstallMtmGroup(_L("z:\\resource\\messaging\\mtm\\SENDASTESTMTM.RSC"))); |
|
90 // Wait one second. Allows the active scheduler to run and update the mtm list. |
|
91 User::After(1000000); |
|
92 |
|
93 // Repopulate sendas list. |
|
94 messageTypes->Reset(); |
|
95 sendAs.ResetMessageFilter(); |
|
96 sendAs.FilteredMessageTypesL(*messageTypes); |
|
97 |
|
98 // Check the sendAs mtm list count is one higher |
|
99 theUtils->WriteComment(_L("\nChecking mtm count is one higher.")); |
|
100 test(messageTypes->Count() == (typeCount + 1)); |
|
101 |
|
102 CleanupStack::PopAndDestroy(4, ob1); // messageTypes, sendAs, session, ob1 |
|
103 theUtils->WriteComment(_L("\nClosing session.")); |
|
104 } |
|
105 |
|
106 |
|
107 void doTestsL() |
|
108 { |
|
109 theUtils->Start(_L("MTM remove test")); |
|
110 TestMTMRemoveL(); // Qualified: No leavescan error |
|
111 theUtils->Complete(); |
|
112 |
|
113 theUtils->Start(_L("MTM add test")); |
|
114 TestMTMAddL(); // Qualified: No leavescan error |
|
115 theUtils->Complete(); |
|
116 } |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |