|
1 // Copyright (c) 2000-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 |
|
17 #include <e32std.h> |
|
18 // Autotest library header file |
|
19 #include <ss_std.h> |
|
20 #include <autotest.h> |
|
21 |
|
22 // Global pointer for use by the autotest.h macro's |
|
23 CAutoTest* gAutoTest; |
|
24 RSocketServ gServ; |
|
25 |
|
26 |
|
27 // Initialise an RTest instance |
|
28 // Autotest construction expects one |
|
29 _LIT(KTestTitle,"Test Harness"); |
|
30 LOCAL_C RTest Test(KTestTitle); |
|
31 |
|
32 |
|
33 LOCAL_C TInt ApiCall1() |
|
34 // Function to represent an API call |
|
35 { |
|
36 // Do nothing but return an error to demonstrate error handling |
|
37 return KErrGeneral; |
|
38 } |
|
39 |
|
40 LOCAL_C TInt ApiCall2() |
|
41 // Function to represent an API call |
|
42 { |
|
43 // Do nothing but return an error to demonstrate error handling |
|
44 return KErrGeneral; |
|
45 } |
|
46 |
|
47 LOCAL_C TInt ApiCall3() |
|
48 // Function to represent an API call |
|
49 { |
|
50 // Do nothing but return 0 |
|
51 return KErrNone; |
|
52 } |
|
53 |
|
54 LOCAL_C void Tests1() |
|
55 // Function that calls one or more API calls |
|
56 { |
|
57 _LIT(KStartMessage,"Begin Test 1"); |
|
58 Test.Start(KStartMessage); |
|
59 // replace the RTest () function operator overloads with this call |
|
60 // If ApiCall1() does not return KErrNone, the error code is written to file |
|
61 // if the "keepgoing" command line argument is used. |
|
62 GLOBAL_CHECKPOINT_CODE(ApiCall1()); |
|
63 _LIT(KNext1,"API Call 1 Ok"); |
|
64 Test.Next(KNext1); |
|
65 Test.End(); |
|
66 } |
|
67 |
|
68 |
|
69 LOCAL_C void Tests2() |
|
70 // Function that calls one or more API calls |
|
71 { |
|
72 _LIT(KStartMessage,"Begin Test 2"); |
|
73 Test.Start(KStartMessage); |
|
74 |
|
75 // replace the RTest () function operator overloads with this call |
|
76 // If ApiCall2() does not return KErrNone, failure (without code) is written to file |
|
77 // if the "keepgoing" command line argument is used. |
|
78 GLOBAL_CHECKPOINT(ApiCall2() == KErrNone); |
|
79 _LIT(KNext2,"API Call 2 Ok"); |
|
80 Test.Next(KNext2); |
|
81 Test.End(); |
|
82 } |
|
83 |
|
84 LOCAL_C void Tests3() |
|
85 // Function that calls one or more API calls |
|
86 { |
|
87 _LIT(KStartMessage,"Begin Test 3"); |
|
88 Test.Start(KStartMessage); |
|
89 _LIT(KMessage,"ApiCall2() value comparison"); |
|
90 GLOBAL_CHECKPOINT_COMPARE(ApiCall1(),KErrNone,KMessage); |
|
91 _LIT(KNext1,"API Call 2 Ok"); |
|
92 Test.Next(KNext1); |
|
93 Test.End(); |
|
94 } |
|
95 |
|
96 |
|
97 LOCAL_C void Tests4L() |
|
98 // Function that calls one or more API calls |
|
99 { |
|
100 _LIT(KStartMessage,"Begin Test 4"); |
|
101 Test.Start(KStartMessage); |
|
102 |
|
103 // Connect to socket server to |
|
104 User::LeaveIfError(gServ.Connect()); |
|
105 |
|
106 User::LeaveIfError(ApiCall3()); |
|
107 _LIT(KNext1,"API Call 3 Ok"); |
|
108 Test.Next(KNext1); |
|
109 Test.End(); |
|
110 } |
|
111 |
|
112 |
|
113 // Set up the array of test functions, which make the API calls |
|
114 LOCAL_C const TAutoTestCase Cases[4] = |
|
115 { |
|
116 {Tests1,_S("Test One")}, |
|
117 {Tests2,_S("Test Two")}, |
|
118 {Tests3,_S("Test Three")}, |
|
119 {Tests4L,_S("Test Four")} |
|
120 }; |
|
121 |
|
122 |
|
123 LOCAL_C void MainL() |
|
124 { |
|
125 Test.Title(); |
|
126 Test.SetLogged(EFalse); |
|
127 |
|
128 _LIT(KDummyTests,"Dummy Tests.Txt"); |
|
129 _LIT8(KComponentInfo,"Dummy Test - xxx"); |
|
130 // Library defined macro |
|
131 // Uses a global pointer instance of CAutoTest |
|
132 GLOBAL_AUTOTEST_EXECUTE(Cases,KDummyTests,KComponentInfo,Test); |
|
133 gServ.Close(); |
|
134 Test.Close(); |
|
135 } |
|
136 |
|
137 |
|
138 GLDEF_C TInt E32Main() |
|
139 { |
|
140 __UHEAP_MARK; |
|
141 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
142 if(cleanup == NULL) |
|
143 { |
|
144 return KErrNoMemory; |
|
145 } |
|
146 TRAPD(err,MainL()); |
|
147 _LIT(KPanic,"Th2"); |
|
148 __ASSERT_ALWAYS(!err, User::Panic(KPanic,err)); |
|
149 delete cleanup; |
|
150 __UHEAP_MARKEND; |
|
151 return KErrNone; |
|
152 } |
|
153 // |