From 3bbc7fb3284687fa5f3572499d56d49eba78fd92 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Tue, 14 Feb 2017 16:45:57 -0800 Subject: [PATCH] CB-12465: Writing new JUnit Test Instrumentation to replace tests and retire problmatic tests This closes #363 --- bin/templates/project/build.gradle | 2 +- test/.classpath | 9 - test/.gitignore | 9 + test/.project | 33 - test/AndroidManifest.xml | 87 - test/README.md | 61 - .../cordova/test/BackButtonMultiPageTest.java | 194 -- .../test/BaseCordovaIntegrationTest.java | 52 - .../cordova/test/CordovaActivityTest.java | 48 - .../cordova/test/CordovaPluginTest.java | 68 - .../cordova/test/CordovaResourceApiTest.java | 280 --- .../org/apache/cordova/test/ErrorUrlTest.java | 44 - .../apache/cordova/test/HtmlNotFoundTest.java | 46 - .../org/apache/cordova/test/IFrameTest.java | 107 - .../cordova/test/InflateLayoutTest.java | 56 - .../cordova/test/IntentPreferenceTest.java | 44 - .../org/apache/cordova/test/util/Purity.java | 171 -- test/app/.gitignore | 1 + test/app/build.gradle | 35 + test/app/proguard-rules.pro | 17 + .../unittests/BackButtonMultipageTest.java | 158 ++ .../unittests/EmbeddedWebViewTest.java | 53 + .../cordova/unittests/ErrorUrlTest.java | 68 + .../apache/cordova/unittests/IFrameTest.java | 114 + .../MessageChannelMultipageTest.java} | 67 +- .../unittests/StandardActivityTest.java | 100 + test/app/src/main/AndroidManifest.xml | 40 + .../assets/www/backbuttonmultipage/index.html | 0 .../www/backbuttonmultipage/sample2.html | 0 .../www/backbuttonmultipage/sample3.html | 0 .../assets/www/backgroundcolor/index.html | 0 test/app/src/main/assets/www/cordova.js | 2208 +++++++++++++++++ .../src/main}/assets/www/cordova_plugins.js | 0 .../main}/assets/www/fullscreen/index.html | 0 .../main}/assets/www/htmlnotfound/error.html | 0 .../src/main}/assets/www/iframe/index.html | 4 +- .../src/main}/assets/www/iframe/index2.html | 0 test/{ => app/src/main}/assets/www/index.html | 7 - .../src/main}/assets/www/lifecycle/index.html | 0 .../main}/assets/www/lifecycle/index2.html | 0 test/{ => app/src/main}/assets/www/main.js | 0 test/{ => app/src/main}/assets/www/master.css | 0 .../src/main}/assets/www/whitelist/index.html | 0 .../main}/assets/www/whitelist/index2.html | 0 .../unittests/EmbeddedWebViewActivity.java | 110 + .../cordova/unittests}/LifeCyclePlugin.java | 2 +- .../cordova/unittests/StandardActivity.java} | 37 +- .../cordova/unittests/TestActivity.java} | 37 +- .../app/src/main/res/layout/activity_main.xml | 16 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes .../app/src/main/res/values-w820dp/dimens.xml | 6 + test/app/src/main/res/values/colors.xml | 6 + test/app/src/main/res/values/dimens.xml | 5 + test/app/src/main/res/values/strings.xml | 3 + test/app/src/main/res/values/styles.xml | 11 + test/{ => app/src/main}/res/xml/config.xml | 6 +- .../unittests/NativeToJsMessageQueueTest.java | 126 + test/assets/www/background/index.html | 103 - test/assets/www/background/index2.html | 102 - test/assets/www/basicauth/index.html | 40 - test/assets/www/jqmtabbackbutton/index.html | 67 - test/assets/www/jqmtabbackbutton/tab1.html | 47 - test/assets/www/jqmtabbackbutton/tab2.html | 48 - test/assets/www/jqmtabbackbutton/tab3.html | 48 - test/assets/www/menus/index.html | 45 - test/assets/www/userwebview/index.html | 65 - test/assets/www/xhr/index.html | 64 - test/build.gradle | 83 +- test/gradle.properties | 17 + test/gradle/wrapper/gradle-wrapper.properties | 6 + test/gradlew | 160 ++ test/gradlew.bat | 90 + test/project.properties | 12 - test/res/drawable-hdpi/ic_launcher.png | Bin 6080 -> 0 bytes test/res/drawable-ldpi/ic_launcher.png | Bin 3096 -> 0 bytes test/res/drawable-mdpi/ic_launcher.png | Bin 4090 -> 0 bytes test/res/drawable/icon.png | Bin 5800 -> 0 bytes test/res/values/strings.xml | 22 - test/settings.gradle | 21 +- .../apache/cordova/test/ActivityPlugin.java | 73 - .../test/CordovaWebViewTestActivity.java | 74 - .../apache/cordova/test/MainTestActivity.java | 45 - test/src/org/apache/cordova/test/menus.java | 81 - .../org/apache/cordova/test/userwebview.java | 84 - 88 files changed, 3455 insertions(+), 2490 deletions(-) delete mode 100644 test/.classpath create mode 100644 test/.gitignore delete mode 100644 test/.project delete mode 100755 test/AndroidManifest.xml delete mode 100755 test/README.md delete mode 100644 test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/CordovaPluginTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/IFrameTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/IntentPreferenceTest.java delete mode 100644 test/androidTest/src/org/apache/cordova/test/util/Purity.java create mode 100644 test/app/.gitignore create mode 100644 test/app/build.gradle create mode 100644 test/app/proguard-rules.pro create mode 100644 test/app/src/androidTest/java/org/apache/cordova/unittests/BackButtonMultipageTest.java create mode 100644 test/app/src/androidTest/java/org/apache/cordova/unittests/EmbeddedWebViewTest.java create mode 100644 test/app/src/androidTest/java/org/apache/cordova/unittests/ErrorUrlTest.java create mode 100644 test/app/src/androidTest/java/org/apache/cordova/unittests/IFrameTest.java rename test/{androidTest/src/org/apache/cordova/test/MessageChannelMultiPageTest.java => app/src/androidTest/java/org/apache/cordova/unittests/MessageChannelMultipageTest.java} (74%) create mode 100644 test/app/src/androidTest/java/org/apache/cordova/unittests/StandardActivityTest.java create mode 100644 test/app/src/main/AndroidManifest.xml rename test/{ => app/src/main}/assets/www/backbuttonmultipage/index.html (100%) rename test/{ => app/src/main}/assets/www/backbuttonmultipage/sample2.html (100%) rename test/{ => app/src/main}/assets/www/backbuttonmultipage/sample3.html (100%) rename test/{ => app/src/main}/assets/www/backgroundcolor/index.html (100%) create mode 100644 test/app/src/main/assets/www/cordova.js rename test/{ => app/src/main}/assets/www/cordova_plugins.js (100%) rename test/{ => app/src/main}/assets/www/fullscreen/index.html (100%) rename test/{ => app/src/main}/assets/www/htmlnotfound/error.html (100%) rename test/{ => app/src/main}/assets/www/iframe/index.html (89%) rename test/{ => app/src/main}/assets/www/iframe/index2.html (100%) rename test/{ => app/src/main}/assets/www/index.html (77%) rename test/{ => app/src/main}/assets/www/lifecycle/index.html (100%) rename test/{ => app/src/main}/assets/www/lifecycle/index2.html (100%) rename test/{ => app/src/main}/assets/www/main.js (100%) rename test/{ => app/src/main}/assets/www/master.css (100%) rename test/{ => app/src/main}/assets/www/whitelist/index.html (100%) rename test/{ => app/src/main}/assets/www/whitelist/index2.html (100%) create mode 100644 test/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java rename test/{src/org/apache/cordova/test => app/src/main/java/org/apache/cordova/unittests}/LifeCyclePlugin.java (97%) rename test/{res/layout/main.xml => app/src/main/java/org/apache/cordova/unittests/StandardActivity.java} (57%) rename test/{src/org/apache/cordova/test/BaseTestCordovaActivity.java => app/src/main/java/org/apache/cordova/unittests/TestActivity.java} (63%) create mode 100644 test/app/src/main/res/layout/activity_main.xml create mode 100644 test/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 test/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 test/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 test/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 test/app/src/main/res/values-w820dp/dimens.xml create mode 100644 test/app/src/main/res/values/colors.xml create mode 100644 test/app/src/main/res/values/dimens.xml create mode 100644 test/app/src/main/res/values/strings.xml create mode 100644 test/app/src/main/res/values/styles.xml rename test/{ => app/src/main}/res/xml/config.xml (92%) create mode 100644 test/app/src/test/java/org/apache/cordova/unittests/NativeToJsMessageQueueTest.java delete mode 100755 test/assets/www/background/index.html delete mode 100755 test/assets/www/background/index2.html delete mode 100755 test/assets/www/basicauth/index.html delete mode 100755 test/assets/www/jqmtabbackbutton/index.html delete mode 100755 test/assets/www/jqmtabbackbutton/tab1.html delete mode 100755 test/assets/www/jqmtabbackbutton/tab2.html delete mode 100755 test/assets/www/jqmtabbackbutton/tab3.html delete mode 100755 test/assets/www/menus/index.html delete mode 100755 test/assets/www/userwebview/index.html delete mode 100755 test/assets/www/xhr/index.html create mode 100644 test/gradle.properties create mode 100644 test/gradle/wrapper/gradle-wrapper.properties create mode 100755 test/gradlew create mode 100644 test/gradlew.bat delete mode 100644 test/project.properties delete mode 100755 test/res/drawable-hdpi/ic_launcher.png delete mode 100755 test/res/drawable-ldpi/ic_launcher.png delete mode 100755 test/res/drawable-mdpi/ic_launcher.png delete mode 100755 test/res/drawable/icon.png delete mode 100644 test/res/values/strings.xml delete mode 100755 test/src/org/apache/cordova/test/ActivityPlugin.java delete mode 100644 test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java delete mode 100644 test/src/org/apache/cordova/test/MainTestActivity.java delete mode 100755 test/src/org/apache/cordova/test/menus.java delete mode 100755 test/src/org/apache/cordova/test/userwebview.java diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle index 5146c991..ef229719 100644 --- a/bin/templates/project/build.gradle +++ b/bin/templates/project/build.gradle @@ -30,7 +30,7 @@ buildscript { // http://tools.android.com/tech-docs/new-build-system/version-compatibility // and https://issues.apache.org/jira/browse/CB-8143 dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:2.2.3' } } diff --git a/test/.classpath b/test/.classpath deleted file mode 100644 index 51769745..00000000 --- a/test/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 00000000..39fb081a --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/test/.project b/test/.project deleted file mode 100644 index 7bacb6f0..00000000 --- a/test/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - CordovaViewTestActivity - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml deleted file mode 100755 index 3507bed3..00000000 --- a/test/AndroidManifest.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/README.md b/test/README.md deleted file mode 100755 index 61957dff..00000000 --- a/test/README.md +++ /dev/null @@ -1,61 +0,0 @@ - -# Android Native Tests - -These tests are designed to verify Android native features and other Android specific features. - -## Initial Setup - -### Setting env vars - -Run: - - ../bin/check_reqs - -Use the output to set your `ANDROID_HOME` and `JAVA_HOME` environment variables. - -### Adding `gradlew` - -Copy it from a freshly created project: - - ../bin/create foo - (cd foo && cordova/build --gradle; cp -r gradlew gradle ..) - rm -r foo - -## Running - -To run manual tests: - - ./gradlew installDebug - -To run unit tests: - - ./gradlew connectedAndroidTest - -`BUILD SUCCESSFUL` means that the tests all passed :) - -## Android Studio - -1. Use "Import Project" and import the `test` directory. -2. Right click on the `org.apache.cordova.test` package on the left-hand nav. -3. Select `Create Run Configuration` -> `Tests in ...` (The one with the Android icon) -4. Review options (mainly - target device) -5. Click the bug icon in the top toolbar to run with debugger attached diff --git a/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java b/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java deleted file mode 100644 index 7dddec6c..00000000 --- a/test/androidTest/src/org/apache/cordova/test/BackButtonMultiPageTest.java +++ /dev/null @@ -1,194 +0,0 @@ -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()); - } -} - diff --git a/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java b/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java deleted file mode 100644 index ecc40f64..00000000 --- a/test/androidTest/src/org/apache/cordova/test/BaseCordovaIntegrationTest.java +++ /dev/null @@ -1,52 +0,0 @@ -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 { - protected MainTestActivity testActivity; - protected FrameLayout containerView; - protected CordovaWebView cordovaWebView; - - - public BaseCordovaIntegrationTest() { - super(MainTestActivity.class); - } - - protected void setUpWithStartUrl(String url, String... prefsAndValues) { - Intent intent = new Intent(getInstrumentation().getContext(), MainTestActivity.class); - intent.putExtra("testStartUrl", url); - for (int i = 0; i < prefsAndValues.length; i += 2) { - intent.putExtra(prefsAndValues[i], prefsAndValues[i + 1]); - } - setActivityIntent(intent); - testActivity = getActivity(); - containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); - cordovaWebView = testActivity.getCordovaWebView(); - } -} - diff --git a/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java b/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java deleted file mode 100644 index 1533e799..00000000 --- a/test/androidTest/src/org/apache/cordova/test/CordovaActivityTest.java +++ /dev/null @@ -1,48 +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.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; - -import org.apache.cordova.CordovaWebViewEngine; -import org.apache.cordova.engine.SystemWebView; - -public class CordovaActivityTest extends BaseCordovaIntegrationTest { - private ViewGroup innerContainer; - private View testView; - - protected void setUp() throws Exception { - super.setUp(); - setUpWithStartUrl(null); - testView = (ViewGroup)containerView.getChildAt(0); - } - - public void testBasicLoad() throws Exception { - assertTrue(testView instanceof SystemWebView); - assertTrue(((CordovaWebViewEngine.EngineView)testView).getCordovaWebView() != null); - String onPageFinishedUrl = testActivity.onPageFinishedUrl.take(); - assertEquals(MainTestActivity.START_URL, onPageFinishedUrl); - } - protected void createViews() { - assertTrue(testView instanceof SystemWebView); - } -} diff --git a/test/androidTest/src/org/apache/cordova/test/CordovaPluginTest.java b/test/androidTest/src/org/apache/cordova/test/CordovaPluginTest.java deleted file mode 100644 index a7c9504d..00000000 --- a/test/androidTest/src/org/apache/cordova/test/CordovaPluginTest.java +++ /dev/null @@ -1,68 +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.app.Activity; -import android.test.ActivityInstrumentationTestCase2; - -import org.apache.cordova.CordovaWebView; - -import java.io.IOException; -import java.lang.reflect.Method; - -public class CordovaPluginTest extends BaseCordovaIntegrationTest { - - protected void setUp() throws Exception { - super.setUp(); - setUpWithStartUrl(null); - } - - private void invokeBlockingCallToLifeCycleEvent(final String lifeCycleEventName) { - testActivity.runOnUiThread( new Runnable() { - public void run() { - try { - Method method = getInstrumentation().getClass().getMethod(lifeCycleEventName, Activity.class); - method.invoke(getInstrumentation(), testActivity); - } catch (Exception e) { - fail("An Exception occurred in invokeBlockingCallToLifeCycleEvent while invoking " + lifeCycleEventName); - } - } - }); - getInstrumentation().waitForIdleSync(); - } - - public void testPluginLifeCycle() throws IOException { - //TODO: add coverage for both cases where handleOnStart is called in CordovaActivity (onStart and init) - //currently only one of the cases is covered - //TODO: add coverage for both cases where onStart is called in CordovaWebViewImpl (handleOnStart and init) - //currently only one of the cases is covered - LifeCyclePlugin testPlugin = (LifeCyclePlugin)cordovaWebView.getPluginManager().getPlugin("LifeCycle"); - testPlugin.calls = ""; - // testOnStart - invokeBlockingCallToLifeCycleEvent("callActivityOnStart"); - invokeBlockingCallToLifeCycleEvent("callActivityOnResume"); - invokeBlockingCallToLifeCycleEvent("callActivityOnPause"); - invokeBlockingCallToLifeCycleEvent("callActivityOnStop"); - assertEquals("start,resume,pause,stop,", testPlugin.calls); - } -} diff --git a/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java b/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java deleted file mode 100644 index 7295987b..00000000 --- a/test/androidTest/src/org/apache/cordova/test/CordovaResourceApiTest.java +++ /dev/null @@ -1,280 +0,0 @@ - -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.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; -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")); - } - if (uri.getQuery() != null && uri.getQuery().contains("pluginUri")) { - return toPluginUri(uri); - } - return null; - } - @Override - public OpenForReadResult handleOpenForRead(Uri uri) throws IOException { - Uri orig = fromPluginUri(uri); - ByteArrayInputStream retStream = new ByteArrayInputStream(orig.toString().getBytes(StandardCharsets.UTF_8)); - return new OpenForReadResult(uri, retStream, "text/plain", retStream.available(), null); - } - @Override - 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); - } - // testPluginUris - { - String origUri = "http://orig/foo?pluginUri"; - Uri uri = resourceApi.remapUri(Uri.parse(origUri)); - OpenForReadResult readResult = resourceApi.openForRead(uri); - assertEquals("openForRead mime-type", "text/plain", readResult.mimeType); - String data = new Scanner(readResult.inputStream, "UTF-8").useDelimiter("\\A").next(); - assertEquals(origUri, data); - assertEquals(origUri.length(), readResult.length); - } - } - - 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); - } -} diff --git a/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java b/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java deleted file mode 100644 index d880f634..00000000 --- a/test/androidTest/src/org/apache/cordova/test/ErrorUrlTest.java +++ /dev/null @@ -1,44 +0,0 @@ -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"; - private static final String INVALID_URL = "file:///android_asset/www/invalid.html"; - - protected void setUp() throws Exception { - super.setUp(); - // 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 { - 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 diff --git a/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java b/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java deleted file mode 100644 index 3f92919f..00000000 --- a/test/androidTest/src/org/apache/cordova/test/HtmlNotFoundTest.java +++ /dev/null @@ -1,46 +0,0 @@ -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 - { - runTestOnUiThread(new Runnable() { - public void run() { - assertTrue(START_URL.equals(testActivity.getCordovaWebView().getUrl())); - } - }); - - //loading a not-found file causes an application error and displayError is called - //the test activity overrides displayError to add message to onPageFinishedUrl - String message = testActivity.onPageFinishedUrl.take(); - assertTrue(message.contains(START_URL)); - assertTrue(message.contains("ERR_FILE_NOT_FOUND")); - } - -} diff --git a/test/androidTest/src/org/apache/cordova/test/IFrameTest.java b/test/androidTest/src/org/apache/cordova/test/IFrameTest.java deleted file mode 100644 index 48dae380..00000000 --- a/test/androidTest/src/org/apache/cordova/test/IFrameTest.java +++ /dev/null @@ -1,107 +0,0 @@ -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"); - } - } -} diff --git a/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java b/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java deleted file mode 100644 index 6fbc50f8..00000000 --- a/test/androidTest/src/org/apache/cordova/test/InflateLayoutTest.java +++ /dev/null @@ -1,56 +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.test.ActivityInstrumentationTestCase2; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.LinearLayout; - -import org.apache.cordova.engine.SystemWebView; - -public class InflateLayoutTest extends ActivityInstrumentationTestCase2 { - - 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 SystemWebView); - assertTrue(innerContainer instanceof LinearLayout); - String onPageFinishedUrl = testActivity.onPageFinishedUrl.take(); - assertEquals(CordovaWebViewTestActivity.START_URL, onPageFinishedUrl); - } -} diff --git a/test/androidTest/src/org/apache/cordova/test/IntentPreferenceTest.java b/test/androidTest/src/org/apache/cordova/test/IntentPreferenceTest.java deleted file mode 100644 index 2d7b2594..00000000 --- a/test/androidTest/src/org/apache/cordova/test/IntentPreferenceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -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.Color; - -import org.apache.cordova.CordovaPreferences; - -public class IntentPreferenceTest extends BaseCordovaIntegrationTest { - private static final String GREEN = Integer.toHexString(Color.GREEN); - private static final String START_URL = "file:///android_asset/www/index.html"; - - CordovaPreferences prefs; - - protected void setUp() throws Exception { - super.setUp(); - // INVALID_URL tests that errorUrl and url are *not* settable via the intent. - setUpWithStartUrl(START_URL, "backgroundcolor", GREEN); - prefs = cordovaWebView.getPreferences(); - } - - public void testUrl() throws Throwable { - assertEquals(START_URL, testActivity.onPageFinishedUrl.take()); - assertFalse(prefs.getInteger("backgroundcolor", Color.BLACK) == Color.GREEN); - } -} diff --git a/test/androidTest/src/org/apache/cordova/test/util/Purity.java b/test/androidTest/src/org/apache/cordova/test/util/Purity.java deleted file mode 100644 index 7171338c..00000000 --- a/test/androidTest/src/org/apache/cordova/test/util/Purity.java +++ /dev/null @@ -1,171 +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. -*/ - -/* - * Purity is a small set of Android utility methods that allows us to simulate touch events on - * Android applications. This is important for simulating some of the most annoying tests. - */ - -package org.apache.cordova.test.util; - -import android.app.Instrumentation; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Picture; -import android.os.SystemClock; -import android.util.DisplayMetrics; -import android.view.MotionEvent; -import android.webkit.WebView; - - -public class Purity { - - Instrumentation inst; - int width, height; - float density; - Bitmap state; - boolean fingerDown = false; - - public Purity(Context ctx, Instrumentation i) - { - inst = i; - DisplayMetrics display = ctx.getResources().getDisplayMetrics(); - density = display.density; - width = display.widthPixels; - height = display.heightPixels; - - } - - /* - * WebKit doesn't give you real pixels anymore, this is done for subpixel fonts to appear on - * iOS and Android. However, Android automation requires real pixels - */ - private int getRealCoord(int coord) - { - return (int) (coord * density); - } - - public int getViewportWidth() - { - return (int) (width/density); - } - - public int getViewportHeight() - { - return (int) (height/density); - } - - public void touch(int x, int y) - { - int realX = getRealCoord(x); - int realY = getRealCoord(y); - long downTime = SystemClock.uptimeMillis(); - // event time MUST be retrieved only by this way! - long eventTime = SystemClock.uptimeMillis(); - if(!fingerDown) - { - MotionEvent downEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, realX, realY, 0); - inst.sendPointerSync(downEvent); - } - MotionEvent upEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, realX, realY, 0); - inst.sendPointerSync(upEvent); - } - - public void touchStart(int x, int y) - { - int realX = getRealCoord(x); - int realY = getRealCoord(y); - long downTime = SystemClock.uptimeMillis(); - // event time MUST be retrieved only by this way! - long eventTime = SystemClock.uptimeMillis(); - MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, realX, realY, 0); - inst.sendPointerSync(event); - fingerDown = true; - } - - //Move from the touch start - public void touchMove(int x, int y) - { - if(!fingerDown) - touchStart(x,y); - else - { - int realX = getRealCoord(x); - int realY = getRealCoord(y); - long downTime = SystemClock.uptimeMillis(); - // event time MUST be retrieved only by this way! - long eventTime = SystemClock.uptimeMillis(); - MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, realX, realY, 0); - inst.sendPointerSync(event); - } - } - - public void touchEnd(int x, int y) - { - if(!fingerDown) - { - touch(x, y); - } - else - { - int realX = getRealCoord(x); - int realY = getRealCoord(y); - long downTime = SystemClock.uptimeMillis(); - // event time MUST be retrieved only by this way! - long eventTime = SystemClock.uptimeMillis(); - MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, realX, realY, 0); - inst.sendPointerSync(event); - fingerDown = false; - } - } - - public void setBitmap(WebView view) - { - Picture p = view.capturePicture(); - state = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888); - } - - public boolean checkRenderView(WebView view) - { - if(state == null) - { - setBitmap(view); - return false; - } - else - { - Picture p = view.capturePicture(); - Bitmap newState = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888); - boolean result = newState.equals(state); - newState.recycle(); - return result; - } - } - - public void clearBitmap() - { - if(state != null) - state.recycle(); - } - - protected void finalize() - { - clearBitmap(); - } -} diff --git a/test/app/.gitignore b/test/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/test/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/test/app/build.gradle b/test/app/build.gradle new file mode 100644 index 00000000..5939414a --- /dev/null +++ b/test/app/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + applicationId "org.apache.cordova.unittests" + minSdkVersion 16 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + debugCompile project(path: ":CordovaLib", configuration: "debug") + releaseCompile project(path: ":CordovaLib", configuration: "release") + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.1.1' + testCompile 'junit:junit:4.12' + testCompile 'org.json:json:20140107' +} diff --git a/test/app/proguard-rules.pro b/test/app/proguard-rules.pro new file mode 100644 index 00000000..73631aff --- /dev/null +++ b/test/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/jbowser/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/test/app/src/androidTest/java/org/apache/cordova/unittests/BackButtonMultipageTest.java b/test/app/src/androidTest/java/org/apache/cordova/unittests/BackButtonMultipageTest.java new file mode 100644 index 00000000..c50c2213 --- /dev/null +++ b/test/app/src/androidTest/java/org/apache/cordova/unittests/BackButtonMultipageTest.java @@ -0,0 +1,158 @@ +/* + 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.unittests; + +import android.content.Intent; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import org.apache.cordova.CordovaWebView; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.pressBack; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.web.sugar.Web.onWebView; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; + + +import static org.apache.cordova.unittests.R.id.cordovaWebView; + + +@RunWith(AndroidJUnit4.class) +public class BackButtonMultipageTest { + + private static final String START_URL = "file:///android_asset/www/backbuttonmultipage/index.html"; + //I have no idea why we picked 100, but we did. + private static final int WEBVIEW_ID = 100; + private TestActivity mActivity; + + // Don't launch the activity, we're going to send it intents + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + TestActivity.class, true, false); + + @Before + public void launchApplicationWithIntent() { + Intent intent = new Intent(); + intent.putExtra("startUrl", START_URL); + mActivity = (TestActivity) mActivityRule.launchActivity(intent); + } + + @Test + public void testViaHref() throws Throwable { + final CordovaWebView webInterface = mActivity.getWebInterface(); + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + webInterface.sendJavascript("window.location = 'sample2.html';"); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + webInterface.sendJavascript("window.location = 'sample3.html';"); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertTrue(webInterface.backHistory()); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertTrue(webInterface.backHistory()); + } + }); + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertFalse(webInterface.backHistory()); + } + }); + } + + @Test + public void testViaLoadUrl() throws Throwable { + final CordovaWebView webInterface = mActivity.getWebInterface(); + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + webInterface.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html"); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + webInterface.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html"); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertTrue(webInterface.backHistory()); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertTrue(webInterface.backHistory()); + } + }); + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertFalse(webInterface.backHistory()); + } + }); + } + + @Test + public void testViaBackButtonOnView() throws Throwable { + final CordovaWebView webInterface = mActivity.getWebInterface(); + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + webInterface.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html"); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + webInterface.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html"); + } + }); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", mActivity.onPageFinishedUrl.take()); + onView(withId(WEBVIEW_ID)).perform(pressBack()); + assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take()); + onView(withId(WEBVIEW_ID)).perform(pressBack()); + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + } +} diff --git a/test/app/src/androidTest/java/org/apache/cordova/unittests/EmbeddedWebViewTest.java b/test/app/src/androidTest/java/org/apache/cordova/unittests/EmbeddedWebViewTest.java new file mode 100644 index 00000000..07933778 --- /dev/null +++ b/test/app/src/androidTest/java/org/apache/cordova/unittests/EmbeddedWebViewTest.java @@ -0,0 +1,53 @@ +/* + 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.unittests; + +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static junit.framework.Assert.assertNotNull; + +/* + * This test is to cover the use case of Cordova Android used as a component in a larger Android + * application. This test is strictly used to cover this use case. In this example, the WebView + * should load, not be null, and the Plugin Manager should also be initialized. + * + + */ + + +@RunWith(AndroidJUnit4.class) +public class EmbeddedWebViewTest { + + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + EmbeddedWebViewActivity.class); + + @Test + public void checkWebViewTest() { + EmbeddedWebViewActivity activity = (EmbeddedWebViewActivity) mActivityRule.getActivity(); + assertNotNull(activity.webInterface); + assertNotNull(activity.webInterface.getPluginManager()); + } +} diff --git a/test/app/src/androidTest/java/org/apache/cordova/unittests/ErrorUrlTest.java b/test/app/src/androidTest/java/org/apache/cordova/unittests/ErrorUrlTest.java new file mode 100644 index 00000000..7300d7c5 --- /dev/null +++ b/test/app/src/androidTest/java/org/apache/cordova/unittests/ErrorUrlTest.java @@ -0,0 +1,68 @@ +/* + 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.unittests; + +import android.content.Intent; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import org.apache.cordova.CordovaWebView; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static junit.framework.Assert.assertEquals; + +@RunWith(AndroidJUnit4.class) +public class ErrorUrlTest { + 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/invalid.html"; + + //I have no idea why we picked 100, but we did. + private static final int WEBVIEW_ID = 100; + private TestActivity mActivity; + + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + TestActivity.class); + + @Before + public void launchApplicationWithIntent() { + Intent intent = new Intent(); + intent.putExtra("startUrl", START_URL); + intent.putExtra("errorurl", INVALID_URL); + intent.putExtra("url", INVALID_URL); + mActivity = (TestActivity) mActivityRule.launchActivity(intent); + } + + @Test + public void errorUrlTest() throws Throwable { + assertEquals(START_URL, mActivity.onPageFinishedUrl.take()); + assertEquals(ERROR_URL, mActivity.onPageFinishedUrl.take()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() { + assertEquals(ERROR_URL, mActivity.getWebInterface().getUrl()); + } + }); + } +} diff --git a/test/app/src/androidTest/java/org/apache/cordova/unittests/IFrameTest.java b/test/app/src/androidTest/java/org/apache/cordova/unittests/IFrameTest.java new file mode 100644 index 00000000..f3f66d73 --- /dev/null +++ b/test/app/src/androidTest/java/org/apache/cordova/unittests/IFrameTest.java @@ -0,0 +1,114 @@ +/* + 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.unittests; + +import android.content.Intent; +import android.support.test.espresso.web.webdriver.Locator; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import org.apache.cordova.CordovaWebView; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.action.ViewActions.pressBack; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.web.sugar.Web.onWebView; +import static android.support.test.espresso.web.webdriver.DriverAtoms.findElement; +import static android.support.test.espresso.web.webdriver.DriverAtoms.webClick; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; + +@RunWith(AndroidJUnit4.class) +public class IFrameTest { + + private static final String START_URL = "file:///android_asset/www/iframe/index.html"; + //I have no idea why we picked 100, but we did. + private static final int WEBVIEW_ID = 100; + private int WEBVIEW_LOAD_DELAY = 500; + + private TestActivity testActivity; + + // Don't launch the activity, we're going to send it intents + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + TestActivity.class, true, false); + + @Before + public void launchApplicationWithIntent() { + Intent intent = new Intent(); + intent.putExtra("startUrl", START_URL); + testActivity = (TestActivity) mActivityRule.launchActivity(intent); + } + + @Test + public void iFrameHistory() throws Throwable { + final CordovaWebView cordovaWebView = (CordovaWebView) testActivity.getWebInterface(); + onWebView().withElement(findElement(Locator.ID, "google_maps")).perform(webClick()); + sleep(WEBVIEW_LOAD_DELAY); + mActivityRule.runOnUiThread(new Runnable() { + public void run() + { + String url = cordovaWebView.getUrl(); + assertTrue(url.endsWith("index.html")); + } + }); + sleep(WEBVIEW_LOAD_DELAY); + onWebView().withElement(findElement(Locator.ID, "javascript_load")).perform(webClick()); + mActivityRule.runOnUiThread(new Runnable() { + public void run() + { + String url = cordovaWebView.getUrl(); + assertTrue(url.endsWith("index.html")); + } + }); + sleep(WEBVIEW_LOAD_DELAY); + //Espresso will kill the application and not trigger the backHistory method, which correctly + //navigates the iFrame history. backHistory is tied to the back button. + mActivityRule.runOnUiThread(new Runnable() { + public void run() + { + assertTrue(cordovaWebView.backHistory()); + String url = cordovaWebView.getUrl(); + assertTrue(url.endsWith("index.html")); + assertFalse(cordovaWebView.backHistory()); + } + }); + + } + + + //BRUTE FORCE THE CRAP OUT OF CONCURRENCY ERRORS + private void sleep(int timeout) { + try { + Thread.sleep(timeout); + } catch (InterruptedException e) { + fail("Unexpected Timeout"); + } + } + +} diff --git a/test/androidTest/src/org/apache/cordova/test/MessageChannelMultiPageTest.java b/test/app/src/androidTest/java/org/apache/cordova/unittests/MessageChannelMultipageTest.java similarity index 74% rename from test/androidTest/src/org/apache/cordova/test/MessageChannelMultiPageTest.java rename to test/app/src/androidTest/java/org/apache/cordova/unittests/MessageChannelMultipageTest.java index 8521a091..e1d473bb 100644 --- a/test/androidTest/src/org/apache/cordova/test/MessageChannelMultiPageTest.java +++ b/test/app/src/androidTest/java/org/apache/cordova/unittests/MessageChannelMultipageTest.java @@ -1,45 +1,45 @@ -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. - * -*/ +package org.apache.cordova.unittests; - -import android.view.KeyEvent; -import android.view.inputmethod.BaseInputConnection; +import android.content.Intent; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaWebView; import org.apache.cordova.CordovaWebViewImpl; import org.apache.cordova.PluginManager; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; import java.lang.reflect.Field; import java.lang.reflect.Method; -public class MessageChannelMultiPageTest extends BaseCordovaIntegrationTest { - private static final String START_URL = "file:///android_asset/www/backbuttonmultipage/index.html"; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.fail; - @Override - public void setUp() throws Exception { - super.setUp(); - setUpWithStartUrl(START_URL); +@RunWith(AndroidJUnit4.class) +public class MessageChannelMultipageTest { + private static final String START_URL = "file:///android_asset/www/backbuttonmultipage/index.html"; + //I have no idea why we picked 100, but we did. + private static final int WEBVIEW_ID = 100; + private TestActivity testActivity; + + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + TestActivity.class); + + @Before + public void launchApplicationWithIntent() { + Intent intent = new Intent(); + intent.putExtra("startUrl", START_URL); + testActivity = (TestActivity) mActivityRule.launchActivity(intent); } + + //test that after a page load the cached callback id and the live callback id match //this is to prevent a regression //the issue was that CordovaWebViewImpl's cached instance of CoreAndroid would become stale on page load @@ -47,7 +47,9 @@ public class MessageChannelMultiPageTest extends BaseCordovaIntegrationTest { //the plugin manager would get a new instance which would be updated with a new callback id //the cached instance's message channel callback id would become stale //effectively this caused message channel events to not be delivered + @Test public void testThatCachedCallbackIdIsValid() throws Throwable { + final CordovaWebView cordovaWebView = testActivity.getWebInterface(); Class cordovaWebViewImpl = CordovaWebViewImpl.class; //send a test event - this initializes cordovaWebViewImpl.appPlugin (the cached instance of CoreAndroid) Method method = cordovaWebViewImpl.getDeclaredMethod("sendJavascriptEvent", String.class); @@ -57,7 +59,7 @@ public class MessageChannelMultiPageTest extends BaseCordovaIntegrationTest { //load a page - this resets the plugin manager and nulls cordovaWebViewImpl.appPlugin //(previously this resets plugin manager but did not null cordovaWebViewImpl.appPlugin, leading to the issue) - runTestOnUiThread(new Runnable() { + mActivityRule.runOnUiThread(new Runnable() { public void run() { cordovaWebView.loadUrl(START_URL); } @@ -81,7 +83,7 @@ public class MessageChannelMultiPageTest extends BaseCordovaIntegrationTest { CallbackContext cachedCallbackContext = (CallbackContext) messageChannelField.get(cachedAppPlugin); //get live CoreAndroid - PluginManager pluginManager = MessageChannelMultiPageTest.this.cordovaWebView.getPluginManager(); + PluginManager pluginManager = cordovaWebView.getPluginManager(); Field coreAndroidPluginNameField = coreAndroid.getField("PLUGIN_NAME"); String coreAndroidPluginName = (String) coreAndroidPluginNameField.get(null); Object liveAppPlugin = pluginManager.getPlugin(coreAndroidPluginName); @@ -106,5 +108,4 @@ public class MessageChannelMultiPageTest extends BaseCordovaIntegrationTest { fail("Unexpected Timeout"); } } - } diff --git a/test/app/src/androidTest/java/org/apache/cordova/unittests/StandardActivityTest.java b/test/app/src/androidTest/java/org/apache/cordova/unittests/StandardActivityTest.java new file mode 100644 index 00000000..f7162d56 --- /dev/null +++ b/test/app/src/androidTest/java/org/apache/cordova/unittests/StandardActivityTest.java @@ -0,0 +1,100 @@ +/* + 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.unittests; + +import android.content.Intent; +import android.graphics.Color; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; +import android.view.View; +import android.widget.LinearLayout; + +import org.apache.cordova.CordovaPreferences; +import org.apache.cordova.CordovaWebView; +import org.apache.cordova.engine.SystemWebView; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNotSame; +import static junit.framework.Assert.assertTrue; + +/** + * The purpose of this test is to test the default application that is generated by Cordova itself + * + */ +@RunWith(AndroidJUnit4.class) +public class StandardActivityTest { + + private static final String FALSE_URI = "http://www.google.com"; + + // Don't launch the activity, we're going to send it intents + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + StandardActivity.class, true, false); + + @Before + public void launchApplicationWithIntent() { + Intent intent = new Intent(); + intent.putExtra("startUrl", FALSE_URI); + intent.putExtra("backgroundcolor", "#0000ff"); + mActivityRule.launchActivity(intent); + } + + + @Test + public void webViewCheck() { + StandardActivity activity = (StandardActivity) mActivityRule.getActivity(); + //Fish the webview out of the mostly locked down Activity using the Android SDK + View view = activity.getWindow().getCurrentFocus(); + assertEquals(SystemWebView.class, view.getClass()); + } + + @Test + public void startUriIntentCheck() { + StandardActivity activity = (StandardActivity) mActivityRule.getActivity(); + final SystemWebView webView = (SystemWebView) activity.getWindow().getCurrentFocus(); + try { + mActivityRule.runOnUiThread(new Runnable() { + @Override + public void run() { + String uri = webView.getUrl(); + assertFalse(uri.equals(FALSE_URI)); + } + }); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } + + @Test + public void checkBackgroundIntentCheck() { + StandardActivity activity = (StandardActivity) mActivityRule.getActivity(); + final SystemWebView webView = (SystemWebView) activity.getWindow().getCurrentFocus(); + CordovaWebView webInterface = webView.getCordovaWebView(); + CordovaPreferences prefs = webInterface.getPreferences(); + assertFalse(prefs.getInteger("backgroundcolor", Color.BLACK) == Color.GREEN); + } + +} diff --git a/test/app/src/main/AndroidManifest.xml b/test/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..86bc83c5 --- /dev/null +++ b/test/app/src/main/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/assets/www/backbuttonmultipage/index.html b/test/app/src/main/assets/www/backbuttonmultipage/index.html similarity index 100% rename from test/assets/www/backbuttonmultipage/index.html rename to test/app/src/main/assets/www/backbuttonmultipage/index.html diff --git a/test/assets/www/backbuttonmultipage/sample2.html b/test/app/src/main/assets/www/backbuttonmultipage/sample2.html similarity index 100% rename from test/assets/www/backbuttonmultipage/sample2.html rename to test/app/src/main/assets/www/backbuttonmultipage/sample2.html diff --git a/test/assets/www/backbuttonmultipage/sample3.html b/test/app/src/main/assets/www/backbuttonmultipage/sample3.html similarity index 100% rename from test/assets/www/backbuttonmultipage/sample3.html rename to test/app/src/main/assets/www/backbuttonmultipage/sample3.html diff --git a/test/assets/www/backgroundcolor/index.html b/test/app/src/main/assets/www/backgroundcolor/index.html similarity index 100% rename from test/assets/www/backgroundcolor/index.html rename to test/app/src/main/assets/www/backgroundcolor/index.html diff --git a/test/app/src/main/assets/www/cordova.js b/test/app/src/main/assets/www/cordova.js new file mode 100644 index 00000000..1814e025 --- /dev/null +++ b/test/app/src/main/assets/www/cordova.js @@ -0,0 +1,2208 @@ +// Platform: android +// 7c5fcc5a5adfbf3fb8ceaf36fbdd4bd970bd9c20 +/* + 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. +*/ +;(function() { +var PLATFORM_VERSION_BUILD_LABEL = '6.2.0-dev'; +// file: src/scripts/require.js + +/*jshint -W079 */ +/*jshint -W020 */ + +var require, + define; + +(function () { + var modules = {}, + // Stack of moduleIds currently being built. + requireStack = [], + // Map of module ID -> index into requireStack of modules currently being built. + inProgressModules = {}, + SEPARATOR = "."; + + + + function build(module) { + var factory = module.factory, + localRequire = function (id) { + var resultantId = id; + //Its a relative path, so lop off the last portion and add the id (minus "./") + if (id.charAt(0) === ".") { + resultantId = module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) + SEPARATOR + id.slice(2); + } + return require(resultantId); + }; + module.exports = {}; + delete module.factory; + factory(localRequire, module.exports, module); + return module.exports; + } + + require = function (id) { + if (!modules[id]) { + throw "module " + id + " not found"; + } else if (id in inProgressModules) { + var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id; + throw "Cycle in require graph: " + cycle; + } + if (modules[id].factory) { + try { + inProgressModules[id] = requireStack.length; + requireStack.push(id); + return build(modules[id]); + } finally { + delete inProgressModules[id]; + requireStack.pop(); + } + } + return modules[id].exports; + }; + + define = function (id, factory) { + if (modules[id]) { + throw "module " + id + " already defined"; + } + + modules[id] = { + id: id, + factory: factory + }; + }; + + define.remove = function (id) { + delete modules[id]; + }; + + define.moduleMap = modules; +})(); + +//Export for use in node +if (typeof module === "object" && typeof require === "function") { + module.exports.require = require; + module.exports.define = define; +} + +// file: src/cordova.js +define("cordova", function(require, exports, module) { + +// Workaround for Windows 10 in hosted environment case +// http://www.w3.org/html/wg/drafts/html/master/browsers.html#named-access-on-the-window-object +if (window.cordova && !(window.cordova instanceof HTMLElement)) { + throw new Error("cordova already defined"); +} + + +var channel = require('cordova/channel'); +var platform = require('cordova/platform'); + + +/** + * Intercept calls to addEventListener + removeEventListener and handle deviceready, + * resume, and pause events. + */ +var m_document_addEventListener = document.addEventListener; +var m_document_removeEventListener = document.removeEventListener; +var m_window_addEventListener = window.addEventListener; +var m_window_removeEventListener = window.removeEventListener; + +/** + * Houses custom event handlers to intercept on document + window event listeners. + */ +var documentEventHandlers = {}, + windowEventHandlers = {}; + +document.addEventListener = function(evt, handler, capture) { + var e = evt.toLowerCase(); + if (typeof documentEventHandlers[e] != 'undefined') { + documentEventHandlers[e].subscribe(handler); + } else { + m_document_addEventListener.call(document, evt, handler, capture); + } +}; + +window.addEventListener = function(evt, handler, capture) { + var e = evt.toLowerCase(); + if (typeof windowEventHandlers[e] != 'undefined') { + windowEventHandlers[e].subscribe(handler); + } else { + m_window_addEventListener.call(window, evt, handler, capture); + } +}; + +document.removeEventListener = function(evt, handler, capture) { + var e = evt.toLowerCase(); + // If unsubscribing from an event that is handled by a plugin + if (typeof documentEventHandlers[e] != "undefined") { + documentEventHandlers[e].unsubscribe(handler); + } else { + m_document_removeEventListener.call(document, evt, handler, capture); + } +}; + +window.removeEventListener = function(evt, handler, capture) { + var e = evt.toLowerCase(); + // If unsubscribing from an event that is handled by a plugin + if (typeof windowEventHandlers[e] != "undefined") { + windowEventHandlers[e].unsubscribe(handler); + } else { + m_window_removeEventListener.call(window, evt, handler, capture); + } +}; + +function createEvent(type, data) { + var event = document.createEvent('Events'); + event.initEvent(type, false, false); + if (data) { + for (var i in data) { + if (data.hasOwnProperty(i)) { + event[i] = data[i]; + } + } + } + return event; +} + + +var cordova = { + define:define, + require:require, + version:PLATFORM_VERSION_BUILD_LABEL, + platformVersion:PLATFORM_VERSION_BUILD_LABEL, + platformId:platform.id, + /** + * Methods to add/remove your own addEventListener hijacking on document + window. + */ + addWindowEventHandler:function(event) { + return (windowEventHandlers[event] = channel.create(event)); + }, + addStickyDocumentEventHandler:function(event) { + return (documentEventHandlers[event] = channel.createSticky(event)); + }, + addDocumentEventHandler:function(event) { + return (documentEventHandlers[event] = channel.create(event)); + }, + removeWindowEventHandler:function(event) { + delete windowEventHandlers[event]; + }, + removeDocumentEventHandler:function(event) { + delete documentEventHandlers[event]; + }, + /** + * Retrieve original event handlers that were replaced by Cordova + * + * @return object + */ + getOriginalHandlers: function() { + return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener}, + 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}}; + }, + /** + * Method to fire event from native code + * bNoDetach is required for events which cause an exception which needs to be caught in native code + */ + fireDocumentEvent: function(type, data, bNoDetach) { + var evt = createEvent(type, data); + if (typeof documentEventHandlers[type] != 'undefined') { + if( bNoDetach ) { + documentEventHandlers[type].fire(evt); + } + else { + setTimeout(function() { + // Fire deviceready on listeners that were registered before cordova.js was loaded. + if (type == 'deviceready') { + document.dispatchEvent(evt); + } + documentEventHandlers[type].fire(evt); + }, 0); + } + } else { + document.dispatchEvent(evt); + } + }, + fireWindowEvent: function(type, data) { + var evt = createEvent(type,data); + if (typeof windowEventHandlers[type] != 'undefined') { + setTimeout(function() { + windowEventHandlers[type].fire(evt); + }, 0); + } else { + window.dispatchEvent(evt); + } + }, + + /** + * Plugin callback mechanism. + */ + // Randomize the starting callbackId to avoid collisions after refreshing or navigating. + // This way, it's very unlikely that any new callback would get the same callbackId as an old callback. + callbackId: Math.floor(Math.random() * 2000000000), + callbacks: {}, + callbackStatus: { + NO_RESULT: 0, + OK: 1, + CLASS_NOT_FOUND_EXCEPTION: 2, + ILLEGAL_ACCESS_EXCEPTION: 3, + INSTANTIATION_EXCEPTION: 4, + MALFORMED_URL_EXCEPTION: 5, + IO_EXCEPTION: 6, + INVALID_ACTION: 7, + JSON_EXCEPTION: 8, + ERROR: 9 + }, + + /** + * Called by native code when returning successful result from an action. + */ + callbackSuccess: function(callbackId, args) { + cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback); + }, + + /** + * Called by native code when returning error result from an action. + */ + callbackError: function(callbackId, args) { + // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative. + // Derive success from status. + cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback); + }, + + /** + * Called by native code when returning the result from an action. + */ + callbackFromNative: function(callbackId, isSuccess, status, args, keepCallback) { + try { + var callback = cordova.callbacks[callbackId]; + if (callback) { + if (isSuccess && status == cordova.callbackStatus.OK) { + callback.success && callback.success.apply(null, args); + } else if (!isSuccess) { + callback.fail && callback.fail.apply(null, args); + } + /* + else + Note, this case is intentionally not caught. + this can happen if isSuccess is true, but callbackStatus is NO_RESULT + which is used to remove a callback from the list without calling the callbacks + typically keepCallback is false in this case + */ + // Clear callback if not expecting any more results + if (!keepCallback) { + delete cordova.callbacks[callbackId]; + } + } + } + catch (err) { + var msg = "Error in " + (isSuccess ? "Success" : "Error") + " callbackId: " + callbackId + " : " + err; + console && console.log && console.log(msg); + cordova.fireWindowEvent("cordovacallbackerror", { 'message': msg }); + throw err; + } + }, + addConstructor: function(func) { + channel.onCordovaReady.subscribe(function() { + try { + func(); + } catch(e) { + console.log("Failed to run constructor: " + e); + } + }); + } +}; + + +module.exports = cordova; + +}); + +// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/android/nativeapiprovider.js +define("cordova/android/nativeapiprovider", function(require, exports, module) { + +/** + * Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi. + */ + +var nativeApi = this._cordovaNative || require('cordova/android/promptbasednativeapi'); +var currentApi = nativeApi; + +module.exports = { + get: function() { return currentApi; }, + setPreferPrompt: function(value) { + currentApi = value ? require('cordova/android/promptbasednativeapi') : nativeApi; + }, + // Used only by tests. + set: function(value) { + currentApi = value; + } +}; + +}); + +// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/android/promptbasednativeapi.js +define("cordova/android/promptbasednativeapi", function(require, exports, module) { + +/** + * Implements the API of ExposedJsApi.java, but uses prompt() to communicate. + * This is used pre-JellyBean, where addJavascriptInterface() is disabled. + */ + +module.exports = { + exec: function(bridgeSecret, service, action, callbackId, argsJson) { + return prompt(argsJson, 'gap:'+JSON.stringify([bridgeSecret, service, action, callbackId])); + }, + setNativeToJsBridgeMode: function(bridgeSecret, value) { + prompt(value, 'gap_bridge_mode:' + bridgeSecret); + }, + retrieveJsMessages: function(bridgeSecret, fromOnlineEvent) { + return prompt(+fromOnlineEvent, 'gap_poll:' + bridgeSecret); + } +}; + +}); + +// file: src/common/argscheck.js +define("cordova/argscheck", function(require, exports, module) { + +var utils = require('cordova/utils'); + +var moduleExports = module.exports; + +var typeMap = { + 'A': 'Array', + 'D': 'Date', + 'N': 'Number', + 'S': 'String', + 'F': 'Function', + 'O': 'Object' +}; + +function extractParamName(callee, argIndex) { + return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex]; +} + +function checkArgs(spec, functionName, args, opt_callee) { + if (!moduleExports.enableChecks) { + return; + } + var errMsg = null; + var typeName; + for (var i = 0; i < spec.length; ++i) { + var c = spec.charAt(i), + cUpper = c.toUpperCase(), + arg = args[i]; + // Asterix means allow anything. + if (c == '*') { + continue; + } + typeName = utils.typeName(arg); + if ((arg === null || arg === undefined) && c == cUpper) { + continue; + } + if (typeName != typeMap[cUpper]) { + errMsg = 'Expected ' + typeMap[cUpper]; + break; + } + } + if (errMsg) { + errMsg += ', but got ' + typeName + '.'; + errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg; + // Don't log when running unit tests. + if (typeof jasmine == 'undefined') { + console.error(errMsg); + } + throw TypeError(errMsg); + } +} + +function getValue(value, defaultValue) { + return value === undefined ? defaultValue : value; +} + +moduleExports.checkArgs = checkArgs; +moduleExports.getValue = getValue; +moduleExports.enableChecks = true; + + +}); + +// file: src/common/base64.js +define("cordova/base64", function(require, exports, module) { + +var base64 = exports; + +base64.fromArrayBuffer = function(arrayBuffer) { + var array = new Uint8Array(arrayBuffer); + return uint8ToBase64(array); +}; + +base64.toArrayBuffer = function(str) { + var decodedStr = typeof atob != 'undefined' ? atob(str) : new Buffer(str,'base64').toString('binary'); + var arrayBuffer = new ArrayBuffer(decodedStr.length); + var array = new Uint8Array(arrayBuffer); + for (var i=0, len=decodedStr.length; i < len; i++) { + array[i] = decodedStr.charCodeAt(i); + } + return arrayBuffer; +}; + +//------------------------------------------------------------------------------ + +/* This code is based on the performance tests at http://jsperf.com/b64tests + * This 12-bit-at-a-time algorithm was the best performing version on all + * platforms tested. + */ + +var b64_6bit = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var b64_12bit; + +var b64_12bitTable = function() { + b64_12bit = []; + for (var i=0; i<64; i++) { + for (var j=0; j<64; j++) { + b64_12bit[i*64+j] = b64_6bit[i] + b64_6bit[j]; + } + } + b64_12bitTable = function() { return b64_12bit; }; + return b64_12bit; +}; + +function uint8ToBase64(rawData) { + var numBytes = rawData.byteLength; + var output=""; + var segment; + var table = b64_12bitTable(); + for (var i=0;i> 12]; + output += table[segment & 0xfff]; + } + if (numBytes - i == 2) { + segment = (rawData[i] << 16) + (rawData[i+1] << 8); + output += table[segment >> 12]; + output += b64_6bit[(segment & 0xfff) >> 6]; + output += '='; + } else if (numBytes - i == 1) { + segment = (rawData[i] << 16); + output += table[segment >> 12]; + output += '=='; + } + return output; +} + +}); + +// file: src/common/builder.js +define("cordova/builder", function(require, exports, module) { + +var utils = require('cordova/utils'); + +function each(objects, func, context) { + for (var prop in objects) { + if (objects.hasOwnProperty(prop)) { + func.apply(context, [objects[prop], prop]); + } + } +} + +function clobber(obj, key, value) { + exports.replaceHookForTesting(obj, key); + var needsProperty = false; + try { + obj[key] = value; + } catch (e) { + needsProperty = true; + } + // Getters can only be overridden by getters. + if (needsProperty || obj[key] !== value) { + utils.defineGetter(obj, key, function() { + return value; + }); + } +} + +function assignOrWrapInDeprecateGetter(obj, key, value, message) { + if (message) { + utils.defineGetter(obj, key, function() { + console.log(message); + delete obj[key]; + clobber(obj, key, value); + return value; + }); + } else { + clobber(obj, key, value); + } +} + +function include(parent, objects, clobber, merge) { + each(objects, function (obj, key) { + try { + var result = obj.path ? require(obj.path) : {}; + + if (clobber) { + // Clobber if it doesn't exist. + if (typeof parent[key] === 'undefined') { + assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated); + } else if (typeof obj.path !== 'undefined') { + // If merging, merge properties onto parent, otherwise, clobber. + if (merge) { + recursiveMerge(parent[key], result); + } else { + assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated); + } + } + result = parent[key]; + } else { + // Overwrite if not currently defined. + if (typeof parent[key] == 'undefined') { + assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated); + } else { + // Set result to what already exists, so we can build children into it if they exist. + result = parent[key]; + } + } + + if (obj.children) { + include(result, obj.children, clobber, merge); + } + } catch(e) { + utils.alert('Exception building Cordova JS globals: ' + e + ' for key "' + key + '"'); + } + }); +} + +/** + * Merge properties from one object onto another recursively. Properties from + * the src object will overwrite existing target property. + * + * @param target Object to merge properties into. + * @param src Object to merge properties from. + */ +function recursiveMerge(target, src) { + for (var prop in src) { + if (src.hasOwnProperty(prop)) { + if (target.prototype && target.prototype.constructor === target) { + // If the target object is a constructor override off prototype. + clobber(target.prototype, prop, src[prop]); + } else { + if (typeof src[prop] === 'object' && typeof target[prop] === 'object') { + recursiveMerge(target[prop], src[prop]); + } else { + clobber(target, prop, src[prop]); + } + } + } + } +} + +exports.buildIntoButDoNotClobber = function(objects, target) { + include(target, objects, false, false); +}; +exports.buildIntoAndClobber = function(objects, target) { + include(target, objects, true, false); +}; +exports.buildIntoAndMerge = function(objects, target) { + include(target, objects, true, true); +}; +exports.recursiveMerge = recursiveMerge; +exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter; +exports.replaceHookForTesting = function() {}; + +}); + +// file: src/common/channel.js +define("cordova/channel", function(require, exports, module) { + +var utils = require('cordova/utils'), + nextGuid = 1; + +/** + * Custom pub-sub "channel" that can have functions subscribed to it + * This object is used to define and control firing of events for + * cordova initialization, as well as for custom events thereafter. + * + * The order of events during page load and Cordova startup is as follows: + * + * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed. + * onNativeReady* Internal event that indicates the Cordova native side is ready. + * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created. + * onDeviceReady* User event fired to indicate that Cordova is ready + * onResume User event fired to indicate a start/resume lifecycle event + * onPause User event fired to indicate a pause lifecycle event + * + * The events marked with an * are sticky. Once they have fired, they will stay in the fired state. + * All listeners that subscribe after the event is fired will be executed right away. + * + * The only Cordova events that user code should register for are: + * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript + * pause App has moved to background + * resume App has returned to foreground + * + * Listeners can be registered as: + * document.addEventListener("deviceready", myDeviceReadyListener, false); + * document.addEventListener("resume", myResumeListener, false); + * document.addEventListener("pause", myPauseListener, false); + * + * The DOM lifecycle events should be used for saving and restoring state + * window.onload + * window.onunload + * + */ + +/** + * Channel + * @constructor + * @param type String the channel name + */ +var Channel = function(type, sticky) { + this.type = type; + // Map of guid -> function. + this.handlers = {}; + // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired. + this.state = sticky ? 1 : 0; + // Used in sticky mode to remember args passed to fire(). + this.fireArgs = null; + // Used by onHasSubscribersChange to know if there are any listeners. + this.numHandlers = 0; + // Function that is called when the first listener is subscribed, or when + // the last listener is unsubscribed. + this.onHasSubscribersChange = null; +}, + channel = { + /** + * Calls the provided function only after all of the channels specified + * have been fired. All channels must be sticky channels. + */ + join: function(h, c) { + var len = c.length, + i = len, + f = function() { + if (!(--i)) h(); + }; + for (var j=0; jNative bridge. + POLLING: 0, + // For LOAD_URL to be viable, it would need to have a work-around for + // the bug where the soft-keyboard gets dismissed when a message is sent. + LOAD_URL: 1, + // For the ONLINE_EVENT to be viable, it would need to intercept all event + // listeners (both through addEventListener and window.ononline) as well + // as set the navigator property itself. + ONLINE_EVENT: 2, + EVAL_BRIDGE: 3 + }, + jsToNativeBridgeMode, // Set lazily. + nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE, + pollEnabled = false, + bridgeSecret = -1; + +var messagesFromNative = []; +var isProcessing = false; +var resolvedPromise = typeof Promise == 'undefined' ? null : Promise.resolve(); +var nextTick = resolvedPromise ? function(fn) { resolvedPromise.then(fn); } : function(fn) { setTimeout(fn); }; + +function androidExec(success, fail, service, action, args) { + if (bridgeSecret < 0) { + // If we ever catch this firing, we'll need to queue up exec()s + // and fire them once we get a secret. For now, I don't think + // it's possible for exec() to be called since plugins are parsed but + // not run until until after onNativeReady. + throw new Error('exec() called without bridgeSecret'); + } + // Set default bridge modes if they have not already been set. + // By default, we use the failsafe, since addJavascriptInterface breaks too often + if (jsToNativeBridgeMode === undefined) { + androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT); + } + + // If args is not provided, default to an empty array + args = args || []; + + // Process any ArrayBuffers in the args into a string. + for (var i = 0; i < args.length; i++) { + if (utils.typeName(args[i]) == 'ArrayBuffer') { + args[i] = base64.fromArrayBuffer(args[i]); + } + } + + var callbackId = service + cordova.callbackId++, + argsJson = JSON.stringify(args); + if (success || fail) { + cordova.callbacks[callbackId] = {success:success, fail:fail}; + } + + var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson); + // If argsJson was received by Java as null, try again with the PROMPT bridge mode. + // This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666. + if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "@Null arguments.") { + androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT); + androidExec(success, fail, service, action, args); + androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT); + } else if (msgs) { + messagesFromNative.push(msgs); + // Always process async to avoid exceptions messing up stack. + nextTick(processMessages); + } +} + +androidExec.init = function() { + //CB-11828 + //This failsafe checks the version of Android and if it's Jellybean, it switches it to + //using the Online Event bridge for communicating from Native to JS + // + //It's ugly, but it's necessary. + var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/); + var version_code = check && check[0].match(/4.[0-3].*/); + if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) { + nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT; + } + + bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode); + channel.onNativeReady.fire(); +}; + +function pollOnceFromOnlineEvent() { + pollOnce(true); +} + +function pollOnce(opt_fromOnlineEvent) { + if (bridgeSecret < 0) { + // This can happen when the NativeToJsMessageQueue resets the online state on page transitions. + // We know there's nothing to retrieve, so no need to poll. + return; + } + var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent); + if (msgs) { + messagesFromNative.push(msgs); + // Process sync since we know we're already top-of-stack. + processMessages(); + } +} + +function pollingTimerFunc() { + if (pollEnabled) { + pollOnce(); + setTimeout(pollingTimerFunc, 50); + } +} + +function hookOnlineApis() { + function proxyEvent(e) { + cordova.fireWindowEvent(e.type); + } + // The network module takes care of firing online and offline events. + // It currently fires them only on document though, so we bridge them + // to window here (while first listening for exec()-releated online/offline + // events). + window.addEventListener('online', pollOnceFromOnlineEvent, false); + window.addEventListener('offline', pollOnceFromOnlineEvent, false); + cordova.addWindowEventHandler('online'); + cordova.addWindowEventHandler('offline'); + document.addEventListener('online', proxyEvent, false); + document.addEventListener('offline', proxyEvent, false); +} + +hookOnlineApis(); + +androidExec.jsToNativeModes = jsToNativeModes; +androidExec.nativeToJsModes = nativeToJsModes; + +androidExec.setJsToNativeBridgeMode = function(mode) { + if (mode == jsToNativeModes.JS_OBJECT && !window._cordovaNative) { + mode = jsToNativeModes.PROMPT; + } + nativeApiProvider.setPreferPrompt(mode == jsToNativeModes.PROMPT); + jsToNativeBridgeMode = mode; +}; + +androidExec.setNativeToJsBridgeMode = function(mode) { + if (mode == nativeToJsBridgeMode) { + return; + } + if (nativeToJsBridgeMode == nativeToJsModes.POLLING) { + pollEnabled = false; + } + + nativeToJsBridgeMode = mode; + // Tell the native side to switch modes. + // Otherwise, it will be set by androidExec.init() + if (bridgeSecret >= 0) { + nativeApiProvider.get().setNativeToJsBridgeMode(bridgeSecret, mode); + } + + if (mode == nativeToJsModes.POLLING) { + pollEnabled = true; + setTimeout(pollingTimerFunc, 1); + } +}; + +function buildPayload(payload, message) { + var payloadKind = message.charAt(0); + if (payloadKind == 's') { + payload.push(message.slice(1)); + } else if (payloadKind == 't') { + payload.push(true); + } else if (payloadKind == 'f') { + payload.push(false); + } else if (payloadKind == 'N') { + payload.push(null); + } else if (payloadKind == 'n') { + payload.push(+message.slice(1)); + } else if (payloadKind == 'A') { + var data = message.slice(1); + payload.push(base64.toArrayBuffer(data)); + } else if (payloadKind == 'S') { + payload.push(window.atob(message.slice(1))); + } else if (payloadKind == 'M') { + var multipartMessages = message.slice(1); + while (multipartMessages !== "") { + var spaceIdx = multipartMessages.indexOf(' '); + var msgLen = +multipartMessages.slice(0, spaceIdx); + var multipartMessage = multipartMessages.substr(spaceIdx + 1, msgLen); + multipartMessages = multipartMessages.slice(spaceIdx + msgLen + 1); + buildPayload(payload, multipartMessage); + } + } else { + payload.push(JSON.parse(message)); + } +} + +// Processes a single message, as encoded by NativeToJsMessageQueue.java. +function processMessage(message) { + var firstChar = message.charAt(0); + if (firstChar == 'J') { + // This is deprecated on the .java side. It doesn't work with CSP enabled. + eval(message.slice(1)); + } else if (firstChar == 'S' || firstChar == 'F') { + var success = firstChar == 'S'; + var keepCallback = message.charAt(1) == '1'; + var spaceIdx = message.indexOf(' ', 2); + var status = +message.slice(2, spaceIdx); + var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1); + var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx); + var payloadMessage = message.slice(nextSpaceIdx + 1); + var payload = []; + buildPayload(payload, payloadMessage); + cordova.callbackFromNative(callbackId, success, status, payload, keepCallback); + } else { + console.log("processMessage failed: invalid message: " + JSON.stringify(message)); + } +} + +function processMessages() { + // Check for the reentrant case. + if (isProcessing) { + return; + } + if (messagesFromNative.length === 0) { + return; + } + isProcessing = true; + try { + var msg = popMessageFromQueue(); + // The Java side can send a * message to indicate that it + // still has messages waiting to be retrieved. + if (msg == '*' && messagesFromNative.length === 0) { + nextTick(pollOnce); + return; + } + processMessage(msg); + } finally { + isProcessing = false; + if (messagesFromNative.length > 0) { + nextTick(processMessages); + } + } +} + +function popMessageFromQueue() { + var messageBatch = messagesFromNative.shift(); + if (messageBatch == '*') { + return '*'; + } + + var spaceIdx = messageBatch.indexOf(' '); + var msgLen = +messageBatch.slice(0, spaceIdx); + var message = messageBatch.substr(spaceIdx + 1, msgLen); + messageBatch = messageBatch.slice(spaceIdx + msgLen + 1); + if (messageBatch) { + messagesFromNative.unshift(messageBatch); + } + return message; +} + +module.exports = androidExec; + +}); + +// file: src/common/exec/proxy.js +define("cordova/exec/proxy", function(require, exports, module) { + + +// internal map of proxy function +var CommandProxyMap = {}; + +module.exports = { + + // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...); + add:function(id,proxyObj) { + console.log("adding proxy for " + id); + CommandProxyMap[id] = proxyObj; + return proxyObj; + }, + + // cordova.commandProxy.remove("Accelerometer"); + remove:function(id) { + var proxy = CommandProxyMap[id]; + delete CommandProxyMap[id]; + CommandProxyMap[id] = null; + return proxy; + }, + + get:function(service,action) { + return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null ); + } +}; +}); + +// file: src/common/init.js +define("cordova/init", function(require, exports, module) { + +var channel = require('cordova/channel'); +var cordova = require('cordova'); +var modulemapper = require('cordova/modulemapper'); +var platform = require('cordova/platform'); +var pluginloader = require('cordova/pluginloader'); +var utils = require('cordova/utils'); + +var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady]; + +function logUnfiredChannels(arr) { + for (var i = 0; i < arr.length; ++i) { + if (arr[i].state != 2) { + console.log('Channel not fired: ' + arr[i].type); + } + } +} + +window.setTimeout(function() { + if (channel.onDeviceReady.state != 2) { + console.log('deviceready has not fired after 5 seconds.'); + logUnfiredChannels(platformInitChannelsArray); + logUnfiredChannels(channel.deviceReadyChannelsArray); + } +}, 5000); + +// Replace navigator before any modules are required(), to ensure it happens as soon as possible. +// We replace it so that properties that can't be clobbered can instead be overridden. +function replaceNavigator(origNavigator) { + var CordovaNavigator = function() {}; + CordovaNavigator.prototype = origNavigator; + var newNavigator = new CordovaNavigator(); + // This work-around really only applies to new APIs that are newer than Function.bind. + // Without it, APIs such as getGamepads() break. + if (CordovaNavigator.bind) { + for (var key in origNavigator) { + if (typeof origNavigator[key] == 'function') { + newNavigator[key] = origNavigator[key].bind(origNavigator); + } + else { + (function(k) { + utils.defineGetterSetter(newNavigator,key,function() { + return origNavigator[k]; + }); + })(key); + } + } + } + return newNavigator; +} + +if (window.navigator) { + window.navigator = replaceNavigator(window.navigator); +} + +if (!window.console) { + window.console = { + log: function(){} + }; +} +if (!window.console.warn) { + window.console.warn = function(msg) { + this.log("warn: " + msg); + }; +} + +// Register pause, resume and deviceready channels as events on document. +channel.onPause = cordova.addDocumentEventHandler('pause'); +channel.onResume = cordova.addDocumentEventHandler('resume'); +channel.onActivated = cordova.addDocumentEventHandler('activated'); +channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready'); + +// Listen for DOMContentLoaded and notify our channel subscribers. +if (document.readyState == 'complete' || document.readyState == 'interactive') { + channel.onDOMContentLoaded.fire(); +} else { + document.addEventListener('DOMContentLoaded', function() { + channel.onDOMContentLoaded.fire(); + }, false); +} + +// _nativeReady is global variable that the native side can set +// to signify that the native code is ready. It is a global since +// it may be called before any cordova JS is ready. +if (window._nativeReady) { + channel.onNativeReady.fire(); +} + +modulemapper.clobbers('cordova', 'cordova'); +modulemapper.clobbers('cordova/exec', 'cordova.exec'); +modulemapper.clobbers('cordova/exec', 'Cordova.exec'); + +// Call the platform-specific initialization. +platform.bootstrap && platform.bootstrap(); + +// Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js. +// The delay allows the attached modules to be defined before the plugin loader looks for them. +setTimeout(function() { + pluginloader.load(function() { + channel.onPluginsReady.fire(); + }); +}, 0); + +/** + * Create all cordova objects once native side is ready. + */ +channel.join(function() { + modulemapper.mapModules(window); + + platform.initialize && platform.initialize(); + + // Fire event to notify that all objects are created + channel.onCordovaReady.fire(); + + // Fire onDeviceReady event once page has fully loaded, all + // constructors have run and cordova info has been received from native + // side. + channel.join(function() { + require('cordova').fireDocumentEvent('deviceready'); + }, channel.deviceReadyChannelsArray); + +}, platformInitChannelsArray); + + +}); + +// file: src/common/init_b.js +define("cordova/init_b", function(require, exports, module) { + +var channel = require('cordova/channel'); +var cordova = require('cordova'); +var modulemapper = require('cordova/modulemapper'); +var platform = require('cordova/platform'); +var pluginloader = require('cordova/pluginloader'); +var utils = require('cordova/utils'); + +var platformInitChannelsArray = [channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady]; + +// setting exec +cordova.exec = require('cordova/exec'); + +function logUnfiredChannels(arr) { + for (var i = 0; i < arr.length; ++i) { + if (arr[i].state != 2) { + console.log('Channel not fired: ' + arr[i].type); + } + } +} + +window.setTimeout(function() { + if (channel.onDeviceReady.state != 2) { + console.log('deviceready has not fired after 5 seconds.'); + logUnfiredChannels(platformInitChannelsArray); + logUnfiredChannels(channel.deviceReadyChannelsArray); + } +}, 5000); + +// Replace navigator before any modules are required(), to ensure it happens as soon as possible. +// We replace it so that properties that can't be clobbered can instead be overridden. +function replaceNavigator(origNavigator) { + var CordovaNavigator = function() {}; + CordovaNavigator.prototype = origNavigator; + var newNavigator = new CordovaNavigator(); + // This work-around really only applies to new APIs that are newer than Function.bind. + // Without it, APIs such as getGamepads() break. + if (CordovaNavigator.bind) { + for (var key in origNavigator) { + if (typeof origNavigator[key] == 'function') { + newNavigator[key] = origNavigator[key].bind(origNavigator); + } + else { + (function(k) { + utils.defineGetterSetter(newNavigator,key,function() { + return origNavigator[k]; + }); + })(key); + } + } + } + return newNavigator; +} +if (window.navigator) { + window.navigator = replaceNavigator(window.navigator); +} + +if (!window.console) { + window.console = { + log: function(){} + }; +} +if (!window.console.warn) { + window.console.warn = function(msg) { + this.log("warn: " + msg); + }; +} + +// Register pause, resume and deviceready channels as events on document. +channel.onPause = cordova.addDocumentEventHandler('pause'); +channel.onResume = cordova.addDocumentEventHandler('resume'); +channel.onActivated = cordova.addDocumentEventHandler('activated'); +channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready'); + +// Listen for DOMContentLoaded and notify our channel subscribers. +if (document.readyState == 'complete' || document.readyState == 'interactive') { + channel.onDOMContentLoaded.fire(); +} else { + document.addEventListener('DOMContentLoaded', function() { + channel.onDOMContentLoaded.fire(); + }, false); +} + +// _nativeReady is global variable that the native side can set +// to signify that the native code is ready. It is a global since +// it may be called before any cordova JS is ready. +if (window._nativeReady) { + channel.onNativeReady.fire(); +} + +// Call the platform-specific initialization. +platform.bootstrap && platform.bootstrap(); + +// Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js. +// The delay allows the attached modules to be defined before the plugin loader looks for them. +setTimeout(function() { + pluginloader.load(function() { + channel.onPluginsReady.fire(); + }); +}, 0); + +/** + * Create all cordova objects once native side is ready. + */ +channel.join(function() { + modulemapper.mapModules(window); + + platform.initialize && platform.initialize(); + + // Fire event to notify that all objects are created + channel.onCordovaReady.fire(); + + // Fire onDeviceReady event once page has fully loaded, all + // constructors have run and cordova info has been received from native + // side. + channel.join(function() { + require('cordova').fireDocumentEvent('deviceready'); + }, channel.deviceReadyChannelsArray); + +}, platformInitChannelsArray); + +}); + +// file: src/common/modulemapper.js +define("cordova/modulemapper", function(require, exports, module) { + +var builder = require('cordova/builder'), + moduleMap = define.moduleMap, + symbolList, + deprecationMap; + +exports.reset = function() { + symbolList = []; + deprecationMap = {}; +}; + +function addEntry(strategy, moduleName, symbolPath, opt_deprecationMessage) { + if (!(moduleName in moduleMap)) { + throw new Error('Module ' + moduleName + ' does not exist.'); + } + symbolList.push(strategy, moduleName, symbolPath); + if (opt_deprecationMessage) { + deprecationMap[symbolPath] = opt_deprecationMessage; + } +} + +// Note: Android 2.3 does have Function.bind(). +exports.clobbers = function(moduleName, symbolPath, opt_deprecationMessage) { + addEntry('c', moduleName, symbolPath, opt_deprecationMessage); +}; + +exports.merges = function(moduleName, symbolPath, opt_deprecationMessage) { + addEntry('m', moduleName, symbolPath, opt_deprecationMessage); +}; + +exports.defaults = function(moduleName, symbolPath, opt_deprecationMessage) { + addEntry('d', moduleName, symbolPath, opt_deprecationMessage); +}; + +exports.runs = function(moduleName) { + addEntry('r', moduleName, null); +}; + +function prepareNamespace(symbolPath, context) { + if (!symbolPath) { + return context; + } + var parts = symbolPath.split('.'); + var cur = context; + for (var i = 0, part; part = parts[i]; ++i) { + cur = cur[part] = cur[part] || {}; + } + return cur; +} + +exports.mapModules = function(context) { + var origSymbols = {}; + context.CDV_origSymbols = origSymbols; + for (var i = 0, len = symbolList.length; i < len; i += 3) { + var strategy = symbolList[i]; + var moduleName = symbolList[i + 1]; + var module = require(moduleName); + // + if (strategy == 'r') { + continue; + } + var symbolPath = symbolList[i + 2]; + var lastDot = symbolPath.lastIndexOf('.'); + var namespace = symbolPath.substr(0, lastDot); + var lastName = symbolPath.substr(lastDot + 1); + + var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null; + var parentObj = prepareNamespace(namespace, context); + var target = parentObj[lastName]; + + if (strategy == 'm' && target) { + builder.recursiveMerge(target, module); + } else if ((strategy == 'd' && !target) || (strategy != 'd')) { + if (!(symbolPath in origSymbols)) { + origSymbols[symbolPath] = target; + } + builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg); + } + } +}; + +exports.getOriginalSymbol = function(context, symbolPath) { + var origSymbols = context.CDV_origSymbols; + if (origSymbols && (symbolPath in origSymbols)) { + return origSymbols[symbolPath]; + } + var parts = symbolPath.split('.'); + var obj = context; + for (var i = 0; i < parts.length; ++i) { + obj = obj && obj[parts[i]]; + } + return obj; +}; + +exports.reset(); + + +}); + +// file: src/common/modulemapper_b.js +define("cordova/modulemapper_b", function(require, exports, module) { + +var builder = require('cordova/builder'), + symbolList = [], + deprecationMap; + +exports.reset = function() { + symbolList = []; + deprecationMap = {}; +}; + +function addEntry(strategy, moduleName, symbolPath, opt_deprecationMessage) { + symbolList.push(strategy, moduleName, symbolPath); + if (opt_deprecationMessage) { + deprecationMap[symbolPath] = opt_deprecationMessage; + } +} + +// Note: Android 2.3 does have Function.bind(). +exports.clobbers = function(moduleName, symbolPath, opt_deprecationMessage) { + addEntry('c', moduleName, symbolPath, opt_deprecationMessage); +}; + +exports.merges = function(moduleName, symbolPath, opt_deprecationMessage) { + addEntry('m', moduleName, symbolPath, opt_deprecationMessage); +}; + +exports.defaults = function(moduleName, symbolPath, opt_deprecationMessage) { + addEntry('d', moduleName, symbolPath, opt_deprecationMessage); +}; + +exports.runs = function(moduleName) { + addEntry('r', moduleName, null); +}; + +function prepareNamespace(symbolPath, context) { + if (!symbolPath) { + return context; + } + var parts = symbolPath.split('.'); + var cur = context; + for (var i = 0, part; part = parts[i]; ++i) { + cur = cur[part] = cur[part] || {}; + } + return cur; +} + +exports.mapModules = function(context) { + var origSymbols = {}; + context.CDV_origSymbols = origSymbols; + for (var i = 0, len = symbolList.length; i < len; i += 3) { + var strategy = symbolList[i]; + var moduleName = symbolList[i + 1]; + var module = require(moduleName); + // + if (strategy == 'r') { + continue; + } + var symbolPath = symbolList[i + 2]; + var lastDot = symbolPath.lastIndexOf('.'); + var namespace = symbolPath.substr(0, lastDot); + var lastName = symbolPath.substr(lastDot + 1); + + var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null; + var parentObj = prepareNamespace(namespace, context); + var target = parentObj[lastName]; + + if (strategy == 'm' && target) { + builder.recursiveMerge(target, module); + } else if ((strategy == 'd' && !target) || (strategy != 'd')) { + if (!(symbolPath in origSymbols)) { + origSymbols[symbolPath] = target; + } + builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg); + } + } +}; + +exports.getOriginalSymbol = function(context, symbolPath) { + var origSymbols = context.CDV_origSymbols; + if (origSymbols && (symbolPath in origSymbols)) { + return origSymbols[symbolPath]; + } + var parts = symbolPath.split('.'); + var obj = context; + for (var i = 0; i < parts.length; ++i) { + obj = obj && obj[parts[i]]; + } + return obj; +}; + +exports.reset(); + + +}); + +// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/platform.js +define("cordova/platform", function(require, exports, module) { + +// The last resume event that was received that had the result of a plugin call. +var lastResumeEvent = null; + +module.exports = { + id: 'android', + bootstrap: function() { + var channel = require('cordova/channel'), + cordova = require('cordova'), + exec = require('cordova/exec'), + modulemapper = require('cordova/modulemapper'); + + // Get the shared secret needed to use the bridge. + exec.init(); + + // TODO: Extract this as a proper plugin. + modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app'); + + var APP_PLUGIN_NAME = Number(cordova.platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App'; + + // Inject a listener for the backbutton on the document. + var backButtonChannel = cordova.addDocumentEventHandler('backbutton'); + backButtonChannel.onHasSubscribersChange = function() { + // If we just attached the first handler or detached the last handler, + // let native know we need to override the back button. + exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [this.numHandlers == 1]); + }; + + // Add hardware MENU and SEARCH button handlers + cordova.addDocumentEventHandler('menubutton'); + cordova.addDocumentEventHandler('searchbutton'); + + function bindButtonChannel(buttonName) { + // generic button bind used for volumeup/volumedown buttons + var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button'); + volumeButtonChannel.onHasSubscribersChange = function() { + exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]); + }; + } + // Inject a listener for the volume buttons on the document. + bindButtonChannel('volumeup'); + bindButtonChannel('volumedown'); + + // The resume event is not "sticky", but it is possible that the event + // will contain the result of a plugin call. We need to ensure that the + // plugin result is delivered even after the event is fired (CB-10498) + var cordovaAddEventListener = document.addEventListener; + + document.addEventListener = function(evt, handler, capture) { + cordovaAddEventListener(evt, handler, capture); + + if (evt === 'resume' && lastResumeEvent) { + handler(lastResumeEvent); + } + }; + + // Let native code know we are all done on the JS side. + // Native code will then un-hide the WebView. + channel.onCordovaReady.subscribe(function() { + exec(onMessageFromNative, null, APP_PLUGIN_NAME, 'messageChannel', []); + exec(null, null, APP_PLUGIN_NAME, "show", []); + }); + } +}; + +function onMessageFromNative(msg) { + var cordova = require('cordova'); + var action = msg.action; + + switch (action) + { + // Button events + case 'backbutton': + case 'menubutton': + case 'searchbutton': + // App life cycle events + case 'pause': + // Volume events + case 'volumedownbutton': + case 'volumeupbutton': + cordova.fireDocumentEvent(action); + break; + case 'resume': + if(arguments.length > 1 && msg.pendingResult) { + if(arguments.length === 2) { + msg.pendingResult.result = arguments[1]; + } else { + // The plugin returned a multipart message + var res = []; + for(var i = 1; i < arguments.length; i++) { + res.push(arguments[i]); + } + msg.pendingResult.result = res; + } + + // Save the plugin result so that it can be delivered to the js + // even if they miss the initial firing of the event + lastResumeEvent = msg; + } + cordova.fireDocumentEvent(action, msg); + break; + default: + throw new Error('Unknown event action ' + action); + } +} + +}); + +// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/plugin/android/app.js +define("cordova/plugin/android/app", function(require, exports, module) { + +var exec = require('cordova/exec'); +var APP_PLUGIN_NAME = Number(require('cordova').platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App'; + +module.exports = { + /** + * Clear the resource cache. + */ + clearCache:function() { + exec(null, null, APP_PLUGIN_NAME, "clearCache", []); + }, + + /** + * Load the url into the webview or into new browser instance. + * + * @param url The URL to load + * @param props Properties that can be passed in to the activity: + * wait: int => wait msec before loading URL + * loadingDialog: "Title,Message" => display a native loading dialog + * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error + * clearHistory: boolean => clear webview history (default=false) + * openExternal: boolean => open in a new browser (default=false) + * + * Example: + * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000}); + */ + loadUrl:function(url, props) { + exec(null, null, APP_PLUGIN_NAME, "loadUrl", [url, props]); + }, + + /** + * Cancel loadUrl that is waiting to be loaded. + */ + cancelLoadUrl:function() { + exec(null, null, APP_PLUGIN_NAME, "cancelLoadUrl", []); + }, + + /** + * Clear web history in this web view. + * Instead of BACK button loading the previous web page, it will exit the app. + */ + clearHistory:function() { + exec(null, null, APP_PLUGIN_NAME, "clearHistory", []); + }, + + /** + * Go to previous page displayed. + * This is the same as pressing the backbutton on Android device. + */ + backHistory:function() { + exec(null, null, APP_PLUGIN_NAME, "backHistory", []); + }, + + /** + * Override the default behavior of the Android back button. + * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired. + * + * Note: The user should not have to call this method. Instead, when the user + * registers for the "backbutton" event, this is automatically done. + * + * @param override T=override, F=cancel override + */ + overrideBackbutton:function(override) { + exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [override]); + }, + + /** + * Override the default behavior of the Android volume button. + * If overridden, when the volume button is pressed, the "volume[up|down]button" + * JavaScript event will be fired. + * + * Note: The user should not have to call this method. Instead, when the user + * registers for the "volume[up|down]button" event, this is automatically done. + * + * @param button volumeup, volumedown + * @param override T=override, F=cancel override + */ + overrideButton:function(button, override) { + exec(null, null, APP_PLUGIN_NAME, "overrideButton", [button, override]); + }, + + /** + * Exit and terminate the application. + */ + exitApp:function() { + return exec(null, null, APP_PLUGIN_NAME, "exitApp", []); + } +}; + +}); + +// file: src/common/pluginloader.js +define("cordova/pluginloader", function(require, exports, module) { + +var modulemapper = require('cordova/modulemapper'); +var urlutil = require('cordova/urlutil'); + +// Helper function to inject a - - - - -

