Skip to content

Commit 1fb9dd7

Browse files
authored
Merge pull request ARMmbed#12122 from AnttiKauppila/visibility_fixes
ATHandler refactoring
2 parents 974baaf + 5553d0a commit 1fb9dd7

File tree

6 files changed

+135
-184
lines changed

6 files changed

+135
-184
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellulardevice/at_cellulardevicetest.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_get_at_handler)
7878
AT_CellularDevice *dev2 = new AT_CellularDevice(&fh1); // AT fh1 ref count 3
7979
EXPECT_TRUE(dev2->open_information(&fh1)); // AT fh1 ref count 4
8080
ATHandler *at = dev2->get_at_handler(); // AT fh1 ref count 5
81-
EXPECT_EQ(at->get_ref_count(), 6);
8281
delete dev2; // AT fh1 2 refs deleted -> ref count 3
83-
EXPECT_EQ(at->get_ref_count(), 4);
82+
8483
AT_CellularDevice dev3(&fh1); // AT fh1 ref count 4
8584
EXPECT_TRUE(dev3.release_at_handler(at) == NSAPI_ERROR_OK); // AT fh1 ref count 3
86-
EXPECT_EQ(ATHandler_stub::ref_count, 4);
8785
}
8886

8987
TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_open_network)
@@ -272,20 +270,16 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_create_delete_context)
272270
AT_CellularDevice *dev = new AT_CellularDevice(&fh1);
273271

274272
ATHandler *at = dev->get_at_handler();
275-
EXPECT_EQ(at->get_ref_count(), 1);
276273
EXPECT_TRUE(dev->release_at_handler(at) == NSAPI_ERROR_OK);
277274

278275
CellularContext *ctx = dev->create_context(NULL);
279276
delete dev;
280277

281278
dev = new AT_CellularDevice(&fh1);
282279
at = dev->get_at_handler();
283-
EXPECT_EQ(at->get_ref_count(), 1);
284280
ctx = dev->create_context(NULL);
285281
CellularContext *ctx1 = dev->create_context(&fh1);
286-
EXPECT_EQ(at->get_ref_count(), 3);
287282
CellularContext *ctx2 = dev->create_context(&fh1);
288-
EXPECT_EQ(at->get_ref_count(), 4);
289283

290284
EXPECT_TRUE(ctx);
291285
EXPECT_TRUE(ctx1);
@@ -296,20 +290,13 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_create_delete_context)
296290
EXPECT_TRUE(xx);
297291

298292
dev->delete_context(ctx);
299-
EXPECT_EQ(at->get_ref_count(), 3);
300293
dev->delete_context(ctx1);
301-
EXPECT_EQ(at->get_ref_count(), 2);
302294
dev->delete_context(NULL);
303-
EXPECT_EQ(at->get_ref_count(), 2);
304295
dev->delete_context(ctx2);
305-
EXPECT_EQ(at->get_ref_count(), 1);
306296

307297
ctx = dev->create_context(NULL);
308-
EXPECT_EQ(at->get_ref_count(), 2);
309298
ctx1 = dev->create_context(&fh1);
310-
EXPECT_EQ(at->get_ref_count(), 3);
311299
ctx2 = dev->create_context(&fh1);
312-
EXPECT_EQ(at->get_ref_count(), 4);
313300
EXPECT_TRUE(dev->release_at_handler(at) == NSAPI_ERROR_OK);
314301
EXPECT_TRUE(ctx);
315302
EXPECT_TRUE(ctx1);

UNITTESTS/features/cellular/framework/AT/athandler/athandlertest.cpp renamed to UNITTESTS/features/cellular/framework/device/athandler/athandlertest.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,18 @@ TEST_F(TestATHandler, test_ATHandler_list)
105105
ATHandler::set_debug_list(false);
106106

107107
ATHandler *at1 = ATHandler::get_instance(&fh1, que, 0, ",", 0, 0);
108-
EXPECT_TRUE(at1->get_ref_count() == 1);
109108

110109
ATHandler::set_at_timeout_list(1000, false);
111110
ATHandler::set_debug_list(true);
112111

