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:
@@ -94,7 +94,9 @@
|
||||
</target>
|
||||
|
||||
<target name="main"
|
||||
depends="prepare,compile.classes_spec,compile.src_share,compile.src_moz,compile.src_ie,create.webclient.scripts"/>
|
||||
depends="prepare,compile.classes_spec,compile.binaries,create.webclient.scripts"/>
|
||||
|
||||
<target name="compile.binaries" depends="compile.src_share,compile.src_moz,compile.src_ie" />
|
||||
|
||||
<target name="compile.classes_spec">
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: MCP.java,v 1.11 2007-06-13 16:57:17 edburns%acm.org Exp $
|
||||
* $Id: MCP.java,v 1.12 2007-06-14 02:03:33 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -516,16 +516,16 @@ public class MCP {
|
||||
*/
|
||||
|
||||
public void clickElement(Element element) {
|
||||
String clientX = null, clientY = null;
|
||||
String screenX = null, screenY = null;
|
||||
String id = element.getAttribute("id");
|
||||
if (null != element) {
|
||||
clientX = element.getAttribute("clientX");
|
||||
clientY = element.getAttribute("clientY");
|
||||
screenX = element.getAttribute("screenX");
|
||||
screenY = element.getAttribute("screenY");
|
||||
int x,y;
|
||||
if (null != clientX && null != clientY) {
|
||||
if (null != screenX && null != screenY) {
|
||||
try {
|
||||
x = Integer.valueOf(clientX).intValue();
|
||||
y = Integer.valueOf(clientY).intValue();
|
||||
x = Integer.valueOf(screenX).intValue();
|
||||
y = Integer.valueOf(screenY).intValue() - 5;
|
||||
Robot robot = getRobot();
|
||||
robot.mouseMove(x, y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
@@ -540,7 +540,7 @@ public class MCP {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null == element || null == clientX || null == clientY) {
|
||||
if (null == element || null == screenX || null == screenY) {
|
||||
throw new IllegalStateException("Unable to click element " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@ AjaxListener::ObserveAjax(nsIRequest *request,
|
||||
PRUint32 responseStatus = 0;
|
||||
PRInt32 readyState = 0;
|
||||
char buf[20];
|
||||
memset(buf, 0, 20);
|
||||
jstring jStr = nsnull;
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
jlong documentLong = nsnull;
|
||||
|
||||
@@ -1619,6 +1619,7 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous
|
||||
// PENDING(edburns): perhaps use a macro to speed this up?
|
||||
rv = mouseEvent->GetScreenX(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, properties, SCREEN_X_KEY,
|
||||
@@ -1629,6 +1630,7 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous
|
||||
|
||||
rv = mouseEvent->GetScreenY(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, properties, SCREEN_Y_KEY,
|
||||
@@ -1639,6 +1641,7 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous
|
||||
|
||||
rv = mouseEvent->GetClientX(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, properties, CLIENT_X_KEY,
|
||||
@@ -1649,6 +1652,7 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous
|
||||
|
||||
rv = mouseEvent->GetClientY(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, properties, CLIENT_Y_KEY,
|
||||
@@ -1660,6 +1664,7 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous
|
||||
int16Val = 0;
|
||||
rv = mouseEvent->GetButton(&int16Val);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(int16Val, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, properties, BUTTON_KEY,
|
||||
|
||||
@@ -372,7 +372,8 @@ nsresult EmbedEventListener::PopulatePropertiesFromEvent(nsIDOMEvent *event)
|
||||
}
|
||||
|
||||
// Store a Long into the properties under the key: NODE_LONG_KEY
|
||||
jlong longVal = (jlong) currentNode.get();
|
||||
PRUint32 longVal = (PRUint32) currentNode.get();
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(longVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
|
||||
@@ -422,6 +423,7 @@ nsresult EmbedEventListener::addMouseEventDataToProperties(nsCOMPtr<nsIDOMMouseE
|
||||
// PENDING(edburns): perhaps use a macro to speed this up?
|
||||
rv = mouseEvent->GetScreenX(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, mProperties, SCREEN_X_KEY,
|
||||
@@ -432,6 +434,10 @@ nsresult EmbedEventListener::addMouseEventDataToProperties(nsCOMPtr<nsIDOMMouseE
|
||||
|
||||
rv = mouseEvent->GetScreenY(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
#if (defined(XP_MAC) || defined(XP_MACOSX)) && defined(MOZ_WIDGET_COCOA)
|
||||
intVal -=5;
|
||||
#endif
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, mProperties, SCREEN_Y_KEY,
|
||||
@@ -442,6 +448,7 @@ nsresult EmbedEventListener::addMouseEventDataToProperties(nsCOMPtr<nsIDOMMouseE
|
||||
|
||||
rv = mouseEvent->GetClientX(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, mProperties, CLIENT_X_KEY,
|
||||
@@ -452,6 +459,7 @@ nsresult EmbedEventListener::addMouseEventDataToProperties(nsCOMPtr<nsIDOMMouseE
|
||||
|
||||
rv = mouseEvent->GetClientY(&intVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(intVal, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, mProperties, CLIENT_Y_KEY,
|
||||
@@ -463,6 +471,7 @@ nsresult EmbedEventListener::addMouseEventDataToProperties(nsCOMPtr<nsIDOMMouseE
|
||||
int16Val = 0;
|
||||
rv = mouseEvent->GetButton(&int16Val);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(int16Val, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, mProperties, BUTTON_KEY,
|
||||
@@ -539,6 +548,7 @@ nsresult EmbedEventListener::addKeyEventDataToProperties(nsCOMPtr<nsIDOMKeyEvent
|
||||
|
||||
rv = keyEvent->GetKeyCode(&int32Val);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
memset(buf, 0, 20);
|
||||
WC_ITOA(int32Val, buf, 10);
|
||||
strVal = ::util_NewStringUTF(env, buf);
|
||||
::util_StoreIntoPropertiesObject(env, mProperties, KEY_CODE,
|
||||
|
||||
@@ -61,8 +61,7 @@
|
||||
#endif
|
||||
//
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS)
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_MACOSX)
|
||||
#define WC_ITOA(intVal, buf, radix) sprintf(buf, "%d", intVal)
|
||||
#else
|
||||
#define WC_ITOA(intVal, buf, radix) itoa(intVal, buf, radix)
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>HistoryTest0</h1>
|
||||
<h1 id="HistoryTest0">HistoryTest0</h1>
|
||||
|
||||
<p>This is page 0 of the history test.</p>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user