Events

-
-

Cordova:  

-

Deviceready:  

-
-
- Press "Home" button, then return to this app to see pause/resume.
- There shouldn't be any "Running" entries between pause and resume.
-
-
-

Info for event testing:

-
-
- - - Clear status - - - - - - diff --git a/test/assets/www/background/index2.html b/test/assets/www/background/index2.html deleted file mode 100755 index fa5a367f..00000000 --- a/test/assets/www/background/index2.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - -Background Page 2 - - - - - - -

Events

-
-

Cordova:  

-

Deviceready:  

-
-
-

Press "Back" button to return to Page 1.

-
-
-

Info for event testing:

-
-
- - Load new page - Clear status - - - - - - diff --git a/test/assets/www/basicauth/index.html b/test/assets/www/basicauth/index.html deleted file mode 100755 index 5d2bc512..00000000 --- a/test/assets/www/basicauth/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - Cordova Tests - - - - - -

Basic Auth

-
-

Cordova:  

-

Deviceready:  

-
-
- Loading link below should be successful and show page indicating username=test & password=test.
-
- Test password - - diff --git a/test/assets/www/jqmtabbackbutton/index.html b/test/assets/www/jqmtabbackbutton/index.html deleted file mode 100755 index 8a4f3ae1..00000000 --- a/test/assets/www/jqmtabbackbutton/index.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - -Backbutton - - - - - - - - - -
-
-

