Re: [gnome-desktop-testing] Selecting an area Gnome-Screenshot
- From: Nagappan Alagappan <nagappan gmail com>
- To: Javier Collado <javier collado canonical com>
- Cc: "desktop-testing-list gnome org" <desktop-testing-list gnome org>
- Subject: Re: [gnome-desktop-testing] Selecting an area Gnome-Screenshot
- Date: Mon, 24 Aug 2009 19:53:40 -0700
Hi Javier / Michael,
Here is the code: This method takes x, y, width, height (arguments) of the file object co-ordinates in nautilus window in host.
def LinDragAndDrop(self, serverInst, client, x, y, width, height):
objList = getobjectlist(mainWindow)
unkObj = None
###################################### Hard coding for testing DnD
objList = ['unk29']
for obj in objList:
if obj.find ('unk') != -1:
print obj
self.harness.AddTestComment(obj)
if hasstate (mainWindow, obj, state.SHOWING) and \
hasstate (mainWindow, obj, state.FOCUSED):
unkObj = obj
break
if not unkObj:
raise ValueError, "Unable to find unknown object"
vm_x, vm_y, vm_width, vm_height = getobjectsize(mainWindow,
unkObj)
print 'File', x, y, width, height
print 'Guest', vm_x, vm_y, vm_width, vm_height
# Press mouse button
generatemouseevent(x + width / 2,
y + height / 2,
'b1p')
# Bring Workstation window to focus
grabfocus(mainWindow, unkObj)
self.MouseMoveInNautilus(serverInst, client,
0, 0, vm_width,
vm_height)
# Move mouse to absolute location
generatemouseevent(vm_x + vm_width / 2,
vm_y + vm_height / 2,
'abs')
wait(1)
self.MouseActionInNautilus(serverInst, client, 'rel',
0, 0, vm_width, vm_height,
False)
wait(1)
self.MouseActionInNautilus(serverInst, client, 'b1p',
0, 0, vm_width, vm_height,
False)
wait(1)
self.MouseActionInNautilus(serverInst, client, 'abs',
0, 0, vm_width, vm_height,
False)
wait(1)
# Release mouse button
self.MouseActionInNautilus(serverInst, client, 'b1r',
0, 0, vm_width, vm_height,
False)
# wait(3)
print 'Host', vm_x, vm_y, vm_width, vm_height, vm_x + vm_width / 2, vm_y + vm_height / 2
print 'Guest', 0, 0, vm_width, vm_height, vm_width / 2, vm_height / 2
generatemouseevent(vm_x + vm_width / 2,
vm_y + vm_height / 2,
'b1r')
generatemouseevent(vm_x + vm_width / 2,
vm_y + vm_height / 2,
'b1c')
wait(1)
On the guest to operate on nautilus window:
if waittillguiexist (nautilusWindow, guiTimeOut = 2) == 0:
# If window doesn't exist, then launch
launchapp ('nautilus')
waittillguiexist (nautilusWindow)
menucheck(nautilusWindow, 'View;Main Toolbar')
grabfocus(nautilusWindow, 'btnReload')
# To get object x,y co-ordinates, we need to uncheck,
# the following options in nautilus window
menuuncheck(nautilusWindow, 'View;Main Toolbar')
menuuncheck(nautilusWindow, 'View;Side Pane')
menuuncheck(nautilusWindow, 'View;Location Bar')
try:
x, y, width, height = getobjectsize(nautilusWindow, nautilusWindow)
generatemouseevent(x + width / 2, y + height / 2, 'abs')
except:
print traceback.format_exc()
Code which calls the above function:
x, y, width, height = getobjectsize(nautilusWindow,
testdata ['filename1'])
guestCommInst.LinDragAndDrop(serverInst, client, x, y,
width, height)
In our scenario, we run a server and client, as the information has to be transferred between host machine and the guest. This may not be required in your automation.
During my DnD automation, I noticed the bug in nautilus. It always gives the coordinates without calculating the toolbar, side pane and location bar. Once you grab the focus of nautilus window, you have to uncheck them. To grab focus of nautilus window, you need to have toolbar visible. The above nautilus code handles this.
MouseActionInNautilus will be done inside the guest.
Thanks
Nagappan
--
Linux Desktop (GUI Application) Testing Project -
http://ldtp.freedesktop.orghttp://nagappanal.blogspot.com
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]