You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/11/16 01:04:20 UTC
android commit: CB-1864: Figured out how to simulate back button,
test both the CordovaWebView back button and the general DroidGap
case using the default implementation
Updated Branches:
refs/heads/master f4612fdb5 -> 6c19a440f
CB-1864: Figured out how to simulate back button, test both the CordovaWebView back button and the general DroidGap case using the default implementation
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/6c19a440
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/6c19a440
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/6c19a440
Branch: refs/heads/master
Commit: 6c19a440f5d7faa3955e039749a3a907af012acc
Parents: f4612fd
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Nov 15 16:04:09 2012 -0800
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Nov 15 16:04:09 2012 -0800
----------------------------------------------------------------------
.../cordova/test/BackButtonMultiPageTest.java | 49 +++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/6c19a440/test/src/org/apache/cordova/test/BackButtonMultiPageTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/BackButtonMultiPageTest.java b/test/src/org/apache/cordova/test/BackButtonMultiPageTest.java
index fa3e0b0..6d4a7ac 100644
--- a/test/src/org/apache/cordova/test/BackButtonMultiPageTest.java
+++ b/test/src/org/apache/cordova/test/BackButtonMultiPageTest.java
@@ -26,6 +26,7 @@ import org.apache.cordova.test.actions.backbuttonmultipage;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
+import android.view.inputmethod.BaseInputConnection;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -97,6 +98,54 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
assertTrue(didGoBack);
}
+ public void testViaBackButtonOnView() {
+ testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
+ sleep();
+ String url = testView.getUrl();
+ assertTrue(url.endsWith("sample2.html"));
+ testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
+ sleep();
+ url = testView.getUrl();
+ assertTrue(url.endsWith("sample3.html"));
+ BaseInputConnection viewConnection = new BaseInputConnection(testView, true);
+ KeyEvent backDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
+ KeyEvent backUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
+ viewConnection.sendKeyEvent(backDown);
+ viewConnection.sendKeyEvent(backUp);
+ sleep();
+ url = testView.getUrl();
+ assertTrue(url.endsWith("sample2.html"));
+ viewConnection.sendKeyEvent(backDown);
+ viewConnection.sendKeyEvent(backUp);
+ sleep();
+ url = testView.getUrl();
+ assertTrue(url.endsWith("index.html"));
+ }
+
+ public void testViaBackButtonOnLayout() {
+ testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
+ sleep();
+ String url = testView.getUrl();
+ assertTrue(url.endsWith("sample2.html"));
+ testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
+ sleep();
+ url = testView.getUrl();
+ assertTrue(url.endsWith("sample3.html"));
+ BaseInputConnection viewConnection = new BaseInputConnection(containerView, true);
+ KeyEvent backDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
+ KeyEvent backUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
+ viewConnection.sendKeyEvent(backDown);
+ viewConnection.sendKeyEvent(backUp);
+ sleep();
+ url = testView.getUrl();
+ assertTrue(url.endsWith("sample2.html"));
+ viewConnection.sendKeyEvent(backDown);
+ viewConnection.sendKeyEvent(backUp);
+ sleep();
+ url = testView.getUrl();
+ assertTrue(url.endsWith("index.html"));
+ }
+
private void sleep() {
try {
Thread.sleep(TIMEOUT);