forked from github/cordova-android
CB-582: Automating User WebView/WebViewClient/WebChromeClient tests
This commit is contained in:
parent
09b753d09e
commit
cdaf620f92
@ -1,6 +1,12 @@
|
||||
package org.apache.cordova.test;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.CordovaWebViewClient;
|
||||
import org.apache.cordova.CordovaChromeClient;
|
||||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
public class UserWebViewTest extends ActivityInstrumentationTestCase2<userwebview> {
|
||||
|
||||
@ -8,4 +14,42 @@ public class UserWebViewTest extends ActivityInstrumentationTestCase2<userwebvie
|
||||
{
|
||||
super(userwebview.class);
|
||||
}
|
||||
|
||||
private int TIMEOUT = 1000;
|
||||
userwebview testActivity;
|
||||
private FrameLayout containerView;
|
||||
private LinearLayout innerContainer;
|
||||
private CordovaWebView testView;
|
||||
|
||||
|
||||
|
||||
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 customTest()
|
||||
{
|
||||
assertTrue(CordovaWebView.class.isInstance(testView));
|
||||
assertTrue(CordovaWebViewClient.class.isInstance(testActivity.testViewClient));
|
||||
assertTrue(CordovaChromeClient.class.isInstance(testActivity.testChromeClient));
|
||||
}
|
||||
|
||||
|
||||
private void sleep() {
|
||||
try {
|
||||
Thread.sleep(TIMEOUT);
|
||||
} catch (InterruptedException e) {
|
||||
fail("Unexpected Timeout");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,9 +26,15 @@ import org.apache.cordova.*;
|
||||
import org.apache.cordova.api.LOG;
|
||||
|
||||
public class userwebview extends DroidGap {
|
||||
|
||||
public TestViewClient testViewClient;
|
||||
public TestChromeClient testChromeClient;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
testViewClient = new TestViewClient(this);
|
||||
testChromeClient = new TestChromeClient(this);
|
||||
super.init(new CordovaWebView(this), new TestViewClient(this), new TestChromeClient(this));
|
||||
super.loadUrl("file:///android_asset/www/userwebview/index.html");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user