2 * Copyright (c) 2017 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.
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
36 error_e NetStat::GetWifiTotalTxBytes(void)
38 uint64_t tx_bytes = 0;
39 GVariant *message = NULL;
40 error_e error = ERROR_NONE;
42 message = InvokeMethod(NETCONFIG_SERVICE,
43 NETCONFIG_NETWORK_STATISTICS_PATH,
44 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
45 GET_WIFI_TOTAL_TX_BYTES,
49 if (message == NULL) {
50 GLOGD("Failed to invoke dbus method");
54 g_variant_get(message, "(t)", &tx_bytes);
55 g_variant_unref(message);
57 GLOGD("Succeeded to get wifi total tx bytes %llu", tx_bytes);
62 error_e NetStat::GetWifiTotalRxBytes(void)
64 uint64_t rx_bytes = 0;
65 GVariant *message = NULL;
66 error_e error = ERROR_NONE;
68 message = InvokeMethod(NETCONFIG_SERVICE,
69 NETCONFIG_NETWORK_STATISTICS_PATH,
70 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
71 GET_WIFI_TOTAL_RX_BYTES,
75 if (message == NULL) {
76 GLOGD("Failed to invoke dbus method");
80 g_variant_get(message, "(t)", &rx_bytes);
81 g_variant_unref(message);
83 GLOGD("Succeeded to get wifi total rx bytes %llu", rx_bytes);
88 error_e NetStat::GetWifiLastTxBytes(void)
90 uint64_t tx_bytes = 0;
91 GVariant *message = NULL;
92 error_e error = ERROR_NONE;
94 message = InvokeMethod(NETCONFIG_SERVICE,
95 NETCONFIG_NETWORK_STATISTICS_PATH,
96 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
97 GET_WIFI_LAST_TX_BYTES,
101 if (message == NULL) {
102 GLOGD("Failed to invoke dbus method");
106 g_variant_get(message, "(t)", &tx_bytes);
107 g_variant_unref(message);
109 GLOGD("Succeeded to get wifi last tx bytes %llu", tx_bytes);
114 error_e NetStat::GetWifiLastRxBytes(void)
116 uint64_t rx_bytes = 0;
117 GVariant *message = NULL;
118 error_e error = ERROR_NONE;
120 message = InvokeMethod(NETCONFIG_SERVICE,
121 NETCONFIG_NETWORK_STATISTICS_PATH,
122 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
123 GET_WIFI_LAST_RX_BYTES,
127 if (message == NULL) {
128 GLOGD("Failed to invoke dbus method");
132 g_variant_get(message, "(t)", &rx_bytes);
133 g_variant_unref(message);
135 GLOGD("Succeeded to get wifi last rx bytes %llu", rx_bytes);
140 error_e NetStat::ResetCellularTotalTxBytes(void)
142 GVariant *message = NULL;
143 error_e error = ERROR_NONE;
145 message = InvokeMethod(NETCONFIG_SERVICE,
146 NETCONFIG_NETWORK_STATISTICS_PATH,
147 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
148 RESET_CELLULAR_TOTAL_TX_BYTES,
152 if (message == NULL) {
153 GLOGD("Failed to invoke dbus method");
157 g_variant_unref(message);
162 error_e NetStat::ResetCellularTotalRxBytes(void)
164 GVariant *message = NULL;
165 error_e error = ERROR_NONE;
167 message = InvokeMethod(NETCONFIG_SERVICE,
168 NETCONFIG_NETWORK_STATISTICS_PATH,
169 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
170 RESET_CELLULAR_TOTAL_RX_BYTES,
174 if (message == NULL) {
175 GLOGD("Failed to invoke dbus method");
179 g_variant_unref(message);
184 error_e NetStat::ResetCellularLastTxBytes(void)
186 GVariant *message = NULL;
187 error_e error = ERROR_NONE;
189 message = InvokeMethod(NETCONFIG_SERVICE,
190 NETCONFIG_NETWORK_STATISTICS_PATH,
191 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
192 RESET_CELLULAR_LAST_TX_BYTES,
196 if (message == NULL) {
197 GLOGD("Failed to invoke dbus method");
201 g_variant_unref(message);
206 error_e NetStat::ResetCellularLastRxBytes(void)
208 GVariant *message = NULL;
209 error_e error = ERROR_NONE;
211 message = InvokeMethod(NETCONFIG_SERVICE,
212 NETCONFIG_NETWORK_STATISTICS_PATH,
213 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
214 RESET_CELLULAR_LAST_RX_BYTES,
218 if (message == NULL) {
219 GLOGD("Failed to invoke dbus method");
223 g_variant_unref(message);
228 error_e NetStat::ResetWifiLastTxBytes(void)
230 GVariant *message = NULL;
231 error_e error = ERROR_NONE;
233 message = InvokeMethod(NETCONFIG_SERVICE,
234 NETCONFIG_NETWORK_STATISTICS_PATH,
235 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
236 RESET_WIFI_LAST_TX_BYTES,
240 if (message == NULL) {
241 GLOGD("Failed to invoke dbus method");
245 g_variant_unref(message);
250 error_e NetStat::ResetWifiLastRxBytes(void)
252 GVariant *message = NULL;
253 error_e error = ERROR_NONE;
255 message = InvokeMethod(NETCONFIG_SERVICE,
256 NETCONFIG_NETWORK_STATISTICS_PATH,
257 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
258 RESET_WIFI_LAST_RX_BYTES,
262 if (message == NULL) {
263 GLOGD("Failed to invoke dbus method");
267 g_variant_unref(message);
272 error_e NetStat::ResetWifiTotalTxBytes(void)
274 GVariant *message = NULL;
275 error_e error = ERROR_NONE;
277 message = InvokeMethod(NETCONFIG_SERVICE,
278 NETCONFIG_NETWORK_STATISTICS_PATH,
279 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
280 RESET_WIFI_TOTAL_TX_BYTES,
284 if (message == NULL) {
285 GLOGD("Failed to invoke dbus method");
289 g_variant_unref(message);
294 error_e NetStat::ResetWifiTotalRxBytes(void)
296 GVariant *message = NULL;
297 error_e error = ERROR_NONE;
299 message = InvokeMethod(NETCONFIG_SERVICE,
300 NETCONFIG_NETWORK_STATISTICS_PATH,
301 NETCONFIG_NETWORK_STATISTICS_INTERFACE,
302 RESET_WIFI_TOTAL_RX_BYTES,
306 if (message == NULL) {
307 GLOGD("Failed to invoke dbus method");
311 g_variant_unref(message);