2626#include " ATHandler_stub.h"
2727#include " SocketAddress.h"
2828#include " CellularDevice_stub.h"
29+ #include " AT_CellularDevice_stub.h"
2930#include " myCellularDevice.h"
3031
3132using namespace mbed ;
@@ -34,22 +35,15 @@ using namespace events;
3435class MyStack : public AT_CellularStack {
3536public:
3637 bool bool_value;
37- bool max_sock_value;
3838 nsapi_error_t create_error;
3939 CellularSocket socket;
4040
4141 MyStack (ATHandler &atr, int cid, nsapi_ip_stack_t typ, AT_CellularDevice &device) : AT_CellularStack(atr, cid, typ, device)
4242 {
4343 bool_value = false ;
44- max_sock_value = 0 ;
4544 create_error = NSAPI_ERROR_OK;
4645 }
4746
48- virtual int get_max_socket_count ()
49- {
50- return max_sock_value;
51- }
52-
5347 virtual bool is_protocol_supported (nsapi_protocol_t protocol)
5448 {
5549 return bool_value;
@@ -211,15 +205,17 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_open)
211205 EXPECT_EQ (st.socket_open (NULL , NSAPI_TCP), NSAPI_ERROR_UNSUPPORTED);
212206
213207 st.bool_value = true ;
214- st. max_sock_value = 0 ;
208+ AT_CellularDevice_stub:: max_sock_value = 0 ;
215209 nsapi_socket_t sock = &st.socket ;
216210 EXPECT_EQ (st.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_NO_SOCKET);
217211
218212 MyStack st2 (at, 0 , IPV6_STACK, *_dev);
219213 st2.bool_value = true ;
220- st2. max_sock_value = 1 ;
214+ AT_CellularDevice_stub:: max_sock_value = 1 ;
221215 sock = &st2.socket ;
222216 EXPECT_EQ (st2.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_OK);
217+
218+ AT_CellularDevice_stub::max_sock_value = 0 ;
223219}
224220
225221TEST_F (TestAT_CellularStack, test_AT_CellularStack_socket_close)
@@ -233,13 +229,13 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_close)
233229
234230 nsapi_socket_t sock = &st.socket ;
235231 st.bool_value = true ;
236- st. max_sock_value = 1 ;
232+ AT_CellularDevice_stub:: max_sock_value = 1 ;
237233 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 ;
239235 EXPECT_EQ (st.socket_close (sock), NSAPI_ERROR_DEVICE_ERROR);
240236
241237 MyStack st2 (at, 0 , IPV6_STACK, *_dev);
242- st2. max_sock_value = 1 ;
238+ AT_CellularDevice_stub:: max_sock_value = 1 ;
243239 st2.bool_value = true ;
244240 sock = &st2.socket ;
245241 EXPECT_EQ (st2.socket_open (&sock, NSAPI_TCP), NSAPI_ERROR_OK);
@@ -306,7 +302,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_send)
306302 EXPECT_EQ (st.socket_send (&st.socket , " addr" , 4 ), NSAPI_ERROR_NO_CONNECTION);
307303
308304 SocketAddress addr (" fc00::" , 123 );
309- st. max_sock_value = 1 ;
305+ AT_CellularDevice_stub:: max_sock_value = 1 ;
310306 st.bool_value = true ;
311307 nsapi_socket_t sock = &st.socket ;
312308 st.socket_open (&sock, NSAPI_TCP);
@@ -325,7 +321,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_sendto)
325321 SocketAddress addr (" fc00::" , 123 );
326322 EXPECT_EQ (st.socket_sendto (NULL , addr, " addr" , 4 ), NSAPI_ERROR_NO_SOCKET);
327323
328- st. max_sock_value = 1 ;
324+ AT_CellularDevice_stub:: max_sock_value = 1 ;
329325 st.bool_value = true ;
330326 nsapi_socket_t sock = &st.socket ;
331327 st.socket_open (&sock, NSAPI_TCP);
@@ -359,7 +355,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_recvfrom)
359355 EXPECT_EQ (st.socket_recvfrom (NULL , NULL , table, 4 ), NSAPI_ERROR_NO_SOCKET);
360356
361357 SocketAddress addr;
362- st. max_sock_value = 1 ;
358+ AT_CellularDevice_stub:: max_sock_value = 1 ;
363359 st.bool_value = true ;
364360 nsapi_socket_t sock = &st.socket ;
365361 st.socket_open (&sock, NSAPI_TCP);
@@ -380,7 +376,7 @@ TEST_F(TestAT_CellularStack, test_AT_CellularStack_socket_attach)
380376 MyStack st (at, 0 , IPV6_STACK, *_dev);
381377
382378 st.socket_attach (NULL , NULL , NULL );
383- st. max_sock_value = 1 ;
379+ AT_CellularDevice_stub:: max_sock_value = 1 ;
384380 st.bool_value = true ;
385381 nsapi_socket_t sock = &st.socket ;
386382 st.socket_open (&sock, NSAPI_TCP);
0 commit comments