@@ -37,22 +37,21 @@ class TestAT_CellularDevice : public testing::Test {
37
37
38
38
TEST_F (TestAT_CellularDevice, Create)
39
39
{
40
- EventQueue que ;
41
- AT_CellularDevice dev (que );
40
+ FileHandle_stub fh1 ;
41
+ AT_CellularDevice dev (&fh1 );
42
42
43
- CellularDevice *dev2 = new AT_CellularDevice (que );
43
+ CellularDevice *dev2 = new AT_CellularDevice (&fh1 );
44
44
45
45
EXPECT_TRUE (dev2 != NULL );
46
46
delete dev2;
47
47
}
48
48
49
49
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_get_at_handler)
50
50
{
51
- EventQueue que;
52
- AT_CellularDevice dev (que);
53
51
FileHandle_stub fh1;
54
52
FileHandle_stub fh2;
55
53
FileHandle_stub fh3;
54
+ AT_CellularDevice dev (&fh1);
56
55
57
56
EXPECT_TRUE (dev.open_network (&fh1));
58
57
EXPECT_TRUE (dev.open_sms (&fh2));
@@ -66,59 +65,73 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_at_handler)
66
65
67
66
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_open_network)
68
67
{
69
- EventQueue que;
70
- AT_CellularDevice dev (que);
71
68
FileHandle_stub fh1;
69
+ AT_CellularDevice dev (&fh1);
72
70
73
- EXPECT_TRUE (!dev.open_network (NULL ));
74
- EXPECT_TRUE (dev.open_network (&fh1));
71
+ CellularNetwork *nw = dev.open_network (NULL );
72
+ CellularNetwork *nw1 = dev.open_network (&fh1);
73
+
74
+ EXPECT_TRUE (nw);
75
+ EXPECT_TRUE (nw1);
76
+ EXPECT_TRUE (nw1 == nw);
75
77
}
76
78
77
79
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_open_sms)
78
80
{
79
- EventQueue que;
80
- AT_CellularDevice dev (que);
81
81
FileHandle_stub fh1;
82
+ AT_CellularDevice dev (&fh1);
82
83
83
- EXPECT_TRUE (!dev.open_sms (NULL ));
84
- EXPECT_TRUE (dev.open_sms (&fh1));
84
+ CellularSMS *sms = dev.open_sms (NULL );
85
+ CellularSMS *sms1 = dev.open_sms (&fh1);
86
+
87
+ EXPECT_TRUE (sms);
88
+ EXPECT_TRUE (sms1);
89
+ EXPECT_TRUE (sms1 == sms);
85
90
}
86
91
87
92
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_open_power)
88
93
{
89
- EventQueue que;
90
- AT_CellularDevice dev (que);
91
94
FileHandle_stub fh1;
95
+ AT_CellularDevice dev (&fh1);
92
96
93
- EXPECT_TRUE (!dev.open_power (NULL ));
94
- EXPECT_TRUE (dev.open_power (&fh1));
97
+ CellularPower *pwr = dev.open_power (NULL );
98
+ CellularPower *pwr1 = dev.open_power (&fh1);
99
+
100
+ EXPECT_TRUE (pwr);
101
+ EXPECT_TRUE (pwr1);
102
+ EXPECT_TRUE (pwr1 == pwr);
95
103
}
96
104
97
105
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_open_sim)
98
106
{
99
- EventQueue que;
100
- AT_CellularDevice dev (que);
101
107
FileHandle_stub fh1;
108
+ AT_CellularDevice dev (&fh1);
102
109
103
- EXPECT_TRUE (! dev.open_sim (NULL ));
104
- EXPECT_TRUE (dev.open_sim (&fh1));
110
+ CellularSIM *sim = dev.open_sim (NULL );
111
+ CellularSIM *sim1 = dev.open_sim (&fh1);
112
+
113
+ EXPECT_TRUE (sim);
114
+ EXPECT_TRUE (sim1);
115
+ EXPECT_TRUE (sim1 == sim);
105
116
}
106
117
107
118
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_open_information)
108
119
{
109
- EventQueue que;
110
- AT_CellularDevice dev (que);
111
120
FileHandle_stub fh1;
121
+ AT_CellularDevice dev (&fh1);
112
122
113
- EXPECT_TRUE (!dev.open_information (NULL ));
114
- EXPECT_TRUE (dev.open_information (&fh1));
123
+ CellularInformation *info = dev.open_information (NULL );
124
+ CellularInformation *info1 = dev.open_information (&fh1);
125
+
126
+ EXPECT_TRUE (info);
127
+ EXPECT_TRUE (info1);
128
+ EXPECT_TRUE (info1 == info);
115
129
}
116
130
117
131
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_close_network)
118
132
{
119
- EventQueue que;
120
- AT_CellularDevice dev (que);
121
133
FileHandle_stub fh1;
134
+ AT_CellularDevice dev (&fh1);
122
135
ATHandler_stub::ref_count = 0 ;
123
136
124
137
EXPECT_TRUE (dev.open_network (&fh1));
@@ -131,9 +144,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_network)
131
144
132
145
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_close_sms)
133
146
{
134
- EventQueue que;
135
- AT_CellularDevice dev (que);
136
147
FileHandle_stub fh1;
148
+ AT_CellularDevice dev (&fh1);
137
149
ATHandler_stub::ref_count = 0 ;
138
150
139
151
EXPECT_TRUE (dev.open_sms (&fh1));
@@ -146,9 +158,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sms)
146
158
147
159
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_close_power)
148
160
{
149
- EventQueue que;
150
- AT_CellularDevice dev (que);
151
161
FileHandle_stub fh1;
162
+ AT_CellularDevice dev (&fh1);
152
163
ATHandler_stub::ref_count = 0 ;
153
164
154
165
EXPECT_TRUE (dev.open_power (&fh1));
@@ -161,9 +172,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_power)
161
172
162
173
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_close_sim)
163
174
{
164
- EventQueue que;
165
- AT_CellularDevice dev (que);
166
175
FileHandle_stub fh1;
176
+ AT_CellularDevice dev (&fh1);
167
177
ATHandler_stub::ref_count = 0 ;
168
178
int ana = 0 ;
169
179
@@ -182,9 +192,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_sim)
182
192
183
193
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_close_information)
184
194
{
185
- EventQueue que;
186
- AT_CellularDevice dev (que);
187
195
FileHandle_stub fh1;
196
+ AT_CellularDevice dev (&fh1);
188
197
ATHandler_stub::int_value = 0 ;
189
198
190
199
EXPECT_TRUE (dev.open_information (&fh1));
@@ -193,6 +202,7 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_information)
193
202
AT_CellularBase_stub::handler_value = NULL ;
194
203
dev.close_information ();
195
204
205
+ EventQueue que;
196
206
ATHandler_stub::fh_value = &fh1;
197
207
ATHandler at (&fh1, que, 0 , " ," );
198
208
AT_CellularBase_stub::handler_value = &at;
@@ -208,9 +218,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_close_information)
208
218
209
219
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_set_timeout)
210
220
{
211
- EventQueue que;
212
- AT_CellularDevice dev (que);
213
221
FileHandle_stub fh1;
222
+ AT_CellularDevice dev (&fh1);
214
223
ATHandler_stub::timeout = 0 ;
215
224
ATHandler_stub::default_timeout = false ;
216
225
@@ -231,9 +240,8 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_set_timeout)
231
240
232
241
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_modem_debug_on)
233
242
{
234
- EventQueue que;
235
- AT_CellularDevice dev (que);
236
243
FileHandle_stub fh1;
244
+ AT_CellularDevice dev (&fh1);
237
245
ATHandler_stub::debug_on = false ;
238
246
239
247
// no interfaces open so debug toggling should not affect
@@ -249,31 +257,16 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_modem_debug_on)
249
257
dev.close_sim ();
250
258
}
251
259
252
- TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_get_stack)
253
- {
254
- EventQueue que;
255
- AT_CellularDevice dev (que);
256
- FileHandle_stub fh1;
257
-
258
- NetworkStack *stack = dev.get_stack ();
259
- EXPECT_TRUE (stack == NULL );
260
-
261
- EXPECT_TRUE (dev.open_network (&fh1));
262
-
263
- stack = dev.get_stack ();
264
- EXPECT_TRUE (stack == NULL ); // Not in PPP so also null but this is got from the network class
265
- }
266
-
267
260
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_get_send_delay)
268
261
{
269
- EventQueue que ;
270
- AT_CellularDevice dev (que );
262
+ FileHandle_stub fh1 ;
263
+ AT_CellularDevice dev (&fh1 );
271
264
EXPECT_TRUE (0 == dev.get_send_delay ());
272
265
}
273
266
274
267
TEST_F (TestAT_CellularDevice, test_AT_CellularDevice_init_module)
275
268
{
276
- EventQueue que ;
277
- AT_CellularDevice dev (que );
278
- EXPECT_TRUE (NSAPI_ERROR_OK == dev.init_module (NULL ));
269
+ FileHandle_stub fh1 ;
270
+ AT_CellularDevice dev (&fh1 );
271
+ EXPECT_TRUE (NSAPI_ERROR_OK == dev.init_module ());
279
272
}
0 commit comments