From aede2235d0d4bacd332fc44dd8aae9a3068ae382 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 14 May 2012 16:07:00 -0700 Subject: [PATCH] Updating Activities --- test/AndroidManifest.xml | 14 +---- .../apache/cordova/test/BackButtonTest.java | 49 --------------- ...eGapActivity.java => CordovaActivity.java} | 2 +- .../cordova/test/CordovaActivityTest.java | 6 +- .../cordova/test/CordovaSplashTest.java | 61 ------------------- .../org/apache/cordova/test/CordovaTest.java | 6 +- ...y.java => CordovaWebViewTestActivity.java} | 2 +- .../org/apache/cordova/test/ErrorUrlTest.java | 8 ++- .../apache/cordova/test/GapClientTest.java | 6 +- .../apache/cordova/test/HtmlNotFoundTest.java | 30 +++++++++ .../apache/cordova/test/PhoneGapSplash.java | 44 ------------- .../cordova/test/PluginManagerTest.java | 6 +- 12 files changed, 53 insertions(+), 181 deletions(-) delete mode 100644 test/src/org/apache/cordova/test/BackButtonTest.java rename test/src/org/apache/cordova/test/{PhoneGapActivity.java => CordovaActivity.java} (96%) delete mode 100644 test/src/org/apache/cordova/test/CordovaSplashTest.java rename test/src/org/apache/cordova/test/{PhoneGapViewTestActivity.java => CordovaWebViewTestActivity.java} (96%) delete mode 100644 test/src/org/apache/cordova/test/PhoneGapSplash.java diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml index 5772c3ed..b8038c7d 100644 --- a/test/AndroidManifest.xml +++ b/test/AndroidManifest.xml @@ -59,7 +59,7 @@ android:windowSoftInputMode="adjustPan" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden" - android:name=".PhoneGapViewTestActivity" > + android:name=".CordovaWebViewTestActivity" > @@ -96,17 +96,7 @@ android:windowSoftInputMode="adjustPan" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden" - android:name="org.apache.cordova.test.PhoneGapSplash" > - - - - - - + android:name=".CordovaActivity" > diff --git a/test/src/org/apache/cordova/test/BackButtonTest.java b/test/src/org/apache/cordova/test/BackButtonTest.java deleted file mode 100644 index db09792f..00000000 --- a/test/src/org/apache/cordova/test/BackButtonTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.cordova.test; - -import org.apache.cordova.CordovaWebView; - -import android.test.ActivityInstrumentationTestCase2; -import android.test.TouchUtils; -import android.widget.FrameLayout; -import android.widget.LinearLayout; - -public class BackButtonTest extends ActivityInstrumentationTestCase2 { - - private backbuttonmultipage testActivity; - private FrameLayout containerView; - private LinearLayout innerContainer; - private CordovaWebView testView; - private TouchUtils touchTest; - private long TIMEOUT = 5000; - - public BackButtonTest() { - super("org.apache.cordova.test",backbuttonmultipage.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); - touchTest = new TouchUtils(); - } - - public void testPreconditions(){ - assertNotNull(innerContainer); - assertNotNull(testView); - } - - public void testClick() { - touchTest.tapView(this, testView); - } - - private void sleep() { - try { - Thread.sleep(TIMEOUT ); - } catch (InterruptedException e) { - fail("Unexpected Timeout"); - } - } - -} diff --git a/test/src/org/apache/cordova/test/PhoneGapActivity.java b/test/src/org/apache/cordova/test/CordovaActivity.java similarity index 96% rename from test/src/org/apache/cordova/test/PhoneGapActivity.java rename to test/src/org/apache/cordova/test/CordovaActivity.java index dc9e50fd..0bb3dbac 100644 --- a/test/src/org/apache/cordova/test/PhoneGapActivity.java +++ b/test/src/org/apache/cordova/test/CordovaActivity.java @@ -23,7 +23,7 @@ import org.apache.cordova.DroidGap; import android.app.Activity; import android.os.Bundle; -public class PhoneGapActivity extends DroidGap { +public class CordovaActivity extends DroidGap { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { diff --git a/test/src/org/apache/cordova/test/CordovaActivityTest.java b/test/src/org/apache/cordova/test/CordovaActivityTest.java index 3a5b47db..b53f000a 100644 --- a/test/src/org/apache/cordova/test/CordovaActivityTest.java +++ b/test/src/org/apache/cordova/test/CordovaActivityTest.java @@ -26,9 +26,9 @@ import android.test.ActivityInstrumentationTestCase2; import android.widget.FrameLayout; import android.widget.LinearLayout; -public class CordovaActivityTest extends ActivityInstrumentationTestCase2 { +public class CordovaActivityTest extends ActivityInstrumentationTestCase2 { - private PhoneGapActivity testActivity; + private CordovaActivity testActivity; private FrameLayout containerView; private LinearLayout innerContainer; private CordovaWebView testView; @@ -36,7 +36,7 @@ public class CordovaActivityTest 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")); - } - -} diff --git a/test/src/org/apache/cordova/test/CordovaTest.java b/test/src/org/apache/cordova/test/CordovaTest.java index ef870075..b7edd099 100644 --- a/test/src/org/apache/cordova/test/CordovaTest.java +++ b/test/src/org/apache/cordova/test/CordovaTest.java @@ -25,15 +25,15 @@ import android.test.ActivityInstrumentationTestCase2; import android.view.View; public class CordovaTest extends - ActivityInstrumentationTestCase2 { + ActivityInstrumentationTestCase2 { private static final long TIMEOUT = 1000; - private PhoneGapViewTestActivity testActivity; + private CordovaWebViewTestActivity testActivity; private View testView; private String rString; public CordovaTest() { - super("com.phonegap.test.activities", PhoneGapViewTestActivity.class); + super("com.phonegap.test.activities", CordovaWebViewTestActivity.class); } protected void setUp() throws Exception { diff --git a/test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java similarity index 96% rename from test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java rename to test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java index e35f359b..6c5f5c92 100644 --- a/test/src/org/apache/cordova/test/PhoneGapViewTestActivity.java +++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java @@ -24,7 +24,7 @@ import org.apache.cordova.CordovaWebView; import android.app.Activity; import android.os.Bundle; -public class PhoneGapViewTestActivity extends Activity { +public class CordovaWebViewTestActivity extends Activity { CordovaWebView phoneGap; /** Called when the activity is first created. */ diff --git a/test/src/org/apache/cordova/test/ErrorUrlTest.java b/test/src/org/apache/cordova/test/ErrorUrlTest.java index 74a35c7d..f60b272d 100644 --- a/test/src/org/apache/cordova/test/ErrorUrlTest.java +++ b/test/src/org/apache/cordova/test/ErrorUrlTest.java @@ -24,7 +24,6 @@ public class ErrorUrlTest extends ActivityInstrumentationTestCase2 { containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); innerContainer = (LinearLayout) containerView.getChildAt(0); testView = (CordovaWebView) innerContainer.getChildAt(0); - } public void testPreconditions(){ @@ -32,4 +31,11 @@ public class ErrorUrlTest extends ActivityInstrumentationTestCase2 { assertNotNull(testView); } + public void testUrl() + { + String good_url = "file:///android_asset/www/htmlnotfound/error.html"; + String url = testView.getUrl(); + assertTrue(url.equals(good_url)); + } + } diff --git a/test/src/org/apache/cordova/test/GapClientTest.java b/test/src/org/apache/cordova/test/GapClientTest.java index 41fe970e..bfee8638 100644 --- a/test/src/org/apache/cordova/test/GapClientTest.java +++ b/test/src/org/apache/cordova/test/GapClientTest.java @@ -31,9 +31,9 @@ import android.view.View; import android.widget.FrameLayout; import android.widget.LinearLayout; -public class GapClientTest extends ActivityInstrumentationTestCase2 { +public class GapClientTest extends ActivityInstrumentationTestCase2 { - private PhoneGapViewTestActivity testActivity; + private CordovaWebViewTestActivity testActivity; private FrameLayout containerView; private LinearLayout innerContainer; private View testView; @@ -41,7 +41,7 @@ public class GapClientTest extends ActivityInstrumentationTestCase2 { + private htmlnotfound testActivity; + private FrameLayout containerView; + private LinearLayout innerContainer; + private CordovaWebView testView; + public HtmlNotFoundTest() { super("org.apache.cordova.test",htmlnotfound.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 testUrl() +{ + String good_url = "file:///android_asset/www/htmlnotfound/error.html"; + String url = testView.getUrl(); + assertFalse(url.equals(good_url)); +} } diff --git a/test/src/org/apache/cordova/test/PhoneGapSplash.java b/test/src/org/apache/cordova/test/PhoneGapSplash.java deleted file mode 100644 index e93a8837..00000000 --- a/test/src/org/apache/cordova/test/PhoneGapSplash.java +++ /dev/null @@ -1,44 +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.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.loadUrl("file:///android_asset/index.html", 5000); - } - - public void onDestroy() - { - super.onDestroy(); - //phoneGap.onDestroy(); - } -} diff --git a/test/src/org/apache/cordova/test/PluginManagerTest.java b/test/src/org/apache/cordova/test/PluginManagerTest.java index 15234e63..f18f14f8 100644 --- a/test/src/org/apache/cordova/test/PluginManagerTest.java +++ b/test/src/org/apache/cordova/test/PluginManagerTest.java @@ -27,9 +27,9 @@ import android.view.View; import android.widget.FrameLayout; import android.widget.LinearLayout; -public class PluginManagerTest extends ActivityInstrumentationTestCase2 { +public class PluginManagerTest extends ActivityInstrumentationTestCase2 { - private PhoneGapViewTestActivity testActivity; + private CordovaWebViewTestActivity testActivity; private FrameLayout containerView; private LinearLayout innerContainer; private View testView; @@ -37,7 +37,7 @@ public class PluginManagerTest extends ActivityInstrumentationTestCase2