Re: [gnome-desktop-testing] Selecting an area Gnome-Screenshot



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

On Mon, Aug 24, 2009 at 8:09 AM, Javier Collado <javier collado canonical com> wrote:
Hello Nagappan,

I was curious about this. Is it possible to generate the drag by sending both
mouse button press and mouse move events?

Best regards,
   Javier

Nagappan Alagappan wrote:
> Hello Michael,
>
> I have done drag and drop automation in VMware Workstation. Transferring files from host to guest. I will share the code on Monday. Today heading out of town (right now). Just ping me, if you don't get reply from me on Monday.
>
> Thanks
> Nagappan
> ________________________________
> From: desktop-testing-list-bounces gnome org [desktop-testing-list-bounces gnome org] On Behalf Of Michael Fletcher [m fletcher theplanet ca]
> Sent: Thursday, August 20, 2009 1:32 PM
> To: desktop-testing-list gnome org
> Subject: [gnome-desktop-testing] Selecting an area Gnome-Screenshot
>
> Gnome screenshot allows you to take a picture of an area of the screen.  After you click 'Take Screenshot' you drag a box on the area of the screen you want.
>
> I thought I might be able to generate a drag but there is no api in either LDTP or AT-SPI (There is a SPI_generatemousevent but it only does clicks and moves).
>
> My options seem to be
> a) Change gnome-screenshot to support using the keyboard to select an area
> b) Change at-spi/ldtp to support sending drag events.
>
> Neither of these are good options.  I will probably abandon testing the area capture.
>
> Does anyone have any other suggestions?
> _______________________________________________
> http://live.gnome.org/DesktopTesting
> desktop-testing-list mailing list
> desktop-testing-list gnome org
> http://mail.gnome.org/mailman/listinfo/desktop-testing-list


_______________________________________________
http://live.gnome.org/DesktopTesting
desktop-testing-list
mailing list
desktop-testing-list gnome org
http://mail.gnome.org/mailman/listinfo/desktop-testing-list




--
Linux Desktop (GUI Application) Testing Project - http://ldtp.freedesktop.org
http://nagappanal.blogspot.com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]