mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
85 lines
2.9 KiB
Java
85 lines
2.9 KiB
Java
#filter substitution
|
|
package @ANDROID_PACKAGE_NAME@.tests;
|
|
|
|
import @ANDROID_PACKAGE_NAME@.*;
|
|
import android.widget.ListView;
|
|
import android.app.Activity;
|
|
import java.util.ArrayList;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
public class testHistory extends PixelTest {
|
|
private View mFirstChild;
|
|
|
|
@Override
|
|
protected int getTestType() {
|
|
return TEST_MOCHITEST;
|
|
}
|
|
|
|
public void testHistory() {
|
|
blockForGeckoReady();
|
|
|
|
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
|
String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
|
|
String url3 = getAbsoluteUrl("/robocop/robocop_blank_03.html");
|
|
|
|
loadAndPaint(url);
|
|
verifyPageTitle("Browser Blank Page 01");
|
|
loadAndPaint(url2);
|
|
verifyPageTitle("Browser Blank Page 02");
|
|
loadAndPaint(url3);
|
|
verifyPageTitle("Browser Blank Page 03");
|
|
|
|
final ListView hList = openHistoryList();
|
|
mAsserter.ok(hList != null, "checking history exists", "history exists");
|
|
|
|
// Click on the history item and wait for the page to load
|
|
// wait for the history list to be populated
|
|
mFirstChild = null;
|
|
boolean success = waitForTest(new BooleanTest() {
|
|
@Override
|
|
public boolean test() {
|
|
mFirstChild = hList.getChildAt(1);
|
|
if (mFirstChild == null) {
|
|
return false;
|
|
}
|
|
if (mFirstChild instanceof android.view.ViewGroup) {
|
|
ViewGroup group = (ViewGroup)mFirstChild;
|
|
if (group.getChildCount() < 1) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < group.getChildCount(); i++) {
|
|
View grandChild = group.getChildAt(i);
|
|
if (grandChild instanceof android.widget.TextView) {
|
|
mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString());
|
|
}
|
|
}
|
|
} else {
|
|
mAsserter.dumpLog("first child not a ViewGroup: "+mFirstChild);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}, MAX_WAIT_MS);
|
|
|
|
Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
|
|
mAsserter.isnot(mFirstChild, null, "Got history item");
|
|
mSolo.clickOnView(mFirstChild);
|
|
contentEventExpecter.blockForEvent();
|
|
contentEventExpecter.unregisterListener();
|
|
verifyUrl(url3);
|
|
}
|
|
|
|
protected ListView openHistoryList() {
|
|
Activity awesomeBarActivity = clickOnAwesomeBar();
|
|
mSolo.clickOnText("History");
|
|
|
|
ArrayList<ListView> views = mSolo.getCurrentListViews();
|
|
for (ListView view : views) {
|
|
if (view.getTag() == "history")
|
|
return view;
|
|
}
|
|
return null;
|
|
}
|
|
}
|