mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 896576 - [fig] Remove [getHistoryList] from BaseTest, r=margaret
This commit is contained in:
parent
9b2f05ebac
commit
adc932ce21
@ -533,16 +533,6 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: Write new versions of these methods and update their consumers to use the new about:home pages.
|
||||
*/
|
||||
protected ListView getHistoryList(String waitText, int expectedChildCount) {
|
||||
return null;
|
||||
}
|
||||
protected ListView getHistoryList(String waitText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long addOrUpdateBookmark(String title, String url, boolean bookmarklet) {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
Uri bookmarksUri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/bookmarks");
|
||||
|
@ -1,5 +1,3 @@
|
||||
# [testHistoryTab] # disabled on fig - bug 880060
|
||||
# [testBookmarksTab] # disabled on fig - bug 880060
|
||||
[testAwesomebar]
|
||||
# [testAwesomebarSwipes] # disabled on fig - bug 880060
|
||||
# [testBookmark] # disabled on fig - bug 880060
|
||||
|
@ -29,9 +29,6 @@
|
||||
|
||||
[testFormHistory]
|
||||
|
||||
#[testHistoryTab]
|
||||
# fails on gs2, nexus-one, lg revolution, droid pro, nexus s
|
||||
|
||||
#[testHistory]
|
||||
# fails on gs2, nexus one,lg revolution, droid pro, nexus s
|
||||
|
||||
|
@ -21,6 +21,7 @@ public class testClearPrivateData extends PixelTest {
|
||||
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
loadAndPaint(url);
|
||||
|
||||
/* Removed by Bug 896576 - [fig] Remove [getHistoryList] from BaseTest
|
||||
// Checking that the history list is not empty
|
||||
ListView hList = getHistoryList("Today|Yesterday");
|
||||
mAsserter.ok(hList.getAdapter().getCount() > 0,"checking history exists","history exists");
|
||||
@ -39,5 +40,6 @@ public class testClearPrivateData extends PixelTest {
|
||||
// Checking that history list is empty
|
||||
hList = getHistoryList("History", 0);
|
||||
mAsserter.ok(hList != null,"checking history is cleared ","history is cleared");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class testHistory extends PixelTest {
|
||||
loadAndPaint(url3);
|
||||
verifyPageTitle("Browser Blank Page 03");
|
||||
|
||||
/* Removed by Bug 896576 - [fig] Remove [getHistoryList] from BaseTest
|
||||
final ListView hList = getHistoryList("Today|Yesterday");
|
||||
mAsserter.ok(hList != null, "checking history exists", "history exists");
|
||||
|
||||
@ -64,6 +65,8 @@ public class testHistory extends PixelTest {
|
||||
|
||||
mAsserter.isnot(mFirstChild, null, "Got history item");
|
||||
mSolo.clickOnView(mFirstChild);
|
||||
*/
|
||||
|
||||
// The first item here (since it was just visited) should be a "Switch to tab" item
|
||||
// i.e. don't expect a DOMCOntentLoaded event
|
||||
verifyPageTitle("Browser Blank Page 03");
|
||||
|
@ -1,233 +0,0 @@
|
||||
#filter substitution
|
||||
package @ANDROID_PACKAGE_NAME@.tests;
|
||||
|
||||
import @ANDROID_PACKAGE_NAME@.*;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ImageView;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/* Tests opening the history tab, that items look correct, clicking on an item
|
||||
and long tapping on an item
|
||||
*/
|
||||
|
||||
public class testHistoryTab extends PixelTest {
|
||||
private static ListView listview = null;
|
||||
private String[] mBookmarks = new String[] {
|
||||
"Browser Blank Page 01",
|
||||
"Firefox: Customize with add-ons"
|
||||
};
|
||||
private View mChild;
|
||||
private boolean mNearMidnight;
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
return TEST_MOCHITEST;
|
||||
}
|
||||
|
||||
public void testHistoryTab() {
|
||||
blockForGeckoReady();
|
||||
|
||||
// very approximate date-rollover detection
|
||||
Calendar cal = new GregorianCalendar();
|
||||
mNearMidnight = (cal.get(Calendar.HOUR_OF_DAY) == 23);
|
||||
|
||||
// load two pages so there is something in our history
|
||||
// bookmark one of them
|
||||
String url = getAbsoluteUrl("/robocop/robocop_big_link.html");
|
||||
loadAndPaint(url);
|
||||
|
||||
url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
loadAndPaint(url);
|
||||
|
||||
toggleBookmark();
|
||||
mAsserter.is(mSolo.waitForText("Bookmark added"), true, "bookmark added successfully");
|
||||
|
||||
testList(url);
|
||||
testContextMenu(url);
|
||||
testClick(getAbsoluteUrl("/robocop/robocop_big_link.html"));
|
||||
}
|
||||
|
||||
private void testList(String url) {
|
||||
listview = getHistoryList("Today|Yesterday", 3);
|
||||
mAsserter.isnot(listview, null, "checking that history list exists and has 3 children");
|
||||
final int count = listview.getAdapter().getCount();
|
||||
String loadUrl = "";
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
View child = listview.getChildAt(i);
|
||||
if (child == null) {
|
||||
// this may simply indicate that the item is not visible
|
||||
Object item = listview.getAdapter().getItem(i);
|
||||
mAsserter.ok(item != null, "adapter item is set", item != null ? item.toString() : "null!");
|
||||
continue;
|
||||
}
|
||||
ArrayList<View> views = mSolo.getViews(child);
|
||||
ArrayList<ImageView> imageViews = new ArrayList<ImageView>();
|
||||
int expectedImages = 1;
|
||||
for (int j = 0; j < views.size(); j++) {
|
||||
View v = views.get(j);
|
||||
|
||||
// First row is going to be a header row
|
||||
if (i == 0) {
|
||||
ArrayList<TextView> views2 = mSolo.getCurrentTextViews(v);
|
||||
TextView t = views2.get(0);
|
||||
String string = t.getText().toString();
|
||||
boolean headerTextOK = string.equals("Today");
|
||||
if (!headerTextOK && mNearMidnight && string.equals("Yesterday")) {
|
||||
headerTextOK = true;
|
||||
}
|
||||
mAsserter.ok(headerTextOK, "First row has Today header", string);
|
||||
expectedImages = 0;
|
||||
} else if (v instanceof TextView) {
|
||||
// if this is a textview, its either the title or the url. In either case, both should be filled in
|
||||
TextView t = (TextView)v;
|
||||
String string = t.getText().toString();
|
||||
mAsserter.ok(!TextUtils.isEmpty(string), "TextView is filled in", string);
|
||||
if (i == 1 || string.startsWith("http")) {
|
||||
loadUrl = string;
|
||||
}
|
||||
|
||||
// if this was a url, check if its a bookmark and should have more than one image view present
|
||||
if (isBookmark(mBookmarks, string)) {
|
||||
expectedImages = 2;
|
||||
}
|
||||
} else if (v instanceof ImageView) {
|
||||
imageViews.add((ImageView)v);
|
||||
}
|
||||
}
|
||||
|
||||
int visible = 0;
|
||||
for (int j = 0; j < imageViews.size(); j++) {
|
||||
ImageView img = imageViews.get(j);
|
||||
visible += (img.getVisibility() == View.VISIBLE) ? 1 : 0;
|
||||
}
|
||||
|
||||
mAsserter.is(visible, expectedImages, "Correct number of ImageViews visible");
|
||||
}
|
||||
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
}
|
||||
|
||||
private void testContextMenu(String url) {
|
||||
listview = getHistoryList("Today|Yesterday");
|
||||
waitForText(url);
|
||||
|
||||
// wait for the history list to be populated
|
||||
mChild = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
@Override
|
||||
public boolean test() {
|
||||
mChild = listview.getChildAt(1);
|
||||
if (mChild == null) {
|
||||
return false;
|
||||
}
|
||||
if (mChild instanceof android.view.ViewGroup) {
|
||||
ViewGroup group = (ViewGroup)mChild;
|
||||
if (group.getChildCount() < 1) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
View grandChild = group.getChildAt(i);
|
||||
if (grandChild instanceof android.widget.TextView) {
|
||||
mAsserter.ok(true, "found TextView:", ((android.widget.TextView)grandChild).getText().toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mAsserter.dumpLog("first child not a ViewGroup: "+mChild);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, MAX_WAIT_MS);
|
||||
if (success == true && mChild != null) {
|
||||
mAsserter.dumpLog("clickLongOnView: "+mChild);
|
||||
mSolo.clickLongOnView(mChild);
|
||||
|
||||
// TODO: Test clicking these does the right thing
|
||||
mAsserter.ok(mSolo.waitForText("Open in New Tab"), "Context menu has Open in New Tab option", "Open in New Tab");
|
||||
mAsserter.ok(mSolo.waitForText("Share"), "Context menu has Share option", "Share");
|
||||
mAsserter.ok(mSolo.searchText("Remove", true), "Context menu has Remove option", "Remove");
|
||||
mAsserter.ok(mSolo.searchText("Add to Home Screen", true), "Context menu has Add to Home Screen option", "Add to Home Screen");
|
||||
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
|
||||
View child = listview.getChildAt(0);
|
||||
mAsserter.ok(child != null, "first list item can be retrieved", child != null ? child.toString() : "null!");
|
||||
mSolo.clickLongOnView(child);
|
||||
mAsserter.is(false, mSolo.waitForText("Share"), "Header rows should not show a context menu");
|
||||
|
||||
} else {
|
||||
mAsserter.ok(false, "waiting for history item", "history item available");
|
||||
}
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
}
|
||||
|
||||
private void testClick(String url) {
|
||||
listview = getHistoryList("Today|Yesterday");
|
||||
waitForText(url);
|
||||
|
||||
View child = listview.getChildAt(0);
|
||||
mAsserter.ok(child != null, "first list item can be retrieved", child != null ? child.toString() : "null!");
|
||||
mSolo.clickOnView(child);
|
||||
// nothing should happen
|
||||
|
||||
mChild = null;
|
||||
boolean success = waitForTest(new BooleanTest() {
|
||||
@Override
|
||||
public boolean test() {
|
||||
// Avoid clicking on the first entry, which is already open and will just switch to the tab
|
||||
mChild = listview.getChildAt(2);
|
||||
if (mChild == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, MAX_WAIT_MS);
|
||||
if (success == true && mChild != null) {
|
||||
Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
|
||||
mSolo.clickOnView(mChild);
|
||||
contentEventExpecter.blockForEvent();
|
||||
contentEventExpecter.unregisterListener();
|
||||
// TODO: Find a better way to wait for update before checking
|
||||
// awesome bar; lesser waits result in intermittent failures
|
||||
mSolo.sleep(2000);
|
||||
verifyUrl(url);
|
||||
} else {
|
||||
mAsserter.ok(false, "waiting for history item", "history item available");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
Uri uri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/history");
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", "default")
|
||||
.appendQueryParameter("sync", "true").build();
|
||||
resolver.delete(uri, "url = ?", new String[] {
|
||||
"http://mochi.test:8888/tests/robocop/robocop_blank_01.html"
|
||||
});
|
||||
resolver.delete(uri, "url = ?", new String[] {
|
||||
"http://mochi.test:8888/tests/robocop/robocop_big_link.html"
|
||||
});
|
||||
|
||||
uri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/bookmarks");
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", "default")
|
||||
.appendQueryParameter("sync", "true").build();
|
||||
resolver.delete(uri, "url = ?", new String[] {
|
||||
"http://mochi.test:8888/tests/robocop/robocop_blank_01.html"
|
||||
});
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
@ -93,6 +93,7 @@ public class testShareLink extends BaseTest {
|
||||
mSolo.clickLongOnView(bookmark);
|
||||
verifySharePopup(shareOptions,"bookmarks");
|
||||
|
||||
// Removed by Bug 896576 - [fig] Remove [getHistoryList] from BaseTest
|
||||
// Test the share popup in the History tab
|
||||
ListView hlist = getHistoryList("Today|Yesterday");
|
||||
View history = hlist.getChildAt(1); // Getting child at 1 because 0 might be the "Today" label
|
||||
|
Loading…
Reference in New Issue
Block a user