Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/commonMethods/commonFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,24 @@ export const stopWPEFramework = function() {
stopProcess('WPEFramework')
return true
}

/**
* This function is used to connect with the available Bluetooth devices
* @param address
* @returns {Promise<AxiosResponse<any>>}
*/
export const connectBTDevice = function(address) {
return this.$thunder.api.BluetoothControl.connect(address)
.then(result => result)
.catch(err => err)
}
/**
* This function is used to disconnect with the available Bluetooth devices
* @param address
* @returns {Promise<AxiosResponse<any>>}
*/
export const disconnectBTDevice = function(address) {
return this.$thunder.api.BluetoothControl.disconnect(address)
.then(result => result)
.catch(err => err)
}
3 changes: 2 additions & 1 deletion src/commonMethods/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
monitorPlugin: 'Monitor',
controllerPlugin: 'Controller',
webKitBrowserPlugin: 'WebKitBrowser',
bluetoothControlPlugin: 'BluetoothControl',
webKitImplementation: 'WebKitImplementation',
deviceInfo: 'DeviceInfo',
youTubePlugin: 'Cobalt',
Expand All @@ -19,6 +20,7 @@ export default {
provisioningPlugin: 'Provisioning',
WPEProcess: 'WPEProcess',
remoteControlPlugin: 'RemoteControl',
invalidAddress: 'invalidstring',

//Plugin states
activate: 'activate',
Expand All @@ -29,4 +31,3 @@ export default {
blankUrl: 'about:blank',
host: config.thunder.host,
}

66 changes: 66 additions & 0 deletions src/tests/bluetoothcontrol/BluetoothControl_Connect_001.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { connectBTDevice } from '../../commonMethods/commonFunctions'
import baseTest from './BluetoothControl_Pair_001.test'

let btdevicelist
let deviceStateChangeListener
let scanCompleteListener

export default {
title: 'Bluetooth Control - Connect 001',
description: 'Check the Connect Functionality of Bluetooth Control Module',
setup() {
scanCompleteListener = this.$thunder.api.BluetoothControl.on('scancomplete', () => {
this.$data.write('scancompleted')
})
deviceStateChangeListener = this.$thunder.api.BluetoothControl.on('devicestatechange', data => {
this.$data.write('address', data.address)
this.$data.write('state', data.state)
})
},
teardown() {
scanCompleteListener.dispose()
deviceStateChangeListener.dispose()
},
steps: [
baseTest,
{
description: 'Connect with the device',
sleep: 5,
test() {
//TODO - Prompt the user to select the device that need to be connected
// and input(instead of btdevicelist[0]) that to the 'connectBTDevice'
return connectBTDevice.call(this, btdevicelist[0])
},
validate(res) {
if (res == null) {
return true
} else {
this.$log('Connecting doesnt happen')
return false
}
},
},
{
description: 'Check whether connecting is success',
sleep: 5,
test() {
return new Promise((resolve, reject) => {
let attempts = 0
const interval = setInterval(() => {
attempts++
if (
this.$data.read('address') === btdevicelist[0] && //TODO - btdevicelist[0] need to be replaced with the user input given in previous step
this.$data.read('state') === 'Connected'
) {
clearInterval(interval)
resolve()
} else if (attempts > 10) {
clearInterval(interval)
reject('Connecting does not happen')
}
}, 1000)
})
},
},
],
}
41 changes: 41 additions & 0 deletions src/tests/bluetoothcontrol/BluetoothControl_Connect_002.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
pluginDeactivate,
pluginActivate,
connectBTDevice,
} from '../../commonMethods/commonFunctions'

import constants from '../../commonMethods/constants'

export default {
title: 'Bluetooth Control - Connect 002',
description: 'Check the Connect Functionality with invalid Bluetooth device',
steps: [
{
description: 'Check if Bluetooth Control Plugin is stopped correctly',
test: pluginDeactivate,
params: constants.bluetoothControlPlugin,
assert: 'deactivated',
},
{
description: 'Check if Bluetooth Control Plugin is started correctly',
test: pluginActivate,
params: constants.bluetoothControlPlugin,
assert: 'activated',
},
{
description: 'Connect with the device',
sleep: 5,
test() {
return connectBTDevice.call(this, constants.invalidAddress)
},
validate(res) {
if (res.code === 22 && res.message === 'ERROR_UNKNOWN_KEY') {
return true
} else {
this.$log('Proper error message is not shown')
return false
}
},
},
],
}
44 changes: 44 additions & 0 deletions src/tests/bluetoothcontrol/BluetoothControl_Connect_003.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { connectBTDevice } from '../../commonMethods/commonFunctions'
import baseTest from './BluetoothControl_Connect_001.test'

let btdevicelist
let deviceStateChangeListener
let scanCompleteListener

