diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index a5496cfd..e1e42948 100644 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -115,4 +115,9 @@ public interface CordovaWebView { PluginManager getPluginManager(); void setLayoutParams(android.widget.FrameLayout.LayoutParams layoutParams); + + // Required for test + + String getUrl(); + boolean isPaused(); } diff --git a/test/res/layout/main.xml b/test/res/layout/main.xml index 9b002ab3..e7b31a42 100644 --- a/test/res/layout/main.xml +++ b/test/res/layout/main.xml @@ -22,7 +22,7 @@ android:layout_height="fill_parent" android:orientation="vertical" > - diff --git a/test/src/org/apache/cordova/test/basicauth.java b/test/src/org/apache/cordova/test/basicauth.java deleted file mode 100755 index 1b09f3d5..00000000 --- a/test/src/org/apache/cordova/test/basicauth.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 android.os.Bundle; -import org.apache.cordova.*; - -public class basicauth extends DroidGap { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - super.init(); - - // LogCat: onReceivedHttpAuthRequest(browserspy.dk:80,BrowserSpy.dk - HTTP Password Test) - AuthenticationToken token = new AuthenticationToken(); - token.setUserName("test"); - token.setPassword("test"); - super.setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password Test"); - - // Add web site to whitelist - Config.init(); - Config.addWhiteListEntry("http://browserspy.dk*", true); - - // Load test - super.loadUrl("file:///android_asset/www/basicauth/index.html"); - } - -} diff --git a/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java b/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java index 923b3763..9fc27de0 100644 --- a/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java +++ b/test/src/org/apache/cordova/test/junit/BackButtonMultiPageTest.java @@ -27,6 +27,7 @@ import org.apache.cordova.test.backbuttonmultipage; import android.test.ActivityInstrumentationTestCase2; import android.test.UiThreadTest; import android.view.KeyEvent; +import android.view.View; import android.view.inputmethod.BaseInputConnection; import android.widget.FrameLayout; import android.widget.LinearLayout; @@ -174,7 +175,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2 { - - public MenuTest() { - super("org.apache.cordova.test", menus.class); - } - -} diff --git a/test/src/org/apache/cordova/test/junit/MessageTest.java b/test/src/org/apache/cordova/test/junit/MessageTest.java deleted file mode 100644 index 4d0ce16b..00000000 --- a/test/src/org/apache/cordova/test/junit/MessageTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package org.apache.cordova.test.junit; - -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.CordovaWebView; -import org.apache.cordova.ScrollEvent; -import org.apache.cordova.pluginApi.pluginStub; -import org.apache.cordova.test.CordovaWebViewTestActivity; -import org.apache.cordova.test.R; - -import com.jayway.android.robotium.solo.By; -import com.jayway.android.robotium.solo.Solo; - -import android.test.ActivityInstrumentationTestCase2; -import android.view.View; - -public class MessageTest extends -ActivityInstrumentationTestCase2 { - private CordovaWebViewTestActivity testActivity; - private CordovaWebView testView; - private pluginStub testPlugin; - private int TIMEOUT = 1000; - - private Solo solo; - - public MessageTest() { - super("org.apache.cordova.test.activities", CordovaWebViewTestActivity.class); - } - - protected void setUp() throws Exception { - super.setUp(); - testActivity = this.getActivity(); - testView = (CordovaWebView) testActivity.findViewById(R.id.cordovaWebView); - testPlugin = (pluginStub) testView.pluginManager.getPlugin("PluginStub"); - solo = new Solo(getInstrumentation(), getActivity()); - } - - public void testOnScrollChanged() - { - solo.waitForWebElement(By.textContent("Cordova Android Tests")); - solo.scrollDown(); - sleep(); - Object data = testPlugin.data; - assertTrue(data.getClass().getSimpleName().equals("ScrollEvent")); - } - - - - private void sleep() { - try { - Thread.sleep(TIMEOUT); - } catch (InterruptedException e) { - fail("Unexpected Timeout"); - } - } -} diff --git a/test/src/org/apache/cordova/test/menus.java b/test/src/org/apache/cordova/test/menus.java deleted file mode 100755 index 12d5230f..00000000 --- a/test/src/org/apache/cordova/test/menus.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package org.apache.cordova.test; - -import android.os.Bundle; -import android.view.ContextMenu; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ContextMenu.ContextMenuInfo; - -import org.apache.cordova.*; -import org.apache.cordova.LOG; - -public class menus extends DroidGap { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - super.init(); - super.registerForContextMenu(super.appView); - super.loadUrl("file:///android_asset/www/menus/index.html"); - } - - // Demonstrate how to add your own menus to app - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - int base = Menu.FIRST; - // Group, item id, order, title - menu.add(base, base, base, "Item1"); - menu.add(base, base + 1, base + 1, "Item2"); - menu.add(base, base + 2, base + 2, "Item3"); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - LOG.d("menus", "Item " + item.getItemId() + " pressed."); - this.appView.loadUrl("javascript:alert('Menu " + item.getItemId() + " pressed.')"); - return super.onOptionsItemSelected(item); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - LOG.d("menus", "onPrepareOptionsMenu()"); - // this.appView.loadUrl("javascript:alert('onPrepareOptionsMenu()')"); - return true; - } - - @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) { - LOG.d("menus", "onCreateContextMenu()"); - menu.setHeaderTitle("Test Context Menu"); - menu.add(200, 200, 200, "Context Item1"); - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - this.appView.loadUrl("javascript:alert('Context Menu " + item.getItemId() + " pressed.')"); - return true; - } - -} diff --git a/test/src/org/apache/cordova/test/userwebview.java b/test/src/org/apache/cordova/test/userwebview.java index 6146a40a..d9879112 100755 --- a/test/src/org/apache/cordova/test/userwebview.java +++ b/test/src/org/apache/cordova/test/userwebview.java @@ -25,7 +25,7 @@ import android.webkit.GeolocationPermissions.Callback; import org.apache.cordova.*; import org.apache.cordova.LOG; -public class userwebview extends DroidGap { +public class userwebview extends CordovaActivity { public TestViewClient testViewClient; public TestChromeClient testChromeClient; @@ -35,12 +35,12 @@ public class userwebview extends DroidGap { super.onCreate(savedInstanceState); testViewClient = new TestViewClient(this); testChromeClient = new TestChromeClient(this); - super.init(new CordovaWebView(this), new TestViewClient(this), new TestChromeClient(this)); + super.init(new AndroidWebView(this), new TestViewClient(this), new TestChromeClient(this)); super.loadUrl("file:///android_asset/www/userwebview/index.html"); } - public class TestChromeClient extends CordovaChromeClient { - public TestChromeClient(DroidGap arg0) { + public class TestChromeClient extends AndroidChromeClient { + public TestChromeClient(CordovaActivity arg0) { super(arg0); LOG.d("userwebview", "TestChromeClient()"); } @@ -56,8 +56,8 @@ public class userwebview extends DroidGap { /** * This class can be used to override the GapViewClient and receive notification of webview events. */ - public class TestViewClient extends CordovaWebViewClient { - public TestViewClient(DroidGap arg0) { + public class TestViewClient extends AndroidWebViewClient { + public TestViewClient(CordovaActivity arg0) { super(arg0); LOG.d("userwebview", "TestViewClient()"); } diff --git a/test/src/org/apache/cordova/test/whitelist.java b/test/src/org/apache/cordova/test/whitelist.java index 26eebf32..879c2f85 100755 --- a/test/src/org/apache/cordova/test/whitelist.java +++ b/test/src/org/apache/cordova/test/whitelist.java @@ -24,20 +24,20 @@ import android.webkit.WebView; import org.apache.cordova.*; import org.apache.cordova.LOG; -public class whitelist extends DroidGap { +public class whitelist extends CordovaActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - super.init(new CordovaWebView(this), new TestViewClient(this), new CordovaChromeClient(this)); + super.init(new AndroidWebView(this), new TestViewClient(this), new AndroidChromeClient(this)); super.loadUrl("file:///android_asset/www/whitelist/index.html"); } /** * This class can be used to override the GapViewClient and receive notification of webview events. */ - public class TestViewClient extends CordovaWebViewClient { + public class TestViewClient extends AndroidWebViewClient { - public TestViewClient(DroidGap arg0) { + public TestViewClient(CordovaActivity arg0) { super(arg0); }