mobile/android/base/tests/testAboutHomePageNavigation.java

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:7b8c55d83ede
1 package org.mozilla.gecko.tests;
2
3 import org.mozilla.gecko.tests.components.AboutHomeComponent.PanelType;
4 import org.mozilla.gecko.tests.helpers.DeviceHelper;
5 import org.mozilla.gecko.tests.helpers.GeckoHelper;
6
7 /**
8 * Tests functionality related to navigating between the various about:home panels.
9 */
10 public class testAboutHomePageNavigation extends UITest {
11 // TODO: Define this test dynamically by creating dynamic representations of the Page
12 // enum for both phone and tablet, then swiping through the panels. This will also
13 // benefit having a HomePager with custom panels.
14 public void testAboutHomePageNavigation() {
15 GeckoHelper.blockForDelayedStartup();
16
17 mAboutHome.assertVisible()
18 .assertCurrentPanel(PanelType.TOP_SITES);
19
20 mAboutHome.swipeToPanelOnRight();
21 mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
22
23 mAboutHome.swipeToPanelOnRight();
24 mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
25
26 // Ideally these helpers would just be their own tests. However, by keeping this within
27 // one method, we're saving test setUp and tearDown resources.
28 if (DeviceHelper.isTablet()) {
29 helperTestTablet();
30 } else {
31 helperTestPhone();
32 }
33 }
34
35 private void helperTestTablet() {
36 mAboutHome.swipeToPanelOnRight();
37 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
38
39 // Edge case.
40 mAboutHome.swipeToPanelOnRight();
41 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
42
43 mAboutHome.swipeToPanelOnLeft();
44 mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
45
46 mAboutHome.swipeToPanelOnLeft();
47 mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
48
49 mAboutHome.swipeToPanelOnLeft();
50 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
51
52 // Edge case.
53 mAboutHome.swipeToPanelOnLeft();
54 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
55 }
56
57 private void helperTestPhone() {
58 // Edge case.
59 mAboutHome.swipeToPanelOnRight();
60 mAboutHome.assertCurrentPanel(PanelType.READING_LIST);
61
62 mAboutHome.swipeToPanelOnLeft();
63 mAboutHome.assertCurrentPanel(PanelType.BOOKMARKS);
64
65 mAboutHome.swipeToPanelOnLeft();
66 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
67
68 mAboutHome.swipeToPanelOnLeft();
69 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
70
71 // Edge case.
72 mAboutHome.swipeToPanelOnLeft();
73 mAboutHome.assertCurrentPanel(PanelType.HISTORY);
74
75 mAboutHome.swipeToPanelOnRight();
76 mAboutHome.assertCurrentPanel(PanelType.TOP_SITES);
77 }
78
79 // TODO: bug 943706 - reimplement this old test code.
80 /*
81 // Removed by Bug 896576 - [fig] Remove [getAllPagesList] from BaseTest
82 // ListView list = getAllPagesList("about:firefox");
83
84 // Test normal sliding of the list left and right
85 ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
86 mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
87
88 int width = mDriver.getGeckoWidth() / 2;
89 int y = mDriver.getGeckoHeight() / 2;
90 mActions.drag(width, 0, y, y);
91 mAsserter.is(pager.getCurrentItem(), 1, "Bookmarks page is selected");
92
93 mActions.drag(0, width, y, y);
94 mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
95
96 // Test tapping on the tab strip changes tabs
97 TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
98 mSolo.clickOnView(tabwidget.getChildAt(1));
99 mAsserter.is(pager.getCurrentItem(), 1, "Clicking on tab selected bookmarks page");
100
101 // Test typing in the awesomebar changes tabs and prevents panning
102 mSolo.typeText(0, "woot");
103 mAsserter.is(pager.getCurrentItem(), 0, "Searching switched to all pages tab");
104 mSolo.scrollToSide(Solo.LEFT);
105 mAsserter.is(pager.getCurrentItem(), 0, "Dragging left is not allowed when searching");
106
107 mSolo.scrollToSide(Solo.RIGHT);
108 mAsserter.is(pager.getCurrentItem(), 0, "Dragging right is not allowed when searching");
109
110 mActions.sendSpecialKey(Actions.SpecialKey.BACK);
111 */
112 }

mercurial