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>
25 #include "restriction.h"
26 #include "statistics.h"
29 using ::testing::InitGoogleTest;
30 using ::testing::Test;
31 using ::testing::TestCase;
33 TEST(StcManager_Statistics, Init_p)
35 error_e ret = ERROR_NONE;
38 ret = stat.InitStatistics();
39 EXPECT_EQ(ERROR_NONE, ret);
42 TEST(StcManager_Statistics, Get_p)
44 error_e ret = ERROR_NONE;
49 from = stat.MakeTime(2000, 1, 1, 1, 1);
52 ret = stat.SetRule("TOTAL_DATACALL",
58 EXPECT_EQ(ERROR_NONE, ret);
60 ret = stat.GetStatistics();
61 EXPECT_EQ(ERROR_NONE, ret);
63 ret = stat.SetRule("TOTAL_WIFI",
69 EXPECT_EQ(ERROR_NONE, ret);
71 ret = stat.GetStatistics();
72 EXPECT_EQ(ERROR_NONE, ret);
75 TEST(StcManager_Statistics, GetAll_p)
77 error_e ret = ERROR_NONE;
82 from = stat.MakeTime(2000, 1, 1, 1, 1);
85 ret = stat.SetRule(NULL,
91 EXPECT_EQ(ERROR_NONE, ret);
93 ret = stat.GetAllStatistics();
94 EXPECT_EQ(ERROR_NONE, ret);
97 TEST(StcManager_Statistics, GetTotal_p)
99 error_e ret = ERROR_NONE;
104 from = stat.MakeTime(2000, 1, 1, 1, 1);
107 ret = stat.SetRule(NULL,
112 TIME_PERIOD_UNKNOWN);
113 EXPECT_EQ(ERROR_NONE, ret);
115 ret = stat.GetTotalStatistics();
116 EXPECT_EQ(ERROR_NONE, ret);
118 ret = stat.SetRule(NULL,
123 TIME_PERIOD_UNKNOWN);
124 EXPECT_EQ(ERROR_NONE, ret);
126 ret = stat.GetTotalStatistics();
127 EXPECT_EQ(ERROR_NONE, ret);
130 TEST(StcManager_Restriction, Set_p)
132 error_e ret = ERROR_NONE;
135 ret = rest.SetRule("Test_tel",
142 EXPECT_EQ(ERROR_NONE, ret);
144 ret = rest.SetRstriction();
145 EXPECT_EQ(ERROR_NONE, ret);
147 ret = rest.SetRule("TOTAL_WIFI",
154 EXPECT_EQ(ERROR_NONE, ret);
156 ret = rest.SetRstriction();
157 EXPECT_EQ(ERROR_NONE, ret);
159 ret = rest.SetRule("Test_eth",
166 EXPECT_EQ(ERROR_NONE, ret);
168 ret = rest.SetRstriction();
169 EXPECT_EQ(ERROR_NONE, ret);
172 TEST(StcManager_Restriction, Exclude_p)
175 error_e ret = ERROR_NONE;
178 ret = rest.SetRule("TOTAL_DATACALL",
185 EXPECT_EQ(ERROR_NONE, ret);
187 ret = rest.ExcludeRstriction();
188 EXPECT_EQ(ERROR_NONE, ret);
191 TEST(StcManager_Restriction, Get_p)
193 error_e ret = ERROR_NONE;
196 ret = rest.SetRule("Test_tel",
203 EXPECT_EQ(ERROR_NONE, ret);
205 ret = rest.GetRstriction();
206 EXPECT_EQ(ERROR_NONE, ret);
208 ret = rest.SetRule("TOTAL_WIFI",
215 EXPECT_EQ(ERROR_NONE, ret);
217 ret = rest.GetRstriction();
218 EXPECT_EQ(ERROR_NONE, ret);
220 ret = rest.SetRule("TOTAL_IPV4",
227 EXPECT_EQ(ERROR_NONE, ret);
229 ret = rest.GetRstriction();
230 EXPECT_EQ(ERROR_NONE, ret);
233 TEST(StcManager_Restriction, GetAll_p)
235 error_e ret = ERROR_NONE;
238 ret = rest.GetAllRstriction();
239 EXPECT_EQ(ERROR_NONE, ret);
242 TEST(StcManager_Restriction, GetRst_p)
244 error_e ret = ERROR_NONE;
246 restriction_status_e status = RESTRICTION_UNKNOWN;
248 ret = rest.SetRule("Test_tel",
255 EXPECT_EQ(ERROR_NONE, ret);
257 ret = rest.GetRstrictionStatus(&status);
258 EXPECT_EQ(ERROR_NONE, ret);
259 EXPECT_LE(RESTRICTION_UNKNOWN, status);
260 EXPECT_GE(RESTRICTION_LAST_ELEM, status);
262 ret = rest.SetRule("Test_eth",
269 EXPECT_EQ(ERROR_NONE, ret);
271 ret = rest.GetRstrictionStatus(&status);
272 EXPECT_EQ(ERROR_NONE, ret);
273 EXPECT_LE(RESTRICTION_UNKNOWN, status);
274 EXPECT_GE(RESTRICTION_LAST_ELEM, status);
277 TEST(StcManager_Restriction, Unset_p)
279 error_e ret = ERROR_NONE;
282 ret = rest.SetRule("Test_tel",
289 EXPECT_EQ(ERROR_NONE, ret);
291 ret = rest.UnsetRstriction();
292 EXPECT_EQ(ERROR_NONE, ret);
294 ret = rest.SetRule("TOTAL_WIFI",
301 EXPECT_EQ(ERROR_NONE, ret);
303 ret = rest.UnsetRstriction();
304 EXPECT_EQ(ERROR_NONE, ret);
306 ret = rest.SetRule("Test_eth",
313 EXPECT_EQ(ERROR_NONE, ret);
315 ret = rest.UnsetRstriction();
316 EXPECT_EQ(ERROR_NONE, ret);
318 ret = rest.SetRule("TOTAL_DATACALL",
325 EXPECT_EQ(ERROR_NONE, ret);
327 ret = rest.UnsetRstriction();
328 EXPECT_EQ(ERROR_NONE, ret);
331 TEST(StcManager_Statistics, Reset_p)
333 error_e ret = ERROR_NONE;
338 from = stat.MakeTime(2000, 1, 1, 1, 1);
341 ret = stat.SetRule("TOTAL_DATACALL",
346 TIME_PERIOD_UNKNOWN);
347 EXPECT_EQ(ERROR_NONE, ret);
349 ret = stat.ResetStatistics();
350 EXPECT_EQ(ERROR_NONE, ret);
352 ret = stat.SetRule(NULL,
357 TIME_PERIOD_UNKNOWN);
358 EXPECT_EQ(ERROR_NONE, ret);
360 ret = stat.ResetStatistics();
361 EXPECT_EQ(ERROR_NONE, ret);
364 TEST(StcManager_Manager, Stop_p)
366 error_e ret = ERROR_NONE;
369 ret = mgr.StopManager();
370 EXPECT_EQ(ERROR_NONE, ret);
373 int main(int argc, char **argv)
375 InitGoogleTest(&argc, argv);
376 return RUN_ALL_TESTS();