113112
EXPECT_TRUE(ATHandler::get_instance(NULL, que, 0, ",", 0, 0) == NULL);
114113

115114
ATHandler *at2 = ATHandler::get_instance(&fh1, que, 0, ",", 0, 0);
116-
EXPECT_TRUE(at1->get_ref_count() == 2);
117-
EXPECT_TRUE(at2->get_ref_count() == 2);
118115

119116
ATHandler::set_at_timeout_list(2000, true);
120117
ATHandler::set_debug_list(false);
121118

122119
EXPECT_TRUE(at1->close() == NSAPI_ERROR_OK);
123-
EXPECT_TRUE(at2->get_ref_count() == 1);
124120
EXPECT_TRUE(at2->close() == NSAPI_ERROR_OK);
125121

126122
ATHandler::set_at_timeout_list(1000, false);
@@ -204,43 +200,6 @@ TEST_F(TestATHandler, test_ATHandler_get_last_device_error)
204200
EXPECT_TRUE(0 == at.get_last_device_error().errCode);
205201
}
206202

207-
TEST_F(TestATHandler, test_ATHandler_inc_ref_count)
208-
{
209-
EventQueue que;
210-
FileHandle_stub fh1;
211-
212-
ATHandler at(&fh1, que, 0, ",");
213-
at.inc_ref_count();
214-
}
215-
216-
TEST_F(TestATHandler, test_ATHandler_dec_ref_count)
217-
{
218-
EventQueue que;
219-
FileHandle_stub fh1;
220-
221-
ATHandler at(&fh1, que, 0, ",");
222-
at.dec_ref_count();
223-
}
224-
225-
TEST_F(TestATHandler, test_ATHandler_get_ref_count)
226-
{
227-
EventQueue que;
228-
FileHandle_stub fh1;
229-
230-
ATHandler at(&fh1, que, 0, ",");
231-
EXPECT_TRUE(1 == at.get_ref_count());
232-
233-
at.inc_ref_count();
234-
EXPECT_TRUE(2 == at.get_ref_count());
235-
236-
at.inc_ref_count();
237-
EXPECT_TRUE(3 == at.get_ref_count());
238-
239-
at.dec_ref_count();
240-
at.dec_ref_count();
241-
EXPECT_TRUE(1 == at.get_ref_count());
242-
}
243-
244203
TEST_F(TestATHandler, test_ATHandler_set_at_timeout)
245204
{
246205
EventQueue que;

UNITTESTS/features/cellular/framework/AT/athandler/unittest.cmake renamed to UNITTESTS/features/cellular/framework/device/athandler/unittest.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ set(unittest-includes ${unittest-includes}
1515

1616
# Source files
1717
set(unittest-sources
18-
../features/cellular/framework/AT/ATHandler.cpp
18+
../features/cellular/framework/device/ATHandler.cpp
1919
)
2020

2121
# Test files
2222
set(unittest-test-sources
23-
features/cellular/framework/AT/athandler/athandlertest.cpp
23+
features/cellular/framework/device/athandler/athandlertest.cpp
2424
stubs/EventQueue_stub.cpp
2525
stubs/FileHandle_stub.cpp
2626
stubs/us_ticker_stub.cpp

UNITTESTS/stubs/ATHandler_stub.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ bool ATHandler::get_debug() const
111111
return ATHandler_stub::debug_on;
112112
}
113113

114+
void ATHandler::set_debug_list(bool debug_on)
115+
{
116+
ATHandler_stub::debug_on = debug_on;
117+
}
118+
114119
ATHandler::~ATHandler()
115120
{
116121
ATHandler_stub::urc_handlers.clear();
@@ -409,11 +414,6 @@ void ATHandler::set_at_timeout_list(uint32_t timeout_milliseconds, bool default_
409414
ATHandler_stub::default_timeout = default_timeout;
410415
}
411416

412-
void ATHandler::set_debug_list(bool debug_on)
413-
{
414-
ATHandler_stub::debug_on = debug_on;
415-
}
416-
417417
void ATHandler::set_send_delay(uint16_t send_delay)
418418
{
419419
}

0 commit comments

Comments
 (0)