Merge lp:~pedro/mago/transmission-gtk into lp:~mago-contributors/mago/mago-testsuite

Proposed by Pedro Villavicencio
Status: Merged
Merged at revision: 5
Proposed branch: lp:~pedro/mago/transmission-gtk
Merge into: lp:~mago-contributors/mago/mago-testsuite
Diff against target: 120 lines (+115/-0)
1 file modified
transmission-gtk/test_transmission-gtk.py (+115/-0)
To merge this branch: bzr merge lp:~pedro/mago/transmission-gtk
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Review via email: mp+46606@code.launchpad.net

Description of the change

transmission gtk test

To post a comment you must log in.
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'transmission-gtk'
2=== added file 'transmission-gtk/test_transmission-gtk.py'
3--- transmission-gtk/test_transmission-gtk.py 1970-01-01 00:00:00 +0000
4+++ transmission-gtk/test_transmission-gtk.py 2011-01-18 14:20:11 +0000
5@@ -0,0 +1,115 @@
6+# Copyright (C) 2010 Canonical Ltd
7+#
8+# This program is free software; you can redistribute it and/or modify
9+# it under the terms of the GNU General Public License as published by
10+# the Free Software Foundation; either version 2 of the License, or
11+# (at your option) any later version.
12+#
13+# This program is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with this program; if not, write to the Free Software
20+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
22+"""Transmission GTK Test
23+
24+This is a test that verifies that Transmission application is working correctly.
25+So far what it does is:
26+ - Add a torrent URL.
27+ - Check that the torrent is being downloaded.
28+ - Remove the torrent and the files downloaded.
29+
30+This test only requires an Internet connection to be run.
31+
32+To run it with:
33+$ mago-ng <path_to_this_file>
34+"""
35+
36+from mago import TestCase
37+import unittest
38+import ldtp
39+import ooldtp
40+
41+TRANSMISSION = 'frmTransmission'
42+DLG_INFORMATION = 'dlgInformation'
43+IACCEPT = 'btnIAccept'
44+MNU_ADD_URL = 'mnuAddURL'
45+DLG_ADD_URL = 'dlgAddURL'
46+TXT_ADD_URL = 'txtURL'
47+BTN_ADD_URL = 'btnAdd'
48+DLG_TORRENT_OPTIONS = 'dlgTorrentOptions'
49+DLG_QUESTION = 'dlgQuestion'
50+BTN_REMOVE = 'btnDelete'
51+TABLE = 'tbl0'
52+MNU_REMOVE_TORRENT = 'mnuDeleteFilesandRemove'
53+SPEED = 'lbl*KiB/s'
54+"""This is the torrent image we download
55+"""
56+TORRENT = 'http://cdimage.ubuntu.com/releases/maverick/release/ubuntu-10.10-dvd-i386.iso.torrent'
57+
58+class TransmissionsTests(TestCase):
59+ """Launcher for the application transmission
60+ """
61+ launcher = 'transmission-gtk'
62+ window_name = TRANSMISSION
63+ setupOnce = True
64+
65+ def transmission_01_test_add_torrent(self):
66+ """Test that adding a torrent works fine.
67+ When you launch transmission for the first time and information dialog
68+ is being displayed with information regarding torrents, we wait for
69+ that dialog and accept.
70+ """
71+ if ldtp.guiexist(DLG_INFORMATION):
72+ i = ooldtp.context(DLG_INFORMATION)
73+ i.getchild(IACCEPT).click()
74+
75+ t = ooldtp.context(TRANSMISSION)
76+ t.getchild(MNU_ADD_URL).selectmenuitem()
77+
78+ ldtp.waittillguiexist(DLG_ADD_URL)
79+ du = ooldtp.context(DLG_ADD_URL)
80+ du.getchild(TXT_ADD_URL).settextvalue(TORRENT)
81+ du.getchild(BTN_ADD_URL).click()
82+
83+ ldtp.waittillguiexist(DLG_TORRENT_OPTIONS)
84+
85+ if ldtp.guiexist(DLG_TORRENT_OPTIONS):
86+ to = ooldtp.context(DLG_TORRENT_OPTIONS)
87+ to.getchild(BTN_ADD_URL).click()
88+
89+ self.assertTrue(ldtp.guiexist(TRANSMISSION))
90+
91+ def transmission_02_test_check_torrent(self):
92+ """Test that checks that the torrent is being downloaded, we double check
93+ that the treeview contains the torrent element and that the speed changes.
94+ """
95+ t = ooldtp.context(TRANSMISSION)
96+ table = t.getchild(TABLE)
97+ self.assertTrue(table.getrowcount() > 0)
98+ """wait until the torrent has started to download.
99+ """
100+ while t.getchild(SPEED).gettextvalue() == '0.00 KiB/s':
101+ ldtp.wait(2)
102+
103+ def transmission_03_test_remove_torrent(self):
104+ """Test that removes the torrent and the files.
105+ """
106+ t = ooldtp.context(TRANSMISSION)
107+ table = t.getchild(TABLE)
108+ table.selectrowindex(0)
109+ t.getchild(MNU_REMOVE_TORRENT).selectmenuitem()
110+
111+ ldtp.waittillguiexist(DLG_QUESTION)
112+
113+ if ldtp.guiexist(DLG_QUESTION):
114+ q = ooldtp.context(DLG_QUESTION)
115+ q.getchild(BTN_REMOVE).click()
116+
117+ self.assertTrue(table.getrowcount() == 0)
118+
119+if __name__ == "__main__":
120+ unittest.main()

Subscribers

People subscribed via source and target branches