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

Commit 4759dbe1 authored by Martin Brabham's avatar Martin Brabham
Browse files

Topshim: Suspend and Resume API exercise tests.

Bug: 228986014
Bug: 228986016
Bug: 228987980
Bug: 218497037
Bug: 220182854
Test: system/gd/cert/run --clean --topshim SuspendTest
Tag: #floss
Change-Id: I82c320ca0a0841dfa322894eeef70a6cf291669d
parent 042c8b1c
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
#
#   Copyright 2022 - The Android Open Source Project
#
#   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.

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

from mobly import test_runner


class SuspendTest(TopshimBaseTest):

    async def __verify_disconnected_suspend(self):
        # Start suspend work
        await self.dut_adapter.clear_event_filter()
        await self.dut_adapter.clear_event_mask()
        await self.dut_adapter.clear_filter_accept_list()
        # TODO(optedoblivion): Find a better way to disconnect active ACLs
        # await self.dut_adapter.disconnect_all_acls()
        random = await self.dut_adapter.le_rand()
        return random

    async def __verify_disconnected_resume(self):
        # Start resume work
        await self.dut_adapter.set_event_filter_inquiry_result_all_devices()
        await self.dut_adapter.set_default_event_mask()
        await self.dut_adapter.restore_filter_accept_list()
        random = await self.dut_adapter.le_rand()
        return random

    def test_disconnected_suspend(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_suspend())

    def test_disconnected_resume(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_resume())

    def test_disconnected_suspend_then_resume(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_suspend())
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_resume())

    def test_disconnected_suspend_then_resume_then_suspend(self):
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_suspend())
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_resume())
        asyncio.get_event_loop().run_until_complete(self.__verify_disconnected_suspend())
+8 −25
Original line number Diff line number Diff line
@@ -15,11 +15,12 @@
#   limitations under the License.

from blueberry.tests.topshim.adapter.adapter_test import AdapterTest
from blueberry.tests.topshim.power.suspend_test import SuspendTest

from mobly import suite_runner
import argparse

ALL_TESTS = [AdapterTest]
ALL_TESTS = [AdapterTest, SuspendTest]


def main():
@@ -27,14 +28,9 @@ def main():
    Local test runner that allows  to specify list of tests to and customize
    test config file location
    """
    parser = argparse.ArgumentParser(
        description="Run local Topshim to Topshim tests.")
    parser.add_argument('-c',
                        '--config',
                        type=str,
                        required=True,
                        metavar='<PATH>',
                        help='Path to the test configuration file.')
    parser = argparse.ArgumentParser(description="Run local Topshim to Topshim tests.")
    parser.add_argument(
        '-c', '--config', type=str, required=True, metavar='<PATH>', help='Path to the test configuration file.')
    parser.add_argument(
        '--tests',
        '--test_case',
@@ -42,22 +38,9 @@ def main():
        type=str,
        metavar='[ClassA[.test_a] ClassB[.test_b] ...]',
        help='A list of test classes and optional tests to execute.')
    parser.add_argument("--all_tests",
                        "-A",
                        type=bool,
                        dest="all_tests",
                        default=False,
                        nargs="?")
    parser.add_argument("--presubmit",
                        type=bool,
                        dest="presubmit",
                        default=False,
                        nargs="?")
    parser.add_argument("--postsubmit",
                        type=bool,
                        dest="postsubmit",
                        default=False,
                        nargs="?")
    parser.add_argument("--all_tests", "-A", type=bool, dest="all_tests", default=False, nargs="?")
    parser.add_argument("--presubmit", type=bool, dest="presubmit", default=False, nargs="?")
    parser.add_argument("--postsubmit", type=bool, dest="postsubmit", default=False, nargs="?")
    args = parser.parse_args()
    test_list = ALL_TESTS
    if args.all_tests: