You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/03/23 23:01:17 UTC

[16/17] Adding the tests from the GitHub Prototype

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('<script type="text/javascript" charset="utf-8" src="../cordova-1.4.1.js"></script>');
+document.write('<script type="text/javascript" charset="utf-8" src="cordova-1.4.1.js"></script>');
+
+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 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+    <title>PhoneGap</title>
+    <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+    <script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>      
+
+      
+<script type="text/javascript" charset="utf-8">
+
+    var deviceReady = false;
+
+    //-------------------------------------------------------------------------
+    // HTML5 Database
+    //-------------------------------------------------------------------------
+    var db;
+    var callDatabase = function() {
+        db = openDatabase("mydb", "1.0", "PhoneGap Demo", 20000);
+        if (db === null) {
+            databaseOutput("Database could not be opened.");
+            return;
+        }
+        databaseOutput("Database opened.");
+        db.transaction(function (tx) {
+            tx.executeSql('DROP TABLE IF EXISTS DEMO');
+            tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)', [],
+                 function(tx,results) { console.log("Created table"); },
+                 function(tx,err) { alert("Error creating table: "+err.message); });
+            tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")', [],
+                 function(tx,results) { console.log("Insert row1 success"); },
+                 function(tx,err) { alert("Error adding 1st row: "+err.message); });
+            tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")', [],
+                 function(tx,results) { console.log("Insert row2 success"); },
+                 function(tx,err) { alert("Error adding 2nd row: "+err.message); });
+            databaseOutput("Data written to DEMO table.");
+            console.log("Data written to DEMO table.");
+
+            tx.executeSql('SELECT * FROM DEMO', [], function (tx, results) {
+                var len = results.rows.length;
+                var text = "DEMO table: " + len + " rows found.<br>";
+                text = text + "<table border='1'><tr><td>Row</td><td>Data</td></tr>";
+                for (var i=0; i<len; i++){
+                    text = text + "<tr><td>" + i + "</td><td>" + results.rows.item(i).id + ", " + results.rows.item(i).data + "</td></tr>";
+                }
+                text = text + "</table>";
+                databaseOutput(text);
+            }, function(tx, err) {
+                alert("Error processing SELECT * SQL: "+err.message);
+            });
+            tx.executeSql('SELECT ID FROM DEMO', [], function (tx, results) {
+                var len = results.rows.length;
+                var text = "DEMO table: " + len + " rows found.<br>";
+                text = text + "<table border='1'><tr><td>Row</td><td>Data</td></tr>";
+                for (var i=0; i<len; i++){
+                    text = text + "<tr><td>" + i + "</td><td>" + results.rows.item(i).id + "</td></tr>";
+                }
+                text = text + "</table>";
+                databaseOutput(text);
+            }, function(tx, err) {
+                alert("Error processing SELECT ID SQL: "+err.message);
+            });
+            
+        },
+        function(err) {
+            console.log("Transaction failed: " + err.message);
+        });
+
+
+    };
+
+    var readDatabase = function() {
+    	if (!db) {
+    	    db = openDatabase("mydb", "1.0", "PhoneGap Demo", 20000);
+    	    if (db === null) {
+                databaseOutput("Database could not be opened.");
+                return;
+    	    }
+        }
+        db.transaction(function (tx) {
+            tx.executeSql('SELECT * FROM DEMO WHERE id=2', [], function (tx, results) {
+                var len = results.rows.length;
+                var text = "DEMO table: " + len + " rows found.<br>";
+                text = text + "<table border='1'><tr><td>Row</td><td>Data</td></tr>";
+                for (var i=0; i<len; i++){
+                    text = text + "<tr><td>" + i + "</td><td>" + results.rows.item(i).id + ", " + results.rows.item(i).data + "</td></tr>";
+                }
+                text = text + "</table>";
+                databaseOutput(text);
+            }, function(tx, err) {
+                alert("Error processing SELECT * WHERE id=2 SQL: "+err.message);
+            });
+        });
+    }
+
+    var databaseOutput = function(s) {
+        var el = document.getElementById("database_results");
+        el.innerHTML = el.innerHTML + s + "<br>";
+    };
+    
+    /**
+     * Function called when page has finished loading.
+     */
+    function init() {
+        document.addEventListener("deviceready", function() {
+                deviceReady = true;
+                console.log("Device="+device.platform+" "+device.version);
+            }, false);
+        window.setTimeout(function() {
+        	if (!deviceReady) {
+        		alert("Error: PhoneGap did not initialize.  Demo will not run correctly.");
+        	}
+        },1000);
+    }
+
+</script>
+
+  </head>
+  <body onload="init();" id="stage" class="theme">
+  
+    <h1>HTML5 Database</h1>   
+    <div id="info">
+        <b>Results:</b><br>
+        <span id="database_results"></span>
+    </div>
+    <h2>Action</h2>
+    <a href="javascript:" class="btn large" onclick="callDatabase();">Create, Add, Read Database</a>
+    <a href="javascript:" class="btn large" onclick="readDatabase();">Read Database</a>
+    <h2>&nbsp</h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>    
+  </body>
+</html>      

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 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+    <title>PhoneGap</title>
+    <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+    <script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>      
+
+      
+<script type="text/javascript" charset="utf-8">
+
+    var deviceReady = false;
+    
+    /**
+     * Function called when page has finished loading.
+     */
+    function init() {
+        document.addEventListener("deviceready", function() {
+                deviceReady = true;
+                console.log("Device="+device.platform+" "+device.version);
+            }, false);
+        window.setTimeout(function() {
+        	if (!deviceReady) {
+        		alert("Error: PhoneGap did not initialize.  Demo will not run correctly.");
+        	}
+        },1000);
+    }
+
+</script>
+
+  </head>
+  <body onload="init();" id="stage" class="theme">
+  
+    <h1>Local Storage</h1>
+    <div id="info">
+        You have run this app <span id="count">an untold number of</span> time(s).
+    </div>
+
+    <script>
+    if (!localStorage.pageLoadCount) {
+        localStorage.pageLoadCount = 0;
+    }
+    localStorage.pageLoadCount = parseInt(localStorage.pageLoadCount) + 1;
+    document.getElementById('count').textContent = localStorage.pageLoadCount;
+    </script>
+
+    <h2>&nbsp</h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+  </body>
+</html>      

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 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+    <title>PhoneGap</title>
+    <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
+  <script type="text/javascript" charset="utf-8" src="main.js"></script>
+
+  </head>
+  <body onload="init();" id="stage" class="theme">
+    <h1>PhoneGap Tests</h1>
+    <div id="info">
+        <h4>Platform: <span id="platform"> &nbsp;</span></h4>
+        <h4>Version: <span id="version">&nbsp;</span></h4>
+        <h4>UUID: <span id="uuid"> &nbsp;</span></h4>
+        <h4>Name: <span id="name">&nbsp;</span></h4>
+        <h4>Width: <span id="width"> &nbsp;</span>,   Height: <span id="height">&nbsp;
+                   </span>, Color Depth: <span id="colorDepth"></span></h4>
+     </div>
+    <a href="autotest/index.html" class="btn large">Automatic Test</a>
+    <a href="accelerometer/index.html" class="btn large">Accelerometer</a>
+    <a href="audio/index.html" class="btn large">Audio Play/Record</a>
+    <a href="camera/index.html" class="btn large">Camera</a>
+    <a href="compass/index.html" class="btn large">Compass</a>
+    <a href="contacts/index.html" class="btn large">Contacts</a>
+    <a href="events/index.html" class="btn large">Events</a>
+    <a href="location/index.html" class="btn large">Location</a>
+    <a href="misc/index.html" class="btn large">Misc Content</a>
+    <a href="notification/index.html" class="btn large">Notification</a>
+    <a href="sql/index.html" class="btn large">Web SQL</a>
+    <a href="storage/index.html" class="btn large">Local Storage</a>
+  </body>
+</html>

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 <methods>;
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+    public <init>(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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+    
+    <com.phonegap.CordovaWebView
+        android:id="@+id/phoneGapView"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent" />
+
+
+</LinearLayout>
\ 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="hello">Hello World!</string>
+    <string name="app_name">CordovaTestTest</string>
+
+</resources>
\ 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<phonegap>
+    <access origin="http://127.0.0.1*"/>
+    <log level="DEBUG"/>
+</phonegap>

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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<plugins>
+    <plugin name="App" value="com.phonegap.App"/>
+    <plugin name="Geolocation" value="com.phonegap.GeoBroker"/>
+    <plugin name="Device" value="com.phonegap.Device"/>
+    <plugin name="Accelerometer" value="com.phonegap.AccelListener"/>
+    <plugin name="Compass" value="com.phonegap.CompassListener"/>
+    <plugin name="Media" value="com.phonegap.AudioHandler"/>
+    <plugin name="Camera" value="com.phonegap.CameraLauncher"/>
+    <plugin name="Contacts" value="com.phonegap.ContactManager"/>
+    <plugin name="File" value="com.phonegap.FileUtils"/>
+    <plugin name="Network Status" value="com.phonegap.NetworkManager"/>
+    <plugin name="Notification" value="com.phonegap.Notification"/>
+    <plugin name="Storage" value="com.phonegap.Storage"/>
+    <plugin name="Temperature" value="com.phonegap.TempListener"/>
+    <plugin name="FileTransfer" value="com.phonegap.FileTransfer"/>
+    <plugin name="Capture" value="com.phonegap.Capture"/>
+    <plugin name="Battery" value="com.phonegap.BatteryListener"/>
+    <plugin name="Keyboard" value="com.phonegap.KeyboardHandler" />
+</plugins>

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<PhoneGapActivity> {
+
+    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<PhoneGapSplash> {
+
+    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<PhoneGapViewTestActivity> {
+
+  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<PhoneGapViewTestActivity> {
+	
+	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<JailActivity> {
+
+    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<PhoneGapViewTestActivity> {
+	
+	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<CordovaDriverAction> {
+	
+    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");
+        }
+	}
+}