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