This enables "refresh". Next step will be to enable history next and
back. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M src_moz/NavigationImpl.cpp - push thru "refresh" behavior. M test/automated/src/classes/org/mozilla/webclient/NavigationTest.java - move test HTTPD server out so it can be used by all tests in suite. M test/automated/src/classes/org/mozilla/webclient/WebclientTestCase.java - make getBrowserBinDir() static.
This commit is contained in:
Родитель
0ec5bbae9b
Коммит
37987a4b25
|
@ -123,11 +123,17 @@ public void refresh(long loadFlags)
|
|||
{
|
||||
ParameterCheck.noLessThan(loadFlags, 0);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
final long finalLoadFlags = loadFlags;
|
||||
Assert.assert_it(-1 != getNativeBrowserControl());
|
||||
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeRefresh(getNativeBrowserControl(), loadFlags);
|
||||
}
|
||||
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
|
||||
public Object run() {
|
||||
nativeRefresh(NavigationImpl.this.getNativeBrowserControl(),
|
||||
finalLoadFlags);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void stop()
|
||||
|
@ -235,7 +241,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("NavigationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.9 2004-06-16 14:37:33 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.10 2004-06-23 17:08:14 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
|
|
@ -271,6 +271,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
|||
delete [] headersAndData;
|
||||
return;
|
||||
}
|
||||
*********************/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeRefresh
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jlong loadFlags)
|
||||
|
@ -285,19 +286,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
|||
return;
|
||||
}
|
||||
|
||||
if (nativeBrowserControl->initComplete) {
|
||||
wsRefreshEvent * actionEvent = new wsRefreshEvent(nativeBrowserControl->webNavigation, (PRInt32) loadFlags);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(nativeBrowserControl, event);
|
||||
|
||||
return;
|
||||
}
|
||||
nsresult rv =
|
||||
nativeBrowserControl->mNavigation->Reload(loadFlags);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't refresh");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
*********************/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeStop
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: NavigationTest.java,v 1.15 2004-06-22 19:23:23 edburns%acm.org Exp $
|
||||
* $Id: NavigationTest.java,v 1.16 2004-06-23 17:08:23 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
|
@ -57,6 +57,12 @@ public class NavigationTest extends WebclientTestCase {
|
|||
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();
|
||||
|
@ -64,12 +70,15 @@ public class NavigationTest extends WebclientTestCase {
|
|||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
serverThread.stopRunning();
|
||||
}
|
||||
};
|
||||
result.addTestSuite(NavigationTest.class);
|
||||
return (result);
|
||||
}
|
||||
|
||||
static THTTPD.ServerThread serverThread;
|
||||
|
||||
static EventRegistration2 eventRegistration;
|
||||
|
||||
static boolean keepWaiting;
|
||||
|
@ -248,6 +257,77 @@ public class NavigationTest extends WebclientTestCase {
|
|||
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
|
||||
}
|
||||
|
||||
public void testRefresh() throws Exception {
|
||||
BrowserControl firstBrowserControl = null;
|
||||
DocumentListener 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);
|
||||
final CurrentPage2 currentPage = (CurrentPage2)
|
||||
firstBrowserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
|
||||
|
||||
assertNotNull(currentPage);
|
||||
|
||||
//
|
||||
// try loading a file over HTTP
|
||||
//
|
||||
|
||||
NavigationTest.keepWaiting = true;
|
||||
|
||||
listener = new DocumentListener() {
|
||||
public void doEndCheck() {
|
||||
currentPage.selectAll();
|
||||
Selection selection = currentPage.getSelection();
|
||||
NavigationTest.keepWaiting = false;
|
||||
assertTrue(-1 != selection.toString().indexOf("This file was downloaded over HTTP."));
|
||||
System.out.println("Selection is: " +
|
||||
selection.toString());
|
||||
}
|
||||
};
|
||||
|
||||
eventRegistration.addDocumentLoadListener(listener);
|
||||
|
||||
String url = "http://localhost:5243/HttpNavigationTest.txt";
|
||||
|
||||
Thread.currentThread().sleep(3000);
|
||||
|
||||
nav.loadURL(url);
|
||||
|
||||
// keep waiting until the previous load completes
|
||||
while (NavigationTest.keepWaiting) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
}
|
||||
|
||||
NavigationTest.keepWaiting = true;
|
||||
nav.refresh(Navigation.LOAD_FORCE_RELOAD);
|
||||
|
||||
// keep waiting until the re-load completes
|
||||
while (NavigationTest.keepWaiting) {
|
||||
Thread.currentThread().sleep(1000);
|
||||
}
|
||||
|
||||
eventRegistration.removeDocumentLoadListener(listener);
|
||||
|
||||
frame.setVisible(false);
|
||||
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
|
||||
}
|
||||
|
||||
public void testHttpLoad() throws Exception {
|
||||
BrowserControl firstBrowserControl = null;
|
||||
DocumentListener listener = null;
|
||||
|
@ -281,20 +361,12 @@ public class NavigationTest extends WebclientTestCase {
|
|||
|
||||
NavigationTest.keepWaiting = true;
|
||||
|
||||
final THTTPD.ServerThread serverThread =
|
||||
new THTTPD.ServerThread("LocalHTTPD",
|
||||
new File (getBrowserBinDir() +
|
||||
"/../../java/webclient/build.test"), 1);
|
||||
serverThread.setSoTimeout(15000);
|
||||
serverThread.start();
|
||||
serverThread.P();
|
||||
|
||||
eventRegistration.addDocumentLoadListener(listener = new DocumentListener() {
|
||||
public void doEndCheck() {
|
||||
currentPage.selectAll();
|
||||
Selection selection = currentPage.getSelection();
|
||||
NavigationTest.keepWaiting = false;
|
||||
serverThread.stopRunning();
|
||||
assertTrue(-1 != selection.toString().indexOf("This file was downloaded over HTTP."));
|
||||
System.out.println("Selection is: " +
|
||||
selection.toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: WebclientTestCase.java,v 1.6 2004-06-18 13:53:13 edburns%acm.org Exp $
|
||||
* $Id: WebclientTestCase.java,v 1.7 2004-06-23 17:08:23 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -44,7 +44,7 @@ import junit.framework.TestCase;
|
|||
*
|
||||
* <B>Lifetime And Scope</B> <P>
|
||||
*
|
||||
* @version $Id: WebclientTestCase.java,v 1.6 2004-06-18 13:53:13 edburns%acm.org Exp $
|
||||
* @version $Id: WebclientTestCase.java,v 1.7 2004-06-23 17:08:23 edburns%acm.org Exp $
|
||||
*
|
||||
* @see Blah
|
||||
* @see Bloo
|
||||
|
@ -134,13 +134,13 @@ protected void verifyLogModuleValueIsAtLeastN(String logModuleName, int n)
|
|||
|
||||
}
|
||||
|
||||
protected void verifyBinDirSet()
|
||||
protected static void verifyBinDirSet()
|
||||
{
|
||||
assertTrue("BROWSER_BIN_DIR is not set",
|
||||
null != System.getProperty("BROWSER_BIN_DIR"));
|
||||
}
|
||||
|
||||
protected String getBrowserBinDir() {
|
||||
protected static String getBrowserBinDir() {
|
||||
return System.getProperty("BROWSER_BIN_DIR");
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче