Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1FDDD10A20 for ; Wed, 11 Feb 2015 22:28:58 +0000 (UTC) Received: (qmail 45302 invoked by uid 500); 11 Feb 2015 22:28:58 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 45259 invoked by uid 500); 11 Feb 2015 22:28:58 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 45242 invoked by uid 99); 11 Feb 2015 22:28:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2015 22:28:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6985CE05E3; Wed, 11 Feb 2015 22:28:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bowserj@apache.org To: commits@cordova.apache.org Date: Wed, 11 Feb 2015 22:28:57 -0000 Message-Id: <2452496a6ad341f88d73d5cc06b28557@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] android commit: Reverting the refactor. I'd rather have 4 failures due to timing than tests completely disappear Repository: cordova-android Updated Branches: refs/heads/master 172157101 -> 390927772 http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/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 new file mode 100644 index 0000000..800dead --- /dev/null +++ b/test/androidTest/src/org/apache/cordova/test/junit/IFrameTest.java @@ -0,0 +1,128 @@ +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/39092777/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 new file mode 100644 index 0000000..e84a8dc --- /dev/null +++ b/test/androidTest/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java @@ -0,0 +1,94 @@ +/* + 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 { + + 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/39092777/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 new file mode 100644 index 0000000..5423575 --- /dev/null +++ b/test/androidTest/src/org/apache/cordova/test/junit/LifecycleTest.java @@ -0,0 +1,34 @@ +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 { + + public LifecycleTest() + { + super("org.apache.cordova.test",lifecycle.class); + } +} http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/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 new file mode 100644 index 0000000..bcdead6 --- /dev/null +++ b/test/androidTest/src/org/apache/cordova/test/junit/PluginManagerTest.java @@ -0,0 +1,70 @@ +/* + 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 { + + 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/39092777/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 new file mode 100644 index 0000000..14da5ac --- /dev/null +++ b/test/androidTest/src/org/apache/cordova/test/junit/SplashscreenTest.java @@ -0,0 +1,49 @@ +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 { + + 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/39092777/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 new file mode 100644 index 0000000..16c977f --- /dev/null +++ b/test/androidTest/src/org/apache/cordova/test/junit/XhrTest.java @@ -0,0 +1,34 @@ +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 { + + public XhrTest() + { + super(xhr.class); + } +} http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/test/assets/www/error.html ---------------------------------------------------------------------- diff --git a/test/assets/www/error.html b/test/assets/www/error.html new file mode 100644 index 0000000..aad167d --- /dev/null +++ b/test/assets/www/error.html @@ -0,0 +1,8 @@ + + + OH NOES! + + +

Things went terribly wrong!

+ + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/test/assets/www/index.html ---------------------------------------------------------------------- diff --git a/test/assets/www/index.html b/test/assets/www/index.html index f55aa0a..d4659f7 100755 --- a/test/assets/www/index.html +++ b/test/assets/www/index.html @@ -26,8 +26,8 @@ + + + +

Splash Screen Test

+
+

Cordova:  

+

Deviceready:  

