Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers test_at_cellulardevice.cpp Source File

test_at_cellulardevice.cpp

00001 /*
00002  * Copyright (c) 2018, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #include "CppUTest/TestHarness.h"
00018 #include "test_at_cellulardevice.h"
00019 #include "AT_CellularDevice.h"
00020 #include "ATHandler_stub.h"
00021 #include "AT_CellularBase_stub.h"
00022 #include <string.h>
00023 
00024 using namespace mbed;
00025 using namespace events;
00026 
00027 Test_AT_CellularDevice::Test_AT_CellularDevice()
00028 {
00029 
00030 }
00031 
00032 Test_AT_CellularDevice::~Test_AT_CellularDevice()
00033 {
00034 }
00035 
00036 void Test_AT_CellularDevice::test_AT_CellularDevice_constructor()
00037 {
00038     EventQueue que;
00039     AT_CellularDevice dev(que);
00040 
00041     CellularDevice *dev2 = new AT_CellularDevice(que);
00042     delete dev2;
00043 }
00044 
00045 void Test_AT_CellularDevice::test_AT_CellularDevice_get_at_handler()
00046 {
00047     EventQueue que;
00048     AT_CellularDevice dev(que);
00049     FileHandle_stub fh1;
00050     FileHandle_stub fh2;
00051     FileHandle_stub fh3;
00052 
00053     dev.open_network(&fh1);
00054     dev.open_sms(&fh2);
00055     AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
00056     dev.open_sim(&fh3);
00057     ATHandler_stub::fh_value = &fh1;
00058     dev.open_power(&fh1);
00059 
00060     ATHandler_stub::fh_value = NULL;
00061 }
00062 
00063 void Test_AT_CellularDevice::test_AT_CellularDevice_open_network()
00064 {
00065     EventQueue que;
00066     AT_CellularDevice dev(que);
00067     FileHandle_stub fh1;
00068 
00069     CHECK(!dev.open_network(NULL));
00070     CHECK(dev.open_network(&fh1));
00071 }
00072 
00073 void Test_AT_CellularDevice::test_AT_CellularDevice_open_sms()
00074 {
00075     EventQueue que;
00076     AT_CellularDevice dev(que);
00077     FileHandle_stub fh1;
00078 
00079     CHECK(!dev.open_sms(NULL));
00080     CHECK(dev.open_sms(&fh1));
00081 }
00082 
00083 void Test_AT_CellularDevice::test_AT_CellularDevice_open_power()
00084 {
00085     EventQueue que;
00086     AT_CellularDevice dev(que);
00087     FileHandle_stub fh1;
00088 
00089     CHECK(!dev.open_power(NULL));
00090     CHECK(dev.open_power(&fh1));
00091 }
00092 
00093 void Test_AT_CellularDevice::test_AT_CellularDevice_open_sim()
00094 {
00095     EventQueue que;
00096     AT_CellularDevice dev(que);
00097     FileHandle_stub fh1;
00098 
00099     CHECK(! dev.open_sim(NULL));
00100     CHECK(dev.open_sim(&fh1));
00101 }
00102 
00103 void Test_AT_CellularDevice::test_AT_CellularDevice_open_information()
00104 {
00105     EventQueue que;
00106     AT_CellularDevice dev(que);
00107     FileHandle_stub fh1;
00108 
00109     CHECK(!dev.open_information(NULL));
00110     CHECK(dev.open_information(&fh1));
00111 }
00112 
00113 void Test_AT_CellularDevice::test_AT_CellularDevice_close_network()
00114 {
00115 
00116 }
00117 
00118 void Test_AT_CellularDevice::test_AT_CellularDevice_close_sms()
00119 {
00120 
00121 }
00122 
00123 void Test_AT_CellularDevice::test_AT_CellularDevice_close_power()
00124 {
00125 
00126 }
00127 
00128 void Test_AT_CellularDevice::test_AT_CellularDevice_close_sim()
00129 {
00130 
00131 }
00132 
00133 void Test_AT_CellularDevice::test_AT_CellularDevice_close_information()
00134 {
00135     EventQueue que;
00136     AT_CellularDevice dev(que);
00137     FileHandle_stub fh1;
00138     ATHandler_stub::int_value = 0;
00139 
00140     CHECK(dev.open_information(&fh1));
00141 
00142     ATHandler_stub::fh_value = NULL;
00143     AT_CellularBase_stub::handler_value = NULL;
00144     dev.close_information();
00145 
00146     ATHandler_stub::fh_value = &fh1;
00147     ATHandler at(&fh1, que, 0, ",");
00148     AT_CellularBase_stub::handler_value = &at;
00149 
00150     CHECK(dev.open_information(&fh1));
00151     AT_CellularBase_stub::handler_value = AT_CellularBase_stub::handler_at_constructor_value;
00152 
00153     dev.close_information();
00154 
00155     ATHandler_stub::fh_value = NULL;
00156 }
00157