appium-android-driver
Version:
Android UiAutomator and Chrome support for Appium
38 lines • 1.57 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mobileBluetooth = mobileBluetooth;
const driver_1 = require("appium/driver");
const lodash_1 = __importDefault(require("lodash"));
const SUPPORTED_ACTIONS = {
ENABLE: 'enable',
DISABLE: 'disable',
UNPAIR_ALL: 'unpairAll',
};
/**
* Performs the requested action on the default bluetooth adapter
*
* @param action The action to perform: 'enable', 'disable', or 'unpairAll'.
* @returns Promise that resolves when the action is completed.
* @throws {Error} If the device under test has no default bluetooth adapter
* or there was a failure while performing the action.
* @throws {errors.InvalidArgumentError} If the action is not one of the supported actions.
*/
async function mobileBluetooth(action) {
switch (action) {
case SUPPORTED_ACTIONS.ENABLE:
await this.settingsApp.setBluetoothState(true);
break;
case SUPPORTED_ACTIONS.DISABLE:
await this.settingsApp.setBluetoothState(false);
break;
case SUPPORTED_ACTIONS.UNPAIR_ALL:
await this.settingsApp.unpairAllBluetoothDevices();
break;
default:
throw new driver_1.errors.InvalidArgumentError(`You must provide a valid 'action' argument. Supported actions are: ${lodash_1.default.values(SUPPORTED_ACTIONS)}`);
}
}
//# sourceMappingURL=bluetooth.js.map