+
+
+ You should have seen the splash screen for 2 seconds.
+ + http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/test/res/drawable/sandy.jpg ---------------------------------------------------------------------- diff --git a/test/res/drawable/sandy.jpg b/test/res/drawable/sandy.jpg new file mode 100755 index 0000000..c956d30 Binary files /dev/null and b/test/res/drawable/sandy.jpg differ http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/test/res/xml/config.xml ---------------------------------------------------------------------- diff --git a/test/res/xml/config.xml b/test/res/xml/config.xml index 894c336..4370357 100644 --- a/test/res/xml/config.xml +++ b/test/res/xml/config.xml @@ -38,4 +38,7 @@ + + + http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/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 new file mode 100644 index 0000000..b91a7af --- /dev/null +++ b/test/src/org/apache/cordova/pluginApi/pluginStub.java @@ -0,0 +1,39 @@ +/* + 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/39092777/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 c6a96ec..19a50a2 100755 --- a/test/src/org/apache/cordova/test/ActivityPlugin.java +++ b/test/src/org/apache/cordova/test/ActivityPlugin.java @@ -28,40 +28,52 @@ 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"; - 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; + /** + * 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; } return false; } - public void startActivity(String className, String startUrl, JSONObject extraPrefs) throws JSONException { + // -------------------------------------------------------------------------- + // LOCAL METHODS + // -------------------------------------------------------------------------- + + public void startActivity(String className) { try { - if (!startUrl.contains(":")) { - startUrl = "file:///android_asset/www/" + startUrl; - } - Intent intent = new Intent(this.cordova.getActivity(), Class.forName(className)); - intent.putExtra("testStartUrl", startUrl); - Iterator iter = extraPrefs.keys(); - while (iter.hasNext()) { - String key = iter.next(); - intent.putExtra(key, extraPrefs.getString(key)); - } + Intent intent = new Intent().setClass(this.cordova.getActivity(), Class.forName(className)); 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/39092777/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 deleted file mode 100644 index 0a28036..0000000 --- a/test/src/org/apache/cordova/test/BaseTestCordovaActivity.java +++ /dev/null @@ -1,50 +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.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 onPageFinishedUrl = new ArrayBlockingQueue(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/39092777/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 new file mode 100644 index 0000000..0559f5f --- /dev/null +++ b/test/src/org/apache/cordova/test/CordovaDriverAction.java @@ -0,0 +1,78 @@ +/* + 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/39092777/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 ce9797e..43e0b2b 100644 --- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java +++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java @@ -19,57 +19,90 @@ package org.apache.cordova.test; -import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; 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; -/** - * 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 onPageFinishedUrl = new ArrayBlockingQueue(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); - } - }; +public class CordovaWebViewTestActivity extends Activity implements CordovaInterface { + public CordovaWebView cordovaWebView; + 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); - - AndroidWebView webView = (AndroidWebView) findViewById(R.id.cordovaWebView); - cordovaWebView = webView; - cordovaWebView.init(cordovaInterface, Config.getPluginEntries(), Config.getWhitelist(), + + cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView); + cordovaWebView.init(this, Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences()); - cordovaWebView.loadUrl(START_URL); + 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 + } - public CordovaWebView getCordovaWebView() { - return cordovaWebView; + //Note: This must always return an activity! + public Activity getActivity() { + return this; + } + + @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 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(); + } } } http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/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 45d8309..2a0f67e 100644 --- a/test/src/org/apache/cordova/test/MainTestActivity.java +++ b/test/src/org/apache/cordova/test/MainTestActivity.java @@ -19,34 +19,14 @@ 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; -import java.util.concurrent.ArrayBlockingQueue; - -public class MainTestActivity extends BaseTestCordovaActivity { - public static final String START_URL = "file:///android_asset/www/index.html"; - +public class MainTestActivity extends CordovaActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - 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); - } + super.loadUrl("file:///android_asset/www/index.html"); } } http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/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 new file mode 100644 index 0000000..7f3edc5 --- /dev/null +++ b/test/src/org/apache/cordova/test/SabotagedActivity.java @@ -0,0 +1,92 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..d744198 --- /dev/null +++ b/test/src/org/apache/cordova/test/backbuttonmultipage.java @@ -0,0 +1,30 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..d7ed101 --- /dev/null +++ b/test/src/org/apache/cordova/test/background.java @@ -0,0 +1,33 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..30e297f --- /dev/null +++ b/test/src/org/apache/cordova/test/backgroundcolor.java @@ -0,0 +1,37 @@ +/* + 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 + // + 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/39092777/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 new file mode 100755 index 0000000..e946e40 --- /dev/null +++ b/test/src/org/apache/cordova/test/errorurl.java @@ -0,0 +1,33 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..0aa1ee9 --- /dev/null +++ b/test/src/org/apache/cordova/test/fullscreen.java @@ -0,0 +1,39 @@ +/* + 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, + // + 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/39092777/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 new file mode 100755 index 0000000..c602922 --- /dev/null +++ b/test/src/org/apache/cordova/test/htmlnotfound.java @@ -0,0 +1,31 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..3d30cfb --- /dev/null +++ b/test/src/org/apache/cordova/test/iframe.java @@ -0,0 +1,30 @@ +/* + 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/39092777/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 new file mode 100644 index 0000000..ce6ca8c --- /dev/null +++ b/test/src/org/apache/cordova/test/junit/GapClientTest.java @@ -0,0 +1,66 @@ +/* + 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 { + + 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/39092777/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 new file mode 100755 index 0000000..d1c4212 --- /dev/null +++ b/test/src/org/apache/cordova/test/lifecycle.java @@ -0,0 +1,30 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..da2c4ff --- /dev/null +++ b/test/src/org/apache/cordova/test/loading.java @@ -0,0 +1,31 @@ +/* + 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/39092777/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 6ef12c5..4c65ed5 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 BaseTestCordovaActivity { +public class menus extends CordovaActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); http://git-wip-us.apache.org/repos/asf/cordova-android/blob/39092777/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 new file mode 100755 index 0000000..34051bb --- /dev/null +++ b/test/src/org/apache/cordova/test/splashscreen.java @@ -0,0 +1,35 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..64ad56e --- /dev/null +++ b/test/src/org/apache/cordova/test/tests.java @@ -0,0 +1,32 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..8a418a3 --- /dev/null +++ b/test/src/org/apache/cordova/test/timeout.java @@ -0,0 +1,34 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..e2029a9 --- /dev/null +++ b/test/src/org/apache/cordova/test/whitelist.java @@ -0,0 +1,51 @@ +/* + 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/39092777/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 new file mode 100755 index 0000000..4f73926 --- /dev/null +++ b/test/src/org/apache/cordova/test/xhr.java @@ -0,0 +1,30 @@ +/* + 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