Add HAL TC for modem, SIM and network 89/184489/2
authorsinikang <sinikang@samsung.com>
Wed, 18 Jul 2018 08:31:33 +0000 (17:31 +0900)
committersinikang <sinikang@samsung.com>
Thu, 19 Jul 2018 00:58:39 +0000 (09:58 +0900)
Change-Id: Iba5d7f3923ca87402ef9ae68d4625bbb0b759bdd

haltest/tapi_hal_tc.cpp
haltest/tapi_hal_tc.h [new file with mode: 0644]
packaging/libtapi.spec

index 56f39db..d2c2863 100644 (file)
 
 #include <tapi_common.h>
 #include <TapiUtility.h>
+#include <ITapiModem.h>
+#include <ITapiNetwork.h>
+#include <ITapiSim.h>
+
+
+#include "tapi_hal_tc.h"
 
 using ::testing::EmptyTestEventListener;
 using ::testing::InitGoogleTest;
@@ -35,60 +41,326 @@ using ::testing::TestInfo;
 using ::testing::TestPartResult;
 using ::testing::UnitTest;
 
-TapiHandle *tapi_h = NULL;
-char **cp_list = NULL;
-int cp_count = 0;
-bool g_bFeatureTelephony = false;
-
 #define FEATURE_TELEPHONY      "tizen.org/feature/network.telephony"
 #define FEATRE_NOT_SUPPORT     "Telephony feature is not supported"
 
+#define ASYNC_RESULT_SUCCESS 0x0
+#define ASYNC_RESULT_UNKNOWN 0x0FFFFFFF
+
+static TapiHandle *tapi_h = NULL;
+static char **cp_list = NULL;
+static int cp_count = 0;
+static bool g_bFeatureTelephony = false;
+static int async_result = ASYNC_RESULT_UNKNOWN;
+
+static TelSimCardStatus_t sim_card_status = TAPI_SIM_STATUS_CARD_ERROR;
+
 static bool __check_telephony_feature_supported()
 {
        bool value = false;
        int ret = system_info_get_platform_bool(FEATURE_TELEPHONY, &value);
-       EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
-       EXPECT_EQ(true, value) << FEATRE_NOT_SUPPORT;
+       EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed" << std::endl;
+       EXPECT_EQ(true, value) << FEATRE_NOT_SUPPORT << std::endl;
        return value;
 }
 
+static gboolean __timeout_callback(gpointer data)
+{
+       EXPECT_TRUE(0) << " - tapi callback timeout!";
+       QUIT_GMAIN_LOOP;
+
+       return false;
+}
+
+static void _get_flight_mode_callback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+       int *mode = (int *)data;
+
+       std::cout << "tel_get_flight_mode() response receive" << std::endl;
+       std::cout << " - result = " << result << " (0=Success)" << std::endl;
+       async_result = result;
+
+       if (mode)
+               std::cout << " - mode = " << *mode << " (0=flight mode OFF, 1=flight mode ON)" <<std::endl;
+       else
+               std::cout << " - mode is invalid" << std::endl;
+
+       QUIT_GMAIN_LOOP;
+
+}
+
+static void _get_sim_iccid_callback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+       TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+       TelSimIccIdInfo_t *iccid = (TelSimIccIdInfo_t *)data;
+
+       std::cout << "tel_get_sim_iccid() response received" << std::endl;
+
+       if ( access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+               async_result = ASYNC_RESULT_SUCCESS;
+               std::cout << " - iccid length = " << iccid->icc_length << std::endl;
+               std::cout << " - iccid = " << iccid->icc_num << std::endl;
+       }
+
+       QUIT_GMAIN_LOOP;
+
+}
+
+static void _get_sim_msisdn_callback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+       TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+       TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
+
+       std::cout << "tel_get_sim_msisdn() response received" << std::endl;
+
+       if ( access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+               async_result = ASYNC_RESULT_SUCCESS;
+               std::cout << " - list->count = " << list->count << std::endl;
+               if (list->count > 0)
+                       std::cout << " - msisdn[0] : name = " << list->list[0].name << ", num = " << list->list[0].num << std::endl;
+       }
 
