You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2015/02/12 21:04:18 UTC
[1/3] android commit: Revert "Reverting the refactor. I'd rather have
4 failures due to timing than tests completely disappear"
Repository: cordova-android
Updated Branches:
refs/heads/master 390927772 -> 9baa27508
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/IFrameTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/IFrameTest.java b/test/androidTest/src/org/apache/cordova/test/junit/IFrameTest.java
deleted file mode 100644
index 800dead..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/IFrameTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.test.iframe;
-import org.apache.cordova.test.util.Purity;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.TouchUtils;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class IFrameTest extends ActivityInstrumentationTestCase2 {
-
-
- private Instrumentation mInstr;
- private Activity testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private CordovaWebView testView;
- private TouchUtils touch;
- private Purity touchTool;
-
- public IFrameTest() {
- super("org.apache.cordova.test",iframe.class);
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- mInstr = this.getInstrumentation();
- testActivity = this.getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = (CordovaWebView) innerContainer.getChildAt(0);
- touch = new TouchUtils();
- touchTool = new Purity(testActivity, getInstrumentation());
- }
-
-
- public void testIframeDest() throws Throwable
- {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- testView.sendJavascript("loadUrl('http://maps.google.com/maps?output=embed');");
- }
- });
- sleep(3000);
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- testView.sendJavascript("loadUrl('index2.html')");
- }
- });
- sleep(1000);
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("index.html"));
- }
- });
- }
-
- public void testIframeHistory() throws Throwable
- {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- testView.sendJavascript("loadUrl('http://maps.google.com/maps?output=embed');");
- }
- });
- sleep(3000);
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- testView.sendJavascript("loadUrl('index2.html')");
- }
- });
- sleep(1000);
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- testView.backHistory();
- }
- });
- sleep(1000);
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("index.html"));
- }
- });
- }
-
- private void sleep(int timeout) {
- try {
- Thread.sleep(timeout);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java b/test/androidTest/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
deleted file mode 100644
index e84a8dc..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
+++ /dev/null
@@ -1,94 +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.CordovaWebView;
-import org.apache.cordova.test.SabotagedActivity;
-import org.apache.cordova.test.splashscreen;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.AssetManager;
-import android.test.ActivityInstrumentationTestCase2;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-
-public class IntentUriOverrideTest extends ActivityInstrumentationTestCase2<SabotagedActivity> {
-
- private int TIMEOUT = 1000;
-
- private SabotagedActivity testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private CordovaWebView testView;
- private Instrumentation mInstr;
- private String BAD_URL = "file:///sdcard/download/wl-exploit.htm";
-
-
- @SuppressWarnings("deprecation")
- public IntentUriOverrideTest()
- {
- super("org.apache.cordova.test",SabotagedActivity.class);
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- mInstr = this.getInstrumentation();
- Intent badIntent = new Intent();
- badIntent.setClassName("org.apache.cordova.test", "org.apache.cordova.test.SabotagedActivity");
- badIntent.putExtra("url", BAD_URL);
- setActivityIntent(badIntent);
- testActivity = getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = (CordovaWebView) innerContainer.getChildAt(0);
- }
-
-
- public void testPreconditions(){
- assertNotNull(innerContainer);
- assertNotNull(testView);
- }
-
- public void testChangeStartUrl() throws Throwable
- {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- sleep();
- boolean isBadUrl = testView.getUrl().equals(BAD_URL);
- assertFalse(isBadUrl);
- }
- });
- }
-
- private void sleep() {
- try {
- Thread.sleep(TIMEOUT);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/LifecycleTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/LifecycleTest.java b/test/androidTest/src/org/apache/cordova/test/junit/LifecycleTest.java
deleted file mode 100644
index 5423575..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/LifecycleTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.test.lifecycle;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-public class LifecycleTest extends ActivityInstrumentationTestCase2<lifecycle> {
-
- public LifecycleTest()
- {
- super("org.apache.cordova.test",lifecycle.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/PluginManagerTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/PluginManagerTest.java b/test/androidTest/src/org/apache/cordova/test/junit/PluginManagerTest.java
deleted file mode 100644
index bcdead6..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/PluginManagerTest.java
+++ /dev/null
@@ -1,70 +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.CordovaWebView;
-import org.apache.cordova.PluginManager;
-import org.apache.cordova.test.CordovaWebViewTestActivity;
-
-import android.test.ActivityInstrumentationTestCase2;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class PluginManagerTest extends ActivityInstrumentationTestCase2<CordovaWebViewTestActivity> {
-
- private CordovaWebViewTestActivity testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private View testView;
- private String rString;
- private PluginManager pMan;
-
- public PluginManagerTest() {
- super("org.apache.cordova.test.activities",CordovaWebViewTestActivity.class);
- }
-
- protected void setUp() throws Exception{
- super.setUp();
- testActivity = this.getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = innerContainer.getChildAt(0);
-
- }
-
- public void testPreconditions(){
- assertNotNull(innerContainer);
- assertNotNull(testView);
- }
-
-
- public void testForPluginManager() {
- /*
- CordovaWebView v = (CordovaWebView) testView;
- pMan = v.getPluginManager();
- assertNotNull(pMan);
- String className = pMan.getClass().getSimpleName();
- assertTrue(className.equals("PluginManager"));
- */
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/SplashscreenTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/SplashscreenTest.java b/test/androidTest/src/org/apache/cordova/test/junit/SplashscreenTest.java
deleted file mode 100644
index 14da5ac..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/SplashscreenTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.test.splashscreen;
-
-import android.app.Dialog;
-import android.test.ActivityInstrumentationTestCase2;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class SplashscreenTest extends ActivityInstrumentationTestCase2<splashscreen> {
-
- private splashscreen testActivity;
- private Dialog containerView;
-
- public SplashscreenTest()
- {
- super("org.apache.cordova.test",splashscreen.class);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- testActivity = this.getActivity();
- //containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- //containerView = (Dialog) testActivity.findViewById(id);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/XhrTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/XhrTest.java b/test/androidTest/src/org/apache/cordova/test/junit/XhrTest.java
deleted file mode 100644
index 16c977f..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/XhrTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.test.xhr;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-public class XhrTest extends ActivityInstrumentationTestCase2<xhr> {
-
- public XhrTest()
- {
- super(xhr.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/assets/www/error.html
----------------------------------------------------------------------
diff --git a/test/assets/www/error.html b/test/assets/www/error.html
deleted file mode 100644
index aad167d..0000000
--- a/test/assets/www/error.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>OH NOES!</title>
- </head>
- <body>
- <h1>Things went terribly wrong!</h1>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/assets/www/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/index.html b/test/assets/www/index.html
index d4659f7..f55aa0a 100755
--- a/test/assets/www/index.html
+++ b/test/assets/www/index.html
@@ -26,8 +26,8 @@
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
<script>
- function startActivity(className) {
- cordova.exec(function() {console.log("Success");}, function(e) {console.log("Error: "+e);}, "Activity", "start", [className]);
+ function startActivity(url, opts, className) {
+ cordova.exec(function() {console.log("Success");}, function(e) {console.log("Error: "+e);}, "Activity", "start", [className, url, opts || {}]);
};
localStorage.lifecyclestatus = "";
@@ -44,22 +44,20 @@
<div id="info">
<h4>Run each of the test activities below:</h4>
</div>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.jqmtabbackbutton');">Backbutton jQM tab</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.backbuttonmultipage');">Backbutton with multiple pages</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.backgroundcolor');">Background Color</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.basicauth');">Basic Authentication</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.errorurl');">Error URL</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.fullscreen');">Full Screen</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.htmlnotfound');">HTML not found</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.iframe');">IFrame</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.lifecycle');">Lifecycle</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.loading');">Loading indicator</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.menus');">Menus</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.background');">No multitasking</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.splashscreen');">Splash screen</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.timeout');">Load timeout</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.userwebview');">User WebView/Client/Chrome</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.whitelist');">Whitelist</button>
- <button class="btn large" onclick="startActivity('org.apache.cordova.test.xhr');">XHR</button>
+ <button class="btn large" onclick="startActivity('jqmtabbackbutton/index.html');">Backbutton jQM tab</button>
+ <button class="btn large" onclick="startActivity('backbuttonmultipage/index.html');">Backbutton with multiple pages</button>
+ <button class="btn large" onclick="startActivity('backgroundcolor/index.html', {backgroundcolor: -16711936});">Background Color</button>
+ <button class="btn large" onclick="startActivity('basicauth/index.html');">Basic Authentication</button>
+ <button class="btn large" onclick="startActivity('errorurl/index.html', {testErrorUrl: 'file:///android_asset/www/htmlnotfound/error.html'});">Error URL</button>
+ <button class="btn large" onclick="startActivity('fullscreen/index.html', {fullscreen: true});">Full Screen</button>
+ <button class="btn large" onclick="startActivity('htmlnotfound/index.html');">HTML not found</button>
+ <button class="btn large" onclick="startActivity('iframe/index.html');">IFrame</button>
+ <button class="btn large" onclick="startActivity('lifecycle/index.html');">Lifecycle</button>
+ <button class="btn large" onclick="startActivity('menus/index.html', null, 'org.apache.cordova.test.menus');">Menus</button>
+ <button class="btn large" onclick="startActivity('background/index.html', {keeprunning: false});">No multitasking</button>
+ <button class="btn large" onclick="startActivity('http://www.google.com', {loadurltimeoutvalue: 10});">Load timeout</button>
+ <button class="btn large" onclick="startActivity('userwebview/index.html', null, 'org.apache.cordova.test.userwebview');">User WebView/Client/Chrome</button>
+ <button class="btn large" onclick="startActivity('whitelist/index.html');">Whitelist</button>
+ <button class="btn large" onclick="startActivity('xhr/index.html');">XHR</button>
</body>
</html>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/assets/www/main.js
----------------------------------------------------------------------
diff --git a/test/assets/www/main.js b/test/assets/www/main.js
index f525a5c..a242139 100755
--- a/test/assets/www/main.js
+++ b/test/assets/www/main.js
@@ -22,139 +22,6 @@ var deviceInfo = function() {
document.getElementById("cordova").innerHTML = cordova.version;
};
-var getLocation = function() {
- var suc = function(p) {
- alert(p.coords.latitude + " " + p.coords.longitude);
- };
- var locFail = function() {
- };
- navigator.geolocation.getCurrentPosition(suc, locFail);
-};
-
-var beep = function() {
- navigator.notification.beep(2);
-};
-
-var vibrate = function() {
- navigator.notification.vibrate(0);
-};
-
-function roundNumber(num) {
- var dec = 3;
- var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
- return result;
-}
-
-var accelerationWatch = null;
-
-function updateAcceleration(a) {
- document.getElementById('x').innerHTML = roundNumber(a.x);
- document.getElementById('y').innerHTML = roundNumber(a.y);
- document.getElementById('z').innerHTML = roundNumber(a.z);
-}
-
-var toggleAccel = function() {
- if (accelerationWatch !== null) {
- navigator.accelerometer.clearWatch(accelerationWatch);
- updateAcceleration({
- x : "",
- y : "",
- z : ""
- });
- accelerationWatch = null;
- } else {
- var options = {};
- options.frequency = 1000;
- accelerationWatch = navigator.accelerometer.watchAcceleration(
- updateAcceleration, function(ex) {
- alert("accel fail (" + ex.name + ": " + ex.message + ")");
- }, options);
- }
-};
-
-var preventBehavior = function(e) {
- e.preventDefault();
-};
-
-function dump_pic(data) {
- var viewport = document.getElementById('viewport');
- console.log(data);
- viewport.style.display = "";
- viewport.style.position = "absolute";
- viewport.style.top = "10px";
- viewport.style.left = "10px";
- document.getElementById("test_img").src = "data:image/jpeg;base64," + data;
-}
-
-function fail(msg) {
- alert(msg);
-}
-
-function show_pic() {
- navigator.camera.getPicture(dump_pic, fail, {
- quality : 50
- });
-}
-
-function close() {
- var viewport = document.getElementById('viewport');
- viewport.style.position = "relative";
- viewport.style.display = "none";
-}
-
-function contacts_success(contacts) {
- alert(contacts.length
- + ' contacts returned.'
- + (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
- : ''));
-}
-
-function get_contacts() {
- var obj = new ContactFindOptions();
- obj.filter = "";
- obj.multiple = true;
- navigator.contacts.find(
- [ "displayName", "name" ], contacts_success,
- fail, obj);
-}
-
-function check_network() {
- var networkState = navigator.network.connection.type;
-
- var states = {};
- states[Connection.UNKNOWN] = 'Unknown connection';
- states[Connection.ETHERNET] = 'Ethernet connection';
- states[Connection.WIFI] = 'WiFi connection';
- states[Connection.CELL_2G] = 'Cell 2G connection';
- states[Connection.CELL_3G] = 'Cell 3G connection';
- states[Connection.CELL_4G] = 'Cell 4G connection';
- states[Connection.NONE] = 'No network connection';
-
- confirm('Connection type:\n ' + states[networkState]);
-}
-
-var watchID = null;
-
-function updateHeading(h) {
- document.getElementById('h').innerHTML = h.magneticHeading;
-}
-
-function toggleCompass() {
- if (watchID !== null) {
- navigator.compass.clearWatch(watchID);
- watchID = null;
- updateHeading({ magneticHeading : "Off"});
- } else {
- var options = { frequency: 1000 };
- watchID = navigator.compass.watchHeading(updateHeading, function(e) {
- alert('Compass Error: ' + e.code);
- }, options);
- }
-}
-
function init() {
- // the next line makes it impossible to see Contacts on the HTC Evo since it
- // doesn't have a scroll button
- // document.addEventListener("touchmove", preventBehavior, false);
document.addEventListener("deviceready", deviceInfo, true);
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/assets/www/splashscreen/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/splashscreen/index.html b/test/assets/www/splashscreen/index.html
deleted file mode 100755
index 5f5d9e8..0000000
--- a/test/assets/www/splashscreen/index.html
+++ /dev/null
@@ -1,38 +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.
--->
-<!DOCTYPE HTML>
-<html>
- <head>
- <meta name="viewport" content="width=320, user-scalable=no" />
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>Cordova Tests</title>
- <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
- <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
- <script type="text/javascript" charset="utf-8" src="../main.js"></script>
- </head>
- <body onload="init();" id="stage" class="theme">
- <h1>Splash Screen Test</h1>
- <div id="info">
- <h4>Cordova: <span id="cordova"> </span></h4>
- <h4>Deviceready: <span id="deviceready"> </span></h4>
- </div>
- <div id="info">
- You should have seen the splash screen for 2 seconds.</div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/res/drawable/sandy.jpg
----------------------------------------------------------------------
diff --git a/test/res/drawable/sandy.jpg b/test/res/drawable/sandy.jpg
deleted file mode 100755
index c956d30..0000000
Binary files a/test/res/drawable/sandy.jpg and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/test/res/xml/config.xml b/test/res/xml/config.xml
index 4370357..894c336 100644
--- a/test/res/xml/config.xml
+++ b/test/res/xml/config.xml
@@ -38,7 +38,4 @@
<feature name="Activity">
<param name="android-package" value="org.apache.cordova.test.ActivityPlugin" />
</feature>
- <feature name="PluginStub">
- <param name="android-package" value="org.apache.cordova.pluginApi.pluginStub" />
- </feature>
</widget>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/pluginApi/pluginStub.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/pluginApi/pluginStub.java b/test/src/org/apache/cordova/pluginApi/pluginStub.java
deleted file mode 100644
index b91a7af..0000000
--- a/test/src/org/apache/cordova/pluginApi/pluginStub.java
+++ /dev/null
@@ -1,39 +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.
-*/
-
-/*
- * This plugin is a test of all the message callbacks and actions available to plugins
- *
- */
-
-package org.apache.cordova.pluginApi;
-
-import org.apache.cordova.CordovaPlugin;
-
-public class pluginStub extends CordovaPlugin {
-
- public String id;
- public Object data;
-
- public Object onMessage(String id, Object input)
- {
- this.data = input;
- return input;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/ActivityPlugin.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/ActivityPlugin.java b/test/src/org/apache/cordova/test/ActivityPlugin.java
index 19a50a2..c6a96ec 100755
--- a/test/src/org/apache/cordova/test/ActivityPlugin.java
+++ b/test/src/org/apache/cordova/test/ActivityPlugin.java
@@ -28,52 +28,40 @@ import android.content.Intent;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;
+import org.json.JSONObject;
+
+import java.util.Collections;
+import java.util.Iterator;
-/**
- * This class provides a service.
- */
public class ActivityPlugin extends CordovaPlugin {
static String TAG = "ActivityPlugin";
+ public static final String BACKBUTTONMULTIPAGE_URL = "file:///android_asset/www/backbuttonmultipage/index.html";
- /**
- * Constructor.
- */
- public ActivityPlugin() {
- }
-
- /**
- * Executes the request and returns PluginResult.
- *
- * @param action The action to execute.
- * @param args JSONArry of arguments for the plugin.
- * @param callbackId The callback id used when calling back into JavaScript.
- * @return A PluginResult object with a status and message.
- */
- public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) {
- PluginResult result = new PluginResult(PluginResult.Status.OK, "");
- try {
- if (action.equals("start")) {
- this.startActivity(args.getString(0));
- callbackContext.sendPluginResult(result);
- callbackContext.success();
- return true;
- }
- } catch (JSONException e) {
- result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, "JSON Exception");
- callbackContext.sendPluginResult(result);
- return false;
+ public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
+ if (action.equals("start")) {
+ String className = args.isNull(0) ? MainTestActivity.class.getCanonicalName() : args.getString(0);
+ String startUrl = args.getString(1);
+ JSONObject extraPrefs = args.getJSONObject(2);
+ this.startActivity(className, startUrl, extraPrefs);
+ callbackContext.success();
+ return true;
}
return false;
}
- // --------------------------------------------------------------------------
- // LOCAL METHODS
- // --------------------------------------------------------------------------
-
- public void startActivity(String className) {
+ public void startActivity(String className, String startUrl, JSONObject extraPrefs) throws JSONException {
try {
- Intent intent = new Intent().setClass(this.cordova.getActivity(), Class.forName(className));
+ if (!startUrl.contains(":")) {
+ startUrl = "file:///android_asset/www/" + startUrl;
+ }
+ Intent intent = new Intent(this.cordova.getActivity(), Class.forName(className));
+ intent.putExtra("testStartUrl", startUrl);
+ Iterator<String> iter = extraPrefs.keys();
+ while (iter.hasNext()) {
+ String key = iter.next();
+ intent.putExtra(key, extraPrefs.getString(key));
+ }
LOG.d(TAG, "Starting activity %s", className);
this.cordova.getActivity().startActivity(intent);
} catch (ClassNotFoundException e) {
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/BaseTestCordovaActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/BaseTestCordovaActivity.java b/test/src/org/apache/cordova/test/BaseTestCordovaActivity.java
new file mode 100644
index 0000000..0a28036
--- /dev/null
+++ b/test/src/org/apache/cordova/test/BaseTestCordovaActivity.java
@@ -0,0 +1,50 @@
+/*
+ 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.content.Intent;
+import android.os.Bundle;
+
+import org.apache.cordova.CordovaActivity;
+import org.apache.cordova.CordovaWebView;
+
+import java.util.concurrent.ArrayBlockingQueue;
+
+public class BaseTestCordovaActivity extends CordovaActivity {
+ public final ArrayBlockingQueue<String> onPageFinishedUrl = new ArrayBlockingQueue<String>(500);
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public Object onMessage(String id, Object data) {
+ if ("onPageFinished".equals(id)) {
+ onPageFinishedUrl.add((String) data);
+ }
+ return super.onMessage(id, data);
+ }
+
+ public CordovaWebView getCordovaWebView() {
+ return appView;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/CordovaDriverAction.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaDriverAction.java b/test/src/org/apache/cordova/test/CordovaDriverAction.java
deleted file mode 100644
index 0559f5f..0000000
--- a/test/src/org/apache/cordova/test/CordovaDriverAction.java
+++ /dev/null
@@ -1,78 +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 java.util.concurrent.ExecutorService;
-
-import org.apache.cordova.CordovaInterface;
-import org.apache.cordova.CordovaPlugin;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-
-
-public class CordovaDriverAction extends Activity implements CordovaInterface {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- public void startActivityForResult(CordovaPlugin command, Intent intent,
- int requestCode) {
- // TODO Auto-generated method stub
-
- }
-
- public void setActivityResultCallback(CordovaPlugin plugin) {
- // TODO Auto-generated method stub
-
- }
-
- public Activity getActivity() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Deprecated
- public Context getContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Deprecated
- public void cancelLoadUrl() {
- // TODO Auto-generated method stub
-
- }
-
- public Object onMessage(String id, Object data) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public ExecutorService getThreadPool() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index 43e0b2b..ce9797e 100644
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@ -19,90 +19,57 @@
package org.apache.cordova.test;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.ArrayBlockingQueue;
import org.apache.cordova.AndroidChromeClient;
+import org.apache.cordova.AndroidWebView;
import org.apache.cordova.AndroidWebViewClient;
import org.apache.cordova.Config;
+import org.apache.cordova.CordovaInterfaceImpl;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.test.R;
import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
import android.os.Bundle;
-public class CordovaWebViewTestActivity extends Activity implements CordovaInterface {
- public CordovaWebView cordovaWebView;
+/**
+ * Tests creating the views via inflating a layout, and also tests *not* using CordovaActivity.
+ */
+public class CordovaWebViewTestActivity extends Activity {
+ private CordovaWebView cordovaWebView;
+ public final ArrayBlockingQueue<String> onPageFinishedUrl = new ArrayBlockingQueue<String>(5);
+ public static final String START_URL = "file:///android_asset/www/index.html";
+
+ protected CordovaInterfaceImpl cordovaInterface = new CordovaInterfaceImpl(this) {
+ @Override
+ public Object onMessage(String id, Object data) {
+ if ("onPageFinished".equals(id)) {
+ onPageFinishedUrl.add((String) data);
+ }
+ return super.onMessage(id, data);
+ }
+ };
- private final ExecutorService threadPool = Executors.newCachedThreadPool();
-
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
setContentView(R.layout.main);
//CB-7238: This has to be added now, because it got removed from somewhere else
Config.init(this);
-
- cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
- cordovaWebView.init(this, Config.getPluginEntries(), Config.getWhitelist(),
- Config.getExternalWhitelist(), Config.getPreferences());
-
- cordovaWebView.loadUrl("file:///android_asset/www/index.html");
-
- }
-
- public Context getContext() {
- return this;
- }
-
- public void startActivityForResult(CordovaPlugin command, Intent intent,
- int requestCode) {
- // TODO Auto-generated method stub
-
- }
- public void setActivityResultCallback(CordovaPlugin plugin) {
- // TODO Auto-generated method stub
-
- }
-
- //Note: This must always return an activity!
- public Activity getActivity() {
- return this;
- }
-
- @Deprecated
- public void cancelLoadUrl() {
- // TODO Auto-generated method stub
-
- }
+ AndroidWebView webView = (AndroidWebView) findViewById(R.id.cordovaWebView);
+ cordovaWebView = webView;
+ cordovaWebView.init(cordovaInterface, Config.getPluginEntries(), Config.getWhitelist(),
+ Config.getExternalWhitelist(), Config.getPreferences());
- public Object onMessage(String id, Object data) {
- // TODO Auto-generated method stub
- return null;
+ cordovaWebView.loadUrl(START_URL);
}
- public ExecutorService getThreadPool() {
- // TODO Auto-generated method stub
- return threadPool;
- }
-
- @Override
- /**
- * The final call you receive before your activity is destroyed.
- */
- public void onDestroy() {
- super.onDestroy();
- if (cordovaWebView != null) {
- // Send destroy event to JavaScript
- cordovaWebView.handleDestroy();
- }
+ public CordovaWebView getCordovaWebView() {
+ return cordovaWebView;
}
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/MainTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/MainTestActivity.java b/test/src/org/apache/cordova/test/MainTestActivity.java
index 2a0f67e..45d8309 100644
--- a/test/src/org/apache/cordova/test/MainTestActivity.java
+++ b/test/src/org/apache/cordova/test/MainTestActivity.java
@@ -19,14 +19,34 @@
package org.apache.cordova.test;
import org.apache.cordova.CordovaActivity;
+import org.apache.cordova.CordovaInterfaceImpl;
+import org.apache.cordova.CordovaWebView;
+import android.content.Intent;
import android.os.Bundle;
-public class MainTestActivity extends CordovaActivity {
+import java.util.concurrent.ArrayBlockingQueue;
+
+public class MainTestActivity extends BaseTestCordovaActivity {
+ public static final String START_URL = "file:///android_asset/www/index.html";
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- super.loadUrl("file:///android_asset/www/index.html");
+ String url = getIntent().getStringExtra("testStartUrl");
+ if (url == null) {
+ url = START_URL;
+ }
+ super.loadUrl(url);
+ }
+
+ @Override protected void loadConfig() {
+ super.loadConfig();
+ // Need to set this explicitly in prefs since it's not settable via bundle extras (for security reasons).
+ String errorUrl = getIntent().getStringExtra("testErrorUrl");
+ if (errorUrl != null) {
+ preferences.set("errorUrl", errorUrl);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/SabotagedActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/SabotagedActivity.java b/test/src/org/apache/cordova/test/SabotagedActivity.java
deleted file mode 100644
index 7f3edc5..0000000
--- a/test/src/org/apache/cordova/test/SabotagedActivity.java
+++ /dev/null
@@ -1,92 +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 java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-
-import org.apache.cordova.Config;
-import org.apache.cordova.CordovaActivity;
-
-import android.content.res.AssetManager;
-import android.os.Bundle;
-import android.os.Environment;
-import android.util.Log;
-
-public class SabotagedActivity extends CordovaActivity {
-
- private String BAD_ASSET = "www/error.html";
- private String LOG_TAG = "SabotagedActivity";
-
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
-// copyErrorAsset();
- super.init();
- super.loadUrl(Config.getStartUrl());
- }
-
- /*
- * Sometimes we need to move code around before we can do anything. This will
- * copy the bad code out of the assets before we initalize Cordova so that when Cordova actually
- * initializes, we have something for it to navigate to.
- */
-
- private void copyErrorAsset () {
- AssetManager assetManager = getAssets();
- String[] files = null;
- try {
- files = assetManager.list(BAD_ASSET);
- } catch (IOException e) {
- Log.e(LOG_TAG, e.getMessage());
- }
-
- for(String filename : files) {
- InputStream in = null;
- OutputStream out = null;
- try {
- in = assetManager.open(BAD_ASSET);
- out = new FileOutputStream(Environment.getExternalStorageDirectory().toString() +"/" + filename);
- copy(in, out);
- in.close();
- in = null;
- out.flush();
- out.close();
- out = null;
- } catch(Exception e) {
- Log.e("tag", e.getMessage());
- }
- }
- }
-
-
- //Quick and Dirty Copy!
- private void copy(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = new byte[1024];
- int read;
- while((read = in.read(buffer)) != -1){
- out.write(buffer, 0, read);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/backbuttonmultipage.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/backbuttonmultipage.java b/test/src/org/apache/cordova/test/backbuttonmultipage.java
deleted file mode 100755
index d744198..0000000
--- a/test/src/org/apache/cordova/test/backbuttonmultipage.java
+++ /dev/null
@@ -1,30 +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 backbuttonmultipage extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.loadUrl("file:///android_asset/www/backbuttonmultipage/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/background.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/background.java b/test/src/org/apache/cordova/test/background.java
deleted file mode 100755
index d7ed101..0000000
--- a/test/src/org/apache/cordova/test/background.java
+++ /dev/null
@@ -1,33 +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 background extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- //super.init(new FixWebView(this), new CordovaWebViewClient(this), new CordovaChromeClient(this));
- preferences.set("keepRunning", false);
- super.loadUrl("file:///android_asset/www/background/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/backgroundcolor.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/backgroundcolor.java b/test/src/org/apache/cordova/test/backgroundcolor.java
deleted file mode 100755
index 30e297f..0000000
--- a/test/src/org/apache/cordova/test/backgroundcolor.java
+++ /dev/null
@@ -1,37 +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.graphics.Color;
-import android.os.Bundle;
-import org.apache.cordova.*;
-
-public class backgroundcolor extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // backgroundColor can also be set in cordova.xml, but you must use the number equivalent of the color. For example, Color.RED is
- // <preference name="backgroundColor" value="-65536" />
- preferences.set("backgroundColor", Color.GREEN);
-
- super.loadUrl("file:///android_asset/www/backgroundcolor/index.html");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/errorurl.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/errorurl.java b/test/src/org/apache/cordova/test/errorurl.java
deleted file mode 100755
index e946e40..0000000
--- a/test/src/org/apache/cordova/test/errorurl.java
+++ /dev/null
@@ -1,33 +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 errorurl extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- preferences.set("errorUrl", "file:///android_asset/www/htmlnotfound/error.html");
- super.loadUrl("file:///android_asset/www/htmlnotfound/index.html");
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/fullscreen.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/fullscreen.java b/test/src/org/apache/cordova/test/fullscreen.java
deleted file mode 100755
index 0aa1ee9..0000000
--- a/test/src/org/apache/cordova/test/fullscreen.java
+++ /dev/null
@@ -1,39 +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 fullscreen extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Properties must be set before init() is called, since some are processed during init().
-
- // fullscreen can also be set in cordova.xml. For example,
- // <preference name="fullscreen" value="true" />
- preferences.set("fullscreen", true);
-
- super.init();
- super.loadUrl("file:///android_asset/www/fullscreen/index.html");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/htmlnotfound.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/htmlnotfound.java b/test/src/org/apache/cordova/test/htmlnotfound.java
deleted file mode 100755
index c602922..0000000
--- a/test/src/org/apache/cordova/test/htmlnotfound.java
+++ /dev/null
@@ -1,31 +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 htmlnotfound extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.init();
- super.loadUrl("file:///android_asset/www/htmlnotfound/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/iframe.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/iframe.java b/test/src/org/apache/cordova/test/iframe.java
deleted file mode 100755
index 3d30cfb..0000000
--- a/test/src/org/apache/cordova/test/iframe.java
+++ /dev/null
@@ -1,30 +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 iframe extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.loadUrl("file:///android_asset/www/iframe/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/junit/GapClientTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/GapClientTest.java b/test/src/org/apache/cordova/test/junit/GapClientTest.java
deleted file mode 100644
index ce6ca8c..0000000
--- a/test/src/org/apache/cordova/test/junit/GapClientTest.java
+++ /dev/null
@@ -1,66 +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.CordovaWebView;
-import org.apache.cordova.PluginManager;
-import org.apache.cordova.test.CordovaWebViewTestActivity;
-
-import android.content.Context;
-import android.content.res.AssetManager;
-import android.content.res.Resources;
-import android.test.ActivityInstrumentationTestCase2;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class GapClientTest extends ActivityInstrumentationTestCase2<CordovaWebViewTestActivity> {
-
- private CordovaWebViewTestActivity testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private View testView;
- private String rString;
-
- public GapClientTest() {
- super("org.apache.cordova.test.activities",CordovaWebViewTestActivity.class);
- }
-
- protected void setUp() throws Exception{
- super.setUp();
- testActivity = this.getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = innerContainer.getChildAt(0);
-
- }
-
- public void testPreconditions(){
- assertNotNull(innerContainer);
- assertNotNull(testView);
- }
-
- public void testForAndroidWebView() {
- String className = testView.getClass().getSimpleName();
- assertTrue(className.equals("AndroidWebView"));
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/lifecycle.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/lifecycle.java b/test/src/org/apache/cordova/test/lifecycle.java
deleted file mode 100755
index d1c4212..0000000
--- a/test/src/org/apache/cordova/test/lifecycle.java
+++ /dev/null
@@ -1,30 +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 lifecycle extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.loadUrl("file:///android_asset/www/lifecycle/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/loading.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/loading.java b/test/src/org/apache/cordova/test/loading.java
deleted file mode 100755
index da2c4ff..0000000
--- a/test/src/org/apache/cordova/test/loading.java
+++ /dev/null
@@ -1,31 +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 loading extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- preferences.set("loadingDialog", "Testing,Loading...");
- super.loadUrl("http://www.google.com");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/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
index 4c65ed5..6ef12c5 100755
--- a/test/src/org/apache/cordova/test/menus.java
+++ b/test/src/org/apache/cordova/test/menus.java
@@ -28,7 +28,7 @@ import android.view.ContextMenu.ContextMenuInfo;
import org.apache.cordova.*;
import org.apache.cordova.LOG;
-public class menus extends CordovaActivity {
+public class menus extends BaseTestCordovaActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/splashscreen.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/splashscreen.java b/test/src/org/apache/cordova/test/splashscreen.java
deleted file mode 100755
index 34051bb..0000000
--- a/test/src/org/apache/cordova/test/splashscreen.java
+++ /dev/null
@@ -1,35 +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 splashscreen extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.init();
-
- // Show splashscreen
- preferences.set("splashscreen", "sandy");
-
- super.loadUrl("file:///android_asset/www/splashscreen/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/tests.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/tests.java b/test/src/org/apache/cordova/test/tests.java
deleted file mode 100755
index 64ad56e..0000000
--- a/test/src/org/apache/cordova/test/tests.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;
-
-import android.os.Bundle;
-import org.apache.cordova.*;
-
-public class tests extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.init();
- //super.pluginManager.addService("Activity", "org.apache.cordova.test.ActivityPlugin");
- super.loadUrl("file:///android_asset/www/index.html");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/timeout.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/timeout.java b/test/src/org/apache/cordova/test/timeout.java
deleted file mode 100755
index 8a418a3..0000000
--- a/test/src/org/apache/cordova/test/timeout.java
+++ /dev/null
@@ -1,34 +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 timeout extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.init();
-
- // Short timeout to cause error
- preferences.set("loadUrlTimeoutValue", 10);
- super.loadUrl("http://www.google.com");
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/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
deleted file mode 100755
index e2029a9..0000000
--- a/test/src/org/apache/cordova/test/whitelist.java
+++ /dev/null
@@ -1,51 +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.webkit.WebView;
-
-import org.apache.cordova.*;
-
-public class whitelist extends MainTestActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.init();
- ((AndroidWebView)appView).setWebViewClient(new TestViewClient(cordovaInterface, ((AndroidWebView)appView)));
- 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 AndroidWebViewClient {
-
- public TestViewClient(CordovaInterface ctx, AndroidWebView app) {
- super(ctx, app);
- }
-
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- LOG.d("whitelist", "shouldOverrideUrlLoading(" + url + ")");
- LOG.d("whitelist", "originalUrl=" + view.getOriginalUrl());
- return super.shouldOverrideUrlLoading(view, url);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/src/org/apache/cordova/test/xhr.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/xhr.java b/test/src/org/apache/cordova/test/xhr.java
deleted file mode 100755
index 4f73926..0000000
--- a/test/src/org/apache/cordova/test/xhr.java
+++ /dev/null
@@ -1,30 +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 xhr extends CordovaActivity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.loadUrl("file:///android_asset/www/xhr/index.html");
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/3] android commit: Add back a test that url (and errorUrl) are not
settable via Intent extras
Posted by ag...@apache.org.
Add back a test that url (and errorUrl) are not settable via Intent extras
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/9baa2750
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/9baa2750
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/9baa2750
Branch: refs/heads/master
Commit: 9baa27508ab7eb7a90ed405809aad9f20b318882
Parents: c3267de
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 12 15:03:44 2015 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 12 15:03:44 2015 -0500
----------------------------------------------------------------------
.../org/apache/cordova/test/BaseCordovaIntegrationTest.java | 9 +++------
.../src/org/apache/cordova/test/ErrorUrlTest.java | 4 +++-
2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/9baa2750/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java b/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
index ff76930..ecc40f6 100644
--- a/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
+++ b/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
@@ -37,14 +37,11 @@ public class BaseCordovaIntegrationTest extends ActivityInstrumentationTestCase2
super(MainTestActivity.class);
}
- protected void setUpWithStartUrl(String url) {
- setUpWithStartUrl(url, null, null);
- }
- protected void setUpWithStartUrl(String url, String prefKey, String prefValue) {
+ protected void setUpWithStartUrl(String url, String... prefsAndValues) {
Intent intent = new Intent(getInstrumentation().getContext(), MainTestActivity.class);
intent.putExtra("testStartUrl", url);
- if (prefKey != null) {
- intent.putExtra(prefKey, prefValue);
+ for (int i = 0; i < prefsAndValues.length; i += 2) {
+ intent.putExtra(prefsAndValues[i], prefsAndValues[i + 1]);
}
setActivityIntent(intent);
testActivity = getActivity();
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/9baa2750/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java b/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
index fc6ce8c..9038380 100644
--- a/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
+++ b/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
@@ -24,10 +24,12 @@ package org.apache.cordova.test;
public class ErrorUrlTest extends BaseCordovaIntegrationTest {
private static final String START_URL = "file:///android_asset/www/htmlnotfound/index.html";
private static final String ERROR_URL = "file:///android_asset/www/htmlnotfound/error.html";
+ private static final String INVALID_URL = "file:///android_asset/www/htmlnotfound/invalid.html";
protected void setUp() throws Exception {
super.setUp();
- setUpWithStartUrl(START_URL, "testErrorUrl", ERROR_URL);
+ // INVALID_URL tests that errorUrl and url are *not* settable via the intent.
+ setUpWithStartUrl(START_URL, "testErrorUrl", ERROR_URL, "errorurl", INVALID_URL, "url", INVALID_URL);
}
public void testUrl() throws Throwable {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/3] android commit: Revert "Reverting the refactor. I'd rather have
4 failures due to timing than tests completely disappear"
Posted by ag...@apache.org.
Revert "Reverting the refactor. I'd rather have 4 failures due to timing than tests completely disappear"
This reverts commit 390927772ea93fae497089d7db4b66775f9a39b3.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/c3267def
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/c3267def
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/c3267def
Branch: refs/heads/master
Commit: c3267def97f53c4a933104f620ce4d98177f0f73
Parents: 3909277
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 12 14:48:49 2015 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 12 14:48:49 2015 -0500
----------------------------------------------------------------------
test/AndroidManifest.xml | 182 ------------
test/README.md | 4 +-
.../cordova/test/BackButtonMultiPageTest.java | 194 +++++++++++++
.../test/BaseCordovaIntegrationTest.java | 55 ++++
.../cordova/test/CordovaActivityTest.java | 45 +++
.../cordova/test/CordovaResourceApiTest.java | 258 +++++++++++++++++
.../org/apache/cordova/test/ErrorUrlTest.java | 42 +++
.../apache/cordova/test/HtmlNotFoundTest.java | 41 +++
.../src/org/apache/cordova/test/IFrameTest.java | 107 +++++++
.../apache/cordova/test/InflateLayoutTest.java | 56 ++++
.../test/junit/BackButtonMultiPageTest.java | 278 ------------------
.../cordova/test/junit/CordovaActivityTest.java | 79 ------
.../test/junit/CordovaResourceApiTest.java | 281 -------------------
.../apache/cordova/test/junit/CordovaTest.java | 116 --------
.../apache/cordova/test/junit/ErrorUrlTest.java | 82 ------
.../apache/cordova/test/junit/FixWebView.java | 43 ---
.../cordova/test/junit/HtmlNotFoundTest.java | 80 ------
.../apache/cordova/test/junit/IFrameTest.java | 128 ---------
.../test/junit/IntentUriOverrideTest.java | 94 -------
.../cordova/test/junit/LifecycleTest.java | 34 ---
.../cordova/test/junit/PluginManagerTest.java | 70 -----
.../cordova/test/junit/SplashscreenTest.java | 49 ----
.../org/apache/cordova/test/junit/XhrTest.java | 34 ---
test/assets/www/error.html | 8 -
test/assets/www/index.html | 36 ++-
test/assets/www/main.js | 133 ---------
test/assets/www/splashscreen/index.html | 38 ---
test/res/drawable/sandy.jpg | Bin 48450 -> 0 bytes
test/res/xml/config.xml | 3 -
.../apache/cordova/pluginApi/pluginStub.java | 39 ---
.../org/apache/cordova/test/ActivityPlugin.java | 60 ++--
.../cordova/test/BaseTestCordovaActivity.java | 50 ++++
.../cordova/test/CordovaDriverAction.java | 78 -----
.../test/CordovaWebViewTestActivity.java | 87 ++----
.../apache/cordova/test/MainTestActivity.java | 24 +-
.../apache/cordova/test/SabotagedActivity.java | 92 ------
.../cordova/test/backbuttonmultipage.java | 30 --
.../src/org/apache/cordova/test/background.java | 33 ---
.../apache/cordova/test/backgroundcolor.java | 37 ---
test/src/org/apache/cordova/test/errorurl.java | 33 ---
.../src/org/apache/cordova/test/fullscreen.java | 39 ---
.../org/apache/cordova/test/htmlnotfound.java | 31 --
test/src/org/apache/cordova/test/iframe.java | 30 --
.../cordova/test/junit/GapClientTest.java | 66 -----
test/src/org/apache/cordova/test/lifecycle.java | 30 --
test/src/org/apache/cordova/test/loading.java | 31 --
test/src/org/apache/cordova/test/menus.java | 2 +-
.../org/apache/cordova/test/splashscreen.java | 35 ---
test/src/org/apache/cordova/test/tests.java | 32 ---
test/src/org/apache/cordova/test/timeout.java | 34 ---
test/src/org/apache/cordova/test/whitelist.java | 51 ----
test/src/org/apache/cordova/test/xhr.java | 30 --
52 files changed, 941 insertions(+), 2603 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml
index e058a42..7ceaf2e 100755
--- a/test/AndroidManifest.xml
+++ b/test/AndroidManifest.xml
@@ -69,201 +69,19 @@
android:windowSoftInputMode="adjustPan"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.background" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.backgroundcolor" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.basicauth" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
android:name="org.apache.cordova.test.MainTestActivity" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.CordovaDriverAction" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.errorurl" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.fullscreen" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.htmlnotfound" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.iframe" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.lifecycle" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.loading" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
</activity>
<activity
android:windowSoftInputMode="adjustPan"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
android:name="org.apache.cordova.test.menus" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.splashscreen" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.tests" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.timeout" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
</activity>
<activity
android:windowSoftInputMode="adjustPan"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
android:name="org.apache.cordova.test.userwebview" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.whitelist" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.xhr" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.backbuttonmultipage" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
- <activity
- android:windowSoftInputMode="adjustPan"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden"
- android:name="org.apache.cordova.test.SabotagedActivity" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
</activity>
</application>
</manifest>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/README.md
----------------------------------------------------------------------
diff --git a/test/README.md b/test/README.md
index 700cee2..24b10c1 100755
--- a/test/README.md
+++ b/test/README.md
@@ -45,9 +45,9 @@ Copy it from a freshly created project:
Robotium has to be installed for the onScrollChanged tests to work correctly. It can be
found at https://code.google.com/p/robotium/ and the jar should be put in the
-'androidTests/libs' directory'.
+'androidTest/libs' directory'.
- mkdir -p androidTests/libs && curl 'http://dl.bintray.com/robotium/generic/robotium-solo-5.2.1.jar' > androidTests/libs/robotium-solo-5.2.1.jar
+ mkdir -p androidTest/libs && curl 'http://dl.bintray.com/robotium/generic/robotium-solo-5.2.1.jar' > androidTest/libs/robotium-solo-5.2.1.jar
## Running
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java b/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java
new file mode 100644
index 0000000..7dddec6
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java
@@ -0,0 +1,194 @@
+package org.apache.cordova.test;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+import android.view.KeyEvent;
+import android.view.inputmethod.BaseInputConnection;
+
+public class BackButtonMultiPageTest extends BaseCordovaIntegrationTest {
+ private static final String START_URL = "file:///android_asset/www/backbuttonmultipage/index.html";
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ setUpWithStartUrl(START_URL);
+ }
+
+ public void testViaHref() throws Throwable {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.sendJavascript("window.location = 'sample2.html';");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.sendJavascript("window.location = 'sample3.html';"); }
+ });
+
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ assertTrue(cordovaWebView.backHistory());
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ assertTrue(cordovaWebView.backHistory());
+ }
+ });
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ assertFalse(cordovaWebView.backHistory());
+ }
+ });
+ }
+
+ public void testViaLoadUrl() throws Throwable {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ assertTrue(cordovaWebView.backHistory());
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ assertTrue(cordovaWebView.backHistory());
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/index.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ assertFalse(cordovaWebView.backHistory());
+ }
+ });
+ }
+
+ public void testViaBackButtonOnView() throws Throwable {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ cordovaWebView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ cordovaWebView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ String url = cordovaWebView.getUrl();
+ assertTrue(url.endsWith("sample3.html"));
+ BaseInputConnection viewConnection = new BaseInputConnection(cordovaWebView.getView(), 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);
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ String url = cordovaWebView.getUrl();
+ assertTrue(url.endsWith("sample2.html"));
+ BaseInputConnection viewConnection = new BaseInputConnection(cordovaWebView.getView(), 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);
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/index.html", testActivity.onPageFinishedUrl.take());
+ }
+
+ public void testViaBackButtonOnLayout() throws Throwable {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ cordovaWebView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ cordovaWebView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ String url = cordovaWebView.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);
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ String url = cordovaWebView.getUrl();
+ assertTrue(url.endsWith("sample2.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);
+ }
+ });
+ assertEquals("file:///android_asset/www/backbuttonmultipage/index.html", testActivity.onPageFinishedUrl.take());
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java b/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
new file mode 100644
index 0000000..ff76930
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java
@@ -0,0 +1,55 @@
+package org.apache.cordova.test;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+import android.content.Intent;
+import android.test.ActivityInstrumentationTestCase2;
+import android.widget.FrameLayout;
+
+import org.apache.cordova.CordovaWebView;
+
+public class BaseCordovaIntegrationTest extends ActivityInstrumentationTestCase2<MainTestActivity> {
+ protected MainTestActivity testActivity;
+ protected FrameLayout containerView;
+ protected CordovaWebView cordovaWebView;
+
+
+ public BaseCordovaIntegrationTest() {
+ super(MainTestActivity.class);
+ }
+
+ protected void setUpWithStartUrl(String url) {
+ setUpWithStartUrl(url, null, null);
+ }
+ protected void setUpWithStartUrl(String url, String prefKey, String prefValue) {
+ Intent intent = new Intent(getInstrumentation().getContext(), MainTestActivity.class);
+ intent.putExtra("testStartUrl", url);
+ if (prefKey != null) {
+ intent.putExtra(prefKey, prefValue);
+ }
+ setActivityIntent(intent);
+ testActivity = getActivity();
+ containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
+ cordovaWebView = testActivity.getCordovaWebView();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java b/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java
new file mode 100644
index 0000000..5fb3847
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java
@@ -0,0 +1,45 @@
+/*
+ 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.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import org.apache.cordova.AndroidWebView;
+
+public class CordovaActivityTest extends BaseCordovaIntegrationTest {
+ private ViewGroup innerContainer;
+ private View testView;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ setUpWithStartUrl(null);
+ innerContainer = (ViewGroup)containerView.getChildAt(0);
+ testView = innerContainer.getChildAt(0);
+ }
+
+ public void testBasicLoad() throws Exception {
+ assertTrue(testView instanceof AndroidWebView);
+ assertTrue(innerContainer instanceof LinearLayout);
+ String onPageFinishedUrl = testActivity.onPageFinishedUrl.take();
+ assertEquals(MainTestActivity.START_URL, onPageFinishedUrl);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java b/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java
new file mode 100644
index 0000000..73aa066
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java
@@ -0,0 +1,258 @@
+
+package org.apache.cordova.test;
+
+/*
+ *
+ * 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.
+ *
+ */
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Environment;
+import android.provider.MediaStore;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.CordovaResourceApi;
+import org.apache.cordova.CordovaResourceApi.OpenForReadResult;
+import org.apache.cordova.PluginEntry;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Scanner;
+
+public class CordovaResourceApiTest extends BaseCordovaIntegrationTest {
+ CordovaResourceApi resourceApi;
+ String execPayload;
+ Integer execStatus;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ setUpWithStartUrl(null);
+ resourceApi = cordovaWebView.getResourceApi();
+ resourceApi.setThreadCheckingEnabled(false);
+ cordovaWebView.getPluginManager().addService(new PluginEntry("CordovaResourceApiTestPlugin1", new CordovaPlugin() {
+ @Override
+ public Uri remapUri(Uri uri) {
+ if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite")) {
+ return cordovaWebView.getResourceApi().remapUri(
+ Uri.parse("data:text/plain;charset=utf-8,pass"));
+ }
+ return null;
+ }
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
+ synchronized (CordovaResourceApiTest.this) {
+ execPayload = args.getString(0);
+ execStatus = args.getInt(1);
+ CordovaResourceApiTest.this.notify();
+ }
+ return true;
+ }
+ }));
+ }
+
+ private Uri createTestImageContentUri() {
+ Bitmap imageBitmap = BitmapFactory.decodeResource(testActivity.getResources(), R.drawable.icon);
+ String stored = MediaStore.Images.Media.insertImage(testActivity.getContentResolver(),
+ imageBitmap, "app-icon", "desc");
+ return Uri.parse(stored);
+ }
+
+ private void performApiTest(Uri uri, String expectedMimeType, File expectedLocalFile,
+ boolean expectRead, boolean expectWrite) throws IOException {
+ uri = resourceApi.remapUri(uri);
+ assertEquals(expectedLocalFile, resourceApi.mapUriToFile(uri));
+
+ try {
+ OpenForReadResult readResult = resourceApi.openForRead(uri);
+ String mimeType2 = resourceApi.getMimeType(uri);
+ assertEquals("openForRead mime-type", expectedMimeType, readResult.mimeType);
+ assertEquals("getMimeType mime-type", expectedMimeType, mimeType2);
+ readResult.inputStream.read();
+ if (!expectRead) {
+ fail("Expected getInputStream to throw.");
+ }
+ } catch (IOException e) {
+ if (expectRead) {
+ throw e;
+ }
+ }
+ try {
+ OutputStream outStream = resourceApi.openOutputStream(uri);
+ outStream.write(123);
+ if (!expectWrite) {
+ fail("Expected getOutputStream to throw.");
+ }
+ outStream.close();
+ } catch (IOException e) {
+ if (expectWrite) {
+ throw e;
+ }
+ }
+ }
+
+ public void testJavaApis() throws IOException {
+ // testValidContentUri
+ {
+ Uri contentUri = createTestImageContentUri();
+ File localFile = resourceApi.mapUriToFile(contentUri);
+ assertNotNull(localFile);
+ performApiTest(contentUri, "image/jpeg", localFile, true, true);
+ }
+ // testInvalidContentUri
+ {
+ Uri contentUri = Uri.parse("content://media/external/images/media/999999999");
+ performApiTest(contentUri, null, null, false, false);
+ }
+ // testValidAssetUri
+ {
+ Uri assetUri = Uri.parse("file:///android_asset/www/index.html?foo#bar"); // Also check for stripping off ? and # correctly.
+ performApiTest(assetUri, "text/html", null, true, false);
+ }
+ // testInvalidAssetUri
+ {
+ Uri assetUri = Uri.parse("file:///android_asset/www/missing.html");
+ performApiTest(assetUri, "text/html", null, false, false);
+ }
+ // testFileUriToExistingFile
+ {
+ File f = File.createTempFile("te s t", ".txt"); // Also check for dealing with spaces.
+ try {
+ Uri fileUri = Uri.parse(f.toURI().toString() + "?foo#bar"); // Also check for stripping off ? and # correctly.
+ performApiTest(fileUri, "text/plain", f, true, true);
+ } finally {
+ f.delete();
+ }
+ }
+ // testFileUriToMissingFile
+ {
+ File f = new File(Environment.getExternalStorageDirectory() + "/somefilethatdoesntexist");
+ Uri fileUri = Uri.parse(f.toURI().toString());
+ try {
+ performApiTest(fileUri, null, f, false, true);
+ } finally {
+ f.delete();
+ }
+ }
+ // testFileUriToMissingFileWithMissingParent
+ {
+ File f = new File(Environment.getExternalStorageDirectory() + "/somedirthatismissing" + System.currentTimeMillis() + "/somefilethatdoesntexist");
+ Uri fileUri = Uri.parse(f.toURI().toString());
+ performApiTest(fileUri, null, f, false, true);
+ }
+ // testUnrecognizedUri
+ {
+ Uri uri = Uri.parse("somescheme://foo");
+ performApiTest(uri, null, null, false, false);
+ }
+ // testRelativeUri
+ {
+ try {
+ resourceApi.openForRead(Uri.parse("/foo"));
+ fail("Should have thrown for relative URI 1.");
+ } catch (Throwable t) {
+ }
+ try {
+ resourceApi.openForRead(Uri.parse("//foo/bar"));
+ fail("Should have thrown for relative URI 2.");
+ } catch (Throwable t) {
+ }
+ try {
+ resourceApi.openForRead(Uri.parse("foo.png"));
+ fail("Should have thrown for relative URI 3.");
+ } catch (Throwable t) {
+ }
+ }
+ // testPluginOverride
+ {
+ Uri uri = Uri.parse("plugin-uri://foohost/android_asset/www/index.html?pluginRewrite=yes");
+ performApiTest(uri, "text/plain", null, true, false);
+ }
+ // testMainThreadUsage
+ {
+ Uri assetUri = Uri.parse("file:///android_asset/www/index.html");
+ resourceApi.setThreadCheckingEnabled(true);
+ try {
+ resourceApi.openForRead(assetUri);
+ fail("Should have thrown for main thread check.");
+ } catch (Throwable t) {
+ }
+ }
+ // testDataUriPlain
+ {
+ Uri uri = Uri.parse("data:text/plain;charset=utf-8,pa%20ss");
+ OpenForReadResult readResult = resourceApi.openForRead(uri);
+ assertEquals("text/plain", readResult.mimeType);
+ String data = new Scanner(readResult.inputStream, "UTF-8").useDelimiter("\\A").next();
+ assertEquals("pa ss", data);
+ }
+ // testDataUriBase64
+ {
+ Uri uri = Uri.parse("data:text/js;charset=utf-8;base64,cGFzcw==");
+ OpenForReadResult readResult = resourceApi.openForRead(uri);
+ assertEquals("text/js", readResult.mimeType);
+ String data = new Scanner(readResult.inputStream, "UTF-8").useDelimiter("\\A").next();
+ assertEquals("pass", data);
+ }
+ }
+
+ public void testWebViewRequestIntercept() throws Throwable
+ {
+ testActivity.onPageFinishedUrl.take();
+ execPayload = null;
+ execStatus = null;
+ cordovaWebView.sendJavascript(
+ "var x = new XMLHttpRequest;\n" +
+ "x.open('GET', 'file:///foo?pluginRewrite=1', false);\n" +
+ "x.send();\n" +
+ "cordova.require('cordova/exec')(null,null,'CordovaResourceApiTestPlugin1', 'foo', [x.responseText, x.status])");
+ try {
+ synchronized (this) {
+ this.wait(2000);
+ }
+ } catch (InterruptedException e) {
+ }
+ assertEquals("pass", execPayload);
+ assertEquals(execStatus.intValue(), 200);
+ }
+
+ public void testWebViewWhiteListRejection() throws Throwable
+ {
+ testActivity.onPageFinishedUrl.take();
+ execPayload = null;
+ execStatus = null;
+ cordovaWebView.sendJavascript(
+ "var x = new XMLHttpRequest;\n" +
+ "x.open('GET', 'http://foo/bar', false);\n" +
+ "x.send();\n" +
+ "cordova.require('cordova/exec')(null,null,'CordovaResourceApiTestPlugin1', 'foo', [x.responseText, x.status])");
+ try {
+ synchronized (this) {
+ this.wait(2000);
+ }
+ } catch (InterruptedException e) {
+ }
+ assertEquals("", execPayload);
+ assertEquals(execStatus.intValue(), 404);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java b/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
new file mode 100644
index 0000000..fc6ce8c
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java
@@ -0,0 +1,42 @@
+package org.apache.cordova.test;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+public class ErrorUrlTest extends BaseCordovaIntegrationTest {
+ private static final String START_URL = "file:///android_asset/www/htmlnotfound/index.html";
+ private static final String ERROR_URL = "file:///android_asset/www/htmlnotfound/error.html";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ setUpWithStartUrl(START_URL, "testErrorUrl", ERROR_URL);
+ }
+
+ public void testUrl() throws Throwable {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ assertEquals(ERROR_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ assertEquals(ERROR_URL, testActivity.getCordovaWebView().getUrl());
+ }
+ });
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java b/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java
new file mode 100644
index 0000000..36fc3bd
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java
@@ -0,0 +1,41 @@
+package org.apache.cordova.test;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+public class HtmlNotFoundTest extends BaseCordovaIntegrationTest {
+ private static final String START_URL = "file:///android_asset/www/htmlnotfound/index.html";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ setUpWithStartUrl(START_URL);
+ }
+ public void testUrl() throws Throwable
+ {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ // TODO: Should this be null? Or some other way to indicate it didn't actually load?
+ runTestOnUiThread(new Runnable() {
+ public void run() {
+ assertEquals(START_URL, testActivity.getCordovaWebView().getUrl());
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/IFrameTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/IFrameTest.java b/test/androidTest/src/org/apache/cordova/test/IFrameTest.java
new file mode 100644
index 0000000..48dae38
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/IFrameTest.java
@@ -0,0 +1,107 @@
+package org.apache.cordova.test;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+import android.test.TouchUtils;
+
+import org.apache.cordova.test.util.Purity;
+
+public class IFrameTest extends BaseCordovaIntegrationTest {
+ private static final String START_URL = "file:///android_asset/www/iframe/index.html";
+
+ private TouchUtils touch;
+ private Purity touchTool;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ setUpWithStartUrl(START_URL);
+ touch = new TouchUtils();
+ touchTool = new Purity(testActivity, getInstrumentation());
+ }
+
+
+ public void testIframeDest() throws Throwable {
+ assertEquals(START_URL, testActivity.onPageFinishedUrl.take());
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.sendJavascript("loadUrl('http://maps.google.com/maps?output=embed');");
+ }
+ });
+ sleep(3000);
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.sendJavascript("loadUrl('index2.html')");
+ }
+ });
+ sleep(1000);
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ String url = cordovaWebView.getUrl();
+ assertTrue(url.endsWith("index.html"));
+ }
+ });
+ }
+
+ public void testIframeHistory() throws Throwable
+ {
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.sendJavascript("loadUrl('http://maps.google.com/maps?output=embed');");
+ }
+ });
+ sleep(3000);
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ cordovaWebView.sendJavascript("loadUrl('index2.html')");
+ }
+ });
+ sleep(1000);
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ String url = cordovaWebView.getUrl();
+ cordovaWebView.backHistory();
+ }
+ });
+ sleep(1000);
+ runTestOnUiThread(new Runnable() {
+ public void run()
+ {
+ String url = cordovaWebView.getUrl();
+ assertTrue(url.endsWith("index.html"));
+ }
+ });
+ }
+
+ private void sleep(int timeout) {
+ try {
+ Thread.sleep(timeout);
+ } catch (InterruptedException e) {
+ fail("Unexpected Timeout");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java b/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java
new file mode 100644
index 0000000..3899cf1
--- /dev/null
+++ b/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java
@@ -0,0 +1,56 @@
+/*
+ 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.test.ActivityInstrumentationTestCase2;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import org.apache.cordova.AndroidWebView;
+
+public class InflateLayoutTest extends ActivityInstrumentationTestCase2<CordovaWebViewTestActivity> {
+
+ private CordovaWebViewTestActivity testActivity;
+ private ViewGroup innerContainer;
+ private View testView;
+
+ @SuppressWarnings("deprecation")
+ public InflateLayoutTest()
+ {
+ super("org.apache.cordova.test",CordovaWebViewTestActivity.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ testActivity = this.getActivity();
+ FrameLayout containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
+ innerContainer = (ViewGroup)containerView.getChildAt(0);
+ testView = innerContainer.getChildAt(0);
+ }
+
+ public void testBasicLoad() throws Exception {
+ assertTrue(testView instanceof AndroidWebView);
+ assertTrue(innerContainer instanceof LinearLayout);
+ String onPageFinishedUrl = testActivity.onPageFinishedUrl.take();
+ assertEquals(CordovaWebViewTestActivity.START_URL, onPageFinishedUrl);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java b/test/androidTest/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
deleted file mode 100644
index cc90538..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.CordovaWebView;
-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;
-
-public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<backbuttonmultipage> {
-
- private int TIMEOUT = 2000;
- backbuttonmultipage testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private CordovaWebView testView;
-
-
- public BackButtonMultiPageTest() {
- super(backbuttonmultipage.class);
- }
-
- @Override
- public void setUp() {
- testActivity = getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = (CordovaWebView) innerContainer.getChildAt(0);
- }
-
- void loadTestPage() {
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/index.html");
- sleep();
- }
-
- @UiThreadTest
- public void testPreconditions(){
- loadTestPage();
- assertNotNull(innerContainer);
- assertNotNull(testView);
- String url = testView.getUrl();
- assertTrue(url.endsWith("index.html"));
- }
-
- public void testViaHref() throws Throwable {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- loadTestPage();
- testView.sendJavascript("window.location = 'sample2.html';");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", url);
- testView.sendJavascript("window.location = 'sample3.html';"); }
- });
-
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", url);
- assertTrue(testView.backHistory());
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", url);
- assertTrue(testView.backHistory());
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertEquals("file:///android_asset/www/backbuttonmultipage/index.html", url);
- }
- });
- }
-
- public void testViaLoadUrl() throws Throwable {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- loadTestPage();
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample2.html"));
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample3.html"));
- testView.backHistory();
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample2.html"));
- testView.backHistory();
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("index.html"));
- testView.backHistory();
- }
- });
- }
-
- public void testViaBackButtonOnView() throws Throwable {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- loadTestPage();
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample2.html"));
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample3.html"));
- 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);
- viewConnection.sendKeyEvent(backUp);
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample2.html"));
- 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);
- viewConnection.sendKeyEvent(backUp);
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("index.html"));
- }
- });
-
- }
-
- public void testViaBackButtonOnLayout() throws Throwable {
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- loadTestPage();
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample2.html"));
- testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
- }
- });
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String 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();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("sample2.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();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String url = testView.getUrl();
- assertTrue(url.endsWith("index.html"));
- }
- });
-
- }
-
- private void sleep() {
- try {
- Thread.sleep(TIMEOUT);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/CordovaActivityTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/CordovaActivityTest.java b/test/androidTest/src/org/apache/cordova/test/junit/CordovaActivityTest.java
deleted file mode 100644
index 965e3d2..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/CordovaActivityTest.java
+++ /dev/null
@@ -1,79 +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.CordovaWebView;
-import org.apache.cordova.PluginManager;
-import org.apache.cordova.test.MainTestActivity;
-
-import android.app.Instrumentation;
-import android.test.ActivityInstrumentationTestCase2;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class CordovaActivityTest extends ActivityInstrumentationTestCase2<MainTestActivity> {
-
- private MainTestActivity testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private CordovaWebView testView;
- private Instrumentation mInstr;
- private int TIMEOUT = 1000;
-
- @SuppressWarnings("deprecation")
- public CordovaActivityTest()
- {
- super("org.apache.cordova.test",MainTestActivity.class);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- mInstr = this.getInstrumentation();
- testActivity = this.getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = (CordovaWebView) innerContainer.getChildAt(0);
-
- }
-
- public void testPreconditions(){
- assertNotNull(innerContainer);
- assertNotNull(testView);
- }
-
-
- public void testForAndroidWebView() {
- String className = testView.getClass().getSimpleName();
- assertTrue(className.equals("AndroidWebView"));
- }
-
- public void testForLinearLayout() {
- String className = innerContainer.getClass().getSimpleName();
- assertTrue(className.equals("LinearLayout"));
- }
-
- private void sleep() {
- try {
- Thread.sleep(TIMEOUT);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java b/test/androidTest/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
deleted file mode 100644
index a8a5370..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/CordovaResourceApiTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-
-package org.apache.cordova.test.junit;
-
-/*
- *
- * 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.
- *
- */
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.CordovaResourceApi;
-import org.apache.cordova.CordovaResourceApi.OpenForReadResult;
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.PluginEntry;
-import org.apache.cordova.test.CordovaWebViewTestActivity;
-import org.apache.cordova.test.R;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Scanner;
-
-public class CordovaResourceApiTest extends ActivityInstrumentationTestCase2<CordovaWebViewTestActivity> {
-
- public CordovaResourceApiTest()
- {
- super(CordovaWebViewTestActivity.class);
- }
-
- CordovaWebView cordovaWebView;
- CordovaResourceApi resourceApi;
-
- private CordovaWebViewTestActivity activity;
- String execPayload;
- Integer execStatus;
-
- protected void setUp() throws Exception {
- super.setUp();
- activity = this.getActivity();
- cordovaWebView = activity.cordovaWebView;
- resourceApi = cordovaWebView.getResourceApi();
- resourceApi.setThreadCheckingEnabled(false);
- cordovaWebView.getPluginManager().addService(new PluginEntry("CordovaResourceApiTestPlugin1", new CordovaPlugin() {
- @Override
- public Uri remapUri(Uri uri) {
- if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite")) {
- return cordovaWebView.getResourceApi().remapUri(
- Uri.parse("data:text/plain;charset=utf-8,pass"));
- }
- return null;
- }
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- synchronized (CordovaResourceApiTest.this) {
- execPayload = args.getString(0);
- execStatus = args.getInt(1);
- CordovaResourceApiTest.this.notify();
- }
- return true;
- }
- }));
- }
-
- private Uri createTestImageContentUri() {
- Bitmap imageBitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.icon);
- String stored = MediaStore.Images.Media.insertImage(activity.getContentResolver(),
- imageBitmap, "app-icon", "desc");
- return Uri.parse(stored);
- }
-
- private void performApiTest(Uri uri, String expectedMimeType, File expectedLocalFile,
- boolean expectRead, boolean expectWrite) throws IOException {
- uri = resourceApi.remapUri(uri);
- assertEquals(expectedLocalFile, resourceApi.mapUriToFile(uri));
-
- try {
- OpenForReadResult readResult = resourceApi.openForRead(uri);
- String mimeType2 = resourceApi.getMimeType(uri);
- assertEquals("openForRead mime-type", expectedMimeType, readResult.mimeType);
- assertEquals("getMimeType mime-type", expectedMimeType, mimeType2);
- readResult.inputStream.read();
- if (!expectRead) {
- fail("Expected getInputStream to throw.");
- }
- } catch (IOException e) {
- if (expectRead) {
- throw e;
- }
- }
- try {
- OutputStream outStream = resourceApi.openOutputStream(uri);
- outStream.write(123);
- if (!expectWrite) {
- fail("Expected getOutputStream to throw.");
- }
- outStream.close();
- } catch (IOException e) {
- if (expectWrite) {
- throw e;
- }
- }
- }
-
- public void testValidContentUri() throws IOException
- {
- Uri contentUri = createTestImageContentUri();
- File localFile = resourceApi.mapUriToFile(contentUri);
- assertNotNull(localFile);
- performApiTest(contentUri, "image/jpeg", localFile, true, true);
- }
-
- public void testInvalidContentUri() throws IOException
- {
- Uri contentUri = Uri.parse("content://media/external/images/media/999999999");
- performApiTest(contentUri, null, null, false, false);
- }
-
- public void testValidAssetUri() throws IOException
- {
- Uri assetUri = Uri.parse("file:///android_asset/www/index.html?foo#bar"); // Also check for stripping off ? and # correctly.
- performApiTest(assetUri, "text/html", null, true, false);
- }
-
- public void testInvalidAssetUri() throws IOException
- {
- Uri assetUri = Uri.parse("file:///android_asset/www/missing.html");
- performApiTest(assetUri, "text/html", null, false, false);
- }
-
- public void testFileUriToExistingFile() throws IOException
- {
- File f = File.createTempFile("te s t", ".txt"); // Also check for dealing with spaces.
- try {
- Uri fileUri = Uri.parse(f.toURI().toString() + "?foo#bar"); // Also check for stripping off ? and # correctly.
- performApiTest(fileUri, "text/plain", f, true, true);
- } finally {
- f.delete();
- }
- }
-
- public void testFileUriToMissingFile() throws IOException
- {
- File f = new File(Environment.getExternalStorageDirectory() + "/somefilethatdoesntexist");
- Uri fileUri = Uri.parse(f.toURI().toString());
- try {
- performApiTest(fileUri, null, f, false, true);
- } finally {
- f.delete();
- }
- }
-
- public void testFileUriToMissingFileWithMissingParent() throws IOException
- {
- File f = new File(Environment.getExternalStorageDirectory() + "/somedirthatismissing" + System.currentTimeMillis() + "/somefilethatdoesntexist");
- Uri fileUri = Uri.parse(f.toURI().toString());
- performApiTest(fileUri, null, f, false, true);
- }
-
- public void testUnrecognizedUri() throws IOException
- {
- Uri uri = Uri.parse("somescheme://foo");
- performApiTest(uri, null, null, false, false);
- }
-
- public void testRelativeUri()
- {
- try {
- resourceApi.openForRead(Uri.parse("/foo"));
- fail("Should have thrown for relative URI 1.");
- } catch (Throwable t) {
- }
- try {
- resourceApi.openForRead(Uri.parse("//foo/bar"));
- fail("Should have thrown for relative URI 2.");
- } catch (Throwable t) {
- }
- try {
- resourceApi.openForRead(Uri.parse("foo.png"));
- fail("Should have thrown for relative URI 3.");
- } catch (Throwable t) {
- }
- }
-
- public void testPluginOverride() throws IOException
- {
- Uri uri = Uri.parse("plugin-uri://foohost/android_asset/www/index.html?pluginRewrite=yes");
- performApiTest(uri, "text/plain", null, true, false);
- }
-
- public void testMainThreadUsage() throws IOException
- {
- Uri assetUri = Uri.parse("file:///android_asset/www/index.html");
- resourceApi.setThreadCheckingEnabled(true);
- try {
- resourceApi.openForRead(assetUri);
- fail("Should have thrown for main thread check.");
- } catch (Throwable t) {
- }
- }
-
-
- public void testDataUriPlain() throws IOException
- {
- Uri uri = Uri.parse("data:text/plain;charset=utf-8,pa%20ss");
- OpenForReadResult readResult = resourceApi.openForRead(uri);
- assertEquals("text/plain", readResult.mimeType);
- String data = new Scanner(readResult.inputStream, "UTF-8").useDelimiter("\\A").next();
- assertEquals("pa ss", data);
- }
-
- public void testDataUriBase64() throws IOException
- {
- Uri uri = Uri.parse("data:text/js;charset=utf-8;base64,cGFzcw==");
- OpenForReadResult readResult = resourceApi.openForRead(uri);
- assertEquals("text/js", readResult.mimeType);
- String data = new Scanner(readResult.inputStream, "UTF-8").useDelimiter("\\A").next();
- assertEquals("pass", data);
- }
-
- public void testWebViewRequestIntercept() throws IOException
- {
- cordovaWebView.sendJavascript(
- "var x = new XMLHttpRequest;\n" +
- "x.open('GET', 'file://foo?pluginRewrite=1', false);\n" +
- "x.send();\n" +
- "cordova.require('cordova/exec')(null,null,'CordovaResourceApiTestPlugin1', 'foo', [x.responseText, x.status])");
- execPayload = null;
- execStatus = null;
- try {
- synchronized (this) {
- this.wait(2000);
- }
- } catch (InterruptedException e) {
- }
- assertEquals("pass", execPayload);
- assertEquals(execStatus.intValue(), 200);
- }
-
- public void testWebViewWhiteListRejection() throws IOException
- {
- cordovaWebView.sendJavascript(
- "var x = new XMLHttpRequest;\n" +
- "x.open('GET', 'http://foo/bar', false);\n" +
- "x.send();\n" +
- "cordova.require('cordova/exec')(null,null,'CordovaResourceApiTestPlugin1', 'foo', [x.responseText, x.status])");
- execPayload = null;
- execStatus = null;
- try {
- synchronized (this) {
- this.wait(2000);
- }
- } catch (InterruptedException e) {
- }
- assertEquals("", execPayload);
- assertEquals(execStatus.intValue(), 404);
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/CordovaTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/CordovaTest.java b/test/androidTest/src/org/apache/cordova/test/junit/CordovaTest.java
deleted file mode 100644
index 2e09611..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/CordovaTest.java
+++ /dev/null
@@ -1,116 +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.CordovaWebView;
-import org.apache.cordova.PluginManager;
-import org.apache.cordova.test.CordovaWebViewTestActivity;
-import org.apache.cordova.test.R;
-
-import android.app.Instrumentation;
-import android.test.ActivityInstrumentationTestCase2;
-import android.view.View;
-
-public class CordovaTest extends
- ActivityInstrumentationTestCase2<CordovaWebViewTestActivity> {
-
- private static final long TIMEOUT = 1000;
- private CordovaWebViewTestActivity testActivity;
- private View testView;
- private String rString;
-
- public CordovaTest() {
- super("org.apache.cordova.test.activities", CordovaWebViewTestActivity.class);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- testActivity = this.getActivity();
- testView = testActivity.findViewById(R.id.cordovaWebView);
- }
-
- public void testPreconditions() {
- assertNotNull(testView);
- }
-
- public void testForAndroidWebView() {
- //Sleep for no reason!!!!
- sleep();
- String className = testView.getClass().getSimpleName();
- assertTrue(className.equals("AndroidWebView"));
- }
-
- /*
- public void testForPluginManager() {
- CordovaWebView v = (CordovaWebView) testView;
- PluginManager p = v.getPluginManager();
- assertNotNull(p);
- String className = p.getClass().getSimpleName();
- assertTrue(className.equals("PluginManager"));
- }
-
- public void testBackButton() {
- CordovaWebView v = (CordovaWebView) testView;
- assertFalse(v.checkBackKey());
- }
-
- public void testLoadUrl() {
- CordovaWebView v = (CordovaWebView) testView;
- v.loadUrlIntoView("file:///android_asset/www/index.html");
- sleep();
- String url = v.getUrl();
- boolean result = url.equals("file:///android_asset/www/index.html");
- assertTrue(result);
- int visible = v.getVisibility();
- assertTrue(visible == View.VISIBLE);
- }
-
- public void testBackHistoryFalse() {
- CordovaWebView v = (CordovaWebView) testView;
- // Move back in the history
- boolean test = v.backHistory();
- assertFalse(test);
- }
-
- // Make sure that we can go back
- public void testBackHistoryTrue() {
- this.testLoadUrl();
- CordovaWebView v = (CordovaWebView) testView;
- v.loadUrlIntoView("file:///android_asset/www/compass/index.html");
- sleep();
- String url = v.getUrl();
- assertTrue(url.equals("file:///android_asset/www/compass/index.html"));
- // Move back in the history
- boolean test = v.backHistory();
- assertTrue(test);
- sleep();
- url = v.getUrl();
- assertTrue(url.equals("file:///android_asset/www/index.html"));
- }
- */
-
-
- private void sleep() {
- try {
- Thread.sleep(TIMEOUT);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/ErrorUrlTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/ErrorUrlTest.java b/test/androidTest/src/org/apache/cordova/test/junit/ErrorUrlTest.java
deleted file mode 100644
index de12bc4..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/ErrorUrlTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.test.errorurl;
-
-import android.test.ActivityInstrumentationTestCase2;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class ErrorUrlTest extends ActivityInstrumentationTestCase2<errorurl> {
-
- private int TIMEOUT = 1000;
- errorurl testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private CordovaWebView testView;
-
- public ErrorUrlTest() {
- super("org.apache.cordova.test",errorurl.class);
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- testActivity = this.getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = (CordovaWebView) innerContainer.getChildAt(0);
- }
-
- public void testPreconditions(){
- assertNotNull(innerContainer);
- assertNotNull(testView);
- }
-
- public void testUrl() throws Throwable
- {
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String good_url = "file:///android_asset/www/htmlnotfound/error.html";
- String url = testView.getUrl();
- assertNotNull(url);
- assertEquals(good_url, url);
-
- }
- });
- }
-
-
- private void sleep() {
- try {
- Thread.sleep(TIMEOUT);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/FixWebView.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/FixWebView.java b/test/androidTest/src/org/apache/cordova/test/junit/FixWebView.java
deleted file mode 100755
index 3b73e29..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/FixWebView.java
+++ /dev/null
@@ -1,43 +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 android.content.Context;
-import android.webkit.WebView;
-
-public class FixWebView extends WebView {
-
- public FixWebView(Context context) {
- super(context);
- }
-
- @Override
- public void pauseTimers() {
- // Do nothing
- }
-
- /**
- * This method is with different signature in order to stop the timers while move application to background
- * @param realPause
- */
- public void pauseTimers(@SuppressWarnings("unused") boolean realPause) {
- super.pauseTimers();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c3267def/test/androidTest/src/org/apache/cordova/test/junit/HtmlNotFoundTest.java
----------------------------------------------------------------------
diff --git a/test/androidTest/src/org/apache/cordova/test/junit/HtmlNotFoundTest.java b/test/androidTest/src/org/apache/cordova/test/junit/HtmlNotFoundTest.java
deleted file mode 100644
index abc4802..0000000
--- a/test/androidTest/src/org/apache/cordova/test/junit/HtmlNotFoundTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.cordova.test.junit;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.test.htmlnotfound;
-
-import android.test.ActivityInstrumentationTestCase2;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-public class HtmlNotFoundTest extends ActivityInstrumentationTestCase2<htmlnotfound> {
-
- private int TIMEOUT = 1000;
- private htmlnotfound testActivity;
- private FrameLayout containerView;
- private LinearLayout innerContainer;
- private CordovaWebView testView;
-
- public HtmlNotFoundTest() {
- super("org.apache.cordova.test",htmlnotfound.class);
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- testActivity = this.getActivity();
- containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
- innerContainer = (LinearLayout) containerView.getChildAt(0);
- testView = (CordovaWebView) innerContainer.getChildAt(0);
- }
-
- public void testPreconditions(){
- assertNotNull(innerContainer);
- assertNotNull(testView);
- }
-
- public void testUrl() throws Throwable
- {
- sleep();
- runTestOnUiThread(new Runnable() {
- public void run()
- {
- String good_url = "file:///android_asset/www/htmlnotfound/error.html";
- String url = testView.getUrl();
- assertNotNull(url);
- assertFalse(url.equals(good_url));
- }
- });
-
- }
-
- private void sleep() {
- try {
- Thread.sleep(TIMEOUT);
- } catch (InterruptedException e) {
- fail("Unexpected Timeout");
- }
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org