I've an Android phone which needs to be paired with an embedded device (Qt based application on Linux) which we test. I've automated the basic scenarios using ADB commands, to turn on/off BT on the phone, and check the status on the embedded device using Squish. We need to automate scenarios, where the bluetooth/phone goes Out of Range, and check the same on the device. Any idea on how to simulate this programmatically using ADB or even Appium?
Simulate Bluetooth "Out of range" scenarios for test automation
295 Views Asked by Sumantha AtThere are 2 best solutions below
Usually test cases like these require a degree of mocking or simulation.
You could simulate your Android phone and fake a lost connection then detect wether the UI displays the expected value on the Qt application side with Squish.
Since it sounds like you work close with the developers team and have means to persuade them, you could fake / mock the communication between the phone and your device under test DUT. In the fake connection you could send a "weak" indicator for signal or cut-off the connection entirely and then check wether the Qt app responds correctly.
In most scenarios it is more easily maintainable and feasible to simulate dependencies. If you need to test on real hardware, then you'd need to invest in the development of a test belch.
You can have a look at this medium article which gives some insight on emulated devices. I bet that you could turn off the WiFi of the emulated device in your test case and thus simulate a disconnect:
https://medium.com/wix-engineering/how-to-execute-android-ui-tests-on-ci-and-stay-alive-eb9089d88c1f
If you are not using any hardware, like a shield box, bluetooth repeater, moving the phone out of reach, adding a shield material, can you control the bluetooth of the embedded device? Like lower the power, turn it off or control the connection between bluetooth and antenna? Do you need this specific mobile or can you use a simulator with a controlable bluetooth?