Add test cases for removing rule post warn and restriction limit are crossed 32/237732/2 submit/tizen/20200708.235825 submit/tizen/20200709.001505
authorNishant Chaprana <n.chaprana@samsung.com>
Fri, 3 Jul 2020 05:51:46 +0000 (11:21 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 7 Jul 2020 07:28:32 +0000 (12:58 +0530)
Change-Id: I47486ce363fb157b77824dd140052262c1b43495
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/stc-manager.spec
unittest/unittest.cpp

index cff6b78..0690fde 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.1.3
+Version:    0.1.4
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index 8b467f7..41d57c4 100644 (file)
@@ -328,6 +328,84 @@ TEST(StcManager_Statistics, Reset_p)
        EXPECT_EQ(ERROR_NONE, ret);
 }
 
+TEST(StcManager_Restriction, RemoveRulePostWarnLimitCrossed_p)
+{
+       error_e ret = ERROR_NONE;
+       int sys_ret;
+       Restriction rest;
+
+       ret = rest.SetRule("TOTAL_WIFI",
+               "wlan0",
+               NULL,
+               IFACE_WIFI,
+               -1,
+               1,
+               ROAMING_UNKNOWN,
+               GTEST_MAC);
+       EXPECT_EQ(ERROR_NONE, ret);
+
+       ret = rest.SetRstriction();
+       EXPECT_EQ(ERROR_NONE, ret);
+
+       sys_ret = system("toybox ping -c 5 www.tizen.org");
+       EXPECT_EQ(0, sys_ret);
+
+       ret = rest.UnsetRstriction();
+       EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(StcManager_Restriction, RemoveRulePostRestrictionLimitCrossed_p)
+{
+       error_e ret = ERROR_NONE;
+       int sys_ret;
+       Restriction rest;
+
+       ret = rest.SetRule("TOTAL_WIFI",
+               "wlan0",
+               NULL,
+               IFACE_WIFI,
+               2,
+               -1,
+               ROAMING_UNKNOWN,
+               GTEST_MAC);
+       EXPECT_EQ(ERROR_NONE, ret);
+
+       ret = rest.SetRstriction();
+       EXPECT_EQ(ERROR_NONE, ret);
+
+       sys_ret = system("toybox ping -c 5 www.tizen.org");
+       EXPECT_NE(0, sys_ret);
+
+       ret = rest.UnsetRstriction();
+       EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(StcManager_Restriction, RemoveRulePostBothLimitCrossed_p)
+{
+       error_e ret = ERROR_NONE;
+       int sys_ret;
+       Restriction rest;
+
+       ret = rest.SetRule("TOTAL_WIFI",
+               "wlan0",
+               NULL,
+               IFACE_WIFI,
+               2,
+               1,
+               ROAMING_UNKNOWN,
+               GTEST_MAC);
+       EXPECT_EQ(ERROR_NONE, ret);
+
+       ret = rest.SetRstriction();
+       EXPECT_EQ(ERROR_NONE, ret);
+
+       sys_ret = system("toybox ping -c 5 www.tizen.org");
+       EXPECT_NE(0, sys_ret);
+
+       ret = rest.UnsetRstriction();
+       EXPECT_EQ(ERROR_NONE, ret);
+}
+
 TEST(StcManager_Firewall, Lock_p)
 {
        error_e ret = ERROR_NONE;