GoodDeviceLabs onJul 29, 2020

Pushing Buttons with CanaryQA

Updated on 29 July 2020 / Attie Grande

When working with devices, one of the most fundamental interfaces is the push button. In their basic form, they produce a digital signal that conveys their state - “pressed” or “not pressed”.

While it is possible to emulate button presses using a pure-software approach, this can inadvertently exclude parts of your product from the end-to-end testing, and may lead you into a false sense of security.

If you were to employ the software-only approach, then depending on where the button’s state is injected, you may be omitting issues arising form incorrect pin configuration, driver and application changes, altered timing.

We strive to provide true end-to-end testing of devices, operating at their physical interfaces much like a user would. To achieve this, it needs to be possible to actually press buttons from within your test scripts.

To demonstrate our button pressing abilities we have produced an example setup that interacts with a simple four-button device - the Beeline Moto. Using one servo per button, and a rigid mount to hold everything in place, we are able to navigate the device’s menu system.

Our API provides a “button” widget that allows you to operate the buttons from within a test script. Once your device is set up in our system, the button will be available with an agreed upon name (i.e: the marking on the enclosure or PCB), and it is then simple to press and release the button.

We take care of all of the intricacies of physically mounting your device and the supporting button-pressing equipment, calibration, and control - you just have to call a series of functions.

import time
from gdl.cell.widgets.button import Button

# get access to the button
btn1 = Button('BTN1')

def test_button():
  # press the button for 1 second, and then release it

This test script can then be extended as necessary to perform a more complex series of operations, as shown below.