mobile/android/base/tests/testHistory.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/tests/testHistory.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +package org.mozilla.gecko.tests;
     1.5 +
     1.6 +import android.view.View;
     1.7 +import android.view.ViewGroup;
     1.8 +import android.widget.ListView;
     1.9 +
    1.10 +public class testHistory extends AboutHomeTest {
    1.11 +    private View mFirstChild;
    1.12 +
    1.13 +    public void testHistory() {
    1.14 +        blockForGeckoReady();
    1.15 +
    1.16 +        String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
    1.17 +        String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
    1.18 +        String url3 = getAbsoluteUrl("/robocop/robocop_blank_03.html");
    1.19 +
    1.20 +        inputAndLoadUrl(url);
    1.21 +        verifyPageTitle("Browser Blank Page 01");
    1.22 +        inputAndLoadUrl(url2);
    1.23 +        verifyPageTitle("Browser Blank Page 02");
    1.24 +        inputAndLoadUrl(url3);
    1.25 +        verifyPageTitle("Browser Blank Page 03");
    1.26 +
    1.27 +        openAboutHomeTab(AboutHomeTabs.MOST_RECENT);
    1.28 +
    1.29 +        final ListView hList = findListViewWithTag("most_recent");
    1.30 +        mAsserter.is(waitForNonEmptyListToLoad(hList), true, "list is properly loaded");
    1.31 +
    1.32 +        // Click on the history item and wait for the page to load
    1.33 +        // wait for the history list to be populated
    1.34 +        mFirstChild = null;
    1.35 +        boolean success = waitForTest(new BooleanTest() {
    1.36 +            @Override
    1.37 +            public boolean test() {
    1.38 +                mFirstChild = hList.getChildAt(1);
    1.39 +                if (mFirstChild == null) {
    1.40 +                    return false;
    1.41 +                }
    1.42 +                if (mFirstChild instanceof android.view.ViewGroup) {
    1.43 +                    ViewGroup group = (ViewGroup)mFirstChild;
    1.44 +                    if (group.getChildCount() < 1) {
    1.45 +                        return false;
    1.46 +                    }
    1.47 +                    for (int i = 0; i < group.getChildCount(); i++) {
    1.48 +                        View grandChild = group.getChildAt(i);
    1.49 +                        if (grandChild instanceof android.widget.TextView) {
    1.50 +                            mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString());
    1.51 +                        }
    1.52 +                    }
    1.53 +                } else {
    1.54 +                    mAsserter.dumpLog("first child not a ViewGroup: "+mFirstChild);
    1.55 +                    return false;
    1.56 +                }
    1.57 +                return true;
    1.58 +            }
    1.59 +        }, MAX_WAIT_MS);
    1.60 +
    1.61 +        mAsserter.isnot(mFirstChild, null, "Got history item");
    1.62 +        mSolo.clickOnView(mFirstChild);
    1.63 +
    1.64 +        // The first item here (since it was just visited) should be a "Switch to tab" item
    1.65 +        // i.e. don't expect a DOMCOntentLoaded event
    1.66 +        verifyPageTitle("Browser Blank Page 03");
    1.67 +        verifyUrl(url3);
    1.68 +    }
    1.69 +}

mercurial