public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: New DnD test
@ 2006-08-17 15:20 Lillian Angel
  0 siblings, 0 replies; 5+ messages in thread
From: Lillian Angel @ 2006-08-17 15:20 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

2006-08-17  Lillian Angel  <langel@redhat.com>

        *
gnu/testlet/java/awt/dnd/DropTargetDropEvent/Constructors.java:
        New test.


[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 3503 bytes --]

Index: gnu/testlet/java/awt/dnd/DropTargetDropEvent/Constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/dnd/DropTargetDropEvent/Constructors.java
diff -N gnu/testlet/java/awt/dnd/DropTargetDropEvent/Constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/dnd/DropTargetDropEvent/Constructors.java	17 Aug 2006 15:19:22 -0000	1.1
@@ -0,0 +1,116 @@
+/* Constructors.java --
+   Copyright (C) 2006 Red Hat
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: FIXME
+
+package gnu.testlet.java.awt.dnd.DropTargetDropEvent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Button;
+import java.awt.Point;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetContext;
+import java.awt.dnd.DropTargetDropEvent;
+
+public class Constructors
+    implements Testlet
+{
+  Button b = new Button("button");
+  DropTarget dt = new DropTarget(b, null);
+  DropTargetContext dtc = dt.getDropTargetContext();
+  Point loc = new Point();
+  boolean caught;
+  
+  public synchronized void test(TestHarness h)
+  {
+    testNullLoc(h);
+    testDropAction(h);
+    testSrcAction(h);
+    testNormal(h);
+  }
+  
+  void testNullLoc(TestHarness h)
+  {
+    caught = false;
+    try
+      {
+        new DropTargetDropEvent(dtc, null, DnDConstants.ACTION_COPY,
+                                DnDConstants.ACTION_COPY, false);
+      }
+    catch (NullPointerException npe)
+      {
+        caught = true;
+      }
+    h.check(caught);
+  }
+  
+  void testDropAction(TestHarness h)
+  {
+    caught = false;
+    try
+      {
+        new DropTargetDropEvent(dtc, loc, 4, DnDConstants.ACTION_COPY, false);
+      }
+    catch (IllegalArgumentException iae)
+      {
+        caught = true;
+      }
+    h.check(caught);
+  }
+  
+  void testSrcAction(TestHarness h)
+  {
+    caught = false;
+    try
+      {
+        new DropTargetDropEvent(dtc, loc, DnDConstants.ACTION_COPY, 4,false);
+      }
+    catch (IllegalArgumentException iae)
+      {
+        caught = true;
+      }
+    h.check(caught);
+  }
+  
+  void testNormal(TestHarness h)
+  {
+    caught = false;
+    DropTargetDropEvent dtde = null;
+    try
+      {
+        dtde = new DropTargetDropEvent(dtc, loc, DnDConstants.ACTION_COPY,
+                                DnDConstants.ACTION_COPY, true);
+      }
+    catch (Exception e)
+      {
+        caught = true;
+      }
+    
+    h.check(!caught);    
+    h.check(dtde != null && dtde.getDropAction() == DnDConstants.ACTION_COPY);
+    h.check(dtde != null && dtde.getSourceActions() == DnDConstants.ACTION_COPY);
+    h.check(dtde != null && dtde.getLocation().equals(loc));
+    h.check(dtde != null && dtde.isLocalTransfer());
+  }
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* FYI: New DnD Test
@ 2006-08-15 20:33 Lillian Angel
  0 siblings, 0 replies; 5+ messages in thread
From: Lillian Angel @ 2006-08-15 20:33 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

Added a new test.

2006-08-13  Lillian Angel  <langel@redhat.com>

        *
gnu/testlet/java/awt/dnd/DropTargetDragEvent/Constructors.java:
        New Test.


[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 3402 bytes --]

Index: gnu/testlet/java/awt/dnd/DropTargetDragEvent/Constructors.java
===================================================================
RCS file: gnu/testlet/java/awt/dnd/DropTargetDragEvent/Constructors.java
diff -N gnu/testlet/java/awt/dnd/DropTargetDragEvent/Constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/dnd/DropTargetDragEvent/Constructors.java	15 Aug 2006 20:32:14 -0000
@@ -0,0 +1,113 @@
+/* Constructors.java -- 
+   Copyright (C) 2006 Red Hat
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+package gnu.testlet.java.awt.dnd.DropTargetDragEvent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Button;
+import java.awt.Point;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetContext;
+import java.awt.dnd.DropTargetDragEvent;
+
+public class Constructors
+    implements Testlet
+{
+  Button b = new Button("button");
+  DropTarget dt = new DropTarget(b, null);
+  DropTargetContext dtc = dt.getDropTargetContext();
+  Point loc = new Point();
+  boolean caught;
+  
+  public synchronized void test(TestHarness h)
+  {
+    testNullLoc(h);
+    testDropAction(h);
+    testSrcAction(h);
+    testNormal(h);
+  }
+  
+  void testNullLoc(TestHarness h)
+  {
+    caught = false;
+    try
+      {
+        new DropTargetDragEvent(dtc, null, DnDConstants.ACTION_COPY,
+                                DnDConstants.ACTION_COPY);
+      }
+    catch (NullPointerException npe)
+      {
+        caught = true;
+      }
+    h.check(caught);
+  }
+  
+  void testDropAction(TestHarness h)
+  {
+    caught = false;
+    try
+      {
+        new DropTargetDragEvent(dtc, loc, 4, DnDConstants.ACTION_COPY);
+      }
+    catch (IllegalArgumentException iae)
+      {
+        caught = true;
+      }
+    h.check(caught);
+  }
+  
+  void testSrcAction(TestHarness h)
+  {
+    caught = false;
+    try
+      {
+        new DropTargetDragEvent(dtc, loc, DnDConstants.ACTION_COPY, 4);
+      }
+    catch (IllegalArgumentException iae)
+      {
+        caught = true;
+      }
+    h.check(caught);
+  }
+  
+  void testNormal(TestHarness h)
+  {
+    caught = false;
+    DropTargetDragEvent dtde = null;
+    try
+      {
+        dtde = new DropTargetDragEvent(dtc, loc, DnDConstants.ACTION_COPY,
+                                DnDConstants.ACTION_COPY);
+      }
+    catch (Exception e)
+      {
+        caught = true;
+      }
+    
+    h.check(!caught);    
+    h.check(dtde != null && dtde.getDropAction() == DnDConstants.ACTION_COPY);
+    h.check(dtde != null && dtde.getSourceActions() == DnDConstants.ACTION_COPY);
+    h.check(dtde != null && dtde.getLocation().equals(loc));
+  }
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* FYI: New Dnd test
@ 2006-08-10 19:51 Lillian Angel
  0 siblings, 0 replies; 5+ messages in thread
From: Lillian Angel @ 2006-08-10 19:51 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

Small test for DropTargetContext

2006-08-10  Lillian Angel  <langel@redhat.com>

        *
gnu/testlet/java/awt/dnd/DropTargetContext/DropTargetContextTest.java:
        New test.


[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 1798 bytes --]

Index: gnu/testlet/java/awt/dnd/DropTargetContext/DropTargetContextTest.java
===================================================================
RCS file: gnu/testlet/java/awt/dnd/DropTargetContext/DropTargetContextTest.java
diff -N gnu/testlet/java/awt/dnd/DropTargetContext/DropTargetContextTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/dnd/DropTargetContext/DropTargetContextTest.java	10 Aug 2006 19:49:17 -0000
@@ -0,0 +1,43 @@
+/* DropTargetContextTest.java -- 
+   Copyright (C) 2006 Red Hat
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+package gnu.testlet.java.awt.dnd.DropTargetContext;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Button;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetContext;
+
+public class DropTargetContextTest implements Testlet
+{
+  Button b = new Button("button");
+  DropTarget dt = new DropTarget(b, null);
+  
+  public void test(TestHarness h)
+  {
+    DropTargetContext dtc = dt.getDropTargetContext();
+    
+    h.check(dt, dtc.getDropTarget());
+    h.check(b, dtc.getComponent());    
+  }
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FYI: New DnD test
  2006-08-08 15:48 FYI: New DnD test Lillian Angel
@ 2006-08-08 15:50 ` Lillian Angel
  0 siblings, 0 replies; 5+ messages in thread
From: Lillian Angel @ 2006-08-08 15:50 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

2006-08-08  Lillian Angel  <langel@redhat.com>

        * gnu/testlet/java/awt/dnd/DnDTest.java
        (doDnD): Removed FIXME.


On Tue, 2006-08-08 at 11:48 -0400, Lillian Angel wrote:
> This test uses the Robot class to perform a drag and drop. It currently
> fails on Classpath.
> 
> 2006-08-08  Lillian Angel  <langel@redhat.com>
> 
>         * gnu/testlet/java/awt/dnd/DnDTest.java: New test.
> 

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 656 bytes --]

Index: gnu/testlet/java/awt/dnd/DnDTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/awt/dnd/DnDTest.java,v
retrieving revision 1.1
diff -u -r1.1 DnDTest.java
--- gnu/testlet/java/awt/dnd/DnDTest.java	8 Aug 2006 15:46:16 -0000	1.1
+++ gnu/testlet/java/awt/dnd/DnDTest.java	8 Aug 2006 15:49:36 -0000
@@ -139,7 +139,6 @@
       r.delay(1000);
       r.mouseMove(tLoc.x + tSize.width/2, tLoc.y + tSize.height/2);
       
-      // FIXME: Fix values, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4363409
       start = tLoc.y + tSize.height/2;
       end = start + 5;
         

^ permalink raw reply	[flat|nested] 5+ messages in thread

* FYI: New DnD test
@ 2006-08-08 15:48 Lillian Angel
  2006-08-08 15:50 ` Lillian Angel
  0 siblings, 1 reply; 5+ messages in thread
From: Lillian Angel @ 2006-08-08 15:48 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

This test uses the Robot class to perform a drag and drop. It currently
fails on Classpath.

2006-08-08  Lillian Angel  <langel@redhat.com>

        * gnu/testlet/java/awt/dnd/DnDTest.java: New test.


[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 8628 bytes --]

Index: gnu/testlet/java/awt/dnd/DnDTest.java
===================================================================
RCS file: gnu/testlet/java/awt/dnd/DnDTest.java
diff -N gnu/testlet/java/awt/dnd/DnDTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/dnd/DnDTest.java	8 Aug 2006 15:46:16 -0000	1.1
@@ -0,0 +1,316 @@
+/* DnDTest.java --
+   Copyright (C) 2006 Red Hat
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+
+package gnu.testlet.java.awt.dnd;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Label;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+
+public class DnDTest
+    implements Testlet
+{
+  TestHarness harness;
+  Robot r;
+
+  boolean unsuccessful;
+  boolean dragGestRec;
+  boolean dragEnter;
+  boolean dragEnterTar;
+  boolean dragOver;
+  boolean dragOverTar;
+  boolean drop;
+  boolean finished;
+  
+  public synchronized void test(TestHarness h)
+  {
+    harness = h;
+    r = harness.createRobot ();
+    
+    new MainClass("");
+  }
+
+  class MainClass
+      extends Frame
+      implements ActionListener, DropTargetListener
+  {
+    MouseThread mt;
+    int start;
+    int end;
+    DragLabel source = new DragLabel("Drag and drop me to the following Button",
+                                     Label.CENTER);
+    Button target = new Button();
+    
+    public MainClass(String title)
+    {
+      super(title);
+      source.setForeground(Color.red);
+      add(source, BorderLayout.NORTH);
+
+      target.addActionListener(this);
+      add(target, BorderLayout.SOUTH);
+
+      new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this);
+      setSize(205, 100);
+      setVisible(true);
+      
+      r.waitForIdle();
+      r.delay (1000);
+      
+      doDnD();
+      
+      r.delay(3000);
+
+      harness.check(!unsuccessful);
+      harness.check(finished);
+      harness.check(dragGestRec);
+      harness.check(dragEnter);
+      harness.check(dragEnterTar);
+      harness.check(dragOver);
+      harness.check(dragOverTar);
+      harness.check(drop);
+    }
+    
+    void doDnD()
+    {
+      Point sLoc = source.getLocationOnScreen();
+      Rectangle sSize = source.getBounds();
+
+      Point tLoc = target.getLocationOnScreen();
+      Rectangle tSize = target.getBounds();
+      
+      // To focus the window
+      r.mouseMove(sLoc.x + sSize.width/2, sLoc.y + sSize.height/2);
+      r.mousePress(InputEvent.BUTTON1_MASK);
+      r.mouseRelease(InputEvent.BUTTON1_MASK);
+
+      // drag and drop
+      r.delay(1000);
+      r.mousePress(InputEvent.BUTTON1_MASK);
+      r.delay(1000);
+      r.mouseMove(tLoc.x + tSize.width/2, tLoc.y + tSize.height/2);
+      
+      // FIXME: Fix values, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4363409
+      start = tLoc.y + tSize.height/2;
+      end = start + 5;
+        
+      mt = new MouseThread();
+      mt.start();
+      
+      r.delay(1000);
+      mt.shouldStop=true;
+      r.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+    
+    class MouseThread extends Thread
+    {
+        public boolean shouldStop;
+        public void run()
+        {
+            try
+            {
+                shouldStop=false;
+                Robot robot=new Robot();
+
+                for(;;)
+                {
+
+                    for(int i=start;i<end;i++)
+                    {
+                        if(shouldStop)break;
+                        robot.mouseMove(150,i);
+                        yield();
+                    }
+                    for(int i=end;i>start;i--)
+                    {
+                        if(shouldStop)break;
+                        robot.mouseMove(150,i);
+                        yield();
+                    }
+                    if(shouldStop)break;
+                }
+            }
+            catch(Exception e)
+            {
+                System.out.println(e);
+            }
+
+        }
+    }
+    
+    public void actionPerformed(ActionEvent e)
+    {
+      Button b = (Button) e.getSource();
+      b.setLabel("");
+      source.setText("Drag and drop me to the following Button");
+    }
+
+    public void dragEnter(DropTargetDragEvent e)
+    {
+      dragEnter = true;
+    }
+
+    public void dragExit(DropTargetEvent e)
+    {
+    }
+
+    public void dragOver(DropTargetDragEvent e)
+    {
+      dragOver = true;
+    }
+
+    public void drop(DropTargetDropEvent e)
+    {
+      drop = true;
+      try
+        {
+          Transferable t = e.getTransferable();
+
+          if (e.isDataFlavorSupported(DataFlavor.stringFlavor))
+            {
+              e.acceptDrop(e.getDropAction());
+
+              String s;
+              s = (String) t.getTransferData(DataFlavor.stringFlavor);
+
+              target.setLabel(s);
+
+              e.dropComplete(true);
+            }
+          else
+            {
+              unsuccessful = true;
+              e.rejectDrop();
+            }
+        }
+      catch (java.io.IOException e2)
+        {
+          unsuccessful = true;
+        }
+      catch (UnsupportedFlavorException e2)
+        {
+          unsuccessful = true;
+        }
+    }
+
+    public void dropActionChanged(DropTargetDragEvent e)
+    {
+    }
+  }
+
+  class DragLabel
+      extends Label
+      implements DragGestureListener, DragSourceListener
+  {
+    private DragSource ds = DragSource.getDefaultDragSource();
+
+    public DragLabel(String s, int alignment)
+    {
+      super(s, alignment);
+      int action = DnDConstants.ACTION_COPY_OR_MOVE;
+      ds.createDefaultDragGestureRecognizer(this, action, this);
+    }
+
+    public void dragGestureRecognized(DragGestureEvent e)
+    {
+      try
+        {
+          Transferable t = new StringSelection(getText());
+          e.startDrag(DragSource.DefaultCopyNoDrop, t, this);
+          dragGestRec = true;
+        }
+      catch (InvalidDnDOperationException e2)
+        {
+          unsuccessful = true;
+        }
+    }
+
+    public void dragDropEnd(DragSourceDropEvent e)
+    {
+      if (e.getDropSuccess() == false)
+        {
+          unsuccessful = true;
+          return;
+        }
+
+      int action = e.getDropAction();
+      if ((action & DnDConstants.ACTION_MOVE) != 0)
+        setText("");
+      finished = true;
+    }
+
+    public void dragEnter(DragSourceDragEvent e)
+    {
+      dragEnterTar = true;
+      DragSourceContext ctx = e.getDragSourceContext();
+
+      int action = e.getDropAction();
+      if ((action & DnDConstants.ACTION_COPY) != 0)
+        ctx.setCursor(DragSource.DefaultCopyDrop);
+      else
+        ctx.setCursor(DragSource.DefaultCopyNoDrop);
+    }
+
+    public void dragExit(DragSourceEvent e)
+    {
+    }
+
+    public void dragOver(DragSourceDragEvent e)
+    {
+      dragOverTar = true;
+    }
+
+    public void dropActionChanged(DragSourceDragEvent e)
+    {
+    }
+  }
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-08-17 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-17 15:20 FYI: New DnD test Lillian Angel
  -- strict thread matches above, loose matches on Subject: below --
2006-08-15 20:33 FYI: New DnD Test Lillian Angel
2006-08-10 19:51 FYI: New Dnd test Lillian Angel
2006-08-08 15:48 FYI: New DnD test Lillian Angel
2006-08-08 15:50 ` Lillian Angel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).