mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Updates to tests, including the use of Purity
This commit is contained in:
parent
23f57ad5a7
commit
1adf268e71
File diff suppressed because it is too large
Load Diff
@ -21,14 +21,72 @@ package org.apache.cordova.test;
|
||||
*/
|
||||
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.test.util.Purity;
|
||||
import org.apache.cordova.test.actions.iframe;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Instrumentation;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.test.TouchUtils;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
public class IFrameTest extends ActivityInstrumentationTestCase2<iframe> {
|
||||
public class IFrameTest extends ActivityInstrumentationTestCase2 {
|
||||
|
||||
|
||||
private Instrumentation mInstr;
|
||||
private Activity testActivity;
|
||||
private FrameLayout containerView;
|
||||
private LinearLayout innerContainer;
|
||||
private CordovaWebView testView;
|
||||
private TouchUtils touch;
|
||||
private Purity touchTool;
|
||||
|
||||
public IFrameTest() {
|
||||
super("org.apache.cordova.test",iframe.class);
|
||||
}
|
||||
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mInstr = this.getInstrumentation();
|
||||
testActivity = this.getActivity();
|
||||
containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
|
||||
innerContainer = (LinearLayout) containerView.getChildAt(0);
|
||||
testView = (CordovaWebView) innerContainer.getChildAt(0);
|
||||
touch = new TouchUtils();
|
||||
touchTool = new Purity(testActivity, getInstrumentation());
|
||||
}
|
||||
|
||||
|
||||
public void testIframeDest()
|
||||
{
|
||||
testView.sendJavascript("loadUrl('http://maps.google.com/maps?output=embed');");
|
||||
sleep(3000);
|
||||
testView.sendJavascript("loadUrl('index2.html')");
|
||||
sleep(1000);
|
||||
String url = testView.getUrl();
|
||||
assertTrue(url.endsWith("index.html"));
|
||||
}
|
||||
|
||||
public void testIframeHistory()
|
||||
{
|
||||
testView.sendJavascript("loadUrl('http://maps.google.com/maps?output=embed');");
|
||||
sleep(3000);
|
||||
testView.sendJavascript("loadUrl('index2.html')");
|
||||
sleep(1000);
|
||||
String url = testView.getUrl();
|
||||
testView.backHistory();
|
||||
sleep(1000);
|
||||
assertTrue(url.endsWith("index.html"));
|
||||
}
|
||||
|
||||
private void sleep(int timeout) {
|
||||
try {
|
||||
Thread.sleep(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
fail("Unexpected Timeout");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ public class JQMTabTest extends ActivityInstrumentationTestCase2<jqmtabbackbutto
|
||||
private CordovaWebView testView;
|
||||
private Purity touchTool;
|
||||
|
||||
public JQMTabTest(Class<jqmtabbackbutton> activityClass) {
|
||||
super(activityClass);
|
||||
// TODO Auto-generated constructor stub
|
||||
public JQMTabTest()
|
||||
{
|
||||
super("org.apache.cordova.test.activity", jqmtabbackbutton.class);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@ -55,5 +55,21 @@ public class JQMTabTest extends ActivityInstrumentationTestCase2<jqmtabbackbutto
|
||||
}
|
||||
|
||||
|
||||
public void testTouch()
|
||||
{
|
||||
sleep(5000);
|
||||
int viewportHeight = touchTool.getViewportHeight() - 40;
|
||||
int viewportWidth = touchTool.getViewportWidth();
|
||||
touchTool.touch(50, viewportHeight);
|
||||
sleep(10000);
|
||||
}
|
||||
|
||||
private void sleep(int timeout) {
|
||||
try {
|
||||
Thread.sleep(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
fail("Unexpected Timeout");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,16 @@ public class Purity {
|
||||
return (int) (coord * density);
|
||||
}
|
||||
|
||||
public int getViewportWidth()
|
||||
{
|
||||
return (int) (width/density);
|
||||
}
|
||||
|
||||
public int getViewportHeight()
|
||||
{
|
||||
return (int) (height/density);
|
||||
}
|
||||
|
||||
public void touch(int x, int y)
|
||||
{
|
||||
int realX = getRealCoord(x);
|
||||
|
Loading…
Reference in New Issue
Block a user