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

Commit 7ccd6571 authored by Thomas Girardier's avatar Thomas Girardier Committed by Android (Google) Code Review
Browse files

Merge changes If2ab94f8,Id3dd6add,Icc142685,Icac3c80b into tm-qpr-dev

* changes:
  [PTS-Bot]: Added 7 OPP/SR test cases
  [PTS-Bot]: Removed rebootBluetooth call from factoryReset function in Host
  Add PTS-Bot GATT tests
  [PTS-Bot]: Added 9 MAP test cases
parents 0033203a 89ca0a33
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ from mmi2grpc.hid import HIDProxy
from mmi2grpc.hogp import HOGPProxy
from mmi2grpc.l2cap import L2CAPProxy
from mmi2grpc.map import MAPProxy
from mmi2grpc.opp import OPPProxy
from mmi2grpc.pbap import PBAPProxy
from mmi2grpc.rfcomm import RFCOMMProxy
from mmi2grpc.sdp import SDPProxy
@@ -80,6 +81,7 @@ class IUT:
        self._hogp = None
        self._l2cap = None
        self._map = None
        self._opp = None
        self._pbap = None
        self._rfcomm = None
        self._sdp = None
@@ -113,6 +115,7 @@ class IUT:
        self._hid = None
        self._hogp = None
        self._map = None
        self._opp = None
        self._pbap = None
        self._rfcomm = None
        self._sdp = None
@@ -232,6 +235,11 @@ class IUT:
            if not self._map:
                self._map = MAPProxy(grpc.insecure_channel(f"localhost:{self.pandora_server_port}"))
            return self._map.interact(test, interaction, description, pts_address)
        # Handles OPP MMIs.
        if profile in ("OPP"):
            if not self._opp:
                self._opp = OPPProxy(grpc.insecure_channel(f"localhost:{self.pandora_server_port}"))
            return self._opp.interact(test, interaction, description, pts_address)
        # Instantiates PBAP proxy and reroutes corresponding MMIs to it.
        if profile in ("PBAP"):
            if not self._pbap:
+55 −3
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

import re
import sys
from threading import Thread

from mmi2grpc._helpers import assert_description
from mmi2grpc._proxy import ProfileProxy
@@ -440,8 +441,25 @@ class GATTProxy(ProfileProxy):

        assert self.connection is not None
        handle = stringHandleToInt(re.findall("'([a0-Z9]*)'O", description)[0])
        def read():
            nonlocal handle
            self.read_response = self.gatt.ReadCharacteristicFromHandle(\
                    connection=self.connection, handle=handle)
        worker = Thread(target=read)
        worker.start()
        worker.join(timeout=30)
        return "OK"

    @assert_description
    def MMI_IUT_READ_TIMEOUT(self, **kwargs):
        """
        Please wait for 30 seconds timeout to abort the procedure.

        Description:
        Verify that the Implementation Under Test (IUT) can handle timeout after
        send Read characteristic without receiving response in 30 seconds.
        """

        return "OK"

    @assert_description
@@ -714,8 +732,26 @@ class GATTProxy(ProfileProxy):
        matches = re.findall("'([a0-Z9]*)'O with <= '([a0-Z9]*)'", description)
        handle = stringHandleToInt(matches[0][0])
        data = bytes([1]) * int(matches[0][1])
        def write():
            nonlocal handle
            nonlocal data
            self.write_response = self.gatt.WriteAttFromHandle(connection=self.connection,\
                handle=handle, value=data)
        worker = Thread(target=write)
        worker.start()
        worker.join(timeout=30)
        return "OK"

    @assert_description
    def MMI_IUT_WRITE_TIMEOUT(self, **kwargs):
        """
        Please wait for 30 second timeout to abort the procedure.

        Description:
        Verify that the Implementation Under Test (IUT) can handle timeout after
        send Write characteristic without receiving response in 30 seconds.
        """

        return "OK"

    @assert_description
