Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 68A5F92FE for ; Fri, 23 Mar 2012 22:01:18 +0000 (UTC) Received: (qmail 44234 invoked by uid 500); 23 Mar 2012 22:01:18 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 44164 invoked by uid 500); 23 Mar 2012 22:01:18 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 43732 invoked by uid 99); 23 Mar 2012 22:01:17 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Mar 2012 22:01:17 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 221018B8B; Fri, 23 Mar 2012 22:01:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bowserj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [16/17] Adding the tests from the GitHub Prototype Message-Id: <20120323220117.221018B8B@tyr.zones.apache.org> Date: Fri, 23 Mar 2012 22:01:17 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/assets/www/phonegap.js ---------------------------------------------------------------------- diff --git a/test/assets/www/phonegap.js b/test/assets/www/phonegap.js new file mode 100755 index 0000000..8931af9 --- /dev/null +++ b/test/assets/www/phonegap.js @@ -0,0 +1,11 @@ +document.write(''); +document.write(''); + +function backHome() { + if (device.platform.toLowerCase() == 'android') { + navigator.app.backHistory(); + } + else { + document.location = "../index.html"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/assets/www/sql/index.html ---------------------------------------------------------------------- diff --git a/test/assets/www/sql/index.html b/test/assets/www/sql/index.html new file mode 100755 index 0000000..c9e1a53 --- /dev/null +++ b/test/assets/www/sql/index.html @@ -0,0 +1,132 @@ + + + + + + PhoneGap + + + + + + + + + +

HTML5 Database

+
+ Results:
+ +
+

Action

+ Create, Add, Read Database + Read Database +

 

Back + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/assets/www/storage/index.html ---------------------------------------------------------------------- diff --git a/test/assets/www/storage/index.html b/test/assets/www/storage/index.html new file mode 100755 index 0000000..ab0ccaa --- /dev/null +++ b/test/assets/www/storage/index.html @@ -0,0 +1,50 @@ + + + + + + PhoneGap + + + + + + + + + +

Local Storage

+
+ You have run this app an untold number of time(s). +
+ + + +

 

Back + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/assets/www/whitelist/index.html ---------------------------------------------------------------------- diff --git a/test/assets/www/whitelist/index.html b/test/assets/www/whitelist/index.html new file mode 100644 index 0000000..ac60e01 --- /dev/null +++ b/test/assets/www/whitelist/index.html @@ -0,0 +1,35 @@ + + + + + + PhoneGap + + + + + + +

PhoneGap Tests

+
+

Platform:  

+

Version:  

+

UUID:  

+

Name:  

+

Width:  , Height:   + , Color Depth:

+
+ Automatic Test + Accelerometer + Audio Play/Record + Camera + Compass + Contacts + Events + Location + Misc Content + Notification + Web SQL + Local Storage + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/android.jar ---------------------------------------------------------------------- diff --git a/test/libs/android.jar b/test/libs/android.jar new file mode 100644 index 0000000..8854842 Binary files /dev/null and b/test/libs/android.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/android_library.jar ---------------------------------------------------------------------- diff --git a/test/libs/android_library.jar b/test/libs/android_library.jar new file mode 100644 index 0000000..53029ee Binary files /dev/null and b/test/libs/android_library.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/android_webdriver_library.jar ---------------------------------------------------------------------- diff --git a/test/libs/android_webdriver_library.jar b/test/libs/android_webdriver_library.jar new file mode 100644 index 0000000..d38a630 Binary files /dev/null and b/test/libs/android_webdriver_library.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/base.jar ---------------------------------------------------------------------- diff --git a/test/libs/base.jar b/test/libs/base.jar new file mode 100644 index 0000000..bc2d933 Binary files /dev/null and b/test/libs/base.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/commons-codec-1.3.jar ---------------------------------------------------------------------- diff --git a/test/libs/commons-codec-1.3.jar b/test/libs/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/test/libs/commons-codec-1.3.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/cordova-1.4.1.jar ---------------------------------------------------------------------- diff --git a/test/libs/cordova-1.4.1.jar b/test/libs/cordova-1.4.1.jar new file mode 100644 index 0000000..927470c Binary files /dev/null and b/test/libs/cordova-1.4.1.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/guava-10.0.1.jar ---------------------------------------------------------------------- diff --git a/test/libs/guava-10.0.1.jar b/test/libs/guava-10.0.1.jar new file mode 100644 index 0000000..d107c0f Binary files /dev/null and b/test/libs/guava-10.0.1.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/junit-4.10.jar ---------------------------------------------------------------------- diff --git a/test/libs/junit-4.10.jar b/test/libs/junit-4.10.jar new file mode 100644 index 0000000..bf5c0b9 Binary files /dev/null and b/test/libs/junit-4.10.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/libs/logging.jar ---------------------------------------------------------------------- diff --git a/test/libs/logging.jar b/test/libs/logging.jar new file mode 100644 index 0000000..e708029 Binary files /dev/null and b/test/libs/logging.jar differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/proguard.cfg ---------------------------------------------------------------------- diff --git a/test/proguard.cfg b/test/proguard.cfg new file mode 100644 index 0000000..b1cdf17 --- /dev/null +++ b/test/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/project.properties ---------------------------------------------------------------------- diff --git a/test/project.properties b/test/project.properties new file mode 100644 index 0000000..730e911 --- /dev/null +++ b/test/project.properties @@ -0,0 +1,11 @@ +# 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-14 http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/drawable-hdpi/ic_launcher.png ---------------------------------------------------------------------- diff --git a/test/res/drawable-hdpi/ic_launcher.png b/test/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..8074c4c Binary files /dev/null and b/test/res/drawable-hdpi/ic_launcher.png differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/drawable-ldpi/ic_launcher.png ---------------------------------------------------------------------- diff --git a/test/res/drawable-ldpi/ic_launcher.png b/test/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000..1095584 Binary files /dev/null and b/test/res/drawable-ldpi/ic_launcher.png differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/drawable-mdpi/ic_launcher.png ---------------------------------------------------------------------- diff --git a/test/res/drawable-mdpi/ic_launcher.png b/test/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..a07c69f Binary files /dev/null and b/test/res/drawable-mdpi/ic_launcher.png differ http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/layout/main.xml ---------------------------------------------------------------------- diff --git a/test/res/layout/main.xml b/test/res/layout/main.xml new file mode 100644 index 0000000..2b020ba --- /dev/null +++ b/test/res/layout/main.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/values/strings.xml ---------------------------------------------------------------------- diff --git a/test/res/values/strings.xml b/test/res/values/strings.xml new file mode 100644 index 0000000..27c3286 --- /dev/null +++ b/test/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + Hello World! + CordovaTestTest + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/xml/phonegap.xml ---------------------------------------------------------------------- diff --git a/test/res/xml/phonegap.xml b/test/res/xml/phonegap.xml new file mode 100644 index 0000000..97f31ea --- /dev/null +++ b/test/res/xml/phonegap.xml @@ -0,0 +1,5 @@ + + + + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/res/xml/plugins.xml ---------------------------------------------------------------------- diff --git a/test/res/xml/plugins.xml b/test/res/xml/plugins.xml new file mode 100644 index 0000000..4d84f59 --- /dev/null +++ b/test/res/xml/plugins.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/CordovaActivityTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/CordovaActivityTest.java b/test/src/org/apache/cordova/test/CordovaActivityTest.java new file mode 100644 index 0000000..96e4b00 --- /dev/null +++ b/test/src/org/apache/cordova/test/CordovaActivityTest.java @@ -0,0 +1,55 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; +import com.phonegap.api.PluginManager; + +import android.test.ActivityInstrumentationTestCase2; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +public class CordovaActivityTest extends ActivityInstrumentationTestCase2 { + + private PhoneGapActivity testActivity; + private FrameLayout containerView; + private LinearLayout innerContainer; + private CordovaWebView testView; + + public CordovaActivityTest() + { + super("com.phonegap.test.activities",PhoneGapActivity.class); + } + + protected void setUp() throws Exception { + super.setUp(); + testActivity = this.getActivity(); + containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); + innerContainer = (LinearLayout) containerView.getChildAt(0); + testView = (CordovaWebView) innerContainer.getChildAt(0); + + } + + public void testPreconditions(){ + assertNotNull(innerContainer); + assertNotNull(testView); + } + + + public void testForCordovaView() { + String className = testView.getClass().getSimpleName(); + assertTrue(className.equals("CordovaWebView")); + } + + public void testForLinearLayout() { + String className = innerContainer.getClass().getSimpleName(); + assertTrue(className.equals("LinearLayoutSoftKeyboardDetect")); + } + + public void testForPluginManager() { + CordovaWebView v = (CordovaWebView) testView; + PluginManager p = v.getPluginManager(); + assertNotNull(p); + String className = p.getClass().getSimpleName(); + assertTrue(className.equals("PluginManager")); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/CordovaDriverAction.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/CordovaDriverAction.java b/test/src/org/apache/cordova/test/CordovaDriverAction.java new file mode 100644 index 0000000..bfb8c0d --- /dev/null +++ b/test/src/org/apache/cordova/test/CordovaDriverAction.java @@ -0,0 +1,13 @@ +package org.apache.cordova.test; + +import android.app.Activity; +import android.os.Bundle; + + +public class CordovaDriverAction extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/CordovaSplashTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/CordovaSplashTest.java b/test/src/org/apache/cordova/test/CordovaSplashTest.java new file mode 100644 index 0000000..307f966 --- /dev/null +++ b/test/src/org/apache/cordova/test/CordovaSplashTest.java @@ -0,0 +1,54 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; +import com.phonegap.api.PluginManager; + +import android.test.ActivityInstrumentationTestCase2; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +public class CordovaSplashTest extends ActivityInstrumentationTestCase2 { + + private PhoneGapSplash testActivity; + private FrameLayout containerView; + private LinearLayout innerContainer; + private CordovaWebView testView; + + public CordovaSplashTest() + { + super("com.phonegap.test.activities",PhoneGapSplash.class); + } + + protected void setUp() throws Exception{ + super.setUp(); + testActivity = this.getActivity(); + containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); + innerContainer = (LinearLayout) containerView.getChildAt(0); + testView = (CordovaWebView) innerContainer.getChildAt(0); + + } + + public void testPreconditions(){ + assertNotNull(innerContainer); + assertNotNull(testView); + } + + + public void testForCordovaView() { + String className = testView.getClass().getSimpleName(); + assertTrue(className.equals("CordovaWebView")); + } + + public void testForPluginManager() { + CordovaWebView v = (CordovaWebView) testView; + PluginManager p = v.getPluginManager(); + assertNotNull(p); + String className = p.getClass().getSimpleName(); + assertTrue(className.equals("PluginManager")); + } + + public void testBackButton() { + CordovaWebView v = (CordovaWebView) testView; + assertFalse(v.checkBackKey()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/CordovaTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/CordovaTest.java b/test/src/org/apache/cordova/test/CordovaTest.java new file mode 100644 index 0000000..8d290f4 --- /dev/null +++ b/test/src/org/apache/cordova/test/CordovaTest.java @@ -0,0 +1,90 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; +import com.phonegap.api.PluginManager; + +import android.test.ActivityInstrumentationTestCase2; +import android.view.View; + +public class CordovaTest extends + ActivityInstrumentationTestCase2 { + + private static final long TIMEOUT = 1000; + private PhoneGapViewTestActivity testActivity; + private View testView; + private String rString; + + public CordovaTest() { + super("com.phonegap.test.activities", PhoneGapViewTestActivity.class); + } + + protected void setUp() throws Exception { + super.setUp(); + testActivity = this.getActivity(); + testView = testActivity.findViewById(R.id.phoneGapView); + } + + public void testPreconditions() { + assertNotNull(testView); + } + + public void testForCordovaView() { + String className = testView.getClass().getSimpleName(); + assertTrue(className.equals("CordovaWebView")); + } + + public void testForPluginManager() { + CordovaWebView v = (CordovaWebView) testView; + PluginManager p = v.getPluginManager(); + assertNotNull(p); + String className = p.getClass().getSimpleName(); + assertTrue(className.equals("PluginManager")); + } + + public void testBackButton() { + CordovaWebView v = (CordovaWebView) testView; + assertFalse(v.checkBackKey()); + } + + public void testLoadUrl() { + CordovaWebView v = (CordovaWebView) testView; + v.loadUrlIntoView("file:///android_asset/www/index.html"); + sleep(); + String url = v.getUrl(); + boolean result = url.equals("file:///android_asset/www/index.html"); + assertTrue(result); + int visible = v.getVisibility(); + assertTrue(visible == View.VISIBLE); + } + + public void testBackHistoryFalse() { + CordovaWebView v = (CordovaWebView) testView; + // Move back in the history + boolean test = v.backHistory(); + assertFalse(test); + } + + // Make sure that we can go back + public void testBackHistoryTrue() { + this.testLoadUrl(); + CordovaWebView v = (CordovaWebView) testView; + v.loadUrlIntoView("file:///android_asset/www/compass/index.html"); + sleep(); + String url = v.getUrl(); + assertTrue(url.equals("file:///android_asset/www/compass/index.html")); + // Move back in the history + boolean test = v.backHistory(); + assertTrue(test); + sleep(); + url = v.getUrl(); + assertTrue(url.equals("file:///android_asset/www/index.html")); + } + + private void sleep() { + try { + Thread.sleep(TIMEOUT); + } catch (InterruptedException e) { + fail("Unexpected Timeout"); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/CordovaViewFactory.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/CordovaViewFactory.java b/test/src/org/apache/cordova/test/CordovaViewFactory.java new file mode 100644 index 0000000..4e2e6a5 --- /dev/null +++ b/test/src/org/apache/cordova/test/CordovaViewFactory.java @@ -0,0 +1,17 @@ +package org.apache.cordova.test; + +import org.openqa.selenium.android.library.WebViewFactory; + +import org.apache.cordova.CordovaWebView; + +import android.app.Activity; +import android.webkit.WebView; + +public class CordovaViewFactory implements WebViewFactory { + + public WebView createNewView(Activity arg0) { + // TODO Auto-generated method stub + return new CordovaWebView(arg0); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/GapClientTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/GapClientTest.java b/test/src/org/apache/cordova/test/GapClientTest.java new file mode 100644 index 0000000..d826ae7 --- /dev/null +++ b/test/src/org/apache/cordova/test/GapClientTest.java @@ -0,0 +1,71 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; +import org.apache.cordova.CordovaChromeClient; +import org.apache.cordova.api.PluginManager; + +import android.content.Context; +import android.content.res.AssetManager; +import android.content.res.Resources; +import android.test.ActivityInstrumentationTestCase2; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +public class GapClientTest extends ActivityInstrumentationTestCase2 { + + private PhoneGapViewTestActivity testActivity; + private FrameLayout containerView; + private LinearLayout innerContainer; + private View testView; + private String rString; + private CordovaChromeClient appCode; + + public GapClientTest() { + super("com.phonegap.test.activities",PhoneGapViewTestActivity.class); + } + + protected void setUp() throws Exception{ + super.setUp(); + testActivity = this.getActivity(); + containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); + innerContainer = (LinearLayout) containerView.getChildAt(0); + testView = innerContainer.getChildAt(0); + appCode = ((CordovaWebView) testView).getGapClient(); + + } + + public void testPreconditions(){ + assertNotNull(innerContainer); + assertNotNull(testView); + } + + public void testForCordovaView() { + String className = testView.getClass().getSimpleName(); + assertTrue(className.equals("CordovaWebView")); + } + + public void testGetResources() { + Resources ls = testActivity.getResources(); + Resources rs = appCode.getResources(); + assertTrue(ls.equals(rs)); + } + + public void testGetPackageName() { + String ls = testActivity.getPackageName(); + String rs = appCode.getPackageName(); + assertTrue(ls.equals(rs)); + } + + public void testGetAssets() { + AssetManager ls = testActivity.getAssets(); + AssetManager rs = testActivity.getAssets(); + assertTrue(ls.equals(rs)); + } + + public void testGetBaseContext() { + Context ls = testActivity.getBaseContext(); + Context rs = testActivity.getBaseContext(); + assertTrue(ls.equals(rs)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/JailActivity.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/JailActivity.java b/test/src/org/apache/cordova/test/JailActivity.java new file mode 100644 index 0000000..77a8527 --- /dev/null +++ b/test/src/org/apache/cordova/test/JailActivity.java @@ -0,0 +1,19 @@ +package org.apache.cordova.test; + +import org.apache.cordova.DroidGap; + +import android.app.Activity; +import android.os.Bundle; + +public class JailActivity extends DroidGap { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if(!super.areAssetsInJail()) + { + super.moveAssetsToJail(); + } + super.loadJailedFile("www/index.html"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/JailTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/JailTest.java b/test/src/org/apache/cordova/test/JailTest.java new file mode 100644 index 0000000..027c8f6 --- /dev/null +++ b/test/src/org/apache/cordova/test/JailTest.java @@ -0,0 +1,62 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; +import org.apache.cordova.api.PluginManager; + +import android.test.ActivityInstrumentationTestCase2; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +public class JailTest extends ActivityInstrumentationTestCase2 { + + private JailActivity testActivity; + private FrameLayout containerView; + private LinearLayout innerContainer; + private CordovaWebView testView; + private static final long TIMEOUT = 2000; + + public JailTest() + { + super("com.phonegap.test.activities",JailActivity.class); + } + + protected void setUp() throws Exception { + super.setUp(); + testActivity = this.getActivity(); + containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); + innerContainer = (LinearLayout) containerView.getChildAt(0); + testView = (CordovaWebView) innerContainer.getChildAt(0); + + } + + public void testPreconditions(){ + assertNotNull(innerContainer); + assertNotNull(testView); + } + + + public void testForCordovaView() { + String className = testView.getClass().getSimpleName(); + assertTrue(className.equals("CordovaWebView")); + } + + public void testForJailedItems() { + sleep(); + String url = testView.getUrl(); + assertTrue(url.contains("file:///data/data/")); + } + + public void testForJailCheck() { + sleep(); + assertTrue(testActivity.areAssetsInJail()); + } + + private void sleep() { + try { + Thread.sleep(TIMEOUT); + } catch (InterruptedException e) { + fail("Unexpected Timeout"); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/PhoneGapActivity.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/PhoneGapActivity.java b/test/src/org/apache/cordova/test/PhoneGapActivity.java new file mode 100644 index 0000000..d15bdb1 --- /dev/null +++ b/test/src/org/apache/cordova/test/PhoneGapActivity.java @@ -0,0 +1,15 @@ +package org.apache.cordova.test; + +import org.apache.cordova.DroidGap; + +import android.app.Activity; +import android.os.Bundle; + +public class PhoneGapActivity extends DroidGap { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + super.loadUrl("file:///android_asset/index.html"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/PhoneGapSplash.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/PhoneGapSplash.java b/test/src/org/apache/cordova/test/PhoneGapSplash.java new file mode 100644 index 0000000..59417e3 --- /dev/null +++ b/test/src/org/apache/cordova/test/PhoneGapSplash.java @@ -0,0 +1,26 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; + +import android.app.Activity; +import android.os.Bundle; + +public class PhoneGapSplash extends Activity { + CordovaWebView phoneGap; + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + phoneGap = (CordovaWebView) findViewById(R.id.phoneGapView); + phoneGap.init(); + phoneGap.loadUrl("file:///android_asset/index.html", 5000); + } + + public void onDestroy() + { + super.onDestroy(); + phoneGap.onDestroy(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java b/test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java new file mode 100644 index 0000000..10d4b36 --- /dev/null +++ b/test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java @@ -0,0 +1,29 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; + +import android.app.Activity; +import android.os.Bundle; + +public class PhoneGapViewTestActivity extends Activity { + + CordovaWebView phoneGap; + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + phoneGap = (CordovaWebView) findViewById(R.id.phoneGapView); + phoneGap.init(); + + phoneGap.loadUrl("file:///android_asset/index.html"); + + } + + public void onDestroy() + { + super.onDestroy(); + phoneGap.onDestroy(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/PluginManagerTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/PluginManagerTest.java b/test/src/org/apache/cordova/test/PluginManagerTest.java new file mode 100644 index 0000000..3c36f27 --- /dev/null +++ b/test/src/org/apache/cordova/test/PluginManagerTest.java @@ -0,0 +1,48 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebView; +import com.phonegap.api.PluginManager; + +import android.test.ActivityInstrumentationTestCase2; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +public class PluginManagerTest extends ActivityInstrumentationTestCase2 { + + private PhoneGapViewTestActivity testActivity; + private FrameLayout containerView; + private LinearLayout innerContainer; + private View testView; + private String rString; + private PluginManager pMan; + + public PluginManagerTest() { + super("com.phonegap.test.activities",PhoneGapViewTestActivity.class); + } + + protected void setUp() throws Exception{ + super.setUp(); + testActivity = this.getActivity(); + containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); + innerContainer = (LinearLayout) containerView.getChildAt(0); + testView = innerContainer.getChildAt(0); + + } + + public void testPreconditions(){ + assertNotNull(innerContainer); + assertNotNull(testView); + } + + + public void testForPluginManager() { + CordovaWebView v = (CordovaWebView) testView; + pMan = v.getPluginManager(); + assertNotNull(pMan); + String className = pMan.getClass().getSimpleName(); + assertTrue(className.equals("PluginManager")); + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/ae8bc77e/test/src/org/apache/cordova/test/WebDriverTest.java ---------------------------------------------------------------------- diff --git a/test/src/org/apache/cordova/test/WebDriverTest.java b/test/src/org/apache/cordova/test/WebDriverTest.java new file mode 100644 index 0000000..68cf285 --- /dev/null +++ b/test/src/org/apache/cordova/test/WebDriverTest.java @@ -0,0 +1,64 @@ +package org.apache.cordova.test; + +import org.apache.cordova.CordovaWebViewClient; +import org.apache.cordova.CordovaWebView; +import org.apache.cordova.CordovaChromeClient; + +import org.apache.cordova.test.CordovaViewFactory; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.android.library.AndroidWebDriver; + +import android.test.ActivityInstrumentationTestCase2; + +public class WebDriverTest extends ActivityInstrumentationTestCase2 { + + private static final long TIMEOUT = 5000; + private CordovaDriverAction testActivity; + private CordovaWebView testView; + private CordovaViewFactory viewFactory; + private CordovaChromeClient appCode; + private CordovaWebViewClient viewHandler; + private AndroidWebDriver testDriver; + + public WebDriverTest() { + super("com.phonegap.test.activities",CordovaDriverAction.class); + } + + protected void setUp() throws Exception{ + super.setUp(); + testActivity = this.getActivity(); + viewFactory = new CordovaViewFactory(); + appCode = new CordovaChromeClient(testActivity); + viewHandler = new CordovaWebViewClient(testActivity); + testDriver = new AndroidWebDriver(testActivity, viewFactory, viewHandler, appCode); + testView = (CordovaWebView) testDriver.getWebView(); + viewHandler.setCordovaView(testView); + appCode.testInit(testView); + } + + public void testPreconditions(){ + assertNotNull(testView); + } + + public void testWebLoad() { + testDriver.get("file:///android_asset/www/index.html"); + sleep(); + String url = testView.getUrl(); + //Check the sanity! + boolean result = url.equals("file:///android_asset/www/index.html"); + assertTrue(result); + WebElement platformSpan = testDriver.findElement(By.id("platform")); + String text = platformSpan.getText(); + assertTrue(text.equals("Android")); + } + + + private void sleep() { + try { + Thread.sleep(TIMEOUT); + } catch (InterruptedException e) { + fail("Unexpected Timeout"); + } + } +}