Main

-
-
- To test, press several tabs.
- The "backbutton" can be pressed any time to exit app. -
-
-
- -
-
-
diff --git a/test/assets/www/jqmtabbackbutton/tab1.html b/test/assets/www/jqmtabbackbutton/tab1.html deleted file mode 100755 index 7d3e5a90..00000000 --- a/test/assets/www/jqmtabbackbutton/tab1.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - -Tab 1 - - - -
-
-

Tab 1

-
-
-Tab 1 content. -
-
-
- -
- -
- -
diff --git a/test/assets/www/jqmtabbackbutton/tab2.html b/test/assets/www/jqmtabbackbutton/tab2.html deleted file mode 100755 index ede55969..00000000 --- a/test/assets/www/jqmtabbackbutton/tab2.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Tab 2 - - - - -
-
-

Tab 2

-
-
-Tab 2 content. -
-
-
- -
- -
- -
diff --git a/test/assets/www/jqmtabbackbutton/tab3.html b/test/assets/www/jqmtabbackbutton/tab3.html deleted file mode 100755 index ef7783c6..00000000 --- a/test/assets/www/jqmtabbackbutton/tab3.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Tab 3 - - - - -
-
-

Tab 3

-
-
-Tab 3 content. -
-
-
- -
- -
- -
diff --git a/test/assets/www/menus/index.html b/test/assets/www/menus/index.html deleted file mode 100755 index ff0b93bf..00000000 --- a/test/assets/www/menus/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - Cordova Tests - - - - - -

