From d4d419c667ec37d118882d5550cb279fab9d17cd Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Wed, 23 Jun 2004 19:21:07 +0000 Subject: [PATCH] Got "back()" working. Next will be to get forward(), and can{Back,Forward}. A test/automated/src/classes/org/mozilla/webclient/DocumentLoadListenerImpl.java A test/automated/src/classes/org/mozilla/webclient/HistoryTest.java A test/automated/src/test/HistoryTest0.html A test/automated/src/test/HistoryTest1.html A test/automated/src/test/HistoryTest2.html A test/automated/src/test/HistoryTest3.html - new test content. M classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java M src_moz/HistoryImpl.cpp - expose back() method M src_moz/Makefile.in M test/automated/src/classes/org/mozilla/util/THTTPD.java - added way for the server to return the content type of the document M test/automated/src/classes/org/mozilla/webclient/NavigationTest.java - pulled out DocumentLoadListener into a separate class. --- java/webclient/build-tests.xml | 1 + .../impl/wrapper_native/HistoryImpl.java | 13 +- java/webclient/src_moz/HistoryImpl.cpp | 86 +++---- java/webclient/src_moz/Makefile.in | 2 +- .../src/classes/org/mozilla/util/THTTPD.java | 22 +- .../org/mozilla/webclient/HistoryTest.java | 235 ++++++++++++++++++ .../org/mozilla/webclient/NavigationTest.java | 42 +--- .../test/automated/src/test/HistoryTest0.html | 17 ++ .../test/automated/src/test/HistoryTest1.html | 17 ++ .../test/automated/src/test/HistoryTest2.html | 18 ++ .../test/automated/src/test/HistoryTest3.html | 17 ++ 11 files changed, 388 insertions(+), 82 deletions(-) create mode 100644 java/webclient/test/automated/src/classes/org/mozilla/webclient/HistoryTest.java create mode 100644 java/webclient/test/automated/src/test/HistoryTest0.html create mode 100644 java/webclient/test/automated/src/test/HistoryTest1.html create mode 100644 java/webclient/test/automated/src/test/HistoryTest2.html create mode 100644 java/webclient/test/automated/src/test/HistoryTest3.html diff --git a/java/webclient/build-tests.xml b/java/webclient/build-tests.xml index dc985ae64cea..a058da94307d 100644 --- a/java/webclient/build-tests.xml +++ b/java/webclient/build-tests.xml @@ -151,6 +151,7 @@ + diff --git a/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java b/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java index 177d446714b2..27c160028e26 100644 --- a/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java +++ b/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java @@ -1,4 +1,4 @@ -/* -*- 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 @@ -79,9 +79,12 @@ public void back() getWrapperFactory().verifyInitialized(); Assert.assert_it(-1 != getNativeBrowserControl()); - synchronized(getBrowserControl()) { - nativeBack(getNativeBrowserControl()); - } + NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() { + public Object run() { + nativeBack(getNativeBrowserControl()); + return null; + } + }); } public boolean canBack() @@ -283,7 +286,7 @@ public static void main(String [] args) Assert.setEnabled(true); Log.setApplicationName("HistoryImpl"); Log.setApplicationVersion("0.0"); - Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.3 2004/04/10 21:50:38 edburns%acm.org Exp $"); + Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.4 2004/06/23 19:21:05 edburns%acm.org Exp $"); } diff --git a/java/webclient/src_moz/HistoryImpl.cpp b/java/webclient/src_moz/HistoryImpl.cpp index 0ce6d1ad31dc..a6a143185cdd 100644 --- a/java/webclient/src_moz/HistoryImpl.cpp +++ b/java/webclient/src_moz/HistoryImpl.cpp @@ -27,41 +27,39 @@ #include "org_mozilla_webclient_impl_wrapper_0005fnative_HistoryImpl.h" -#include "HistoryActionEvents.h" - #include "ns_util.h" +#include "NativeBrowserControl.h" #include "nsCRT.h" - JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeBack -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { - JNIEnv * pEnv = env; - jobject jobj = obj; + JNIEnv * pEnv = env; + jobject jobj = obj; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr; - if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellBack"); - return; - } - - if (initContext->initComplete) { - wsBackEvent * actionEvent = - new wsBackEvent(initContext->webNavigation); - PLEvent * event = (PLEvent*) *actionEvent; + if (nativeBrowserControl == nsnull) { + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeBack"); + return; + } - ::util_PostEvent(initContext, event); + nsresult rv = + nativeBrowserControl->mNavigation->GoBack(); + if (NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Exception: Can't GoBack"); } return; } +/******************* + JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBack -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { jboolean result = JNI_FALSE; JNIEnv * pEnv = env; @@ -69,10 +67,10 @@ JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBac void * voidResult; // PRBool voidResult; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellCanBack"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellCanBack"); return result; } @@ -90,7 +88,7 @@ JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBac } JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetBackList -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { jobjectArray result = nsnull; @@ -99,21 +97,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_H JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeClearHistory -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { } JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeForward -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { JNIEnv * pEnv = env; jobject jobj = obj; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellForward"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellForward"); return; } @@ -129,17 +127,17 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryIm } JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanForward -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { jboolean result = JNI_FALSE; JNIEnv * pEnv = env; jobject jobj = obj; void * voidResult; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellCanForward"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellCanForward"); return result; } @@ -157,7 +155,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Histo } JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetForwardList -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { jobjectArray result = nsnull; @@ -165,7 +163,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_H } JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistory -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { jobjectArray result = nsnull; @@ -174,7 +172,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_H JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryEntry -(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex) +(JNIEnv *env, jobject obj, jint nativeBCPtr, jint historyIndex) { jobject result = nsnull; @@ -183,17 +181,17 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryEntr JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIndex -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { JNIEnv * pEnv = env; jobject jobj = obj; void * voidResult = nsnull; jint result = -1; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryIndex"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellGetHistoryIndex"); return result; } @@ -212,15 +210,15 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetCurrentHist JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIndex -(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex) +(JNIEnv *env, jobject obj, jint nativeBCPtr, jint historyIndex) { JNIEnv * pEnv = env; jobject jobj = obj; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetCurrentHistoryIndex"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeSetCurrentHistoryIndex"); return; } @@ -237,17 +235,17 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeSetCurrentHist JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryLength -(JNIEnv *env, jobject obj, jint webShellPtr) +(JNIEnv *env, jobject obj, jint nativeBCPtr) { JNIEnv * pEnv = env; jobject jobj = obj; void * voidResult = nsnull; jint result = -1; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryLength"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellGetHistoryLength"); return result; } @@ -265,17 +263,17 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryLeng } JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetURLForIndex -(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex) +(JNIEnv *env, jobject obj, jint nativeBCPtr, jint historyIndex) { JNIEnv * pEnv = env; jobject jobj = obj; char * charResult = nsnull; jstring urlString = nsnull; - NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr; + NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr; if (initContext == nsnull) { - ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetURL"); + ::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellGetURL"); return nsnull; } @@ -299,3 +297,5 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Histor return urlString; } + +**********************/ diff --git a/java/webclient/src_moz/Makefile.in b/java/webclient/src_moz/Makefile.in index e4b0c76a34ba..9a11849270d3 100644 --- a/java/webclient/src_moz/Makefile.in +++ b/java/webclient/src_moz/Makefile.in @@ -89,13 +89,13 @@ REQUIRES = xpcom \ # CBrowserContainer.cpp \ # PromptActionEvents.cpp \ # CurrentPageActionEvents.cpp \ -# HistoryImpl.cpp \ # HistoryActionEvents.cpp \ # ISupportsPeer.cpp \ # NativeEventThreadActionEvents.cpp \ # WindowControlActionEvents.cpp \ CPPSRCS = \ + HistoryImpl.cpp \ WindowCreator.cpp \ nsActions.cpp \ NavigationActionEvents.cpp \ diff --git a/java/webclient/test/automated/src/classes/org/mozilla/util/THTTPD.java b/java/webclient/test/automated/src/classes/org/mozilla/util/THTTPD.java index c8d6218b8ca2..810677eb22f9 100644 --- a/java/webclient/test/automated/src/classes/org/mozilla/util/THTTPD.java +++ b/java/webclient/test/automated/src/classes/org/mozilla/util/THTTPD.java @@ -1,5 +1,5 @@ /* - * $Id: THTTPD.java,v 1.2 2004/06/22 19:23:23 edburns%acm.org Exp $ + * $Id: THTTPD.java,v 1.3 2004/06/23 19:21:06 edburns%acm.org Exp $ */ /* @@ -126,7 +126,10 @@ public class THTTPD extends Object { while (null != (curLine = responseReader.readLine())) { responseString.append(curLine); } - curLine = "Content-type: text/plain\r\nContent-Length: " + responseString.length() + "\r\n\r\n"; + curLine = "Content-type: " + + getContentTypeForFile(responseFile) + + "\r\nContent-Length: " + + responseString.length() + "\r\n\r\n"; responseWriter.write(curLine, 0, curLine.length()); responseWriter.write(responseString.toString(), @@ -176,6 +179,21 @@ public class THTTPD extends Object { return result; } + protected String getContentTypeForFile(File file) { + String + fileName = file.getName(), + result = "text/plain"; + + int lastDot = fileName.lastIndexOf("."); + if (-1 != lastDot) { + result = fileName.substring(lastDot+1); + if (result.equalsIgnoreCase("html")) { + result = "text/html"; + } + } + return result; + } + public synchronized void P() { while (count <= 0) { try { wait(); } catch (InterruptedException ex) {} diff --git a/java/webclient/test/automated/src/classes/org/mozilla/webclient/HistoryTest.java b/java/webclient/test/automated/src/classes/org/mozilla/webclient/HistoryTest.java new file mode 100644 index 000000000000..cadc805c5558 --- /dev/null +++ b/java/webclient/test/automated/src/classes/org/mozilla/webclient/HistoryTest.java @@ -0,0 +1,235 @@ +/* + * $Id: HistoryTest.java,v 1.1 2004/06/23 19:21:06 edburns%acm.org Exp $ + */ + +/* + * + * 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 mozilla.org code. + * + * The Initial Developer of the Original Code is Sun + * Microsystems, Inc. Portions created by Sun are + * Copyright (C) 1999 Sun Microsystems, Inc. All + * Rights Reserved. + * + * Contributor(s): Ed Burns <edburns@acm.org> + */ + +package org.mozilla.webclient; + +import org.mozilla.util.THTTPD; + +import junit.framework.TestSuite; +import junit.framework.TestResult; +import junit.framework.Test; + +import java.util.Enumeration; + +import java.awt.Frame; +import java.awt.BorderLayout; + +import java.io.File; +import java.io.FileInputStream; + +// HistoryTest.java + +public class HistoryTest extends WebclientTestCase { + + public HistoryTest(String name) { + super(name); + try { + BrowserControlFactory.setAppData(getBrowserBinDir()); + } + catch (Exception e) { + fail(); + } + } + + public static Test suite() { + TestSuite result = new TestSuite() { + public void run(TestResult result) { + serverThread = + new THTTPD.ServerThread("LocalHTTPD", + new File (getBrowserBinDir() + + "/../../java/webclient/build.test"), -1); + serverThread.start(); + serverThread.P(); + super.run(result); + try { + BrowserControlFactory.appTerminate(); + } + catch (Exception e) { + fail(); + } + serverThread.stopRunning(); + } + }; + result.addTestSuite(HistoryTest.class); + return (result); + } + + static THTTPD.ServerThread serverThread; + + static EventRegistration2 eventRegistration; + + static CurrentPage2 currentPage = null; + + static boolean keepWaiting; + + // + // Constants + // + + // + // Testcases + // + + public void testHistory() throws Exception { + BrowserControl firstBrowserControl = null; + DocumentLoadListenerImpl listener = null; + Selection selection = null; + firstBrowserControl = BrowserControlFactory.newBrowserControl(); + assertNotNull(firstBrowserControl); + History history = (History) + firstBrowserControl.queryInterface(BrowserControl.HISTORY_NAME); + 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() { + HistoryTest.keepWaiting = false; + } + }); + + Thread.currentThread().sleep(3000); + + + // + // load four files. + // + HistoryTest.keepWaiting = true; + nav.loadURL("http://localhost:5243/HistoryTest0.html"); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + HistoryTest.keepWaiting = true; + nav.loadURL("http://localhost:5243/HistoryTest1.html"); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + HistoryTest.keepWaiting = true; + nav.loadURL("http://localhost:5243/HistoryTest2.html"); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + HistoryTest.keepWaiting = true; + nav.loadURL("http://localhost:5243/HistoryTest3.html"); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + eventRegistration.removeDocumentLoadListener(listener); + + // + // new DocumentLoadListenerImpl that + + // + // Step back through each and verify selection + // + HistoryVerify historyListener = new HistoryVerify(); + + eventRegistration.addDocumentLoadListener(historyListener); + + HistoryTest.keepWaiting = true; + historyListener.setStringToVerify("This is page 2 of the history test."); + history.back(); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + HistoryTest.keepWaiting = true; + historyListener.setStringToVerify("This is page 1 of the history test."); + history.back(); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + HistoryTest.keepWaiting = true; + historyListener.setStringToVerify("This is page 0 of the history test."); + history.back(); + + // keep waiting until the previous load completes + while (HistoryTest.keepWaiting) { + Thread.currentThread().sleep(1000); + } + + eventRegistration.removeDocumentLoadListener(historyListener); + + + frame.setVisible(false); + BrowserControlFactory.deleteBrowserControl(firstBrowserControl); + } + + public static class HistoryVerify extends DocumentLoadListenerImpl { + + protected String stringToVerify = ""; + public String getStringToVerify() { + return stringToVerify; + } + + public void setStringToVerify(String newStringToVerify) { + stringToVerify = newStringToVerify; + } + + public void doEndCheck() { + currentPage.selectAll(); + Selection selection = currentPage.getSelection(); + assertTrue(-1 !=selection.toString().indexOf(getStringToVerify())); + System.out.println("Selection is: " + + selection.toString()); + HistoryTest.keepWaiting = false; + } + } +} diff --git a/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java b/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java index 033f6bccbfc1..e86bb4d97c2e 100644 --- a/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java +++ b/java/webclient/test/automated/src/classes/org/mozilla/webclient/NavigationTest.java @@ -1,5 +1,5 @@ /* - * $Id: NavigationTest.java,v 1.16 2004/06/23 17:08:23 edburns%acm.org Exp $ + * $Id: NavigationTest.java,v 1.17 2004/06/23 19:21:06 edburns%acm.org Exp $ */ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -93,7 +93,7 @@ public class NavigationTest extends WebclientTestCase { public void testFileAndStreamLoad() throws Exception { BrowserControl firstBrowserControl = null; - DocumentListener listener = null; + DocumentLoadListenerImpl listener = null; Selection selection = null; firstBrowserControl = BrowserControlFactory.newBrowserControl(); assertNotNull(firstBrowserControl); @@ -128,7 +128,7 @@ public class NavigationTest extends WebclientTestCase { NavigationTest.keepWaiting = true; System.out.println("Loading url: " + testPage.toURL().toString()); - eventRegistration.addDocumentLoadListener(listener = new DocumentListener() { + eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() { public void doEndCheck() { currentPage.selectAll(); Selection selection = currentPage.getSelection(); @@ -152,7 +152,7 @@ public class NavigationTest extends WebclientTestCase { // RandomHTMLInputStream rhis = new RandomHTMLInputStream(10, false); - eventRegistration.addDocumentLoadListener(listener = new DocumentListener() { + eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() { public void doEndCheck() { currentPage.selectAll(); Selection selection = currentPage.getSelection(); @@ -177,7 +177,7 @@ public class NavigationTest extends WebclientTestCase { NavigationTest.keepWaiting = true; FileInputStream fis = new FileInputStream(testPage); - eventRegistration.addDocumentLoadListener(listener = new DocumentListener() { + eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() { public void doEndCheck() { currentPage.selectAll(); Selection selection = currentPage.getSelection(); @@ -200,7 +200,7 @@ public class NavigationTest extends WebclientTestCase { } public void testStop() throws Exception { - DocumentListener listener = null; + DocumentLoadListenerImpl listener = null; BrowserControl firstBrowserControl = BrowserControlFactory.newBrowserControl(); assertNotNull(firstBrowserControl); BrowserControlCanvas canvas = (BrowserControlCanvas) @@ -228,7 +228,7 @@ public class NavigationTest extends WebclientTestCase { // RandomHTMLInputStream rhis = new RandomHTMLInputStream(10, false); - eventRegistration.addDocumentLoadListener(listener = new DocumentListener() { + eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() { private int progressCalls = 0; public void doProgressCheck() { @@ -259,7 +259,7 @@ public class NavigationTest extends WebclientTestCase { public void testRefresh() throws Exception { BrowserControl firstBrowserControl = null; - DocumentListener listener = null; + DocumentLoadListenerImpl listener = null; Selection selection = null; firstBrowserControl = BrowserControlFactory.newBrowserControl(); assertNotNull(firstBrowserControl); @@ -290,7 +290,7 @@ public class NavigationTest extends WebclientTestCase { NavigationTest.keepWaiting = true; - listener = new DocumentListener() { + listener = new DocumentLoadListenerImpl() { public void doEndCheck() { currentPage.selectAll(); Selection selection = currentPage.getSelection(); @@ -330,7 +330,7 @@ public class NavigationTest extends WebclientTestCase { public void testHttpLoad() throws Exception { BrowserControl firstBrowserControl = null; - DocumentListener listener = null; + DocumentLoadListenerImpl listener = null; Selection selection = null; firstBrowserControl = BrowserControlFactory.newBrowserControl(); assertNotNull(firstBrowserControl); @@ -362,7 +362,7 @@ public class NavigationTest extends WebclientTestCase { NavigationTest.keepWaiting = true; - eventRegistration.addDocumentLoadListener(listener = new DocumentListener() { + eventRegistration.addDocumentLoadListener(listener = new DocumentLoadListenerImpl() { public void doEndCheck() { currentPage.selectAll(); Selection selection = currentPage.getSelection(); @@ -389,24 +389,4 @@ public class NavigationTest extends WebclientTestCase { BrowserControlFactory.deleteBrowserControl(firstBrowserControl); } - public static abstract class DocumentListener implements DocumentLoadListener { - - public void eventDispatched(WebclientEvent event) { - if (event instanceof DocumentLoadEvent) { - switch ((int) event.getType()) { - case ((int) DocumentLoadEvent.END_DOCUMENT_LOAD_EVENT_MASK): - doEndCheck(); - break; - case ((int) DocumentLoadEvent.PROGRESS_URL_LOAD_EVENT_MASK): - doProgressCheck(); - break; - } - } - } - - public void doEndCheck() {} - - public void doProgressCheck() {} - } - } diff --git a/java/webclient/test/automated/src/test/HistoryTest0.html b/java/webclient/test/automated/src/test/HistoryTest0.html new file mode 100644 index 000000000000..aad0a6dee132 --- /dev/null +++ b/java/webclient/test/automated/src/test/HistoryTest0.html @@ -0,0 +1,17 @@ + + + + HistoryTest0 + + + +

