|
1 // Copyright (c) 1999-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 "T_SmsSendNbs.h" |
|
17 #include <smsuaddr.h> |
|
18 |
|
19 RTest test(_L("T_SmsSendNbs Testrig")); |
|
20 CTrapCleanup* theCleanup; |
|
21 |
|
22 void CSmsSendNbsTest::TestSendingL() |
|
23 /** |
|
24 Tests Sending |
|
25 */ |
|
26 { |
|
27 DoTestSendingL(iScriptFile); |
|
28 } |
|
29 |
|
30 void CSmsSendNbsTest::TestSchedulingL() |
|
31 /** |
|
32 Tests schedule sending |
|
33 */ |
|
34 { |
|
35 DoTestSchedulingL(iScriptFile); |
|
36 } |
|
37 |
|
38 |
|
39 CSmsSendNbsTest::CSmsSendNbsTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aCurrentTest) |
|
40 : CSmsSendTestBase(aSmsTest, aScriptFile, aCurrentTest) |
|
41 /** |
|
42 Constructor |
|
43 */ |
|
44 { |
|
45 } |
|
46 |
|
47 LOCAL_C void doMainL() |
|
48 { |
|
49 RSocketServ serv; |
|
50 RSocket socket; |
|
51 |
|
52 User::LeaveIfError(serv.Connect()); |
|
53 CleanupClosePushL(serv); |
|
54 |
|
55 TProtocolDesc protoinfo; |
|
56 TProtocolName protocolname(KSmsDatagram); |
|
57 User::LeaveIfError(serv.FindProtocol(protocolname,protoinfo)); |
|
58 User::LeaveIfError(socket.Open(serv,protoinfo.iAddrFamily,protoinfo.iSockType,protoinfo.iProtocol)); |
|
59 |
|
60 TSmsAddr smsaddr; |
|
61 smsaddr.SetSmsAddrFamily(ESmsAddrSendOnly); |
|
62 User::LeaveIfError(socket.Bind(smsaddr)); |
|
63 |
|
64 CleanupClosePushL(socket); |
|
65 |
|
66 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
67 CleanupStack::PushL(scheduler); |
|
68 CActiveScheduler::Install( scheduler ); |
|
69 |
|
70 CSmsTestUtils* smsTest = CSmsTestUtils::NewL(test); |
|
71 CleanupStack::PushL(smsTest); |
|
72 TInt nextTest = 0; |
|
73 |
|
74 smsTest->NotifySaPhoneOnL(); |
|
75 smsTest->WaitForInitializeL(); |
|
76 |
|
77 CSmsSendNbsTest* nbsTest = CSmsSendNbsTest::NewL(*smsTest, KNbsScript, nextTest); |
|
78 CleanupStack::PushL(nbsTest); |
|
79 |
|
80 nbsTest->StartL(); |
|
81 |
|
82 CleanupStack::PopAndDestroy(3); //SmsTest, scheduler |
|
83 |
|
84 CleanupStack::PopAndDestroy(&socket); |
|
85 CleanupStack::PopAndDestroy(&serv); |
|
86 } |
|
87 |
|
88 GLDEF_C TInt E32Main() |
|
89 { |
|
90 __UHEAP_MARK; |
|
91 test.Start(_L("Setup")); |
|
92 theCleanup = CTrapCleanup::New(); |
|
93 TRAPD(ret,doMainL()); |
|
94 test(ret==KErrNone); |
|
95 delete theCleanup; |
|
96 test.Console()->SetPos(0, 13); |
|
97 test.End(); |
|
98 test.Close(); |
|
99 __UHEAP_MARKEND; |
|
100 return(KErrNone); |
|
101 } |
|
102 |
|
103 CSmsSendNbsTest* CSmsSendNbsTest::NewL(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aCurrentTest) |
|
104 { |
|
105 CSmsSendNbsTest* self = new (ELeave) CSmsSendNbsTest(aSmsTest, aScriptFile, aCurrentTest); |
|
106 CleanupStack::PushL(self); |
|
107 |
|
108 self->ConstructL(); |
|
109 |
|
110 CleanupStack::Pop(); |
|
111 return self; |
|
112 } |
|
113 |