cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject 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
Date Fri, 16 Nov 2012 00:04:20 GMT
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 <bowserj@apache.org>
Authored: Thu Nov 15 16:04:09 2012 -0800
Committer: Joe Bowser <bowserj@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);


Mime
View raw message