Merge lp:~mikefletcher/mago/gnome-screenshot into lp:~mago-contributors/mago/mago-1.0

Proposed by Michael Fletcher
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mikefletcher/mago/gnome-screenshot
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~mikefletcher/mago/gnome-screenshot
Reviewer Review Type Date Requested Status
Ara Pulido Approve
Michael Fletcher (community) Abstain
Joker Wild (community) in process test Approve
James Tatum Approve
Nagappan Alagappan Approve
Review via email: mp+10684@code.launchpad.net

Commit message

Added a basic test suite for gnome-screenshot. I followed the existing tests documented at http://testcases.qa.ubuntu.com/Applications/TakeScreenshot.

To post a comment you must log in.
Revision history for this message
Michael Fletcher (mikefletcher) wrote :

This is a basic test suite for gnome-screenshot. I followed the existings tests documented at http://testcases.qa.ubuntu.com/Applications/TakeScreenshot.

Please be gentle. This is my first attempt at merging branches with launchpad. I might have totally messed up the branch or merge.

Revision history for this message
Joker Wild (lajjr-deactivatedaccount) wrote :

Michael,
Were you going to use mouse event to do this I looked at the source it seemed you started to add pointer. Then you removed it this is nice I see it grabbed a screen shot in my test it works well, but just curious if you were going to use a mouse event maybe use it to create an area to grab.

Regards,
Leo Jackson
lajjr

review: Needs Information (in process test)
Revision history for this message
Michael Fletcher (mikefletcher) wrote :

Hi.

> Were you going to use mouse event to do this I looked at the source it seemed
> you started to add pointer.
gnome-screenshot has an option to include the mouse pointer when taking the screenshot. 'include_pointer' was going to be part of those tests. However I thought I should "release early, release often" so I took those unfinished parts out.

> Then you removed it this is nice I see it grabbed
> a screen shot in my test it works well, but just curious if you were going to
> use a mouse event maybe use it to create an area to grab.
I did implement the area grab (with help from Nagappan). Its in gnome.py around line 67.

Revision history for this message
Nagappan Alagappan (nagappan) wrote :

It will be nice to move the screenshot file name to take_screenshot.xml

In gnome.py line # 164-166 coordinate information are hard coded. Will this work on all test environment ? I have a dual screen monitor ;-) I recommend to use getobjectsize and then use the relative x, y coordinates.

review: Needs Fixing
Revision history for this message
Michael Fletcher (mikefletcher) wrote :

Hi.

I will put all the arguments into the .xml file.

Gnomescreenshot is asking you to select an area of your entire screen. As
long as your screen is larger that 200x200 pixels this should be fine. In
either case you need a window for getobjectsize and in this test I don't
have one.

... sent from my Android Phone

On Aug 25, 2009 3:57 PM, "Nagappan Alagappan" <email address hidden> wrote:

Review: Needs Fixing
It will be nice to move the screenshot file name to take_screenshot.xml

In gnome.py line # 164-166 coordinate information are hard coded. Will this
work on all test environment ? I have a dual screen monitor ;-) I recommend
to use getobjectsize and then use the relative x, y coordinates.

--
https://code.launchpad.net/~mikefletcher/mago/gnome-screenshot/+merge/10684You
are the owner of...

Revision history for this message
James Tatum (jtatum) wrote :

It looks good overall. The meat of the LDTP commands in mago/application/gnome.py are all wrapped in try/catch blocks to provide a helpful failure description for the log file. +1 to the comments for moving as many parameters as possible to XML.

review: Needs Fixing
Revision history for this message
James Tatum (jtatum) wrote :

Sorry, one additional note regarding style, I notice that most of the mago/application/gnome.py applications are written as ooldtp, and the proposed code for gnome-screenshot is procedural. I'm not sure if that's a factor since I'm new here myself :) Just pointing it out.

Revision history for this message
Michael Fletcher (mikefletcher) wrote :

Hi. I made all of the requested changes to the gnome-screenshot tests.

* ooldtp is being used
* try: except: should indicate where something fails
* the arguments are being specified using the xml files.

review: Needs Resubmitting
Revision history for this message
Nagappan Alagappan (nagappan) wrote :

> Hi. I made all of the requested changes to the gnome-screenshot tests.
>
> * ooldtp is being used
> * try: except: should indicate where something fails
> * the arguments are being specified using the xml files.

Am I missing something ? I could not see any new diff in this review.

Thanks

review: Needs Information
Revision history for this message
Nagappan Alagappan (nagappan) wrote :

