Friday, July 26, 2013

An autopilot emulator for ubuntu sdk apps: Part II

A little over a month ago, I posted about creating an autopilot emulator for
ubuntu sdk applications. Thanks to some hard work by Leo Arias and the ubuntu sdk team, I'm happy to announce the little side project from my +junk branch is all grown up and even more ready for your consumption. Leo has made the emulator a proper part of the sdk, complete with tests for all of it's functions!  You can now easily install it and incorporate it into your project. Here's how to snag your copy.

1) Add the ubuntu sdk team ppa if you haven't already

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa

2) Install the ubuntu-ui-toolkit-autopilot package

sudo apt-get update && sudo apt-get install ubuntu-ui-toolkit-autopilot

This will install the emulator as a python module, ready for you to import. If you want to checkout what the module can do, have a look at the documentation.

Incorporating the module might seem a little tricky, so Leo has also put together an example of one of the ubuntu touch core apps using the new module. Check out it. Here's a branch showing off the work done for ubuntu-filemanager-app. And here's one for dropping-letters.

Please do check out the module and incorporate it into your ubuntu sdk project. Feedback is encouraged, and bug reports too! Please file any issues you find against the ubuntu-ui-toolkit project. Happy Automated Testing!


  1. How do I actually run these tests and see the emulator in action? When I run 'autopilot list ubuntu_filemanager_app,' I have 24 tests, none of which are methods listed in the documentation.

    1. John, the tests utilize the emulator calls if you look at the source code for them. You can run the tests themselves (which are for file manager) by running autopilot run ubuntu_filemanager_app, as you know :-)

      Look at the source code and you'll see "from ubuntuuitoolkit import emulators as toolkit_emulators".. Inside the test*.py file you'll see stuff like:

      toolbar = self.main_view.open_toolbar()

      That's using the emulator

  2. I'm trying to help with the core music app. Right now we have 3 very simple tests (music loading, play, pause). The test copies "Swansong" from the Ubuntu Free Culture Showcase and uses that for tests. Some tests (like verification of shuffle mode) need several songs in order to work. Since Swansong is the only audio file I can think of that can be expected on an Ubuntu install, would it be a bad idea to pull down some audio files from the web that are in the public domain? Is it bad to depend on an internet connection in the test? (I guess many apps won't have any way around this)

    1. Micah, public domain media sounds perfect for what you need. If we can include it in the archive, let's do it. It's ok to depend on the internet for the test, but I would include the audio files directly in the source tree and load them up for the test. Specifically, I would grab the files you want, create a folder in the tests subdirectory called media, and then have your tests reference and use those files. Make sense?

    2. "If we can include it in the archive, let's do it." By "archive" do you mean somewhere inside the music app directory? (like the ...tests/media folder you mentioned)

    3. Yes, I mean checked into the bzr branch :-) Sorry for the confusing terms ;-)

    4. No worries. Thanks for your advice, Nick, it is much appreciated. :)