One unit test is still failing: WindowCreator. Oof. Threading problem.

M webclient/build.xml

- separate out "compile.binaries" target

M webclient/classes_spec/org/mozilla/mcp/MCP.java

- account for mac coordinate wierdness.

M webclient/src_moz/AjaxListener.cpp
M webclient/src_moz/CBrowserContainer.cpp
M webclient/src_moz/EmbedEventListener.cpp
M webclient/src_moz/ns_util.h

- make sure to initialize the buffer before calling WC_ITOA

M webclient/test/automated/src/classes/org/mozilla/webclient/CurrentPageTest.java
M webclient/test/automated/src/classes/org/mozilla/webclient/KeyListenerTest.java
M webclient/test/automated/src/classes/org/mozilla/webclient/MouseListenerTest.java

- Make these tests run

M webclient/test/automated/src/test/HistoryTest0.html

- add an ID.

M webclient/test/manual/src/classes/org/mozilla/webclient/test/TestBrowser.java

- print out coordinates


git-svn-id: svn://10.0.0.236/trunk@228024 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2007-06-14 02:03:34 +00:00
parent 60a622726b
commit 04e78a3a4d
11 changed files with 118 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
/*
* $Id: CurrentPageTest.java,v 1.18 2007-06-12 14:21:02 edburns%acm.org Exp $
* $Id: CurrentPageTest.java,v 1.19 2007-06-14 02:03:34 edburns%acm.org Exp $
*/
/*
@@ -193,7 +193,7 @@ public class CurrentPageTest extends WebclientTestCase implements ClipboardOwner
buf.append(contentLine);
System.out.println(contentLine);
}
assertEquals(" <h1>HistoryTest0</h1><p>This is page 0 of the history test.</p><p><a id=\"HistoryTest1.html\" href=\"http://localhost:5243/HistoryTest1.html\">next</a></p> <hr> ",
assertEquals(" <h1 id=\"HistoryTest0\">HistoryTest0</h1><p>This is page 0 of the history test.</p><p><a id=\"HistoryTest1.html\" href=\"http://localhost:5243/HistoryTest1.html\">next</a></p> <hr> ",
buf.toString());

View File

@@ -1,5 +1,5 @@
/*
* $Id: KeyListenerTest.java,v 1.5 2007-05-04 17:10:35 edburns%acm.org Exp $
* $Id: KeyListenerTest.java,v 1.6 2007-06-14 02:03:34 edburns%acm.org Exp $
*/
/*
@@ -37,6 +37,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import java.awt.BorderLayout;
import org.mozilla.mcp.junit.WebclientTestCase;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -96,7 +97,6 @@ public class KeyListenerTest extends WebclientTestCase {
assertNotNull(canvas);
Frame frame = new Frame();
frame.setUndecorated(true);
frame.setBounds(0, 0, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
@@ -154,8 +154,7 @@ public class KeyListenerTest extends WebclientTestCase {
id = element.getAttribute("id"),
name = element.getAttribute("name"),
nodeName = domNode.getNodeName(),
value = domNode.getNodeValue();
assertEquals("field1", id);
value = domNode.getNodeValue(); assertEquals("field1", id);
assertEquals("field1", name);
assertEquals("INPUT", nodeName);
assertEquals("", value);
@@ -182,23 +181,33 @@ public class KeyListenerTest extends WebclientTestCase {
while (KeyListenerTest.keepWaiting) {
Thread.currentThread().sleep(1000);
}
Document dom = currentPage.getDOM();
assertNotNull(dom);
Element textField = dom.getElementById("field1");
assertNotNull(textField);
String screenX = textField.getAttribute("screenX");
String screenY = textField.getAttribute("screenY");
assertNotNull(screenX);
assertNotNull(screenY);
int x = Integer.valueOf(screenX).intValue();
int y = Integer.valueOf(screenY).intValue() - 5;
Robot robot = new Robot();
robot.mouseMove(IN_X, IN_Y);
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
/****
// uncomment to enable manual testing
/*************
KeyListenerTest.keepWaiting = true;
// keep waiting until the previous load completes
while (KeyListenerTest.keepWaiting) {
Thread.currentThread().sleep(1000);
}
******************/
****/
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);

View File

