The bug in question related to the launcher getting into a very confused state where it thought there were multiple active applications. And clicking on a launcher icon that was in this confused state caused a new application to be started rather than switching to the one that was running.
The first step in making all this work then, is to create a branch that is based off a revision that was before the fix. This way we can write a test that fails first. A key part of tests is to make sure they fail first. Then when they start passing, you know it isn't by mistake, and that you have tested what you think, not just created something that passes.
Firstly, find that revision...
$ bzr log | less
The fix is revision 1977, so lets make a branch of trunk from revision 1976.
$ bzr cbranch trunk -r 1976 hud-ap-test
$ cd hud-ap-test/
$ bzr revno
1976
I use light weight checkouts for the unity repo, hence cbranch rather than branch.
At this revision, there is a HUD test that really just checks the reveal. Lets make sure it passes...
$ cd tests/autopilot/
$ python -m testtools.run autopilot.tests.test_hud
Tests running...
No handlers could be found for logger "autopilot.emulators.X11"
Ran 1 test in 4.238s
OK
I deleted a bunch of gtk warnings, they don't add any value for what I'm trying to show here. Would be great if someone fixed them though :-)
Now I need to actually build and run my local unity (and test the autopilot test again).
Found out that my machine was failing to build for other reasons, so we switched to Thomi's. The existing test still passed (of course it did), so the next step was to write a test that encapsulated the broken behaviour that we had found during the many hours of analysis.
That can be found at lp:~thomir/unity/autopilot-hud-triple-hit.
The test failed with the old revision, we then merged trunk, rebuilt, and ran the test again. Test passed. Job done.