Menu Test

-
-

Cordova:  

-

Deviceready:  

-
-
-

The options menu items should be:

-
  • Item1
    -
  • Item2
    -
  • Item3
    -

    There is also a context menu. Touch and hold finger here to see:

    -
  • Context Item1
    -
  • - - - diff --git a/test/assets/www/userwebview/index.html b/test/assets/www/userwebview/index.html deleted file mode 100755 index b1a653a2..00000000 --- a/test/assets/www/userwebview/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - Cordova Tests - - - - - -

    User WebView/Client/Chrome Test

    -
    -

    Cordova:  

    -

    Deviceready:  

    -
    -
    -

    The following should be seen in LogCat:

    -
  • userwebview: TestViewClient()
    -
  • userwebview: TestChromeClient()
    -
  • userwebview: onGeolocationPermissionsShowPrompt(file://)
    -
  • userwebview: shouldOverrideUrlLoading(test://this_will_call_shouldOverrideUrlLoading)
    - -
  • - - - diff --git a/test/assets/www/xhr/index.html b/test/assets/www/xhr/index.html deleted file mode 100755 index d1b997a9..00000000 --- a/test/assets/www/xhr/index.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - Cordova Tests - - - - - - -

    XHR

    -
    -

    Cordova:  

    -

    Deviceready:  

    -
    -
    - Press buttons below to test. You should see an alert with results displayed. -
    - Load file:// - Load Google - - - diff --git a/test/build.gradle b/test/build.gradle index dd30a4a9..74b2ab0d 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -1,31 +1,14 @@ -/* - 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. -*/ - -apply plugin: 'android' +// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } - dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:2.2.3' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files } } @@ -35,58 +18,6 @@ allprojects { } } -ext { - apply from: '../framework/cordova.gradle' - cdvCompileSdkVersion = privateHelpers.getProjectTarget() - cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools() +task clean(type: Delete) { + delete rootProject.buildDir } - -android { - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src'] - resources.srcDirs = ['src'] - res.srcDirs = ['res'] - assets.srcDirs = ['assets'] - } - androidTest { - java.srcDirs = ['androidTest/src'] - resources.srcDirs = ['androidTest/src'] - res.srcDirs = [] - assets.srcDirs = [] - } - } - - defaultConfig { - testInstrumentationRunner "android.test.InstrumentationTestRunner" - } - - testOptions { - unitTests.returnDefaultValues = true - } - - compileSdkVersion cdvCompileSdkVersion - buildToolsVersion cdvBuildToolsVersion - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_6 - targetCompatibility JavaVersion.VERSION_1_6 - } -} - -dependencies { - debugCompile project(path: ":CordovaLib", configuration: "debug") - releaseCompile project(path: ":CordovaLib", configuration: "release") - androidTestCompile fileTree(dir: 'androidTest/libs', include: '*.jar') - testCompile 'junit:junit:4.12' -} - -task copyCordovaJs (type: Copy) { - from '../bin/templates/project/assets/www' - into 'assets/www' - include('cordova.js') -} -preBuild.dependsOn copyCordovaJs - - diff --git a/test/gradle.properties b/test/gradle.properties new file mode 100644 index 00000000..aac7c9b4 --- /dev/null +++ b/test/gradle.properties @@ -0,0 +1,17 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/test/gradle/wrapper/gradle-wrapper.properties b/test/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..04e285f3 --- /dev/null +++ b/test/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Dec 28 10:00:20 PST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/test/gradlew b/test/gradlew new file mode 100755 index 00000000..9d82f789 --- /dev/null +++ b/test/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/test/gradlew.bat b/test/gradlew.bat new file mode 100644 index 00000000..8a0b282a --- /dev/null +++ b/test/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/test/project.properties b/test/project.properties deleted file mode 100644 index fcee01ff..00000000 --- a/test/project.properties +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-21 -android.library.reference.1=../framework diff --git a/test/res/drawable-hdpi/ic_launcher.png b/test/res/drawable-hdpi/ic_launcher.png deleted file mode 100755 index 4d27634485b3a20d8a0188107e84812f4f71084b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6080 zcmbVQWmHscyB@kl0Vx%Rc%`R+p}SK`8U%)6K$wtW7+OLJkr3%dKvIw{X%wVWLIDvJ zMLHzKgKvE2{CL;*iZj*;3DiM5qL3y?M`z!AZ;|o<0GX?snWdM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EeqbSf+@42Jke$GCf_X zQ4(=VCA_{j@2LarrEU`?b)j&%Zo0r{~?x?6_qdn^tzZCZDSM7~q#CcB? zGct~$ez|49-Uv4md*~13-b(F zvlmb^D<8p$fx+zwBdf&GD%jUFatBc|(aqJWv9S*iXZPNJ_H6p&(2{NxY};t0=)GuMay~J6<6`@uCg{@3*adwT^WQzg(ECKdQO}=gOSvn()h3-Gu$RY9Xb8;H*v9h;` zoQ2`>ckG+4 z*Jn9B>kr@bHfVRCRfkjeWVSHzX>pfjEYr>HK9!$x&eNQB3=GU!3 z8Ydz9>1KDRE!E?&MmO8PjRwL@_OL5gSyo+S~j32bXAWI(43+?vBAmjpfN x7!UQ(CucrH2U}Yz;xlIQ9|EqN9x0Jf0&+IH2i=|^UjP25uA^b7UZLs``adt{1eE{) diff --git a/test/res/drawable-ldpi/ic_launcher.png b/test/res/drawable-ldpi/ic_launcher.png deleted file mode 100755 index cd5032a4f2e0b734d4bdece13564c4b55de963a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3096 zcmbVOdpOf=AD>7yrx2x*ZB!CFna$?3*)TMDQ0d?>Gpu%C8%8OIN0gS{Bs@8bP&p(i z#OqN=j*U=}LPX_k)I;xdc;5GquIG>UcU`~Vec#{v^ZA~?*Y!K+=wPD&+zJE$01CEb zl9OcBS$)^bO1^IZ$;pyMgKy=^cjox;gQ;9PfZ)yXqJwN%RA0Iio$4JD@Puv(07&~W zTwM9ClzliFhXtjsVxR(+zl03{m|6(@sk9SxKFEvi%V3*9CaY>8AcnUYF5NlQ!G#ujf`;{mSeS!M1vrTU7M)K830O=v4<|5#eAA1Q>{rDw2a!BZ$c1(m_U0xB(50Mu5;LC;|n?qOkfPBpd;UA&@XQ#sC4w8DVg61n9>Dkyzt; z`{0~N)<0}XPG%54KHnb)g9Qf%LxT;W9Ih`6fyH8Ba3l{++cp+>)Rbas8Y5&wf zqVs56hCiRdVS`pRQoT5Vd^3o|)9)d${3(>b6|;Fi5+z9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P|S7cd7)vRa$(U z9TudY75Q;)N5AW_>}QKQ<;(=HSTncnh4LmQ2n%~d=f?aa#U`STqipouTpO>`U>UJu z%o>-QJsSs)bQM0&Ujwg!W#kQf&_A%SP!LIWQ*%;f*Pb)J(xN_=zFX@?N||rLnmi^z zJp#2O7o^z92>!h}@elCCI)GG5p7zsvfPz%vfS*%NXXf!N{E}yKjo^6t#kO{ldlA0d zPK}Y}FdrI)>@(f@+AZhLF8Q>tV~Edx?zSLkyaZ&Xmo&<_G+mf2mpx0bH%QtkRR{zQ z0XNzMb{}7}4^WUPhnZ|yBn=;nTpm_Fv+qJm$91i7FJkNH>?ZSo^SuvfjyHvaMYZ4-DWs zr#1x<^JCr?SL1h>w`@^?SNk(jgalRERPSdz-HEj=Mtv!{BsVFaC1cn&K#-}BHwF6O z%@%;Kj*^u!ZNg;MzZruzJP-!74Y$Neqh6v+0$pT!Wlf*|CR?mDf=uKH2&S*_oB{=0 zT9N;kC)%nmx4KIF?R)LEJ-8(oHR&~b`l^kx5`6KbeWrDt`twg-w*xkDQ$q!mn5UdV z`8wovr2H^IPq;zUEEgm;oGTZJMWYsB7?r$EjP;j;t|cE<9u6p}i5EvMN2e5ZUxUbE z&wssEq({55dw=?zJ`BdehlzkX+urn&Q{Uyq%W3<@4+VZ+noys=`u_gt=q{~09`U?E zeQ<1Z{JNc1OkTa(#wcp;kjx>ePv*;_SZAU#BGw)l{up1lM_NC@0rpJSs254=zke*nlqMCSki diff --git a/test/res/drawable-mdpi/ic_launcher.png b/test/res/drawable-mdpi/ic_launcher.png deleted file mode 100755 index e79c6062c1dcd9e98f092dbd7e51b5b76dd897d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4090 zcmbVPc{tST+aFu@;zT4g#*%EaV3;u+!`Mzn_UsvBVk|S5!B~_j7;l{r=;LH#ITf$8Q3N;YtM*yH*$u0z-kvGnbU{1if2KhcGpa1|CccP^Y z)dp*f#FM?1a7QvqG;bdU8UR53PV>RxJq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qF0e4%0kF9vN}WKRpg_>yL^TfoX9zz7|&y=l)1&{IwyxR z5i@r)0(jokhdA3s_9b2=2`U`MQY1LUSMCFG{HEtWd=Z$}VfW{)+2AxiCgurGZ?sU% z%lFucEMaE1X@V!o3Y|&yZ*kV<1`Vn{&C(&jJ-ot2)wzP+v=%IIo~+5R=}7}fUXZh> zIwc$RDZ5y_9{>v0GLW(39GH2^cV3M?#3k!n$FJ~yB+`wTkapFAKuot>(MFpQLJ_@IVg6pa++M9$h>jpu~f&y9)96mKEWoQ z;o3li-I&z&X5gew0Xf)mUq$C+peE9P`2y<=O9ac}WWJM*2oA zm`CrrTO_VFCRR4+vs{^&Sorachh>ip;*}FT8V3tzyEVUFG^-yBu{L+badMt`^R8=e zVKc*hp! z2YZhn?~iRR=3d)L24A*o^7|Y!$FA|zyPo2xaO!P%-lgU63qg8^Ls5^bX_J-Vl%bqu zI4&$KjK!gBaB$G_o%psz%gc6$fT+Mp7hPT5FLEO2s;wQ7Ad18i-owLVoS=<$14j!W zWaF&HctWO3NC(`^^AE0%JC+MR`a=-vx1>;6dk zm2rLU@7bxt%jW2b-X}w?pvh>1VG(wnEq3s|I}s5Pn=>;r_NGeVoC-9FXiAeH`$mR+ zM(!})K{U0NG~IGXXWWDBrAj9_Wky;quR!Xz_>K2tmS&$uU~m*_Cq7vWTd|Y1MR`;+YshYoBbT7wbR=?)tQT6s-QkHI7FJ3yq$lHf5|(|RHjKi+DI7tGDfQ-OS)))F`yr7%IhyS$#slD7Nf eTI2Uz01KeUnH^M8$gFYn8aL82!BpuuNB$2fN-7Zm diff --git a/test/res/drawable/icon.png b/test/res/drawable/icon.png deleted file mode 100755 index 697df7f37de3bc418dcee9409240eab4891e496d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5800 zcmV;Z7FX$sP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXA- z4K^yy<5HLa02U}oL_t(&-i@1Svt7q^o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9e&}ywTLKD$NK&wCzjl!jB z5GA{+7#2HNt3y%w+-2nSo71)Ze)MU$KNi&)hS(BPJ;AfV#eXI=TDxT@WT^hjtv}(CNl8Ctc_gRYk2cs#l0%v6iSgi z25KwgrOVBvYY<|Z;*iFmO0G#`XeRRJG?f@#PP17j->eQl_5kzDz~oUN=>~3>k2^Q) z7P(m}-`OZRKJkpbGH=u2=f@9f-g!`QecB*SC|t_4c5v)@*}WU7{|mX6v@uPW)Bz0< zZxD4^7A&`hU60v?nur{n4qg%G{J79>A9ZDAzC5>DtHa9oW-U95KFw{On4 zw%Z^AMWI - - - CordovaNativeTests - diff --git a/test/settings.gradle b/test/settings.gradle index 1de15898..0113229d 100644 --- a/test/settings.gradle +++ b/test/settings.gradle @@ -1,22 +1,3 @@ -/* 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. -*/ - -include ":" +include ':app' include ":CordovaLib" project(':CordovaLib').projectDir = new File('../framework') - diff --git a/test/src/org/apache/cordova/test/ActivityPlugin.java b/test/src/org/apache/cordova/test/ActivityPlugin.java deleted file mode 100755 index c6a96ec0..00000000 --- a/test/src/org/apache/cordova/test/ActivityPlugin.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package org.apache.cordova.test; - -import org.apache.cordova.CordovaArgs; -import org.apache.cordova.LOG; -import org.json.JSONArray; -import org.json.JSONException; - -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; - -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; - } - return false; - } - - public void startActivity(String className, String startUrl, JSONObject extraPrefs) throws JSONException { - 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)); - } - LOG.d(TAG, "Starting activity %s", className); - this.cordova.getActivity().startActivity(intent); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - LOG.e(TAG, "Error starting activity %s", className); - } - } - -} diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java deleted file mode 100644 index e79e1069..00000000 --- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java +++ /dev/null @@ -1,74 +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.ArrayBlockingQueue; - -import org.apache.cordova.Config; -import org.apache.cordova.ConfigXmlParser; -import org.apache.cordova.CordovaInterfaceImpl; -import org.apache.cordova.CordovaWebView; -import org.apache.cordova.CordovaWebViewImpl; -import org.apache.cordova.engine.SystemWebView; -import org.apache.cordova.engine.SystemWebViewEngine; - -import android.app.Activity; -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); - } - }; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - - //Set up the webview - ConfigXmlParser parser = new ConfigXmlParser(); - parser.parse(this); - - SystemWebView webView = (SystemWebView) findViewById(R.id.cordovaWebView); - cordovaWebView = new CordovaWebViewImpl(new SystemWebViewEngine(webView)); - cordovaWebView.init(cordovaInterface, parser.getPluginEntries(), parser.getPreferences()); - - cordovaWebView.loadUrl(START_URL); - } - - public CordovaWebView getCordovaWebView() { - return cordovaWebView; - } -} diff --git a/test/src/org/apache/cordova/test/MainTestActivity.java b/test/src/org/apache/cordova/test/MainTestActivity.java deleted file mode 100644 index 76697c37..00000000 --- a/test/src/org/apache/cordova/test/MainTestActivity.java +++ /dev/null @@ -1,45 +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; - -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); - 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. - String errorUrl = getIntent().getStringExtra("testErrorUrl"); - if (errorUrl != null) { - preferences.set("errorUrl", errorUrl); - } - } -} diff --git a/test/src/org/apache/cordova/test/menus.java b/test/src/org/apache/cordova/test/menus.java deleted file mode 100755 index 6ef12c5c..00000000 --- a/test/src/org/apache/cordova/test/menus.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package org.apache.cordova.test; - -import android.os.Bundle; -import android.view.ContextMenu; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ContextMenu.ContextMenuInfo; - -import org.apache.cordova.*; -import org.apache.cordova.LOG; - -public class menus extends BaseTestCordovaActivity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - // need the title to be shown (config.xml) for the options menu to be visible - super.init(); - super.registerForContextMenu(super.appView.getView()); - super.loadUrl("file:///android_asset/www/menus/index.html"); - } - - // Demonstrate how to add your own menus to app - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - int base = Menu.FIRST; - // Group, item id, order, title - menu.add(base, base, base, "Item1"); - menu.add(base, base + 1, base + 1, "Item2"); - menu.add(base, base + 2, base + 2, "Item3"); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - LOG.d("menus", "Item " + item.getItemId() + " pressed."); - this.appView.loadUrl("javascript:alert('Menu " + item.getItemId() + " pressed.')"); - return super.onOptionsItemSelected(item); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - LOG.d("menus", "onPrepareOptionsMenu()"); - // this.appView.loadUrl("javascript:alert('onPrepareOptionsMenu()')"); - return true; - } - - @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) { - LOG.d("menus", "onCreateContextMenu()"); - menu.setHeaderTitle("Test Context Menu"); - menu.add(200, 200, 200, "Context Item1"); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')"); - return true; - } - -} diff --git a/test/src/org/apache/cordova/test/userwebview.java b/test/src/org/apache/cordova/test/userwebview.java deleted file mode 100755 index a37114fa..00000000 --- a/test/src/org/apache/cordova/test/userwebview.java +++ /dev/null @@ -1,84 +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 android.webkit.GeolocationPermissions.Callback; - -import org.apache.cordova.*; -import org.apache.cordova.engine.SystemWebChromeClient; -import org.apache.cordova.engine.SystemWebViewClient; -import org.apache.cordova.engine.SystemWebViewEngine; - -public class userwebview extends MainTestActivity { - - public TestViewClient testViewClient; - public TestChromeClient testChromeClient; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - SystemWebViewEngine engine = (SystemWebViewEngine)appView.getEngine(); - testViewClient = new TestViewClient(engine); - testChromeClient = new TestChromeClient(engine); - super.init(); - WebView webView = (WebView)engine.getView(); - webView.setWebViewClient(testViewClient); - webView.setWebChromeClient(testChromeClient); - super.loadUrl("file:///android_asset/www/userwebview/index.html"); - } - - public class TestChromeClient extends SystemWebChromeClient { - public TestChromeClient(SystemWebViewEngine parentEngine) { - super(parentEngine); - LOG.d("userwebview", "TestChromeClient()"); - } - - @Override - public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) { - LOG.d("userwebview", "onGeolocationPermissionsShowPrompt(" + origin + ")"); - super.onGeolocationPermissionsShowPrompt(origin, callback); - callback.invoke(origin, true, false); - } - } - - /** - * This class can be used to override the GapViewClient and receive notification of webview events. - */ - public class TestViewClient extends SystemWebViewClient { - public TestViewClient(SystemWebViewEngine parentEngine) { - super(parentEngine); - LOG.d("userwebview", "TestViewClient()"); - } - - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - LOG.d("userwebview", "shouldOverrideUrlLoading(" + url + ")"); - return super.shouldOverrideUrlLoading(view, url); - } - - @Override - public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { - LOG.d("userwebview", "onReceivedError: Error code=" + errorCode + " Description=" + description + " URL=" + failingUrl); - super.onReceivedError(view, errorCode, description, failingUrl); - } - } - -}