Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52d84167 authored by Martin Brabham's avatar Martin Brabham
Browse files

Topshim Tests: Add a central function for perfoming async functions.

Make it simpler to type out tests.

Bug: 234756905
Test: system/gd/cert/run --clean --topshim
Change-Id: I619c6f7e7d17b7556fa4dd3d5db99fbcbe3166d9
parent 815a4338
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class AdapterTest(TopshimBaseTest):
        print("Adapter is verified when test starts")

    def test_enable_page_scan(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_enable_page_scan())
        self.post(self.__verify_enable_page_scan())


if __name__ == "__main__":
+3 −0
Original line number Diff line number Diff line
@@ -181,6 +181,9 @@ class TopshimBaseTest(base_test.BaseTestClass):
        await self.cert_adapter.terminate()
        await self.cert_gatt.terminate()

    def post(self, async_fn):
        asyncio.get_event_loop().run_until_complete(async_fn)

    def setup_class(self):
        """
        Configure rootcanal and setup test parameters
+14 −16
Original line number Diff line number Diff line
@@ -14,8 +14,6 @@
#   See the License for the specific language governing permissions and
#   limitations under the License.

import asyncio

from blueberry.tests.gd.cert.truth import assertThat
from blueberry.tests.topshim.lib.topshim_base_test import TopshimBaseTest
from blueberry.tests.topshim.lib.adapter_client import AdapterClient
@@ -70,34 +68,34 @@ class SuspendTest(TopshimBaseTest):
        return await self.dut_adapter.le_rand()

    def test_no_wake_suspend(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_suspend())
        self.post(self.__verify_no_wake_suspend())

    def test_no_wake_resume(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_resume())
        self.post(self.__verify_no_wake_resume())

    def test_no_wake_suspend_then_resume(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_suspend())
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_resume())
        self.post(self.__verify_no_wake_suspend())
        self.post(self.__verify_no_wake_resume())

    def test_no_wake_suspend_then_resume_then_suspend(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_suspend())
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_resume())
        asyncio.get_event_loop().run_until_complete(self.__verify_no_wake_suspend())
        self.post(self.__verify_no_wake_suspend())
        self.post(self.__verify_no_wake_resume())
        self.post(self.__verify_no_wake_suspend())

    def test_wakeful_suspend_no_a2dp(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_suspend(False))
        self.post(self.__verify_wakeful_suspend(False))

    def test_wakeful_resume_no_a2dp(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_resume(False))
        self.post(self.__verify_wakeful_resume(False))

    def test_wakeful_suspend_then_resume_no_a2dp(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_suspend(False))
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_resume(False))
        self.post(self.__verify_wakeful_suspend(False))
        self.post(self.__verify_wakeful_resume(False))

    def test_wakeful_suspend_then_resume_then_suspend_no_a2dp(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_suspend(False))
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_resume(False))
        asyncio.get_event_loop().run_until_complete(self.__verify_wakeful_suspend(False))
        self.post(self.__verify_wakeful_suspend(False))
        self.post(self.__verify_wakeful_resume(False))
        self.post(self.__verify_wakeful_suspend(False))


if __name__ == "__main__":
+1 −3
Original line number Diff line number Diff line
@@ -14,8 +14,6 @@
#   See the License for the specific language governing permissions and
#   limitations under the License.

import asyncio

from blueberry.tests.gd.cert.truth import assertThat
from blueberry.tests.topshim.lib.topshim_base_test import TopshimBaseTest
from blueberry.tests.topshim.lib.adapter_client import AdapterClient
@@ -32,7 +30,7 @@ class SecurityTest(TopshimBaseTest):
        return await self.dut_adapter.le_rand()

    def test_remove_bond_with_no_bonded_devices(self):
        asyncio.get_event_loop().run_until_complete(self.__test_remove_bond(self.DEFAULT_ADDRESS))
        self.post(self.__test_remove_bond(self.DEFAULT_ADDRESS))


if __name__ == "__main__":