2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <gtest/gtest.h>
19 #include "tethering.h"
22 #include "mocks/tethering_dummy_client.h"
23 #include "mocks/tethering_memory.h"
24 #include "mocks/tethering_system_info.h"
25 #include "mocks/tethering_vconf.h"
28 class TetheringClientTest: public ::testing::Test {
30 tethering_client_h client;
34 tethering_mock_set_memory_result(true);
35 tethering_mock_set_sysinfo_result(true);
36 tethering_mock_set_vconf_result(true);
37 tethering_mock_create_dummy_client(&client);
40 void TearDown() override
42 tethering_mock_set_vconf_result(false);
43 tethering_mock_set_sysinfo_result(false);
44 tethering_mock_set_memory_result(true);
45 tethering_mock_destroy_dummy_client(client);
49 TEST_F(TetheringClientTest, CloneN)
51 tethering_client_h clone = NULL;
53 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_clone(NULL, client));
54 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_clone(&clone, NULL));
55 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_clone(NULL, NULL));
57 tethering_mock_set_memory_result(false);
58 EXPECT_EQ(TETHERING_ERROR_OUT_OF_MEMORY, tethering_client_clone(&clone, client));
61 TEST_F(TetheringClientTest, CloneP)
63 tethering_client_h clone = NULL;
65 EXPECT_EQ(TETHERING_ERROR_NONE, tethering_client_clone(&clone, client));
67 tethering_client_destroy(clone);
70 TEST_F(TetheringClientTest, DestroyN)
72 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_destroy(NULL));
75 TEST_F(TetheringClientTest, DestroyP)
77 EXPECT_EQ(TETHERING_ERROR_NONE, tethering_client_destroy(client));
81 TEST_F(TetheringClientTest, GetTetheringTypeN)
83 tethering_type_e type;
85 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_tethering_type(NULL, &type));
86 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_tethering_type(client, NULL));
87 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_tethering_type(NULL, NULL));
90 TEST_F(TetheringClientTest, GetTetheringTypeP)
92 tethering_type_e type;
94 EXPECT_EQ(TETHERING_ERROR_NONE, tethering_client_get_tethering_type(client, &type));
97 TEST_F(TetheringClientTest, GetNameN)
101 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_name(NULL, &name));
102 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_name(client, NULL));
103 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_name(NULL, NULL));
106 TEST_F(TetheringClientTest, GetNameP)
110 EXPECT_EQ(TETHERING_ERROR_NONE, tethering_client_get_name(client, &name));
115 TEST_F(TetheringClientTest, GetIpAddressN)
117 char *ip_address = NULL;
119 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER,
120 tethering_client_get_ip_address(NULL, TETHERING_ADDRESS_FAMILY_IPV4, &ip_address));
121 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER,
122 tethering_client_get_ip_address(client, TETHERING_ADDRESS_FAMILY_IPV4, NULL));
123 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER,
124 tethering_client_get_ip_address(NULL, TETHERING_ADDRESS_FAMILY_IPV4, NULL));
127 TEST_F(TetheringClientTest, GetIpAddressP)
129 char *ip_address = NULL;
131 EXPECT_EQ(TETHERING_ERROR_NONE,
132 tethering_client_get_ip_address(client, TETHERING_ADDRESS_FAMILY_IPV4, &ip_address));
137 TEST_F(TetheringClientTest, GetMacAddressN)
139 char *mac_address = NULL;
141 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_mac_address(NULL, &mac_address));
142 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_mac_address(client, NULL));
143 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_mac_address(NULL, NULL));
146 TEST_F(TetheringClientTest, GetMacAddressP)
148 char *mac_address = NULL;
150 EXPECT_EQ(TETHERING_ERROR_NONE, tethering_client_get_mac_address(client, &mac_address));
155 TEST_F(TetheringClientTest, GetTimeN)
159 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_time(NULL, ×tamp));
160 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_time(client, NULL));
161 EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_client_get_time(NULL, NULL));
164 TEST_F(TetheringClientTest, GetTimeP)
168 EXPECT_EQ(TETHERING_ERROR_NONE, tethering_client_get_time(client, ×tamp));