cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: Added two more required methods to CordovaWebView to get the Junit tests running, removed tests that make no sense
Date Wed, 14 May 2014 18:09:28 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/pluggable_webview e595c313a -> b6664cc85


Added two more required methods to CordovaWebView to get the Junit tests running, removed
tests that make no sense


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/b6664cc8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/b6664cc8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/b6664cc8

Branch: refs/heads/pluggable_webview
Commit: b6664cc859fdea4039a223466e4eddddc3426d94
Parents: e595c31
Author: Joe Bowser <bowserj@apache.org>
Authored: Wed May 14 11:08:46 2014 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Wed May 14 11:09:21 2014 -0700

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebView.java  |  5 ++
 test/res/layout/main.xml                        |  2 +-
 test/src/org/apache/cordova/test/basicauth.java | 44 -----------
 .../test/junit/BackButtonMultiPageTest.java     |  5 +-
 .../test/junit/CordovaResourceApiTest.java      |  2 +-
 .../org/apache/cordova/test/junit/MenuTest.java | 32 --------
 .../apache/cordova/test/junit/MessageTest.java  | 73 ------------------
 test/src/org/apache/cordova/test/menus.java     | 80 --------------------
 .../org/apache/cordova/test/userwebview.java    | 12 +--
 test/src/org/apache/cordova/test/whitelist.java |  8 +-
 10 files changed, 20 insertions(+), 243 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index a5496cf..e1e4294 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -115,4 +115,9 @@ public interface CordovaWebView {
     PluginManager getPluginManager();
 
     void setLayoutParams(android.widget.FrameLayout.LayoutParams layoutParams);
+    
+    // Required for test
+    
+    String getUrl();
+    boolean isPaused();
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/res/layout/main.xml
----------------------------------------------------------------------
diff --git a/test/res/layout/main.xml b/test/res/layout/main.xml
index 9b002ab..e7b31a4 100644
--- a/test/res/layout/main.xml
+++ b/test/res/layout/main.xml
@@ -22,7 +22,7 @@
     android:layout_height="fill_parent"
     android:orientation="vertical" >
     
-    <org.apache.cordova.CordovaWebView
+    <org.apache.cordova.AndroidWebView
         android:id="@+id/cordovaWebView"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" />

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/basicauth.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/basicauth.java b/test/src/org/apache/cordova/test/basicauth.java
deleted file mode 100755
index 1b09f3d..0000000
--- a/test/src/org/apache/cordova/test/basicauth.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-package org.apache.cordova.test;
-
-import android.os.Bundle;
-import org.apache.cordova.*;
-
-public class basicauth extends DroidGap {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        super.init();
-
-        // LogCat: onReceivedHttpAuthRequest(browserspy.dk:80,BrowserSpy.dk - HTTP Password
Test)
-        AuthenticationToken token = new AuthenticationToken();
-        token.setUserName("test");
-        token.setPassword("test");
-        super.setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password
Test");
-
-        // Add web site to whitelist
-        Config.init();
-        Config.addWhiteListEntry("http://browserspy.dk*", true);
-
-        // Load test
-        super.loadUrl("file:///android_asset/www/basicauth/index.html");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java b/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
index 923b376..9fc27de 100644
--- a/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
+++ b/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
@@ -27,6 +27,7 @@ import org.apache.cordova.test.backbuttonmultipage;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.view.KeyEvent;
+import android.view.View;
 import android.view.inputmethod.BaseInputConnection;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
@@ -174,7 +175,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
           {
               String url = testView.getUrl();
               assertTrue(url.endsWith("sample3.html"));
-              BaseInputConnection viewConnection = new BaseInputConnection(testView, true);
+              BaseInputConnection viewConnection = new BaseInputConnection((View) 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);
@@ -187,7 +188,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
           {
               String url = testView.getUrl();
               assertTrue(url.endsWith("sample2.html"));
-              BaseInputConnection viewConnection = new BaseInputConnection(testView, true);
+              BaseInputConnection viewConnection = new BaseInputConnection((View) 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);

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java b/test/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
index 1c91922..a8a5370 100644
--- a/test/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
+++ b/test/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
@@ -65,7 +65,7 @@ public class CordovaResourceApiTest extends ActivityInstrumentationTestCase2<Cor
         cordovaWebView = activity.cordovaWebView;
         resourceApi = cordovaWebView.getResourceApi();
         resourceApi.setThreadCheckingEnabled(false);
-        cordovaWebView.pluginManager.addService(new PluginEntry("CordovaResourceApiTestPlugin1",
new CordovaPlugin() {
+        cordovaWebView.getPluginManager().addService(new PluginEntry("CordovaResourceApiTestPlugin1",
new CordovaPlugin() {
             @Override
             public Uri remapUri(Uri uri) {
                 if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite"))
{

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/junit/MenuTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/MenuTest.java b/test/src/org/apache/cordova/test/junit/MenuTest.java
deleted file mode 100644
index 6c1ace6..0000000
--- a/test/src/org/apache/cordova/test/junit/MenuTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-
-package org.apache.cordova.test.junit;
-
-import org.apache.cordova.test.menus;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-public class MenuTest extends ActivityInstrumentationTestCase2<menus> {
-
-    public MenuTest() {
-      super("org.apache.cordova.test", menus.class);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/junit/MessageTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/MessageTest.java b/test/src/org/apache/cordova/test/junit/MessageTest.java
deleted file mode 100644
index 4d0ce16..0000000
--- a/test/src/org/apache/cordova/test/junit/MessageTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-package org.apache.cordova.test.junit;
-
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.ScrollEvent;
-import org.apache.cordova.pluginApi.pluginStub;
-import org.apache.cordova.test.CordovaWebViewTestActivity;
-import org.apache.cordova.test.R;
-
-import com.jayway.android.robotium.solo.By;
-import com.jayway.android.robotium.solo.Solo;
-
-import android.test.ActivityInstrumentationTestCase2;
-import android.view.View;
-
-public class MessageTest extends
-ActivityInstrumentationTestCase2<CordovaWebViewTestActivity> { 
-    private CordovaWebViewTestActivity testActivity;
-    private CordovaWebView testView;
-    private pluginStub testPlugin;
-    private int TIMEOUT = 1000;
-    
-    private Solo solo;
-
-    public MessageTest() {
-        super("org.apache.cordova.test.activities", CordovaWebViewTestActivity.class);
-      }
-
-      protected void setUp() throws Exception {
-        super.setUp();
-        testActivity = this.getActivity();
-        testView = (CordovaWebView) testActivity.findViewById(R.id.cordovaWebView);
-        testPlugin = (pluginStub) testView.pluginManager.getPlugin("PluginStub");
-        solo = new Solo(getInstrumentation(), getActivity());
-      }
-      
-      public void testOnScrollChanged()
-      {
-          solo.waitForWebElement(By.textContent("Cordova Android Tests"));
-          solo.scrollDown();
-          sleep();
-          Object data = testPlugin.data;
-          assertTrue(data.getClass().getSimpleName().equals("ScrollEvent"));
-      }
-
-      
-      
-      private void sleep() {
-          try {
-            Thread.sleep(TIMEOUT);
-          } catch (InterruptedException e) {
-            fail("Unexpected Timeout");
-          }
-        }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/menus.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/menus.java b/test/src/org/apache/cordova/test/menus.java
deleted file mode 100755
index 12d5230..0000000
--- a/test/src/org/apache/cordova/test/menus.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-package org.apache.cordova.test;
-
-import android.os.Bundle;
-import android.view.ContextMenu;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ContextMenu.ContextMenuInfo;
-
-import org.apache.cordova.*;
-import org.apache.cordova.LOG;
-
-public class menus extends DroidGap {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        super.init();
-        super.registerForContextMenu(super.appView);
-        super.loadUrl("file:///android_asset/www/menus/index.html");
-    }
-
-    // Demonstrate how to add your own menus to app
-
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        super.onCreateOptionsMenu(menu);
-        int base = Menu.FIRST;
-        // Group, item id, order, title
-        menu.add(base, base, base, "Item1");
-        menu.add(base, base + 1, base + 1, "Item2");
-        menu.add(base, base + 2, base + 2, "Item3");
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        LOG.d("menus", "Item " + item.getItemId() + " pressed.");
-        this.appView.loadUrl("javascript:alert('Menu " + item.getItemId() + " pressed.')");
-        return super.onOptionsItemSelected(item);
-    }
-
-    @Override
-    public boolean onPrepareOptionsMenu(Menu menu) {
-        LOG.d("menus", "onPrepareOptionsMenu()");
-        // this.appView.loadUrl("javascript:alert('onPrepareOptionsMenu()')");
-        return true;
-    }
-
-    @Override
-    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
-        LOG.d("menus", "onCreateContextMenu()");
-        menu.setHeaderTitle("Test Context Menu");
-        menu.add(200, 200, 200, "Context Item1");
-    }
-
-    @Override
-    public boolean onContextItemSelected(MenuItem item) {
-        this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')");
-        return true;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/userwebview.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/userwebview.java b/test/src/org/apache/cordova/test/userwebview.java
index 6146a40..d987911 100755
--- a/test/src/org/apache/cordova/test/userwebview.java
+++ b/test/src/org/apache/cordova/test/userwebview.java
@@ -25,7 +25,7 @@ import android.webkit.GeolocationPermissions.Callback;
 import org.apache.cordova.*;
 import org.apache.cordova.LOG;
 
-public class userwebview extends DroidGap {
+public class userwebview extends CordovaActivity {
     
     public TestViewClient testViewClient;
     public TestChromeClient testChromeClient;
@@ -35,12 +35,12 @@ public class userwebview extends DroidGap {
         super.onCreate(savedInstanceState);
         testViewClient = new TestViewClient(this);
         testChromeClient = new TestChromeClient(this);
-        super.init(new CordovaWebView(this), new TestViewClient(this), new TestChromeClient(this));
+        super.init(new AndroidWebView(this), new TestViewClient(this), new TestChromeClient(this));
         super.loadUrl("file:///android_asset/www/userwebview/index.html");
     }
 
-    public class TestChromeClient extends CordovaChromeClient {
-        public TestChromeClient(DroidGap arg0) {
+    public class TestChromeClient extends AndroidChromeClient {
+        public TestChromeClient(CordovaActivity arg0) {
             super(arg0);
             LOG.d("userwebview", "TestChromeClient()");
         }
@@ -56,8 +56,8 @@ public class userwebview extends DroidGap {
     /**
      * This class can be used to override the GapViewClient and receive notification of webview
events.
      */
-    public class TestViewClient extends CordovaWebViewClient {
-        public TestViewClient(DroidGap arg0) {
+    public class TestViewClient extends AndroidWebViewClient {
+        public TestViewClient(CordovaActivity arg0) {
             super(arg0);
             LOG.d("userwebview", "TestViewClient()");
         }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b6664cc8/test/src/org/apache/cordova/test/whitelist.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/whitelist.java b/test/src/org/apache/cordova/test/whitelist.java
index 26eebf3..879c2f8 100755
--- a/test/src/org/apache/cordova/test/whitelist.java
+++ b/test/src/org/apache/cordova/test/whitelist.java
@@ -24,20 +24,20 @@ import android.webkit.WebView;
 import org.apache.cordova.*;
 import org.apache.cordova.LOG;
 
-public class whitelist extends DroidGap {
+public class whitelist extends CordovaActivity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        super.init(new CordovaWebView(this), new TestViewClient(this), new CordovaChromeClient(this));
+        super.init(new AndroidWebView(this), new TestViewClient(this), new AndroidChromeClient(this));
         super.loadUrl("file:///android_asset/www/whitelist/index.html");
     }
 
     /**
      * This class can be used to override the GapViewClient and receive notification of webview
events.
      */
-    public class TestViewClient extends CordovaWebViewClient {
+    public class TestViewClient extends AndroidWebViewClient {
 
-        public TestViewClient(DroidGap arg0) {
+        public TestViewClient(CordovaActivity arg0) {
             super(arg0);
         }
 


Mime
View raw message