diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 27 | ||||
-rw-r--r-- | test/afb-test/CMakeLists.txt | 22 | ||||
-rw-r--r-- | test/afb-test/etc/CMakeLists.txt | 31 | ||||
-rw-r--r-- | test/afb-test/etc/aft-agl-ahl-4a-config.json | 66 | ||||
-rw-r--r-- | test/afb-test/fixtures/4a-hal-manager.lua | 21 | ||||
-rw-r--r-- | test/afb-test/fixtures/4a-hal-rcar-m3kf.lua | 76 | ||||
-rw-r--r-- | test/afb-test/fixtures/CMakeLists.txt | 30 | ||||
-rw-r--r-- | test/afb-test/tests/CMakeLists.txt | 31 | ||||
-rw-r--r-- | test/afb-test/tests/ahl-4a_BasicAPITest.lua | 83 |
9 files changed, 387 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..f0aa472 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,27 @@ +########################################################################### +# Copyright 2015 - 2018 IoT.bzh +# +# author:Frédéric Marec <frederic.marec@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) + +ADD_TEST(NAME AHL-4A_TESTS + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND afm-test ${CMAKE_BINARY_DIR}/package ${CMAKE_BINARY_DIR}/package-test +)
\ No newline at end of file diff --git a/test/afb-test/CMakeLists.txt b/test/afb-test/CMakeLists.txt new file mode 100644 index 0000000..9df744e --- /dev/null +++ b/test/afb-test/CMakeLists.txt @@ -0,0 +1,22 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec <frederic.marec@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
\ No newline at end of file diff --git a/test/afb-test/etc/CMakeLists.txt b/test/afb-test/etc/CMakeLists.txt new file mode 100644 index 0000000..8645d9f --- /dev/null +++ b/test/afb-test/etc/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec <frederic.marec@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +################################################## +# Audio 4A test configuration files +################################################## +PROJECT_TARGET_ADD(afb-test-config) + + file(GLOB CONF_FILES "*.json") + + add_input_files("${CONF_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-CONFIG" + OUTPUT_NAME ${TARGET_NAME} + )
\ No newline at end of file diff --git a/test/afb-test/etc/aft-agl-ahl-4a-config.json b/test/afb-test/etc/aft-agl-ahl-4a-config.json new file mode 100644 index 0000000..f97348b --- /dev/null +++ b/test/afb-test/etc/aft-agl-ahl-4a-config.json @@ -0,0 +1,66 @@ +{ + "id": "http://iot.bzh/download/public/schema/json/ctl-schema.json#", + "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json#", + "metadata": { + "uid": "Test", + "version": "1.0", + "api": "aft-ahl-4a", + "info": "AFB-test binding configuration file to test 4a High level api.", + "require": [ + "ahl-4a" + ] + }, + "testVerb": { + "uid": "launch_all_tests", + "info": "Launch all the tests", + "action": "lua://AFT#_launch_test", + "args": { + "trace": "ahl-4a", + "files": ["ahl-4a_BasicAPITest.lua"] + } + }, + "mapis": [{ + "uid": "4a-hal-manager", + "info": "Faked 4a-hal-manager API", + "libs": "4a-hal-manager.lua", + "verbs": [ + { + "uid": "loaded", + "info": "loaded to signals events", + "action": "lua://4a-hal-manager#_loaded" + } + ] + }, + { + "uid": "4a-hal-rcar-m3kf", + "info": "Faked 4a-hal-rcar-m3kf API", + "libs": "4a-hal-rcar-m3kf.lua", + "verbs": [ + { + "uid": "info", + "info": "info to signals events", + "action": "lua://4a-hal-rcar-m3kf#_info" + }, + { + "uid": "multimedia", + "info": "multimedia to signals events", + "action": "lua://4a-hal-rcar-m3kf#_multimedia" + }, + { + "uid": "emergency", + "info": "emergency to signals events", + "action": "lua://4a-hal-rcar-m3kf#_emergency" + }, + { + "uid": "radio_stream", + "info": "radio to signals events", + "action": "lua://4a-hal-rcar-m3kf#_radio" + }, + { + "uid": "navigation", + "info": "navigation to signals events", + "action": "lua://4a-hal-rcar-m3kf#_navigation" + } + ] + }] +}
\ No newline at end of file diff --git a/test/afb-test/fixtures/4a-hal-manager.lua b/test/afb-test/fixtures/4a-hal-manager.lua new file mode 100644 index 0000000..fcf5d20 --- /dev/null +++ b/test/afb-test/fixtures/4a-hal-manager.lua @@ -0,0 +1,21 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Frédéric Marec <frederic.marec@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--]] + + +function _loaded (request) + AFB:success(request, {"4a-hal-rcar-m3kf"}) + end
\ No newline at end of file diff --git a/test/afb-test/fixtures/4a-hal-rcar-m3kf.lua b/test/afb-test/fixtures/4a-hal-rcar-m3kf.lua new file mode 100644 index 0000000..8747c4d --- /dev/null +++ b/test/afb-test/fixtures/4a-hal-rcar-m3kf.lua @@ -0,0 +1,76 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Frédéric Marec <frederic.marec@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--]] + +function _info(request) + AFB:success(request, + {streams= { + { + name= "multimedia", + cardId = "hw:0,0,0" + }, + { + name = "emergency", + cardId = "hw:0,1,0" + }, + { + name = "navigation", + cardId = "hw:0,1,1" + }, + { + name = "radio_stream", + cardId = "hw:1,0,0" + }, + { + name = "radio_stream", + cardId = "hw:1,0,0" + } + } + } +) +end + +function _multimedia(request, args, json_object) + if json_object["volume"] then AFB:success(request, json_object["volume"]) + elseif json_object["mute"] then AFB:success(request, true) + elseif not json_object["mute"] then AFB:success(request, true) + else AFB:fail(request, false) + end +end + +function _emergency(request, args, json_object) + if json_object["volume"] then AFB:success(request, json_object["volume"]) + elseif json_object["mute"] then AFB:success(request, true) + elseif not json_object["mute"] then AFB:success(request, true) + else AFB:fail(request, false) + end +end + +function _radio(request, args, json_object) + if json_object["volume"] then AFB:error(request, "Test error") + elseif json_object["mute"] then AFB:error(request, "Test error") + elseif not json_object["mute"] then AFB:error(request, "Test error") + else AFB:error(request, false) + end +end + +function _navigation(request, args, json_object) + if json_object["volume"] then AFB:error(request, "Test error") + elseif json_object["mute"] then AFB:error(request, "Test error") + elseif not json_object["mute"] then AFB:error(request, "Test error") + else AFB:error(request, false) + end +end
\ No newline at end of file diff --git a/test/afb-test/fixtures/CMakeLists.txt b/test/afb-test/fixtures/CMakeLists.txt new file mode 100644 index 0000000..8b33784 --- /dev/null +++ b/test/afb-test/fixtures/CMakeLists.txt @@ -0,0 +1,30 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec <frederic.marec@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +################################################## +# Audio 4A test configuration files +################################################## +PROJECT_TARGET_ADD(data-files) + + file(GLOB DATA_FILES "*.lua" ) + add_input_files("${DATA_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-DATA" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/test/afb-test/tests/CMakeLists.txt b/test/afb-test/tests/CMakeLists.txt new file mode 100644 index 0000000..583e9ff --- /dev/null +++ b/test/afb-test/tests/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2018 IoT.bzh +# +# author:Frédéric Marec <frederic.marec@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + + +################################################## +# Audio 4A Lua Scripts +################################################## +PROJECT_TARGET_ADD(test-files) + + file(GLOB LUA_FILES "*.lua") + add_input_files("${LUA_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "TEST-DATA" + OUTPUT_NAME ${TARGET_NAME} + )
\ No newline at end of file diff --git a/test/afb-test/tests/ahl-4a_BasicAPITest.lua b/test/afb-test/tests/ahl-4a_BasicAPITest.lua new file mode 100644 index 0000000..ba1dbe9 --- /dev/null +++ b/test/afb-test/tests/ahl-4a_BasicAPITest.lua @@ -0,0 +1,83 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Frédéric Marec <frederic.marec@iot.bzh> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +local testPrefix ="ahl_BasicAPITest_" +local roles = {"multimedia", "emergency", "navigation", "radio"} + +-- This tests the 'get_roles' verb of the 4a-hal-mutimedia API +_AFT.testVerbStatusSuccess(testPrefix.."get_roles","ahl-4a", "get_roles", {verbose = true}, nil, nil) + +for _, role in pairs(roles) +do + + -- This tests the 'open' verb of the 4a-hal-mutimedia API + _AFT.testVerbStatusSuccess(testPrefix.."open_"..role,"ahl-4a", role, {action = "open"}, nil, + function() + _AFT.callVerb("ahl-4a", role, {action = "close"}) + end + ) + + -- This tests the 'volume' verb of the 4a-hal-mutimedia API + _AFT.describe(testPrefix.."volume_"..role, function() + _AFT.callVerb("ahl-4a", role, {action = "open"}) + + _AFT.callVerb("ahl-4a", role, {action = "volume", value = 80}) + _AFT.callVerb("ahl-4a", role, {action = "volume", value = 60}) + _AFT.callVerb("ahl-4a", role, {action = "volume", value = 40}) + _AFT.callVerb("ahl-4a", role, {action = "volume", value = 20}) + _AFT.callVerb("ahl-4a", role, {action = "volume", value = 0}) + _AFT.callVerb("ahl-4a", role, {action = "volume", value = 100}) + + _AFT.callVerb("ahl-4a", role, {action = "close"}) + end, + nil, nil) + + -- This tests the 'mute' and 'unmute' verb of the 4a-hal-mutimedia API + _AFT.describe(testPrefix.."mute-unmute_"..role, function() + _AFT.callVerb("ahl-4a", role, {action = "open"}) + + _AFT.callVerb("ahl-4a", role, {action = "mute"}) + _AFT.callVerb("ahl-4a", role, {action = "unmute"}) + _AFT.callVerb("ahl-4a", role, {action = "mute"}) + _AFT.callVerb("ahl-4a", role, {action = "unmute"}) + _AFT.callVerb("ahl-4a", role, {action = "unmute"}) + _AFT.callVerb("ahl-4a", role, {action = "mute"}) + _AFT.callVerb("ahl-4a", role, {action = "mute"}) + _AFT.callVerb("ahl-4a", role, {action = "unmute"}) + + _AFT.callVerb("ahl-4a", role, {action = "close"}) + end, + nil, nil) + + -- This tests the 'close' verb of the 4a-hal-mutimedia API + _AFT.testVerbStatusSuccess(testPrefix.."close_"..role,"ahl-4a", role, {action = "close"}, + function() + _AFT.callVerb("ahl-4a", role, {action = "open"}) + end + , nil) + + _AFT.testVerbStatusError(testPrefix.."unknown_action_"..role,"ahl-4a", role, {action = "test_fail_unknown_action"}, nil , nil) + + -- This tests the 'open' verb of the 4a-hal-mutimedia API + _AFT.testVerbStatusSuccess(testPrefix.."open_"..role,"ahl-4a", role, {action = "open"}, nil, nil) + +end + +_AFT.exitAtEnd() |