@@ -1,5 +1,5 @@
/*
* $Id: MouseListenerTest.java,v 1.4 2007-05-04 17:10:35 edburns%acm.org Exp $
* $Id: MouseListenerTest.java,v 1.5 2007-06-14 02:03:34 edburns%acm.org Exp $
*/
/*
@@ -26,6 +26,7 @@
package org.mozilla.webclient;
import java.awt.Rectangle;
import junit.framework.TestSuite;
import junit.framework.Test;
import java.util.Map;
@@ -38,6 +39,7 @@ import java.awt.event.MouseEvent;
import java.awt.event.InputEvent;
import java.awt.BorderLayout;
import org.mozilla.mcp.junit.WebclientTestCase;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -61,17 +63,15 @@ public class MouseListenerTest extends WebclientTestCase {
return (result);
}
static final int IN_X = 20;
static final int IN_Y = 117;
static final int OUT_X = 700;
static final int OUT_Y = 500;
static EventRegistration2 eventRegistration;
static CurrentPage2 currentPage = null;
static boolean keepWaiting;
int x;
int y;
//
// Constants
@@ -96,15 +96,14 @@ public class MouseListenerTest extends WebclientTestCase {
assertNotNull(firstBrowserControl);
History history = (History)
firstBrowserControl.queryInterface(BrowserControl.HISTORY_NAME);
BrowserControlCanvas canvas = (BrowserControlCanvas)
final BrowserControlCanvas canvas = (BrowserControlCanvas)
firstBrowserControl.queryInterface(BrowserControl.BROWSER_CONTROL_CANVAS_NAME);
eventRegistration = (EventRegistration2)
firstBrowserControl.queryInterface(BrowserControl.EVENT_REGISTRATION_NAME);
assertNotNull(canvas);
Frame frame = new Frame();
frame.setUndecorated(true);
frame.setBounds(0, 0, 640, 480);
final Frame frame = new Frame();
frame.setBounds(0, 30, 640, 480);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
canvas.setVisible(true);
@@ -127,8 +126,13 @@ public class MouseListenerTest extends WebclientTestCase {
// PENDING(edburns): flesh this out with more content
MouseListener mouseListener = new MouseListener() {
public void mouseEntered(MouseEvent e) {
assertEquals(IN_X, e.getX());
assertEquals(IN_Y, e.getY());
Rectangle
frameBounds = frame.getBounds(),
canvasBounds = canvas.getBounds();
assertEquals(MouseListenerTest.this.x, e.getX() +
frameBounds.x + canvasBounds.x);
assertEquals(MouseListenerTest.this.y, e.getY() +
frameBounds.y + canvasBounds.y);
assertTrue(e instanceof WCMouseEvent);
WCMouseEvent wcMouseEvent = (WCMouseEvent) e;
@@ -175,15 +179,6 @@ public class MouseListenerTest extends WebclientTestCase {
}
};
if (addToCanvas) {
canvas.addMouseListener(mouseListener);
}
else {
eventRegistration.addMouseListener(mouseListener);
}
Thread.currentThread().sleep(3000);
//
// load four files.
@@ -198,18 +193,57 @@ public class MouseListenerTest extends WebclientTestCase {
}
Robot robot = new Robot();
robot.mouseMove(IN_X, IN_Y);
Document dom = currentPage.getDOM();
assertNotNull(dom);
Element toClick = dom.getElementById("HistoryTest0");
assertNotNull(toClick);
String
screenX = toClick.getAttribute("screenX"),
screenY = toClick.getAttribute("screenY");
assertNotNull(screenX);
assertNotNull(screenY);
x = Integer.valueOf(screenX).intValue();
y = Integer.valueOf(screenY).intValue() - 5;
// Click the H1 just to ensure the window has focus.
robot.mouseMove(x,y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
// Now, add our test listener
if (addToCanvas) {
canvas.addMouseListener(mouseListener);
}
else {
eventRegistration.addMouseListener(mouseListener);
}
Thread.currentThread().sleep(3000);
toClick = dom.getElementById("HistoryTest1.html");
assertNotNull(toClick);
screenX = toClick.getAttribute("screenX");
screenY = toClick.getAttribute("screenY");
assertNotNull(screenX);
assertNotNull(screenY);
x = Integer.valueOf(screenX).intValue();
y = Integer.valueOf(screenY).intValue() - 5;
MouseListenerTest.keepWaiting = true;
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
while (MouseListenerTest.keepWaiting) {
Thread.currentThread().sleep(1000);
}
robot.mouseMove(OUT_X, OUT_Y);
robot.mouseMove(x + 50, y + 50);
Thread.currentThread().sleep(3000);

View File

@@ -5,7 +5,7 @@
</head>
<body>
<h1>HistoryTest0</h1>
<h1 id="HistoryTest0">HistoryTest0</h1>
<p>This is page 0 of the history test.</p>

View File

@@ -383,7 +383,11 @@ public class TestBrowser extends JPanel {
name = element.getAttribute("name"),
nodeName = domNode.getNodeName(),
value = domNode.getNodeValue(),
status = "";
status = "",
clientX = element.getAttribute("clientX"),
clientY = element.getAttribute("clientY"),
screenX = element.getAttribute("screenX"),
screenY = element.getAttribute("screenY");
if (null != href) {
// PENDING(edburns): take care of relative URL
status = href;
@@ -391,7 +395,10 @@ public class TestBrowser extends JPanel {
if (null != id || null != name || null != nodeName
|| null != value) {
status = status + " domNode: " + nodeName + " id: " + id
+ " name: " + name + " value: " + value;
+ " name: " + name + " value: " +
value + "client(" + clientX + "," +
clientY + ") screen(" + screenX + "," +
screenY + ")";
updateStatusInfo(status);
}
}