@@ -118,10 +118,11 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_network()
118
118
ATHandler_stub::ref_count = 0 ;
119
119
120
120
CHECK (dev.open_network (&fh1));
121
+ AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
121
122
CHECK (ATHandler_stub::ref_count == 1 );
122
123
123
124
dev.close_network ();
124
- CHECK (ATHandler_stub::ref_count == 0 );
125
+ CHECK (ATHandler_stub::ref_count == kATHandler_destructor_ref_ount );
125
126
}
126
127
127
128
void Test_AT_CellularDevice::test_AT_CellularDevice_close_sms ()
@@ -132,10 +133,11 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_sms()
132
133
ATHandler_stub::ref_count = 0 ;
133
134
134
135
CHECK (dev.open_sms (&fh1));
136
+ AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
135
137
CHECK (ATHandler_stub::ref_count == 1 );
136
138
137
139
dev.close_sms ();
138
- CHECK (ATHandler_stub::ref_count == 0 );
140
+ CHECK (ATHandler_stub::ref_count == kATHandler_destructor_ref_ount );
139
141
}
140
142
141
143
void Test_AT_CellularDevice::test_AT_CellularDevice_close_power ()
@@ -146,10 +148,11 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_power()
146
148
ATHandler_stub::ref_count = 0 ;
147
149
148
150
CHECK (dev.open_power (&fh1));
151
+ AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
149
152
CHECK (ATHandler_stub::ref_count == 1 );
150
153
151
154
dev.close_power ();
152
- CHECK (ATHandler_stub::ref_count == 0 );
155
+ CHECK (ATHandler_stub::ref_count == kATHandler_destructor_ref_ount );
153
156
}
154
157
155
158
void Test_AT_CellularDevice::test_AT_CellularDevice_close_sim ()
@@ -161,11 +164,13 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_sim()
161
164
162
165
163
166
CHECK (dev.open_sim (&fh1));
167
+ AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
168
+
164
169
dev.close_sms (); // this should not affect to refcount as it's not opened
165
170
CHECK (ATHandler_stub::ref_count == 1 );
166
171
167
172
dev.close_sim ();
168
- CHECK (ATHandler_stub::ref_count == 0 );
173
+ CHECK (ATHandler_stub::ref_count == kATHandler_destructor_ref_ount );
169
174
}
170
175
171
176
void Test_AT_CellularDevice::test_AT_CellularDevice_close_information ()
@@ -174,21 +179,28 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_information()
174
179
AT_CellularDevice dev (que);
175
180
FileHandle_stub fh1;
176
181
ATHandler_stub::int_value = 0 ;
182
+ ATHandler_stub::ref_count = 0 ;
183
+ ATHandler_stub::fh_value = NULL ;
184
+ AT_CellularBase_stub::handler_value = NULL ;
177
185
178
186
CHECK (dev.open_information (&fh1));
187
+ CHECK (ATHandler_stub::ref_count == 1 );
179
188
180
- ATHandler_stub::fh_value = NULL ;
181
- AT_CellularBase_stub::handler_value = NULL ;
189
+ // at handler is not found as it's NULL (e.g. AT_CellularBase_stub::handler_value is NULL)
182
190
dev.close_information ();
191
+ CHECK (ATHandler_stub::ref_count == 1 );
183
192
193
+ // same filehandle but different at
184
194
ATHandler_stub::fh_value = &fh1;
185
195
ATHandler at (&fh1, que, 0 , " ," );
186
196
AT_CellularBase_stub::handler_value = &at;
187
197
188
198
CHECK (dev.open_information (&fh1));
189
- AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
199
+ // refcount is two it's one when we create athandler and then in open_information it's incremented by one
200
+ CHECK (ATHandler_stub::ref_count == 2 );
190
201
191
202
dev.close_information ();
203
+ CHECK (ATHandler_stub::ref_count == 1 );
192
204
193
205
ATHandler_stub::fh_value = NULL ;
194
206
}
0 commit comments