> Am I missing something ? I could not see any new diff in this review.

jtatum gave me the link - http://bazaar.launchpad.net/~mikefletcher/mago/gnome-screenshot/revision/109

Its nice to see the exceptions are caught in each and every line. But this will make the script writer job more difficult !?!

Thanks

review: Approve
Revision history for this message
James Tatum (jtatum) wrote :

+1 - that is a lot of exceptions :) It can always be condensed later of course. I think the balance in e.g. seahorse in gnome.py is pretty good.

review: Approve
Revision history for this message
Michael Fletcher (mikefletcher) wrote :

Sorry about the change-of-status spam. I had heard that changing the status of the merge proposal would regenerate the diff but it didn't work.

Revision history for this message
Michael Fletcher (mikefletcher) wrote :

I think the exception handling is a bit much. However it is consistent with
the rest of the code and i'm not interested in rocking.

The ldtp exception says
    u'Unable to find object name in application map'

And the exceptions we raise says
    'Window dlgSaveScreenshot did not appear'

I think a good solution would be to add information to the ldtp exceptions
so that the mago exception handling is superfluous. But I wont mention it
again until I have written a patch :).

110. By Michael Fletcher

Updated test to work with 9.10. It will now fail with 9.04.

111. By Michael Fletcher

Fixed silly mistake. I should have run the tests before I commited.

Revision history for this message
Joker Wild (lajjr-deactivatedaccount) wrote :

With changes in place very good.

review: Approve (in process test)
Revision history for this message
Michael Fletcher (mikefletcher) :
review: Abstain
Revision history for this message
Javier Collado (javier.collado) wrote :

> Sorry about the change-of-status spam. I had heard that changing the status
> of the merge proposal would regenerate the diff but it didn't work.

I also noticed this in other reviews.

It seems like this is known problem that is going to be solved:
https://bugs.launchpad.net/launchpad-code/+bug/338002

Look at comment #1 for a tool that is supposed to help to workaround it.

112. By Michael Fletcher

Reformatted and updated the documentation for epydoc.

Revision history for this message
Michael Fletcher (mikefletcher) wrote :

I pushed some fixes to the documentation strings so they get picked
up by epydoc.

Reminder: The diff does not get updated so you will have to look at
the individual changes (changes 106 -> 112).

Revision history for this message
Ara Pulido (ara) wrote :

> I think the exception handling is a bit much. However it is consistent with
> the rest of the code and i'm not interested in rocking.
>
>
> The ldtp exception says
> u'Unable to find object name in application map'
>
> And the exceptions we raise says
> 'Window dlgSaveScreenshot did not appear'
>
>
> I think a good solution would be to add information to the ldtp exceptions
> so that the mago exception handling is superfluous. But I wont mention it
> again until I have written a patch :).

I agree with you, Michael, although I was the one that started the try/catch madness, I never liked it myself.

Revision history for this message
Ara Pulido (ara) wrote :

