Bug 759041 - Tests for swipe between screens. r=lucasr
authorWes Johnston <wjohnston@mozilla.com>
Mon, 12 Nov 2012 10:49:26 -0800
changeset 113006 d8fed46ba90d78fb9d27d2a45292f43b93fdc93b
parent 113005 0a14e7f19dbf609a670403c5bf2bc60413a95c86
child 113007 a557ce61d622e955d3a0981661b3bd57859cd25a
push id23847
push userphilringnalda@gmail.com
push dateTue, 13 Nov 2012 05:07:25 +0000
treeherdermozilla-central@1b0226622e94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs759041
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 759041 - Tests for swipe between screens. r=lucasr
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testAwesomebarSwipes.java.in
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -1,12 +1,13 @@
 [testAllPagesTab]
 [testHistoryTab]
 [testBookmarksTab]
 [testAwesomebar]
+[testAwesomebarSwipes]
 [testBookmark]
 [testBookmarklets]
 [testMigration]
 [testLoad]
 [testNewTab]
 [testPanCorrectness]
 # [test_bug720538] # see bug 746876
 [testFlingCorrectness]
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/testAwesomebarSwipes.java.in
@@ -0,0 +1,71 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import com.jayway.android.robotium.solo.Solo;
+
+import android.app.Activity;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.TabWidget;
+import android.support.v4.view.ViewPager;
+
+import java.util.ArrayList;
+
+import @ANDROID_PACKAGE_NAME@.*;
+
+/* Tests opening the all pages tab, that items look correct, clicking on an item
+   and long tapping on an item
+*/
+
+public class testAwesomebarSwipes extends BaseTest {
+    private static final String ABOUT_HOME_URL = "about:home";
+
+    @Override
+    protected int getTestType() {
+        return TEST_MOCHITEST;
+    }
+
+    public void testAwesomebarSwipes() {
+        mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
+
+        ListView list = getAllPagesList("about:firefox");
+
+        // Test normal sliding of the list left and right
+        ViewPager pager = (ViewPager)mSolo.getView(ViewPager.class, 0);
+        mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
+
+        mSolo.scrollToSide(Solo.RIGHT);
+        mAsserter.is(pager.getCurrentItem(), 1, "Bookmarks page is selected");
+
+        mSolo.scrollToSide(Solo.LEFT);
+        mAsserter.is(pager.getCurrentItem(), 0, "All pages is selected");
+
+        // Test tapping on the tab strip changes tabs
+        TabWidget tabwidget = (TabWidget)mSolo.getView(TabWidget.class, 0);
+        mSolo.clickOnView(tabwidget.getChildAt(1));
+        mAsserter.is(pager.getCurrentItem(), 1, "Clicking on tab selected bookmarks page");
+
+        // Test typing in the awesomebar changes tabs and prevents panning
+        mSolo.typeText(0, "woot");
+        mAsserter.is(pager.getCurrentItem(), 0, "Searching switched to all pages tab");
+        mSolo.scrollToSide(Solo.LEFT);
+        mAsserter.is(pager.getCurrentItem(), 0, "Dragging left is not allowed when searching");
+
+        mSolo.scrollToSide(Solo.RIGHT);
+        mAsserter.is(pager.getCurrentItem(), 0, "Dragging right is not allowed when searching");
+
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK);
+    }
+
+    private ListView getAllPagesList(String url) {
+        Activity awesomeBarActivity = clickOnAwesomeBar();
+        mSolo.waitForText(url);
+
+        ArrayList<ListView> views = mSolo.getCurrentListViews();
+        for (ListView view : views) {
+            if (view.getTag() == "allPages")
+                return view;
+        }
+        return null;
+    }
+}