Updated Branches:
  refs/heads/CordovaWebView 79048a5a8 -> afa1ecf3c

Removing tests that don't work and modifying CordovaWebView so it works as a 
stand-alone component again.  Mobile-spec currently doesn't work


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/afa1ecf3
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/afa1ecf3
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/afa1ecf3

Branch: refs/heads/CordovaWebView
Commit: afa1ecf3c5c082eb0732fd94f89192989d63a0e1
Parents: 295b9f4
Author: Joe Bowser <bows...@apache.org>
Authored: Tue May 15 13:24:43 2012 -0700
Committer: Joe Bowser <bows...@apache.org>
Committed: Tue May 15 13:24:43 2012 -0700

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebView.java     |   67 +++++++++---
 .../apache/cordova/test/CordovaDriverAction.java   |   32 ------
 .../apache/cordova/test/CordovaViewFactory.java    |   36 ------
 .../src/org/apache/cordova/test/WebDriverTest.java |   84 ---------------
 4 files changed, 52 insertions(+), 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/afa1ecf3/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java 
b/framework/src/org/apache/cordova/CordovaWebView.java
index a6f152e..720b4cc 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -38,6 +38,7 @@ import android.content.res.XmlResourceParser;
 import android.net.Uri;
 import android.os.Bundle;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebSettings.LayoutAlgorithm;
@@ -73,24 +74,40 @@ public class CordovaWebView extends WebView {
      * 
      * @param context
      */
-    public CordovaWebView(CordovaInterface context) {
-        super(context.getActivity());
-        this.mCtx = context;
+    public CordovaWebView(Context context) {
+        super(context);
+        if(CordovaInterface.class.isInstance(context))
+        {
+          this.mCtx = (CordovaInterface) context;
+        }
+        else
+        {
+          Log.d(TAG, "Your activity must implement CordovaInterface to work");
+        }
         this.loadConfiguration();
         this.setup();
     }
 
+    
     /**
      * Constructor.
      * 
      * @param context
      * @param attrs
      */
-    public CordovaWebView(CordovaInterface context, AttributeSet attrs) {
-        super(context.getActivity(), attrs);
-        this.mCtx = context;
-        this.loadConfiguration();
-        this.setup();
+    public CordovaWebView(Context context, AttributeSet attrs) {
+      super(context, attrs);
+      if(CordovaInterface.class.isInstance(context))
+      {
+        this.mCtx = (CordovaInterface) context;
+      }          
+      else
+      {
+        Log.d(TAG, "Your activity must implement CordovaInterface to work");
+      }
+
+      this.loadConfiguration();
+      this.setup();
     }
 
     /**
@@ -99,10 +116,18 @@ public class CordovaWebView extends WebView {
      * @param context
      * @param attrs
      * @param defStyle
+     * @throws CordovaException 
      */
-    public CordovaWebView(CordovaInterface context, AttributeSet attrs, int 
defStyle) {
-        super(context.getActivity(), attrs, defStyle);
-        this.mCtx = context;
+    public CordovaWebView(Context context, AttributeSet attrs, int defStyle)  {
+        super(context, attrs, defStyle);
+        if(CordovaInterface.class.isInstance(context))
+        {
+          this.mCtx = (CordovaInterface) context;
+        }
+        else
+        {
+          Log.d(TAG, "Your activity must implement CordovaInterface to work");
+        }
         this.loadConfiguration();
         this.setup();
     }
@@ -115,9 +140,16 @@ public class CordovaWebView extends WebView {
      * @param defStyle
      * @param privateBrowsing
      */
-    public CordovaWebView(CordovaInterface context, AttributeSet attrs, int 
defStyle, boolean privateBrowsing) {
-        super(context.getActivity(), attrs, defStyle, privateBrowsing);
-        this.mCtx = context;
+    public CordovaWebView(Context context, AttributeSet attrs, int defStyle, 
boolean privateBrowsing) {
+        super(context, attrs, defStyle, privateBrowsing);
+        if(CordovaInterface.class.isInstance(context))
+        {
+          this.mCtx = (CordovaInterface) context;
+        }
+        else
+        {
+          Log.d(TAG, "Your activity must implement CordovaInterface to work");
+        }
         this.loadConfiguration();
         this.setup();
     }
@@ -153,7 +185,12 @@ public class CordovaWebView extends WebView {
         settings.setGeolocationEnabled(true);
 
         //Start up the plugin manager
-        this.pluginManager = new PluginManager(this, this.mCtx);
+        try {
+          this.pluginManager = new PluginManager(this, mCtx);
+        } catch (Exception e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/afa1ecf3/test/src/org/apache/cordova/test/CordovaDriverAction.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaDriverAction.java 
b/test/src/org/apache/cordova/test/CordovaDriverAction.java
deleted file mode 100644
index 49926ed..0000000
--- a/test/src/org/apache/cordova/test/CordovaDriverAction.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-
-package org.apache.cordova.test;
-
-import android.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/afa1ecf3/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
deleted file mode 100644
index f591773..0000000
--- a/test/src/org/apache/cordova/test/CordovaViewFactory.java
+++ /dev/null
@@ -1,36 +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.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/afa1ecf3/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
deleted file mode 100644
index 975e7ce..0000000
--- a/test/src/org/apache/cordova/test/WebDriverTest.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 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.setWebView(testView);
-               appCode.setWebView(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");
-        }
-       }
-}

Reply via email to