Next really will be to get POST working.

A test/automated/src/classes/org/mozilla/webclient/DocumentLoadListenerImpl.java

- Forgot to add this.

M classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java
M src_moz/HistoryImpl.cpp

- push through can{back,forward}(), forward().

M test/automated/src/classes/org/mozilla/webclient/HistoryTest.java

- exercise new methods.
This commit is contained in:
edburns%acm.org 2004-06-23 19:58:12 +00:00
Родитель 14ed3630a3
Коммит f230524ab5
4 изменённых файлов: 153 добавлений и 105 удалений

Просмотреть файл

@ -91,12 +91,16 @@ public boolean canBack()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
boolean result = false;
synchronized(getBrowserControl()) {
result = nativeCanBack(getNativeBrowserControl());
Boolean result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
public Object run() {
boolean canBack = nativeCanBack(getNativeBrowserControl());
return new Boolean(canBack);
}
return result;
});
return result.booleanValue();
}
public HistoryEntry [] getBackList()
@ -127,30 +131,38 @@ public void clearHistory()
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::clearHistory has not yet been implemented.\n");
}
public void forward()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
public Object run() {
nativeForward(getNativeBrowserControl());
return null;
}
});
}
public boolean canForward()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
boolean result = false;
synchronized(getBrowserControl()) {
result = nativeCanForward(getNativeBrowserControl());
Boolean result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
public Object run() {
boolean canForward = nativeCanForward(getNativeBrowserControl());
return new Boolean(canForward);
}
return result;
});
return result.booleanValue();
}
public HistoryEntry [] getForwardList()
{
HistoryEntry [] result = null;
@ -275,21 +287,4 @@ public native int nativeGetHistoryLength(int webShellPtr);
public native String nativeGetURLForIndex(int webShellPtr, int historyIndex);
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("HistoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.4 2004-06-23 19:21:05 edburns%acm.org Exp $");
}
// ----VERTIGO_TEST_END
} // end of class HistoryImpl

Просмотреть файл

@ -55,8 +55,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeBack
return;
}
/*******************
JNIEXPORT jboolean
JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBack
(JNIEnv *env, jobject obj, jint nativeBCPtr)
@ -64,29 +62,73 @@ JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBac
jboolean result = JNI_FALSE;
JNIEnv * pEnv = env;
jobject jobj = obj;
void * voidResult;
// PRBool voidResult;
NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr;
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellCanBack");
if (nativeBrowserControl == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeCanBack");
return result;
}
if (initContext->initComplete) {
wsCanBackEvent * actionEvent =
new wsCanBackEvent(initContext->webNavigation);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
result = (PR_FALSE == ((PRBool) voidResult)) ? JNI_FALSE : JNI_TRUE;
nsresult rv =
nativeBrowserControl->mNavigation->GetCanGoBack((PRBool *) &result);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: Can't GetCanGoBack");
}
return result;
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeForward
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
JNIEnv * pEnv = env;
jobject jobj = obj;
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nativeBrowserControl == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeForward");
return;
}
nsresult rv =
nativeBrowserControl->mNavigation->GoForward();
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: Can't GoForward");
}
return;
}
JNIEXPORT jboolean
JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanForward
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
jboolean result = JNI_FALSE;
JNIEnv * pEnv = env;
jobject jobj = obj;
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nativeBrowserControl == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to nativeCanForward");
return result;
}
nsresult rv =
nativeBrowserControl->mNavigation->GetCanGoForward((PRBool *) &result);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: Can't GetCanGoForward");
}
return result;
}
/*******************
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetBackList
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
@ -102,58 +144,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeClearHistory
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeForward
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
JNIEnv * pEnv = env;
jobject jobj = obj;
NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellForward");
return;
}
if (initContext->initComplete) {
wsForwardEvent * actionEvent =
new wsForwardEvent(initContext->webNavigation);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
}
return;
}
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanForward
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
jboolean result = JNI_FALSE;
JNIEnv * pEnv = env;
jobject jobj = obj;
void * voidResult;
NativeBrowserControl* initContext = (NativeBrowserControl *) nativeBCPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBCPtr passed to raptorWebShellCanForward");
return result;
}
if (initContext->initComplete) {
wsCanForwardEvent * actionEvent =
new wsCanForwardEvent(initContext->webNavigation);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
result = (PR_FALSE == ((PRBool) voidResult)) ? JNI_FALSE : JNI_TRUE;
}
return result;
}
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetForwardList
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{

Просмотреть файл

@ -0,0 +1,48 @@
/*
* $Id: DocumentLoadListenerImpl.java,v 1.1 2004-06-23 19:58:12 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;
public abstract class DocumentLoadListenerImpl 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() {}
}

Просмотреть файл

@ -1,5 +1,5 @@
/*
* $Id: HistoryTest.java,v 1.1 2004-06-23 19:21:06 edburns%acm.org Exp $
* $Id: HistoryTest.java,v 1.2 2004-06-23 19:58:12 edburns%acm.org Exp $
*/
/*
@ -135,6 +135,9 @@ public class HistoryTest extends WebclientTestCase {
// load four files.
//
HistoryTest.keepWaiting = true;
assertTrue(!history.canBack());
assertTrue(!history.canForward());
nav.loadURL("http://localhost:5243/HistoryTest0.html");
// keep waiting until the previous load completes
@ -143,6 +146,8 @@ public class HistoryTest extends WebclientTestCase {
}
HistoryTest.keepWaiting = true;
assertTrue(!history.canBack());
assertTrue(!history.canForward());
nav.loadURL("http://localhost:5243/HistoryTest1.html");
// keep waiting until the previous load completes
@ -151,6 +156,8 @@ public class HistoryTest extends WebclientTestCase {
}
HistoryTest.keepWaiting = true;
assertTrue(history.canBack());
assertTrue(!history.canForward());
nav.loadURL("http://localhost:5243/HistoryTest2.html");
// keep waiting until the previous load completes
@ -159,6 +166,8 @@ public class HistoryTest extends WebclientTestCase {
}
HistoryTest.keepWaiting = true;
assertTrue(history.canBack());
assertTrue(!history.canForward());
nav.loadURL("http://localhost:5243/HistoryTest3.html");
// keep waiting until the previous load completes
@ -180,6 +189,8 @@ public class HistoryTest extends WebclientTestCase {
HistoryTest.keepWaiting = true;
historyListener.setStringToVerify("This is page 2 of the history test.");
assertTrue(history.canBack());
assertTrue(!history.canForward());
history.back();
// keep waiting until the previous load completes
@ -189,6 +200,8 @@ public class HistoryTest extends WebclientTestCase {
HistoryTest.keepWaiting = true;
historyListener.setStringToVerify("This is page 1 of the history test.");
assertTrue(history.canBack());
assertTrue(history.canForward());
history.back();
// keep waiting until the previous load completes
@ -198,6 +211,8 @@ public class HistoryTest extends WebclientTestCase {
HistoryTest.keepWaiting = true;
historyListener.setStringToVerify("This is page 0 of the history test.");
assertTrue(history.canBack());
assertTrue(history.canForward());
history.back();
// keep waiting until the previous load completes