Make BackButtonMultiPageTest tests not hang forever.

They still don't pass, but at least fail now.
This commit is contained in:
Andrew Grieve 2015-01-20 14:53:31 -05:00
parent 0e19f88a04
commit 9e04eec9dd

View File

@ -44,19 +44,22 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
super(backbuttonmultipage.class); super(backbuttonmultipage.class);
} }
@UiThreadTest @Override
protected void setUp() throws Exception { public void setUp() {
super.setUp(); testActivity = getActivity();
testActivity = this.getActivity();
containerView = (FrameLayout) testActivity.findViewById(android.R.id.content); containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
innerContainer = (LinearLayout) containerView.getChildAt(0); innerContainer = (LinearLayout) containerView.getChildAt(0);
testView = (CordovaWebView) innerContainer.getChildAt(0); testView = (CordovaWebView) innerContainer.getChildAt(0);
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/index.html"); }
sleep();
void loadTestPage() {
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/index.html");
sleep();
} }
@UiThreadTest @UiThreadTest
public void testPreconditions(){ public void testPreconditions(){
loadTestPage();
assertNotNull(innerContainer); assertNotNull(innerContainer);
assertNotNull(testView); assertNotNull(testView);
String url = testView.getUrl(); String url = testView.getUrl();
@ -67,6 +70,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
runTestOnUiThread(new Runnable() { runTestOnUiThread(new Runnable() {
public void run() public void run()
{ {
loadTestPage();
testView.sendJavascript("window.location = 'sample2.html';"); testView.sendJavascript("window.location = 'sample2.html';");
} }
}); });
@ -111,6 +115,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
runTestOnUiThread(new Runnable() { runTestOnUiThread(new Runnable() {
public void run() public void run()
{ {
loadTestPage();
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html"); testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
} }
}); });
@ -156,6 +161,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
runTestOnUiThread(new Runnable() { runTestOnUiThread(new Runnable() {
public void run() public void run()
{ {
loadTestPage();
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html"); testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
} }
}); });
@ -209,6 +215,7 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
runTestOnUiThread(new Runnable() { runTestOnUiThread(new Runnable() {
public void run() public void run()
{ {
loadTestPage();
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html"); testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
} }
}); });
@ -258,7 +265,6 @@ public class BackButtonMultiPageTest extends ActivityInstrumentationTestCase2<ba
} }
@UiThreadTest
private void sleep() { private void sleep() {
try { try {
Thread.sleep(TIMEOUT); Thread.sleep(TIMEOUT);