Next step is to try to re-enable the printing APIs. Not sure if this

will work.

A test/automated/src/test/DOMSelectionTest.html

- test CurrentPage.highlightSelection and clearAllSelections().

M classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java

- send all native methods through the event thread

M classes_spec/org/mozilla/webclient/impl/wrapper_native/SelectionImpl.java

- never return null from toString().  Return "" instead.

M src_moz/CurrentPageImpl.cpp

- copy from CurrentPageActionEvents.cpp

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

- new test conent


git-svn-id: svn://10.0.0.236/trunk@169173 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2005-02-14 02:16:18 +00:00
parent a686f22491
commit a5d1754eb2
6 changed files with 271 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
/*
* $Id: CurrentPageTest.java,v 1.7 2005-02-12 21:29:47 edburns%acm.org Exp $
* $Id: CurrentPageTest.java,v 1.8 2005-02-14 02:16:18 edburns%acm.org Exp $
*/
/*
@@ -44,6 +44,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedReader;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
// CurrentPageTest.java
public class CurrentPageTest extends WebclientTestCase implements ClipboardOwner {
@@ -301,5 +304,81 @@ public class CurrentPageTest extends WebclientTestCase implements ClipboardOwner
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
}
public void testHighlightDomRegion() throws Exception {
BrowserControl firstBrowserControl = null;
DocumentLoadListenerImpl listener = null;
Selection selection = null;
firstBrowserControl = BrowserControlFactory.newBrowserControl();
assertNotNull(firstBrowserControl);
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);
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
canvas.setVisible(true);
Navigation2 nav = (Navigation2)
firstBrowserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
assertNotNull(nav);
currentPage = (CurrentPage2)
firstBrowserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
assertNotNull(currentPage);
eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() {
public void doEndCheck() {
CurrentPageTest.keepWaiting = false;
}
});
Thread.currentThread().sleep(3000);
CurrentPageTest.keepWaiting = true;
nav.loadURL("http://localhost:5243/DOMSelectionTest.html");
// keep waiting until the previous load completes
while (CurrentPageTest.keepWaiting) {
Thread.currentThread().sleep(1000);
}
Document dom = currentPage.getDOM();
assertNotNull(dom);
Node
start = dom.getElementById("p2"),
end = dom.getElementById("p4");
assertNotNull(start);
assertNotNull(end);
selection = currentPage.getSelection();
selection.init("", start, end, 0, 0);
// select Paragraphs 2 - 4 exclusive
currentPage.highlightSelection(selection);
Thread.currentThread().sleep(3000); // PENDING remove
selection = currentPage.getSelection();
assertTrue(-1 == selection.toString().indexOf("Paragraph 1"));
assertTrue(-1 != selection.toString().indexOf("Paragraph 2"));
assertTrue(-1 != selection.toString().indexOf("Paragraph 3"));
assertTrue(-1 == selection.toString().indexOf("Paragraph 4"));
assertTrue(-1 == selection.toString().indexOf("Paragraph 5"));
currentPage.clearAllSelections();
selection = currentPage.getSelection();
assertEquals(0, selection.toString().length());
frame.setVisible(false);
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
}
}

View File

@@ -1,5 +1,5 @@
/*
* $Id: DOMTest.java,v 1.1 2005-02-04 15:43:47 edburns%acm.org Exp $
* $Id: DOMTest.java,v 1.2 2005-02-14 02:16:18 edburns%acm.org Exp $
*/
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
@@ -73,7 +73,7 @@ public class DOMTest extends WebclientTestCase {
// Testcases
//
public void testHttpLoad() throws Exception {
public void testGetDOM() throws Exception {
BrowserControl firstBrowserControl = null;
DocumentLoadListenerImpl listener = null;
Selection selection = null;

View File

@@ -0,0 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>DOM Selection Test</title>
</head>
<body>
<h1>DOM Selection Test</h1>
<p id="p1">Paragraph 1</p>
<p id="p2">Paragraph 2</p>
<p id="p3">Paragraph 3</p>
<p id="p4">Paragraph 4</p>
<p id="p5">Paragraph 5</p>
<hr>
<!-- Created: Sun Feb 13 11:20:10 Eastern Standard Time 2005 -->
<!-- hhmts start -->
Last modified: Sun Feb 13 11:21:35 Eastern Standard Time 2005
<!-- hhmts end -->
</body>
</html>