зеркало из https://github.com/mozilla/pjs.git
M dist/build.xml
- added a target to ease iterative development M dist/netbeans/logging.properties - turn on logging for all mozilla java classes M webclient/classes_spec/org/mozilla/mcp/MCP.java - make the logger package private A webclient/classes_spec/org/mozilla/mcp/RandomHTMLInputStream.java R webclient/classes_spec/org/mozilla/webclient/test/RandomHTMLInputStream.java R webclient/test/automated/src/classes/org/mozilla/webclient/RandomHTMLInputStream.java - rewrote and copied this here so THTTPD could use it. M webclient/classes_spec/org/mozilla/mcp/THTTPD.java - use RandomHtmlInputStream for the NavigationTest.stopTest(). M webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java M webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java - use THTTPD to create RandomHTMLInputStream instances.
This commit is contained in:
Родитель
616e145d3f
Коммит
996449e8c8
|
@ -72,6 +72,20 @@
|
|||
<antcall target="build.zip" />
|
||||
</target>
|
||||
|
||||
<target name="test-release"
|
||||
description="Build a Webclient Release">
|
||||
|
||||
<antcall target="prepare" />
|
||||
<antcall target="uptodate" />
|
||||
<antcall target="compile.all" />
|
||||
<antcall target="build.dist.jar" />
|
||||
<antcall target="copy.binaries" />
|
||||
<antcall target="copy.test.src" />
|
||||
<antcall target="copy.core.src" />
|
||||
<antcall target="copy.build.support" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="build.zip">
|
||||
<condition property="platform" value="win32">
|
||||
<and>
|
||||
|
|
|
@ -8,5 +8,5 @@ java.util.logging.FileHandler.limit = 50000
|
|||
java.util.logging.FileHandler.append = true
|
||||
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
|
||||
|
||||
org.mozilla.webclient.level=ALL
|
||||
org.mozilla.level=ALL
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: MCP.java,v 1.10 2007-05-04 17:10:17 edburns%acm.org Exp $
|
||||
* $Id: MCP.java,v 1.11 2007-06-13 16:57:17 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -71,7 +71,7 @@ public class MCP {
|
|||
private static final String MCP_LOG = "org.mozilla.mcp";
|
||||
private static final String MCP_LOG_STRINGS = "org.mozilla.mcp.MCPLogStrings";
|
||||
|
||||
private static final Logger LOGGER = getLogger(MCP_LOG);
|
||||
static final Logger LOGGER = getLogger(MCP_LOG);
|
||||
|
||||
private static Logger getLogger( String loggerName ) {
|
||||
return Logger.getLogger(loggerName, MCP_LOG_STRINGS );
|
||||
|
|
|
@ -0,0 +1,335 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.mcp;
|
||||
|
||||
/*
|
||||
* RandomHTMLInputStream.java
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
|
||||
* This class simulates a nasty, misbehavin' InputStream.
|
||||
|
||||
* It randomly throws IOExceptions, blocks on read, and is bursty.
|
||||
|
||||
*/
|
||||
|
||||
class RandomHTMLInputStream extends InputStream
|
||||
{
|
||||
|
||||
//
|
||||
// Class variables
|
||||
//
|
||||
|
||||
private static final int MAX_AVAILABLE = 4096;
|
||||
private static final int MIN_AVAILABLE = 71;
|
||||
|
||||
private static final String HTML_START = "<HTML><BODY><PRE>START Random Data\n";
|
||||
private static final String HTML_END = "\nEND Random Data</PRE></BODY></HTML>\n";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* This makes it so only when we get a random between 0 and 100 number
|
||||
* that evenly divides by three do we throw an IOException
|
||||
|
||||
*/
|
||||
|
||||
private static final int EXCEPTION_DIVISOR = 179;
|
||||
|
||||
private static final byte [] CHARSET;
|
||||
|
||||
//
|
||||
// relationship ivars
|
||||
//
|
||||
|
||||
private Random random;
|
||||
|
||||
//
|
||||
// attribute ivars
|
||||
//
|
||||
|
||||
private boolean isClosed;
|
||||
|
||||
private boolean firstRead;
|
||||
|
||||
private boolean randomExceptions = true;
|
||||
|
||||
/**
|
||||
|
||||
* the number of times that read(bytearray) can be called and still get
|
||||
* data.
|
||||
|
||||
*/
|
||||
|
||||
private int numReads;
|
||||
|
||||
private int available;
|
||||
|
||||
/**
|
||||
|
||||
* @param yourNumReads must be at least 2
|
||||
|
||||
*/
|
||||
|
||||
static {
|
||||
String charSet = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890[]{}";
|
||||
CHARSET = charSet.getBytes();
|
||||
}
|
||||
|
||||
public RandomHTMLInputStream(int yourNumReads, boolean yourRandomExceptions)
|
||||
{
|
||||
this(yourNumReads, -1, yourRandomExceptions);
|
||||
}
|
||||
|
||||
public RandomHTMLInputStream(int yourNumReads, int size, boolean yourRandomExceptions)
|
||||
{
|
||||
randomExceptions = yourRandomExceptions;
|
||||
|
||||
random = new Random(1234);
|
||||
|
||||
isClosed = false;
|
||||
firstRead = true;
|
||||
numReads = yourNumReads;
|
||||
if (-1 == size) {
|
||||
available = MAX_AVAILABLE;
|
||||
}
|
||||
else {
|
||||
available = size;
|
||||
}
|
||||
}
|
||||
|
||||
public int available() throws IOException
|
||||
{
|
||||
int result;
|
||||
if (shouldThrowException()) {
|
||||
throw new IOException("It's time for an IOException!");
|
||||
}
|
||||
if (isClosed) {
|
||||
result = 0;
|
||||
}
|
||||
else {
|
||||
result = available;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int read() throws IOException
|
||||
{
|
||||
int result = 0;
|
||||
if (shouldThrowException()) {
|
||||
throw new IOException("It's time for an IOException!");
|
||||
}
|
||||
|
||||
if (0 < available) {
|
||||
result = (int) 'a';
|
||||
available--;
|
||||
}
|
||||
else {
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int read(byte[] b, int off, int len) throws IOException
|
||||
{
|
||||
if (shouldThrowException()) {
|
||||
throw new IOException("It's time for an IOException!");
|
||||
}
|
||||
|
||||
byte [] bytes;
|
||||
int i = 0;
|
||||
int max = 0;
|
||||
int numRead = 0;
|
||||
|
||||
// base write case, the stream has been closed
|
||||
if (isClosed) {
|
||||
return -1;
|
||||
}
|
||||
// write case 0, no more reads left
|
||||
if (0 == numReads) {
|
||||
available = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (firstRead) {
|
||||
maybeSleep();
|
||||
// write case 1, yes enough length to write htmlHead
|
||||
max = HTML_START.length();
|
||||
if (numRead < len) {
|
||||
bytes = HTML_START.getBytes();
|
||||
for (i = 0; i < max; i++) {
|
||||
b[off+i] = bytes[i];
|
||||
}
|
||||
numRead += max;
|
||||
available -= max;
|
||||
}
|
||||
firstRead = false;
|
||||
}
|
||||
else {
|
||||
// If this is the last read...
|
||||
if (1 == numReads) {
|
||||
numRead = writeHTMLEnd(b, off, len);
|
||||
}
|
||||
else {
|
||||
// If we have more bytes than HTML_END.length...
|
||||
if (HTML_END.length() <= available) {
|
||||
// Write some random stuff.
|
||||
// If what we have is greater than or equal to what was asked for...
|
||||
if (len <= available) {
|
||||
// If both len and available are less than or equal to HTML_END...
|
||||
if ((len - HTML_END.length()) <= 0) {
|
||||
// just write HTML_END.
|
||||
numRead = writeHTMLEnd(b, off, len);
|
||||
numReads = 0;
|
||||
return numRead;
|
||||
}
|
||||
else {
|
||||
// otherwise, write some filler
|
||||
max = len - HTML_END.length();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// otherwise, write some filler
|
||||
max = available - HTML_END.length();
|
||||
if (0 == max) {
|
||||
// just write HTML_END.
|
||||
numRead = writeHTMLEnd(b, off, len);
|
||||
numReads = 0;
|
||||
return numRead;
|
||||
}
|
||||
}
|
||||
maybeSleep();
|
||||
bytes = new byte[max];
|
||||
for (i = 0; i < max; i++) {
|
||||
if (0 == (i % 78)) {
|
||||
b[off+i] = (byte) '\n';
|
||||
}
|
||||
else {
|
||||
b[off+i] = CHARSET[random.nextInt(CHARSET.length)];
|
||||
}
|
||||
}
|
||||
numRead += max;
|
||||
available -= max;
|
||||
}
|
||||
else {
|
||||
// Otherwise, just write HTML_END
|
||||
writeHTMLEnd(b, off, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
numReads--;
|
||||
return numRead;
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
if (shouldThrowException()) {
|
||||
throw new IOException("It's time for an IOException!");
|
||||
}
|
||||
isClosed = true;
|
||||
try {
|
||||
synchronized(this) {
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IOException("RandomHTMLInputStream: Can't notify listeners");
|
||||
}
|
||||
}
|
||||
|
||||
private int writeHTMLEnd(byte [] b, int off, int len) {
|
||||
int numRead = -1;
|
||||
byte [] bytes = HTML_END.getBytes();
|
||||
int i, max = 0;
|
||||
|
||||
// Determine how many bytes of HTML_END to write.
|
||||
|
||||
// If we have enough space to write out HTML_END,...
|
||||
if (bytes.length <= available) {
|
||||
// verify the caller can handle all of HTML_END...
|
||||
if (bytes.length <= len) {
|
||||
// write out the whole HTML_END.
|
||||
max = bytes.length;
|
||||
}
|
||||
// if not, write out only the first len bytes of HTML_END
|
||||
else {
|
||||
max = len;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We do not have enough space to write out HTML_END.
|
||||
if (available <= len) {
|
||||
// If what we have is less than or equal to what the caller asked for...
|
||||
max = available;
|
||||
}
|
||||
else {
|
||||
// What we have is more than the caller asked for.
|
||||
max = len;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < max; i++) {
|
||||
b[off+i] = bytes[i];
|
||||
}
|
||||
numRead = max;
|
||||
available -= max;
|
||||
|
||||
return numRead;
|
||||
}
|
||||
|
||||
private void maybeSleep() throws IOException {
|
||||
if (random.nextBoolean()) {
|
||||
try {
|
||||
System.out.println("RandomHTMLInputStream:: sleeping");
|
||||
System.out.flush();
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldThrowException()
|
||||
{
|
||||
if (!randomExceptions) {
|
||||
return false;
|
||||
}
|
||||
int nextInt = random.nextInt(10000);
|
||||
|
||||
boolean result = false;
|
||||
|
||||
if (nextInt > EXCEPTION_DIVISOR) {
|
||||
result = (0 == (nextInt % EXCEPTION_DIVISOR));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: THTTPD.java,v 1.1 2007-05-04 17:10:17 edburns%acm.org Exp $
|
||||
* $Id: THTTPD.java,v 1.2 2007-06-13 16:57:17 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -27,6 +27,7 @@
|
|||
package org.mozilla.mcp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -34,7 +35,8 @@ import java.io.InputStreamReader;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.net.SocketException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
// THTTPD.java
|
||||
|
@ -43,6 +45,22 @@ public class THTTPD extends Object {
|
|||
|
||||
public final static int PORT = 5243;
|
||||
|
||||
public static InputStream newRandomHtmlInputStream(int yourNumReads,
|
||||
boolean yourRandomExceptions) {
|
||||
InputStream result = new RandomHTMLInputStream(yourNumReads,
|
||||
yourRandomExceptions);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static InputStream newRandomHtmlInputStream(int yourNumReads,
|
||||
int yourSize,
|
||||
boolean yourRandomExceptions) {
|
||||
InputStream result = new RandomHTMLInputStream(yourNumReads,
|
||||
yourSize,
|
||||
yourRandomExceptions);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class ServerThread extends Thread {
|
||||
|
||||
protected File root = null;
|
||||
|
@ -96,7 +114,7 @@ public class THTTPD extends Object {
|
|||
responseReader = null,
|
||||
requestReader = null;
|
||||
InputStream socketInputStream = null;
|
||||
BufferedWriter
|
||||
OutputStreamWriter
|
||||
responseWriter = null;
|
||||
String
|
||||
requestLine = null,
|
||||
|
@ -139,19 +157,37 @@ public class THTTPD extends Object {
|
|||
System.out.println("THTTPD: POST");
|
||||
// intentional fall through!
|
||||
case REQUEST_GET:
|
||||
responseWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
|
||||
if (null !=
|
||||
(responseFile = getFileForRequestURI(getRequestURI(requestLine)))) {
|
||||
curLine = "HTTP/1.0 200 OK\r\n";
|
||||
responseWriter = new OutputStreamWriter(socket.getOutputStream(), "US-ASCII");
|
||||
curLine = "HTTP/1.0 200 OK\r\nServer: THTTPD\r\n";
|
||||
responseWriter.write(curLine, 0, curLine.length());
|
||||
String requestURI = getRequestURI(requestLine);
|
||||
responseReader = null;
|
||||
if (requestURI.equals("/randomHtml")) {
|
||||
curLine = "Content-type: text/html\r\n\r\n";
|
||||
responseWriter.write(curLine, 0,
|
||||
curLine.length());
|
||||
RandomHTMLInputStream instance = new RandomHTMLInputStream(100, 65380, false);
|
||||
InputStreamReader isr = new InputStreamReader(instance,
|
||||
"US-ASCII");
|
||||
int n;
|
||||
char [] line = new char[2048];
|
||||
while (-1 != (n = isr.read(line, 0, 2048))) {
|
||||
curLine = new String(line, 0, n);
|
||||
responseWriter.write(curLine, 0, curLine.length());
|
||||
responseWriter.flush();
|
||||
}
|
||||
if (-1 == n) {
|
||||
responseWriter.close();
|
||||
}
|
||||
|
||||
} else if (null != (responseFile =
|
||||
getFileForRequestURI(requestURI))) {
|
||||
responseReader = new BufferedReader(new InputStreamReader(new FileInputStream(responseFile)));
|
||||
responseString = new StringBuffer();
|
||||
responseString = new StringBuffer();
|
||||
while (null != (curLine = responseReader.readLine())) {
|
||||
responseString.append(curLine);
|
||||
}
|
||||
curLine = "Server: THTTPD\r\n" +
|
||||
"Content-type: " +
|
||||
curLine = "Content-type: " +
|
||||
getContentTypeForFile(responseFile) +
|
||||
"\r\nContent-Length: " +
|
||||
responseString.length() + "\r\n\r\n";
|
||||
|
@ -168,9 +204,30 @@ public class THTTPD extends Object {
|
|||
socket.close();
|
||||
serverSocket.close();
|
||||
}
|
||||
catch (SocketException se) {
|
||||
if (MCP.LOGGER.isLoggable(Level.SEVERE)) {
|
||||
MCP.LOGGER.log(Level.SEVERE,
|
||||
"Error while writing response", se);
|
||||
}
|
||||
try {
|
||||
socket.close();
|
||||
serverSocket.close();
|
||||
} catch (IOException ex) {
|
||||
if (MCP.LOGGER.isLoggable(Level.SEVERE)) {
|
||||
MCP.LOGGER.log(Level.SEVERE,
|
||||
"Error while trying to clean up after SocketException. Exiting Server.",
|
||||
ex);
|
||||
}
|
||||
stopRunning();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("Exception: " + e + " " +
|
||||
e.getMessage());
|
||||
if (MCP.LOGGER.isLoggable(Level.SEVERE)) {
|
||||
MCP.LOGGER.log(Level.SEVERE,
|
||||
"Error serving response. Exiting Server.",
|
||||
e);
|
||||
}
|
||||
stopRunning();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import javax.swing.*;
|
|||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.*;
|
||||
import org.mozilla.mcp.RandomHTMLInputStream;
|
||||
|
||||
import org.mozilla.webclient.*;
|
||||
import org.mozilla.util.Assert;
|
||||
|
@ -59,7 +60,7 @@ import java.io.FileInputStream;
|
|||
* This is a test application for using the BrowserControl.
|
||||
|
||||
*
|
||||
* @version $Id: EMWindow.java,v 1.45 2004-09-09 20:17:16 edburns%acm.org Exp $
|
||||
* @version $Id: EMWindow.java,v 1.46 2007-06-13 16:57:17 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: NavigationTest.java,v 1.22 2007-05-04 17:10:35 edburns%acm.org Exp $
|
||||
* $Id: NavigationTest.java,v 1.23 2007-06-13 16:57:17 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
|
@ -26,6 +26,7 @@
|
|||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.io.InputStream;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
|
@ -36,6 +37,7 @@ import java.awt.BorderLayout;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import org.mozilla.mcp.THTTPD;
|
||||
import org.mozilla.mcp.junit.WebclientTestCase;
|
||||
|
||||
// NavigationTest.java
|
||||
|
@ -83,8 +85,7 @@ public class NavigationTest extends WebclientTestCase {
|
|||
|
||||
assertNotNull(canvas);
|
||||
Frame frame = new Frame();
|
||||
frame.setUndecorated(true);
|
||||
frame.setBounds(0, 0, 640, 480);
|
||||
frame.setBounds(0, 30, 640, 480);
|
||||
frame.add(canvas, BorderLayout.CENTER);
|
||||
frame.setVisible(true);
|
||||
canvas.setVisible(true);
|
||||
|
@ -129,7 +130,7 @@ public class NavigationTest extends WebclientTestCase {
|
|||
//
|
||||
// try loading from the dreaded RandomHTMLInputStream
|
||||
//
|
||||
RandomHTMLInputStream rhis = new RandomHTMLInputStream(10, false);
|
||||
InputStream rhis = THTTPD.newRandomHtmlInputStream(10, 13320, false);
|
||||
|
||||
eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() {
|
||||
public void doEndCheck() {
|
||||
|
@ -189,8 +190,7 @@ public class NavigationTest extends WebclientTestCase {
|
|||
|
||||
assertNotNull(canvas);
|
||||
Frame frame = new Frame();
|
||||
frame.setUndecorated(true);
|
||||
frame.setBounds(0, 0, 640, 480);
|
||||
frame.setBounds(0, 30, 640, 480);
|
||||
frame.add(canvas, BorderLayout.CENTER);
|
||||
frame.setVisible(true);
|
||||
canvas.setVisible(true);
|
||||
|
@ -202,23 +202,18 @@ public class NavigationTest extends WebclientTestCase {
|
|||
firstBrowserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
|
||||
|
||||
NavigationTest.keepWaiting = true;
|
||||
//
|
||||
// try loading from the dreaded RandomHTMLInputStream
|
||||
//
|
||||
RandomHTMLInputStream rhis = new RandomHTMLInputStream(10, false);
|
||||
|
||||
eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() {
|
||||
private int progressCalls = 0;
|
||||
|
||||
public void doProgressCheck() {
|
||||
if (5 == ++progressCalls) {
|
||||
if (2 == ++progressCalls) {
|
||||
nav.stop();
|
||||
NavigationTest.keepWaiting = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
nav.loadFromStream(rhis, "http://randomstream.com/",
|
||||
"text/html", -1, null);
|
||||
nav.loadURL("http://localhost:5243/randomHtml");
|
||||
|
||||
// keep waiting until the previous load completes
|
||||
while (NavigationTest.keepWaiting) {
|
||||
|
@ -249,7 +244,6 @@ public class NavigationTest 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);
|
||||
|
@ -267,8 +261,40 @@ public class NavigationTest extends WebclientTestCase {
|
|||
// try loading a file over HTTP
|
||||
//
|
||||
|
||||
// clear cache listener
|
||||
|
||||
listener = new DocumentLoadListenerImpl() {
|
||||
public void doEndCheck() {
|
||||
NavigationTest.keepWaiting = false;
|
||||
}
|
||||
};
|
||||
|
||||
eventRegistration.addDocumentLoadListener(listener);
|
||||
|
||||
String url = "http://localhost:5243/HttpNavigationTest.txt";
|
||||
|
||||
Thread.currentThread().sleep(3000);
|
||||
NavigationTest.keepWaiting = true;
|
||||
|
||||
nav.loadURL(url);
|
||||
|
||||
// keep waiting until the previous load completes
|
||||
while (NavigationTest.keepWaiting) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
}
|
||||
|
||||
NavigationTest.keepWaiting = true;
|
||||
nav.loadURL(url);
|
||||
|
||||
// keep waiting until the previous load completes
|
||||
while (NavigationTest.keepWaiting) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
eventRegistration.removeDocumentLoadListener(listener);
|
||||
|
||||
listener = new DocumentLoadListenerImpl() {
|
||||
public void doEndCheck() {
|
||||
currentPage.selectAll();
|
||||
|
@ -282,13 +308,15 @@ public class NavigationTest extends WebclientTestCase {
|
|||
|
||||
eventRegistration.addDocumentLoadListener(listener);
|
||||
|
||||
String url = "http://localhost:5243/HttpNavigationTest.txt";
|
||||
url = "http://localhost:5243/HttpNavigationTest.txt";
|
||||
|
||||
Thread.currentThread().sleep(3000);
|
||||
|
||||
nav.loadURL(url);
|
||||
NavigationTest.keepWaiting = true;
|
||||
|
||||
// keep waiting until the previous load completes
|
||||
nav.loadURL(url);
|
||||
|
||||
// keep waiting until the previous load completes
|
||||
while (NavigationTest.keepWaiting) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
}
|
||||
|
@ -320,7 +348,6 @@ public class NavigationTest 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);
|
||||
|
@ -381,7 +408,6 @@ public class NavigationTest 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче