1#!/usr/bin/env python3 2# Copyright (C) 2019 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); you may not 5# use this file except in compliance with the License. You may obtain a copy of 6# the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13# License for the specific language governing permissions and limitations under 14# the License. 15 16"""A stub implementation of a DUT interface. 17 18This a stub interface which allows automated test to run 19without automating the hardware. This here for two reasons, first 20as an example of how to write a dut implementation, and second as 21an implementation that can be used to test case without writing 22out the full implementation. 23""" 24 25import logging 26 27class BluethoothDevice: 28 """The api interface used in the test for the stub. 29 30 This is interface which defines all the functions that can be 31 called by the bt test suite. 32 """ 33 34 def __init__(self, config): 35 print('Init Stub with ', config) 36 logging.info('Init Stub with '+str(config)) 37 38 def answer_phone(self): 39 input('Answer the phone and then press enter\n') 40 41 def hang_up(self): 42 input('Hang up the phone and then press enter\n') 43 44 def toggle_pause(self): 45 input('Press pause on device then press enter\n') 46 47 def volume(self, direction): 48 """Adjust the volume specified by the value of direction. 49 50 Args: 51 direction: A string that is either UP or DOWN 52 that indicates which way to adjust the volume. 53 """ 54 55 return input('move volume '+direction+' and then press enter\n') 56 57 def connect(self, android): 58 input('Connect device and press enter\n') 59 60 def is_bt_connected(self): 61 con = input('Is device connected? y/n').lower() 62 while con not in ['y', 'n']: 63 con = input('Is device connected? y/n').lower() 64 return con == 'y' 65 66 def close(self): 67 """This where the hardware is released. 68 """ 69 print('Close Stub') 70 logging.info('Close Stub') 71 72