26
26
#include " ATHandler_stub.h"
27
27
#include " SocketAddress.h"
28
28
#include " CellularDevice_stub.h"
29
+ #include " AT_CellularDevice_stub.h"
29
30
#include " myCellularDevice.h"
30
31
31
32
using namespace mbed ;
@@ -34,22 +35,15 @@ using namespace events;
34
35
class MyStack : public AT_CellularStack {
35
36
public:
36
37
bool bool_value;
37
- bool max_sock_value;
38
38
nsapi_error_t create_error;
39
39
CellularSocket socket;
40
40
41
41
MyStack (ATHandler &atr, int cid, nsapi_ip_stack_t typ, AT_CellularDevice &device) : AT_CellularStack(atr, cid, typ, device)
42
42
{
43
43
bool_value = false ;
44
- max_sock_value = 0 ;
45
44
create_error = NSAPI_ERROR_OK;
46
45
}
47
46
48
- virtual int get_max_socket_count ()
49
- {
50
- return max_sock_value;
51
- }
52
-
53
47
virtual bool is_protocol_supported (nsapi_protocol_t protocol)
54
48
{
55
49
return bool_value;
@@ -211,15 +205,17 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
211
205
EXPECT_EQ (st.socket_open (NULL , NSAPI_TCP), NSAPI_ERROR_UNSUPPORTED);
212
206
213
207
st.bool_value = true ;
214
- st. max_sock_value = 0 ;
208
+ AT_CellularDevice_stub:: max_sock_value = 0 ;
215
209
nsapi_socket_t sock = &st.socket ;
216
210
EXPECT_EQ (st.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_NO_SOCKET);
217
211
218
212
MyStack st2 (at, 0 , IPV6_STACK, *_dev);
219
213
st2.bool_value = true ;
220
- st2. max_sock_value = 1 ;
214
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
221
215
sock = &st2.socket ;
222
216
EXPECT_EQ (st2.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_OK);
217
+
218
+ AT_CellularDevice_stub::max_sock_value = 0 ;
223
219
}
224
220
225
221
TEST_F (TestAT_CellularStack, test_AT_CellularStack_socket_close)
@@ -233,13 +229,13 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
233
229
234
230
nsapi_socket_t sock = &st.socket ;
235
231
st.bool_value = true ;
236
- st. max_sock_value = 1 ;
232
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
237
233
EXPECT_EQ (st.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_OK);
238
- st. max_sock_value = 0 ;
234
+ AT_CellularDevice_stub:: max_sock_value = 0 ;
239
235
EXPECT_EQ (st.socket_close (sock), NSAPI_ERROR_DEVICE_ERROR);
240
236
241
237
MyStack st2 (at, 0 , IPV6_STACK, *_dev);
242
- st2. max_sock_value = 1 ;
238
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
243
239
st2.bool_value = true ;
244
240
sock = &st2.socket ;
245
241
EXPECT_EQ (st2.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_OK);
@@ -306,7 +302,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_send)
306
302
EXPECT_EQ (st.socket_send (&st.socket , " addr" , 4 ), NSAPI_ERROR_NO_CONNECTION);
307
303
308
304
SocketAddress addr (" fc00::" , 123 );
309
- st. max_sock_value = 1 ;
305
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
310
306
st.bool_value = true ;
311
307
nsapi_socket_t sock = &st.socket ;
312
308
st.socket_open (&sock, NSAPI_TCP);
@@ -325,7 +321,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_sendto)
325
321
SocketAddress addr (" fc00::" , 123 );
326
322
EXPECT_EQ (st.socket_sendto (NULL , addr, " addr" , 4 ), NSAPI_ERROR_NO_SOCKET);
327
323
328
- st. max_sock_value = 1 ;
324
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
329
325
st.bool_value = true ;
330
326
nsapi_socket_t sock = &st.socket ;
331
327
st.socket_open (&sock, NSAPI_TCP);
@@ -359,7 +355,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_recvfrom)
359
355
EXPECT_EQ (st.socket_recvfrom (NULL , NULL , table, 4 ), NSAPI_ERROR_NO_SOCKET);
360
356
361
357
SocketAddress addr;
362
- st. max_sock_value = 1 ;
358
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
363
359
st.bool_value = true ;
364
360
nsapi_socket_t sock = &st.socket ;
365
361
st.socket_open (&sock, NSAPI_TCP);
@@ -380,7 +376,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_attach)
380
376
MyStack st (at, 0 , IPV6_STACK, *_dev);
381
377
382
378
st.socket_attach (NULL , NULL , NULL );
383
- st. max_sock_value = 1 ;
379
+ AT_CellularDevice_stub:: max_sock_value = 1 ;
384
380
st.bool_value = true ;
385
381
nsapi_socket_t sock = &st.socket ;
386
382
st.socket_open (&sock, NSAPI_TCP);
0 commit comments