HistoryTest0

+ +

This is page 0 of the history test.

+ +

next

+ + +
+ + diff --git a/java/webclient/test/automated/src/test/HistoryTest1.html b/java/webclient/test/automated/src/test/HistoryTest1.html new file mode 100644 index 000000000000..50b38a27db4a --- /dev/null +++ b/java/webclient/test/automated/src/test/HistoryTest1.html @@ -0,0 +1,17 @@ + + + + HistoryTest1 + + + +

HistoryTest1

+ +

This is page 1 of the history test.

+ +

next

+ + +
+ + diff --git a/java/webclient/test/automated/src/test/HistoryTest2.html b/java/webclient/test/automated/src/test/HistoryTest2.html new file mode 100644 index 000000000000..a28fba78eebb --- /dev/null +++ b/java/webclient/test/automated/src/test/HistoryTest2.html @@ -0,0 +1,18 @@ + + + + HistoryTest2 + + + +

HistoryTest2

+ +

This is page 2 of the history test.

+ +

next

+ + + +
+ + diff --git a/java/webclient/test/automated/src/test/HistoryTest3.html b/java/webclient/test/automated/src/test/HistoryTest3.html new file mode 100644 index 000000000000..3d2ebfceb17e --- /dev/null +++ b/java/webclient/test/automated/src/test/HistoryTest3.html @@ -0,0 +1,17 @@ + + + + HistoryTest3 + + + +

HistoryTest3

+ +

This is page 3 of the history test.

+ +

start over

+ + +
+ +