@@ -765,6 +801,22 @@ class GATTProxy(ProfileProxy):
                handle=handle, value=data)
        return "OK"

    def _mmi_150(self, description: str, **kwargs):
        """
        Please send an ATT_Write_Request to Client Support Features handle =
        'XXXX'O to enable Multiple Handle Value Notifications.

        Discover all
        characteristics if needed.
        """

        assert self.connection is not None
        handle = stringHandleToInt(re.findall("'([a0-Z9]*)'O", description)[0])
        data = bytes([4]) # Multiple Handle Value Notifications
        self.write_response = self.gatt.WriteAttFromHandle(connection=self.connection,\
                handle=handle, value=data)
        return "OK"

    def MMI_IUT_SEND_PREPARE_WRITE_GREATER_OFFSET(self, description: str, **kwargs):
        """
        Please send prepare write request with handle = 'XXXX'O and offset
+19 −4
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class MAPProxy(ProfileProxy):
        self._android = Android(channel)

        self.connection = None
        self._init_send_sms()

    @assert_description
    def TSC_MMI_iut_connectable(self, **kwargs):
@@ -60,11 +61,16 @@ class MAPProxy(ProfileProxy):
        return "OK"

    @assert_description
    def TSC_OBEX_MMI_iut_accept_connect(self, pts_addr: bytes, **kwargs):
    def TSC_OBEX_MMI_iut_accept_connect(self, test: str, pts_addr: bytes, **kwargs):
        """
        Please accept the OBEX CONNECT REQ.
        """

        if test in {"MAP/MSE/GOEP/BC/BV-01-I", "MAP/MSE/GOEP/BC/BV-03-I", "MAP/MSE/MMN/BV-02-I"}:
            if self.connection is None:
                self._android.SetAccessPermission(address=pts_addr, access_type=AccessType.ACCESS_MESSAGE)
                self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"

    @assert_description
@@ -155,6 +161,9 @@ class MAPProxy(ProfileProxy):
        """
        Send Set Event Report with New GSM Message.
        """

        self._android.SendSMS()

        return "OK"

    @assert_description
@@ -171,3 +180,9 @@ class MAPProxy(ProfileProxy):
        """

        return "OK"

    def _init_send_sms(self):

        min_sms_count = 2  # Few test cases requires minimum 2 sms to pass
        for index in range(min_sms_count):
            self._android.SendSMS()
+118 −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.
"""OPP proxy module."""

from typing import Optional

from mmi2grpc._helpers import assert_description
from mmi2grpc._proxy import ProfileProxy

from pandora_experimental.host_grpc import Host
from pandora_experimental.host_pb2 import Connection
from pandora_experimental._android_grpc import Android
from pandora_experimental._android_pb2 import AccessType


class OPPProxy(ProfileProxy):
    """OPP proxy.

    Implements OPP PTS MMIs.
    """
    connection: Optional[Connection] = None

    def __init__(self, channel):
        super().__init__(channel)

        self.host = Host(channel)
        self._android = Android(channel)

        self.connection = None

    @assert_description
    def TSC_OBEX_MMI_iut_accept_connect_OPP(self, pts_addr: bytes, **kwargs):
        """
        Please accept the OBEX CONNECT REQ command for OPP.
        """
        if self.connection is None:
            self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"

    @assert_description
    def TSC_OPP_mmi_user_action_remove_object(self, **kwargs):
        """
        If necessary take action to remove any file(s) named 'BC_BV01.bmp' from
        the IUT.  

        Press 'OK' to confirm that the file is not present on the
        IUT.
        """

        return "OK"

    @assert_description
    def TSC_OBEX_MMI_iut_accept_put(self, **kwargs):
        """
         Please accept the PUT REQUEST.
        """
        self._android.AcceptIncomingFile()

        return "OK"

    @assert_description
    def TSC_OPP_mmi_user_verify_does_object_exist(self, **kwargs):
        """
        Does the IUT now contain the following files?

        BC_BV01.bmp

        Note: If
        TSPX_supported_extension is not .bmp, the file content of the file will
        not be formatted for the TSPX_supported extension, this is normal.
        """

        return "OK"

    @assert_description
    def TSC_OBEX_MMI_iut_accept_slc_connect_l2cap(self, pts_addr: bytes, **kwargs):
        """
        Please accept the l2cap channel connection for an OBEX connection.
        """
        self.connection = self.host.WaitConnection(address=pts_addr).connection

        return "OK"

    @assert_description
    def TSC_OBEX_MMI_iut_reject_action(self, **kwargs):
        """
         Take action to reject the ACTION command sent by PTS.
        """

        return "OK"

    @assert_description
    def TSC_OBEX_MMI_iut_accept_disconnect(self, **kwargs):
        """
         Please accept the OBEX DISCONNECT REQ command.
        """

        return "OK"

    @assert_description
    def TSC_OBEX_MMI_iut_accept_slc_disconnect(self, **kwargs):
        """
         Please accept the disconnection of the transport channel.
        """

        return "OK"
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ java_library_static {
    static_libs: [
        "androidx.test.runner",
        "androidx.test.core",
        "androidx.test.uiautomator_uiautomator",
        "grpc-java-netty-shaded-test",
        "grpc-java-lite",
        "guava",
Loading