-TEST(TAPI_COMMON, tel_get_cp_name_list)
+       QUIT_GMAIN_LOOP;
+}
+
+TEST(TAPI_INIT, tel_get_cp_name_list)
 {
        g_bFeatureTelephony = __check_telephony_feature_supported();
-       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT;
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
 
        cp_list = tel_get_cp_name_list();
-       ASSERT_TRUE(cp_list != NULL);
+       ASSERT_TRUE(cp_list != NULL) << "cp_list is null" << std::endl;
 
        unsigned int i = 0;
        while (cp_list[i]) {
                cp_count++;
                i++;
        }
-       ASSERT_TRUE(cp_count > 0);
+       ASSERT_TRUE(cp_count > 0) << "cp_count is 0" << std::endl;
+       std::cout << " - cp_count:" << cp_count << std::endl;
+       std::cout << " - cp_list[0] = " << cp_list[0] << std::endl;
 }
 
-TEST(TAPI_COMMON, tel_init_P)
+TEST(TAPI_INIT, tel_init_P)
 {
-       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT;
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
        ASSERT_TRUE(cp_list != NULL && cp_count > 0);
 
        tapi_h = tel_init(cp_list[0]);
-       ASSERT_TRUE(tapi_h != NULL);
+       ASSERT_TRUE(tapi_h != NULL) << "tel_init() is failed" << std::endl;
+}
+
+
+TEST(TAPI_INIT, tel_get_ready_state_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       int state = 0;
+       int ret = tel_get_ready_state(&state);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_get_ready_state() is failed" << std::endl;
+       ASSERT_TRUE(state == 1) << "TELEPHONY_STATE_NOT_READY" << std::endl;
+
+       std::cout << " - telephony_state : TELEPHONY_STATE_READY" << std::endl;
+}
+
+TEST(TAPI_MODEM, telephony_modem_get_power_status_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       int modem_status = -1;
+       int ret = tel_check_modem_power_status(tapi_h, &modem_status);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_check_modem_power_status() is failed" << std::endl;
+
+       std::cout << " - modem_power_status = " << modem_status << " (0=on,1=off,2=rst,3=low)" << std::endl;
 }
 
