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

Commit 19e462d1 authored by Thomas Girardier's avatar Thomas Girardier Committed by Gerrit Code Review
Browse files

Merge "pandora: Add first basic avatar test"

parents 2292d9d2 c649f011
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
// 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.

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

python_test_host {
    name: "avatar",
    main: "connect.py",
    srcs: [
        "connect.py",
    ],
    libs: [
        "libavatar",
    ],
    required: ["PandoraServer"],
    test_suites: ["general-tests"],
    test_options: {
        unit_test: false,
    },
    data: ["config.yml"],
}
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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.
  -->
<configuration description="Avatar tests.">
    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
        <option name="test-file-name" value="PandoraServer.apk" />
        <option name="install-arg" value="-r" />
        <option name="install-arg" value="-g" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.PythonVirtualenvPreparer">
        <option name="dep-module" value="grpcio" />
        <option name="dep-module" value="pyee" />
        <option name="dep-module" value="ansicolors" />
        <option name="dep-module" value="websockets" />
        <option name="dep-module" value="bitstruct" />
    </target_preparer>
    <test class="com.android.tradefed.testtype.mobly.MoblyBinaryHostTest">
        <option name="mobly-par-file-name" value="avatar" />
        <option name="mobly-config-file-name" value="config.yml" />
        <option name="mobly-test-timeout" value="1800000" />
    </test>
</configuration>
+12 −0
Original line number Diff line number Diff line
---

TestBeds:
- Name: ExampleTest
  Controllers:
    AndroidDevice: '*'
    PandoraDevice:
    - class: AndroidPandoraDevice
      config: '*'
    - class: BumblePandoraDevice
      transport: 'tcp-client:127.0.0.1:7300'
      classic_enabled: true
+50 −0
Original line number Diff line number Diff line
# Copyright 2022 Google LLC
#
# 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
#
#     https://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 logging
import sys
import time

from mobly import test_runner, base_test, asserts
from grpc import RpcError

from avatar.controllers import pandora_device


class ExampleTest(base_test.BaseTestClass):

    def setup_class(self):
        self.pandora_devices = self.register_controller(pandora_device)
        self.dut = self.pandora_devices[0]
        self.ref = self.pandora_devices[1]

    def setup_test(self):
        self.dut.host.Reset()
        # TODO: wait for server
        time.sleep(3)

    def test_classic_connect(self):
        dut_address = self.dut.address
        self.dut.log.info(f'Address: {dut_address}')
        response = self.ref.host.Connect(address=dut_address)
        assert response.WhichOneof("result") == "connection"


if __name__ == '__main__':
    # MoblyBinaryHostTest pass test_runner arguments after a "--"
    # to make it work with rewrite argv to skip the "--"
    index = sys.argv.index('--')
    sys.argv = sys.argv[:1] + sys.argv[index + 1:]
    logging.basicConfig(level=logging.DEBUG)
    test_runner.main()