michael@0: package org.mozilla.gecko.tests; michael@0: michael@0: import android.view.View; michael@0: import android.view.ViewGroup; michael@0: import android.widget.ListView; michael@0: michael@0: public class testHistory extends AboutHomeTest { michael@0: private View mFirstChild; michael@0: michael@0: public void testHistory() { michael@0: blockForGeckoReady(); michael@0: michael@0: String url = getAbsoluteUrl("/robocop/robocop_blank_01.html"); michael@0: String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html"); michael@0: String url3 = getAbsoluteUrl("/robocop/robocop_blank_03.html"); michael@0: michael@0: inputAndLoadUrl(url); michael@0: verifyPageTitle("Browser Blank Page 01"); michael@0: inputAndLoadUrl(url2); michael@0: verifyPageTitle("Browser Blank Page 02"); michael@0: inputAndLoadUrl(url3); michael@0: verifyPageTitle("Browser Blank Page 03"); michael@0: michael@0: openAboutHomeTab(AboutHomeTabs.MOST_RECENT); michael@0: michael@0: final ListView hList = findListViewWithTag("most_recent"); michael@0: mAsserter.is(waitForNonEmptyListToLoad(hList), true, "list is properly loaded"); michael@0: michael@0: // Click on the history item and wait for the page to load michael@0: // wait for the history list to be populated michael@0: mFirstChild = null; michael@0: boolean success = waitForTest(new BooleanTest() { michael@0: @Override michael@0: public boolean test() { michael@0: mFirstChild = hList.getChildAt(1); michael@0: if (mFirstChild == null) { michael@0: return false; michael@0: } michael@0: if (mFirstChild instanceof android.view.ViewGroup) { michael@0: ViewGroup group = (ViewGroup)mFirstChild; michael@0: if (group.getChildCount() < 1) { michael@0: return false; michael@0: } michael@0: for (int i = 0; i < group.getChildCount(); i++) { michael@0: View grandChild = group.getChildAt(i); michael@0: if (grandChild instanceof android.widget.TextView) { michael@0: mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString()); michael@0: } michael@0: } michael@0: } else { michael@0: mAsserter.dumpLog("first child not a ViewGroup: "+mFirstChild); michael@0: return false; michael@0: } michael@0: return true; michael@0: } michael@0: }, MAX_WAIT_MS); michael@0: michael@0: mAsserter.isnot(mFirstChild, null, "Got history item"); michael@0: mSolo.clickOnView(mFirstChild); michael@0: michael@0: // The first item here (since it was just visited) should be a "Switch to tab" item michael@0: // i.e. don't expect a DOMCOntentLoaded event michael@0: verifyPageTitle("Browser Blank Page 03"); michael@0: verifyUrl(url3); michael@0: } michael@0: }