I think it is ready to be merged. I am waiting for Michael's reply to an email I sent him, before commiting

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'gnome-screenshot'
=== added file 'gnome-screenshot/take_screenshot.py'
--- gnome-screenshot/take_screenshot.py 1970-01-01 00:00:00 +0000
+++ gnome-screenshot/take_screenshot.py 2009-08-25 18:33:48 +0000
@@ -0,0 +1,48 @@
1import os
2from mago.test_suite.gnome import GnomeScreenshotTestSuite
3
4class TakeScreenshot(GnomeScreenshotTestSuite):
5 def grab_desktop(self, delay=5, file_name='baz.png'):
6 self.application.open()
7 self.application.take_whole_desktop_screenshot(delay)
8
9 self.application.save_to_file(file_name)
10
11 file_path = os.getenv('HOME') + '/' + file_name
12
13 if os.access(file_path, os.F_OK):
14 os.remove(file_path)
15 else:
16 raise AssertionError('Screenshot ' + file_path + ' was not created')
17
18 def grab_window(self, delay=5, file_name='baz.png'):
19 self.application.open()
20
21 self.application.take_current_window_screenshot(delay)
22
23 self.application.save_to_file(file_name)
24
25 file_path = os.getenv('HOME') + '/' + file_name
26
27 if os.access(file_path, os.F_OK):
28 os.remove(file_path)
29 else:
30 raise AssertionError('Screenshot ' + file_path + ' was not created')
31
32 def grab_area(self, delay=5, file_name='baz.png'):
33 self.application.open()
34
35 self.application.grab_selected_area(delay)
36
37 self.application.save_to_file(file_name)
38
39 file_path = os.getenv('HOME') + '/' + file_name
40
41 if os.access(file_path, os.F_OK):
42 os.remove(file_path)
43 else:
44 raise AssertionError('Screenshot ' + file_path + ' was not created')
45
46if __name__ == "__main__":
47 test = TakeScreenshot()
48 test.run()
049
=== added file 'gnome-screenshot/take_screenshot.xml'
--- gnome-screenshot/take_screenshot.xml 1970-01-01 00:00:00 +0000
+++ gnome-screenshot/take_screenshot.xml 2009-08-25 18:33:48 +0000
@@ -0,0 +1,25 @@
1<?xml version="1.0"?>
2<suite name="take screenshot">
3 <class>take_screenshot.TakeScreenshot</class>
4 <description>
5 Tests which verify the Take Screenshot functionality.
6 </description>
7 <case name="Grab Desktop">
8 <method>grab_desktop</method>
9 <description>
10 Grab a screenshot of the desktop after a delay.
11 </description>
12 </case>
13 <case name="Grab Window">
14 <method>grab_window</method>
15 <description>
16 Grab a screenshot of the current window after a delay.
17 </description>
18 </case>
19 <case name="Grab Area">
20 <method>grab_area</method>
21 <description>
22 Grab a screenshot of the select area after a delay.
23 </description>
24 </case>
25</suite>
026
=== modified file 'mago/application/gnome.py'
--- mago/application/gnome.py 2009-07-10 09:24:57 +0000
+++ mago/application/gnome.py 2009-08-25 18:33:48 +0000
@@ -4,9 +4,98 @@
4The gnome module provides wrappers for LDTP to make the write of Gnome tests easier. 4The gnome module provides wrappers for LDTP to make the write of Gnome tests easier.
5"""5"""
6import ooldtp6import ooldtp
7import ldtp 7import ldtp
8from .main import Application8from .main import Application
99
10class GnomeScreenshot(Application):
11 LAUNCHER = 'gnome-screenshot'
12 LAUNCHER_ARGS = ['--interactive']
13 CLOSE_TYPE = 'button'
14 CLOSE_NAME = 'btnCancel'
15
16 WINDOW = 'dlgTakeScreenshot'
17
18 GRAB_AFTER_DELAY_FIELD = 'sbtnGrabafteradelayof'
19 GRAB_THE_WHOLE_DESKTOP_RADIO = 'rbtnGrabthewholedesktop'
20 GRAB_THE_CURRENT_WINDOW_RADIO = 'rbtnGrabthecurrentwindow'
21 GRAB_A_SELECTED_AREA = 'rbtnGrabaselectedarea'
22
23 TAKE_SCREENSHOT_BUTTON = 'btnTakeScreenshot'
24
25 SAVE_FILE_WINDOW = 'dlgSaveScreenshot'
26 SAVE_FILE_BUTTON = 'btnSave'
27 SAVE_FILE_NAME_TEXT = 'txtName'
28 SAVE_FILE_FOLDER_DROPDOWN = 'cbSaveFile'
29
30 def __init__(self):
31 Application.__init__(self)
32
33 """
34 Complete the "Take Screenshot" dialog box by choosing whole desktop and
35 clicking Take Screenshot.
36
37 You must have started the application already.
38 """
39 def take_whole_desktop_screenshot(self, delay):
40 ldtp.click(self.WINDOW, self.GRAB_THE_WHOLE_DESKTOP_RADIO)
41
42 ldtp.setvalue (self.WINDOW, self.GRAB_AFTER_DELAY_FIELD, delay)
43
44 ldtp.click(self.WINDOW, self.TAKE_SCREENSHOT_BUTTON)
45
46 ldtp.waittillguinotexist(self.WINDOW)
47
48 """
49 Complete the "Take Screenshot" dialog box by choosing current window and
50 clicking Take Screenshot.
51
52 You must have started the application already.
53 """
54 def take_current_window_screenshot(self, delay):
55 ldtp.click(self.WINDOW, self.GRAB_THE_CURRENT_WINDOW_RADIO)
56
57 ldtp.setvalue (self.WINDOW, self.GRAB_AFTER_DELAY_FIELD, delay)
58
59 ldtp.click(self.WINDOW, self.TAKE_SCREENSHOT_BUTTON)
60
61 ldtp.waittillguinotexist(self.WINDOW)
62
63 """
64 Complete the "Take Screenshot" dialog box by choosing selected area and
65 clicking Take Screenshot.
66
67 You must have started the application already.
68 """
69 def grab_selected_area(self, delay):
70 ldtp.click(self.WINDOW, self.GRAB_A_SELECTED_AREA)
71
72 ldtp.setvalue (self.WINDOW, self.GRAB_AFTER_DELAY_FIELD, delay)
73
74 ldtp.click(self.WINDOW, self.TAKE_SCREENSHOT_BUTTON)
75
76 ldtp.waittillguinotexist(self.WINDOW)
77
78 ldtp.generatemouseevent(100,100,'b1p')
79 ldtp.generatemouseevent(200,200,'abs')
80 ldtp.generatemouseevent(200,200,'b1r')
81
82 """
83 Complete the save to file dialog. You must have completed a grab_ already
84 """
85 def save_to_file(self, filename):
86 ldtp.waittillguiexist(self.SAVE_FILE_WINDOW)
87
88 ldtp.settextvalue(self.SAVE_FILE_WINDOW, self.SAVE_FILE_NAME_TEXT, filename)
89
90 # There is a bug in gnome-screenshot that prevents the combobox
91 # name from being used. There is only one combo box so its easy to
92 # select it by index.
93 ldtp.comboselectindex(self.SAVE_FILE_WINDOW, 'cbo#0', 0)
94
95 ldtp.click(self.SAVE_FILE_WINDOW, self.SAVE_FILE_BUTTON)
96
97 ldtp.waittillguinotexist(self.SAVE_FILE_WINDOW)
98
10class Seahorse(Application):99class Seahorse(Application):
11 """100 """
12 Seahorse manages the Seahorse application.101 Seahorse manages the Seahorse application.
13102
=== modified file 'mago/application/main.py'
--- mago/application/main.py 2009-07-29 11:14:24 +0000
+++ mago/application/main.py 2009-08-20 02:40:51 +0000
@@ -10,13 +10,16 @@
10 Superclass for the rest of the applications10 Superclass for the rest of the applications
1111
12 Constants that should be defined in the classes that inherit from this class12 Constants that should be defined in the classes that inherit from this class
13 LAUNCHER: Argument to be passed when launching the application through ldtp.launchapp13 LAUNCHER: Command to launching the application through ldtp.launchapp
14 LAUNCHER_ARGS: Arguments to pass when launching the application through
15 ldtp.launchapp.
14 WINDOW: Top application frame pattern using ldtp syntax16 WINDOW: Top application frame pattern using ldtp syntax
15 CLOSE_TYPE: Close object type (one of 'menu' or 'button')17 CLOSE_TYPE: Close object type (one of 'menu' or 'button')
16 CLOSE_NAME: Close object name18 CLOSE_NAME: Close object name
17 """19 """
18 CLOSE_TYPE = 'menu'20 CLOSE_TYPE = 'menu'
19 CLOSE_NAME = 'mnuQuit'21 CLOSE_NAME = 'mnuQuit'
22 LAUNCHER_ARGS = ['']
20 WINDOW = ''23 WINDOW = ''
21 TOP_PANEL = 'frmTopExpandedEdgePanel'24 TOP_PANEL = 'frmTopExpandedEdgePanel'
2225
@@ -68,7 +71,7 @@
68 71
69 """72 """
70 self._enable_a11y(True)73 self._enable_a11y(True)
71 ldtp.launchapp(self.LAUNCHER)74 ldtp.launchapp(self.LAUNCHER, arg=self.LAUNCHER_ARGS)
72 self._enable_a11y(False)75 self._enable_a11y(False)
7376
74 ldtp.wait(2)77 ldtp.wait(2)
7578
=== modified file 'mago/test_suite/gnome.py'
--- mago/test_suite/gnome.py 2009-05-27 10:45:38 +0000
+++ mago/test_suite/gnome.py 2009-08-25 18:33:48 +0000
@@ -4,7 +4,10 @@
4"""4"""
5import ldtp, ooldtp5import ldtp, ooldtp
6from .main import SingleApplicationTestSuite6from .main import SingleApplicationTestSuite
7from ..application.gnome import Application, Seahorse, GEdit7from ..application.gnome import Application, GnomeScreenshot, Seahorse, GEdit
8
9class GnomeScreenshotTestSuite(SingleApplicationTestSuite):
10 APPLICATION_FACTORY = GnomeScreenshot
811
9class SeahorseTestSuite(SingleApplicationTestSuite):12class SeahorseTestSuite(SingleApplicationTestSuite):
10 """13 """

Subscribers

People subscribed via source and target branches

to status/vote changes: