Wallpapoz Is Back November 11th, 2006

After vacuum again, the development of wallpapoz is back. Until now, from svn repository, you will get the functional gui. It can import directory of image files (recursive too), the edit menu is complete except for preferences dialog launcher, image widget to show the wallpaper, combobox to choose how to display the wallpaper (zoom,scale,tile.etc) and…. ooops, only that. But the remaining jobs to the functional application are preferences dialog, implementing “how to display wallpaper” option in configuration file, and…. the hardest part, the daemon part. Until now, I don’t know how to catch event when user change workspace if user use compiz or beryl. Maybe I will do the polling algorithm for this problem. But I hope I will find the way to detect changes nicely.

I told my self that I will not use gui testing for wallpapoz application but a week ago after “got sick” by testing development style in rails virus, I tried to learn gui testing frameworks. The first one is dogtail. It is designed by python programming language and targeted to gnome/gtk+ application (other gui are supported too as long as it support accessibility feature). First I got issue that it take a long time to launch the gui application to be tested. Then I try to run application separately. The second issue was I could not figure out how to test whether some dialogs exists. I just want to test that if I click “About” menu item, it launch “About Wallpapoz” dialog. I have to use some dirty hack to check if the dialog exists. I use exception. To make it worse, the documentation is lacking. Here is the code if you curious.
from dogtail import tree, utils, config
import unittest
class WallpapozWindow(unittest.TestCase):
  def setUp(self):
    utils.run("python wallpapoz.py", timeout=3, dumb=True)
    self.wallpapoz = tree.root.application("wallpapoz.py")
  def testAboutDialog(self):
    # After clicking About menu item from Wallpapoz window, About dialog must appear
    self.wallpapoz.menuItem("About").click()
    try:
      about_dialog = self.wallpapoz.dialog("About Wallpapoz")
    except tree.SearchError:
      assert False
    # After clicking dialog close button, About dialog must dissapear
    about_dialog.button("Close").click()
    try:
      about_dialog = self.wallpapoz.dialog("About Wallpapoz")
    except tree.SearchError:
      assert True
  def testAddFilesDialog(self):
    # After clicking File -> Add Files menu item from Wallpapoz window, Add Files dialog must appear
    self.wallpapoz.menuItem("Add Wallpapers (Files)").click()
    try:
      add_files_dialog = self.wallpapoz.dialog("Choose Wallpapers")
    except tree.SearchError:
      assert False
    # select one wallpaper
    add_files_dialog.child('wallpaper', roleName='table cell').doAction('activate')
    add_files_dialog.child('arda.jpg', roleName='table cell').grabFocus()
    add_files_dialog.child("Add", roleName="push button", description="Add wallpapers").click()
    # After clicking dialog add button, Add Files dialog must disappear
    try:
      add_files_dialog = self.wallpapoz.dialog("Choose Wallpapers")
    except tree.SearchError:
      assert True
    # and the added files must present on treecel
    try:
      added_file = self.wallpapoz.child("/home/knight/wallpaper/arda.jpg", roleName="table cell")
    except tree.SearchError:
      assert False
  def tearDown(self):
    self.wallpapoz.menuItem("Quit").click()
if __name__ == "__main__":
  cfg = config._Config()
  cfg.__setattr__("searchCutoffCount", 2)
  cfg.__setattr__("searchBackoffDuration", 1)
  cfg.__setattr__("searchWarningThreshold", 2)
  unittest.main()

I got angry with this testing tool. So I tried to search another testing framework. There was another one, LDTP (Linux Desktop Testing Project). This was more worse than dogtail, at least for me.

selectmenuitem ('Wallpapoz', 'mnuHelp;mnuAbout')
The code above should click “About” menu item. But it didn’t in Wallpapoz. It did in another application, such as Gedit and Firefox. I could not figure out why. To make it worse, sometimes the it hanged for some function. Sometimes it hanged, sometimes it did not.

So I ditch it and back to dogtail and try to live inconveniently with it. After hours, I try to get sense how to test gui with dogtail. I could simulate this action: click File->Add Files menu item (it open file selection dialog), open certain directory, choose file and click add button. But I need 4 hours to learn this such simple thing! I still don’t know how to test whether the selection file is showing up in the treeview. Maybe I should intregate this testing tool with Wallpapoz gui class. But I think I need many many hours to learn dogtail until I really really understand and be able to simulate the whole thing you can do to gui application. That means delaying Wallpapoz development and I don’t like it. So… for this time, no gui testing. I realize unit testing is important in software development but sometimes you have to make priority. Wallpapoz is delayed too often.

So I decided not to use gui testing frameworks for developing Wallpapoz. Maybe later, after dogtail is getting matured or I have more time to play with these gui testing frameworks.

Leave a Reply