-TEST(TAPI_COMMON, tel_deinit_P)
+TEST(TAPI_MODEM, tel_get_misc_me_version_sync_P)
 {
-       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT;
-       ASSERT_TRUE(tapi_h != NULL);
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       TelMiscVersionInformation *info = NULL;
+       info = tel_get_misc_me_version_sync(tapi_h);
+       EXPECT_TRUE(NULL != info) << "tel_get_misc_me_version_sync() is failed" << std::endl;
+
+       std::cout << " - sw version = " << info->szSwVersion << std::endl;
+       std::cout << " - hw version = " << info->szHwVersion << std::endl;
+       std::cout << " - RfCal Date = " << info->szRfCalDate << std::endl;
+       std::cout << " - Product Code = " << info->szProductCode << std::endl;
+       std::cout << " - Model ID = " << info->szModelId << std::endl;
+       std::cout << " - Prl Version = " << info->szPrlVersion << std::endl;
+       std::cout << " - ERI Version = " << info->szEriVersion << std::endl;
+
+       free(info);
+}
+
+TEST(TAPI_MODEM, tel_get_misc_me_sn_sync_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       TelMiscSNInformation *sn;
+       sn = tel_get_misc_me_sn_sync(tapi_h);
+       EXPECT_TRUE(NULL != sn) << "tel_get_misc_me_sn_sync() is failed" << std::endl;
+
+
+       std::cout << " - esn number = " << sn->szEsn << std::endl;
+       std::cout << " - meid number = " << sn->szMeid << std::endl;
+       std::cout << " - imei number = " << sn->szImei << std::endl;
+       std::cout << " - imeisv number = " << sn->szImeiSv << std::endl;
+
+       free(sn);
+}
+
+TEST(TAPI_MODEM, tel_get_misc_me_imei_sync_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       char *imei;
+       imei = tel_get_misc_me_imei_sync(tapi_h);
+       EXPECT_TRUE(NULL != imei) << "tel_get_misc_me_imei_sync() is failed" << std::endl;
+
+       std::cout << " - imei number = " << imei << std::endl;
+
+       free(imei);
+}
+
+TEST(TAPI_MODEM, tel_get_flight_mode_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       int ret = tel_get_flight_mode(tapi_h, _get_flight_mode_callback, NULL);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_get_flight_mode() is failed" << std::endl;
+
+       RUN_GMAIN_LOOP(__timeout_callback);
+
+       EXPECT_EQ(ASYNC_RESULT_SUCCESS, async_result) << "tel_get_flight_mode() is failed failed";
+       async_result = ASYNC_RESULT_UNKNOWN;
+}
+
+TEST(TAPI_SIM, tel_get_sim_init_info_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       int ret = 0;
+       int sim_card_changed = 0;
+
+       ret = tel_get_sim_init_info(tapi_h, &sim_card_status, &sim_card_changed);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_get_sim_init_info() is failed" << std::endl;
+
+       if (sim_card_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+               std::cout << " - SIM status = SIM_INIT_COMPLETED" << std::endl;
+               std::cout << " - SIM changed = " << sim_card_changed<< std::endl;
+       } else if (sim_card_status == TAPI_SIM_STATUS_CARD_NOT_PRESENT) {
+               std::cout << "- SIM status = No SIM" << std::endl;
+       } else {
+               std::cout << "- SIM status = SIM card Error" << std::endl;
+       }
+
+}
+
+TEST(TAPI_SIM, tel_get_sim_imsi_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+       ASSERT_TRUE(sim_card_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) << "SIM status is invalid" << std::endl;
+
+       int ret = 0;
+       TelSimImsiInfo_t imsi;
+       memset(&imsi, 0, sizeof(TelSimImsiInfo_t));
+
+       ret = tel_get_sim_imsi(tapi_h, &imsi);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_get_sim_imsi() is failed" << std::endl;
+
+       std::cout << " - mcc = "<< imsi.szMcc << std::endl;
+       std::cout << " - mnc = " << imsi.szMnc << std::endl;
+       std::cout << " - msin = " << imsi.szMsin << std::endl;
+}
+
+TEST(TAPI_SIM, tel_get_sim_iccid_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+       ASSERT_TRUE(sim_card_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) << "SIM status is invalid" << std::endl;
+
+       int ret = tel_get_sim_iccid(tapi_h, _get_sim_iccid_callback, NULL);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_get_sim_iccid() is failed" << std::endl;
+
+       RUN_GMAIN_LOOP(__timeout_callback);
+
+       EXPECT_EQ(ASYNC_RESULT_SUCCESS, async_result) << "tel_get_sim_iccid() is failed failed";
+       async_result = ASYNC_RESULT_UNKNOWN;
+}
+
+TEST(TAPI_SIM, tel_get_sim_msisdn_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+       ASSERT_TRUE(sim_card_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) << "SIM status is invalid" << std::endl;
+
+       int ret = tel_get_sim_msisdn(tapi_h, _get_sim_msisdn_callback, NULL);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_get_sim_msisdn() is failed" << std::endl;
+
+       RUN_GMAIN_LOOP(__timeout_callback);
+
+       EXPECT_EQ(ASYNC_RESULT_SUCCESS, async_result) << "tel_get_sim_msisdn() is failed failed";
+       async_result = ASYNC_RESULT_UNKNOWN;
+}
+
+TEST(TAPI_NETWORK, tel_get_network_properties_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
+
+       int svc_type = -1, act = -1, ps_type = -1, cs = -1, ps = -1;
+       int roam = -1, sig_level = -1;
+       char *plmn = NULL, *n_name = NULL, *s_name = NULL;
+
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_ACT, &act);
+       tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_PLMN, &plmn);
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_PS_TYPE, &ps_type);
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_CIRCUIT_STATUS, &cs);
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_PACKET_STATUS, &ps);
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_SIGNALSTRENGTH_LEVEL, &sig_level);
+       tel_get_property_int(tapi_h, TAPI_PROP_NETWORK_ROAMING_STATUS, &roam);
+       tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_NETWORK_NAME, &n_name);
+       tel_get_property_string(tapi_h, TAPI_PROP_NETWORK_SPN_NAME, &s_name);
+
+       std::cout << "<network properties>" << std::endl;
+       std::cout <<"  [service_type]: " << svc_type << std::endl;
+       std::cout <<"  [act]: " << act << std::endl;
+       std::cout <<"  [plmn]: " << plmn << std::endl;
+       std::cout <<"  [ps_type]: " <<ps_type << std::endl;
+       std::cout <<"  [cs_status]: " << cs << std::endl;
+       std::cout <<"  [ps_status]: " << ps << std::endl;
+       std::cout <<"  [sig_level]: " << sig_level << std::endl;
+       std::cout <<"  [roaming_status]: " << roam << std::endl;
+       std::cout <<"  [network_name]: " << n_name << std::endl;
+       std::cout <<"  [spn_name]: " << s_name << std::endl;
+
+       g_free(plmn);
+       g_free(n_name);
+       g_free(s_name);
+
+}
+
+
+TEST(TAPI_DEINIT, tel_deinit_P)
+{
+       ASSERT_EQ(true, g_bFeatureTelephony) << FEATRE_NOT_SUPPORT << std::endl;
+       ASSERT_TRUE(tapi_h != NULL) << "tapi_h is NULL" << std::endl;
 
        int ret = tel_deinit(tapi_h);
-       EXPECT_EQ(TAPI_API_SUCCESS, ret);
+       EXPECT_EQ(TAPI_API_SUCCESS, ret) << "tel_deinit() is failed" << std::endl;
        tapi_h = NULL;
 }
 