export default {
title: 'Bluetooth Control - Connect 003',
description:
'Check the Connect Functionality of Bluetooth Control Module with the device which is already connected',
setup() {
scanCompleteListener = this.$thunder.api.BluetoothControl.on('scancomplete', () => {
this.$data.write('scancompleted')
})
deviceStateChangeListener = this.$thunder.api.BluetoothControl.on('devicestatechange', data => {
this.$data.write('address', data.address)
this.$data.write('state', data.state)
})
},
teardown() {
scanCompleteListener.dispose()
deviceStateChangeListener.dispose()
},
steps: [
baseTest,
{
description:
'Validate error message when already connected device is trying to connect again',
sleep: 5,
test() {
return connectBTDevice.call(this, btdevicelist[0]) //TODO - btdevicelist[0] need to be replaced with the MAC of already connected device
},
validate(res) {
if (res.code === 9 && res.message === 'ERROR_ALREADY_CONNECTED') {
return true
} else {
this.$log('Proper error message is not shown')
return false
}
},
},
],
}
66 changes: 66 additions & 0 deletions src/tests/bluetoothcontrol/BluetoothControl_Disconnect_001.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { disconnectBTDevice } from '../../commonMethods/commonFunctions'
import baseTest from './BluetoothControl_Connect_001.test'

let btdevicelist
let deviceStateChangeListener
let scanCompleteListener

export default {
title: 'Bluetooth Control - Disconnect 001',
description: 'Check the disconnect Functionality of Bluetooth Control Module',
setup() {
scanCompleteListener = this.$thunder.api.BluetoothControl.on('scancomplete', () => {
this.$data.write('scancompleted')
})
deviceStateChangeListener = this.$thunder.api.BluetoothControl.on('devicestatechange', data => {
this.$data.write('address', data.address)
this.$data.write('state', data.state)
})
},
teardown() {
scanCompleteListener.dispose()
deviceStateChangeListener.dispose()
},
steps: [
baseTest,
{
description: 'Disconnect with the device',
sleep: 5,
test() {
//TODO - Prompt the user to select the device that need to be disconnected
// and input(instead of btdevicelist[0]) that to the 'disconnectBTDevice'
return disconnectBTDevice.call(this, btdevicelist[0])
},
validate(res) {
if (res == null) {
return true
} else {
this.$log('Disconnection doesnt happen')
return false
}
},
},
{
description: 'Check whether disconnecting is success',
sleep: 5,
test() {
return new Promise((resolve, reject) => {
let attempts = 0
const interval = setInterval(() => {
attempts++
if (
this.$data.read('address') === btdevicelist[0] && //TODO - btdevicelist[0] need to be replaced with the user input given in previous step
this.$data.read('state') === 'Disconnected'
) {
clearInterval(interval)
resolve()
} else if (attempts > 10) {
clearInterval(interval)
reject('Disconnection is not success')
}
}, 1000)
})
},
},
],
}
41 changes: 41 additions & 0 deletions src/tests/bluetoothcontrol/BluetoothControl_Disconnect_002.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
pluginDeactivate,
pluginActivate,
disconnectBTDevice,
} from '../../commonMethods/commonFunctions'

import constants from '../../commonMethods/constants'

export default {
title: 'Bluetooth Control - Disconnect 002',
description: 'Check the disconnect Functionality with invalid MAC of Bluetooth Control Module',
steps: [
{
description: 'Check if Bluetooth Control Plugin is stopped correctly',
test: pluginDeactivate,
params: constants.bluetoothControlPlugin,
assert: 'deactivated',
},
{
description: 'Check if Bluetooth Control Plugin is started correctly',
test: pluginActivate,
params: constants.bluetoothControlPlugin,
assert: 'activated',
},
{
description: 'Disconnect with the device',
sleep: 5,
test() {
return disconnectBTDevice.call(this, constants.invalidAddress)
},
validate(res) {
if (res.code == 22 && res.message == 'ERROR_UNKNOWN_KEY ') {
return true
} else {
this.$log('Proper error message is not shown')
return false
}
},
},
],
}
44 changes: 44 additions & 0 deletions src/tests/bluetoothcontrol/BluetoothControl_Disconnect_003.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { disconnectBTDevice } from '../../commonMethods/commonFunctions'
import baseTest from './BluetoothControl_Disconnect_001.test'

let btdevicelist
let deviceStateChangeListener
let scanCompleteListener

export default {
title: 'Bluetooth Control - Disconnect 003',
description:
'Check the Disconnect Functionality of Bluetooth Control Module for device which is already disconnected',
setup() {
scanCompleteListener = this.$thunder.api.BluetoothControl.on('scancomplete', () => {
this.$data.write('scancompleted')
})
deviceStateChangeListener = this.$thunder.api.BluetoothControl.on('devicestatechange', data => {
this.$data.write('address', data.address)
this.$data.write('state', data.state)
})
},
teardown() {
scanCompleteListener.dispose()
deviceStateChangeListener.dispose()
},
steps: [
baseTest,
{
description:
'Validate error message when already disconnected device is trying to disconnect again',
sleep: 5,
test() {
return disconnectBTDevice.call(this, btdevicelist[0]) //TODO - btdevicelist[0] need to be replaced with the MAC of already disconnected device
},
validate(res) {
if (res.code === 36 && res.message === 'ERROR_ALREADY_RELEASED') {
return true
} else {
this.$log('Proper error message is not shown')
return false
}
},
},
],
}