summaryrefslogtreecommitdiffstats
path: root/test/afb-test/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test/afb-test/tests')
-rw-r--r--test/afb-test/tests/low-can_FilterTest01.lua34
1 files changed, 27 insertions, 7 deletions
diff --git a/test/afb-test/tests/low-can_FilterTest01.lua b/test/afb-test/tests/low-can_FilterTest01.lua
index a5744768..888b44d4 100644
--- a/test/afb-test/tests/low-can_FilterTest01.lua
+++ b/test/afb-test/tests/low-can_FilterTest01.lua
@@ -26,12 +26,11 @@ end)
_AFT.describe("Filter_Test_01/Step_1", function()
local api = "low-can"
local evt = "engine.speed"
- local min = 30;
- local max = 100;
_AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data)
_AFT.assertEquals(data.name,evt)
end)
+
_AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { min = 30, max = 100}})
os.execute("./var/replay_launcher.sh ./var/testFilter01filteredOut.canreplay");
_AFT.assertEvtNotReceived(api .. "/" ..evt, 1000000)
@@ -40,17 +39,38 @@ end)
_AFT.describe("Filter_Test_01/Step_2", function()
local api = "low-can"
local evt = "messages.engine.speed"
- local min = 30;
- local max = 100;
_AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data)
- print(data.name .."-vs-" .. evt)
_AFT.assertEquals(data.name,evt)
_AFT.assertIsTrue(data.value > min and data.value < max )
end)
- _AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { min = 30, max = 100}})
+ _AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = {min = 30, max = 100}})
os.execute("./var/replay_launcher.sh ./var/testFilter01pass.canreplay");
_AFT.assertEvtReceived(api .. "/" ..evt, 1000000)
_AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt })
-end) \ No newline at end of file
+end)
+
+_AFT.describe("Filter_Test_01/Step_3", function()
+ local api = "low-can"
+ local evt = "messages.engine.speed"
+
+ _AFT.enableEventHistory() -- You will need this to check for time intervals between two events
+
+ _AFT.addEventToMonitor(api .. "/" ..evt, function(eventname,data,dataH)
+ local first = dataH[1];
+ local second = dataH[2];
+
+ _AFT.assertEquals(first.name,evt)
+ _AFT.assertIsTrue(first.value > 30 and first.value < 100 )
+ _AFT.assertEquals(second.name,evt)
+ _AFT.assertIsTrue(second.value > 30 and second.value < 100 )
+ assertIsTrue(second.timestamp-first.timestamp > 1000000000) --This is in nano-seconds as it fetchs the low-can timestamp from the data field
+ end)
+ _AFT.assertVerbStatusSuccess(api ,"subscribe", { event = evt, filter = { frequency = 1 , min = 30, max = 100}})
+ os.execute("./var/replay_launcher.sh ./var/testFilter01pass.canreplay");
+
+ _AFT.assertEvtGrpReceived({api .. "/" ..evt,api .. "/" ..evt}, 10000000)
+ _AFT.assertVerbStatusSuccess(api,"unsubscribe", { event = evt })
+end)
+