mobile/android/base/tests/testHistory.java

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 package org.mozilla.gecko.tests;
michael@0 2
michael@0 3 import android.view.View;
michael@0 4 import android.view.ViewGroup;
michael@0 5 import android.widget.ListView;
michael@0 6
michael@0 7 public class testHistory extends AboutHomeTest {
michael@0 8 private View mFirstChild;
michael@0 9
michael@0 10 public void testHistory() {
michael@0 11 blockForGeckoReady();
michael@0 12
michael@0 13 String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
michael@0 14 String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
michael@0 15 String url3 = getAbsoluteUrl("/robocop/robocop_blank_03.html");
michael@0 16
michael@0 17 inputAndLoadUrl(url);
michael@0 18 verifyPageTitle("Browser Blank Page 01");
michael@0 19 inputAndLoadUrl(url2);
michael@0 20 verifyPageTitle("Browser Blank Page 02");
michael@0 21 inputAndLoadUrl(url3);
michael@0 22 verifyPageTitle("Browser Blank Page 03");
michael@0 23
michael@0 24 openAboutHomeTab(AboutHomeTabs.MOST_RECENT);
michael@0 25
michael@0 26 final ListView hList = findListViewWithTag("most_recent");
michael@0 27 mAsserter.is(waitForNonEmptyListToLoad(hList), true, "list is properly loaded");
michael@0 28
michael@0 29 // Click on the history item and wait for the page to load
michael@0 30 // wait for the history list to be populated
michael@0 31 mFirstChild = null;
michael@0 32 boolean success = waitForTest(new BooleanTest() {
michael@0 33 @Override
michael@0 34 public boolean test() {
michael@0 35 mFirstChild = hList.getChildAt(1);
michael@0 36 if (mFirstChild == null) {
michael@0 37 return false;
michael@0 38 }
michael@0 39 if (mFirstChild instanceof android.view.ViewGroup) {
michael@0 40 ViewGroup group = (ViewGroup)mFirstChild;
michael@0 41 if (group.getChildCount() < 1) {
michael@0 42 return false;
michael@0 43 }
michael@0 44 for (int i = 0; i < group.getChildCount(); i++) {
michael@0 45 View grandChild = group.getChildAt(i);
michael@0 46 if (grandChild instanceof android.widget.TextView) {
michael@0 47 mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString());
michael@0 48 }
michael@0 49 }
michael@0 50 } else {
michael@0 51 mAsserter.dumpLog("first child not a ViewGroup: "+mFirstChild);
michael@0 52 return false;
michael@0 53 }
michael@0 54 return true;
michael@0 55 }
michael@0 56 }, MAX_WAIT_MS);
michael@0 57
michael@0 58 mAsserter.isnot(mFirstChild, null, "Got history item");
michael@0 59 mSolo.clickOnView(mFirstChild);
michael@0 60
michael@0 61 // The first item here (since it was just visited) should be a "Switch to tab" item
michael@0 62 // i.e. don't expect a DOMCOntentLoaded event
michael@0 63 verifyPageTitle("Browser Blank Page 03");
michael@0 64 verifyUrl(url3);
michael@0 65 }
michael@0 66 }

mercurial