-
 int main(int argc, char **argv) {
   InitGoogleTest(&argc, argv);
 
diff --git a/haltest/tapi_hal_tc.h b/haltest/tapi_hal_tc.h
new file mode 100644 (file)
index 0000000..8315f8b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __TAPI_HAL_TC_H__
+#define __TAPI_HAL_TC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+#define GMAINTIMEOUT   20000
+
+GMainLoop *g_pMainLoop;
+guint g_nTimeoutId;
+
+#define RUN_GMAIN_LOOP(callback) {\
+       g_pMainLoop = g_main_loop_new(NULL, false);\
+       g_nTimeoutId = g_timeout_add(GMAINTIMEOUT, callback, g_pMainLoop);\
+       g_main_loop_run(g_pMainLoop);\
+       g_source_remove(g_nTimeoutId);\
+       g_pMainLoop = NULL;\
+}
+
+#define QUIT_GMAIN_LOOP {\
+       if (g_pMainLoop)\
+               g_main_loop_quit(g_pMainLoop);\
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TAPI_HAL_TC_H__ */
index 94b2fc6..7a139e5 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
 %define minor 8
-%define patchlevel 26
+%define patchlevel 27
 
 Name:           libtapi
 Version:        %{major}.%{minor}.%{patchlevel}
@@ -83,4 +83,4 @@ rm -rf %{buildroot}%{_includedir}/telephony/tapi/.gitignore
 %files haltests
 %manifest libtapi.manifest
 %{_bindir}/tapi_hal_tc
-%{_libdir}/*.so
\ No newline at end of file
+%{_libdir}/*.so