Bug 869123: Fix testShareLink to support submenu in 14+. [r=mfinkle]

--HG--
extra : rebase_source : 5291de20acb1e4c4500b8ef26eaf1a6816f3647f
This commit is contained in:
Sriram Ramasubramanian 2013-05-29 16:06:41 -07:00
parent 5bbd465bbe
commit 8daebcf929

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Build;
import android.util.DisplayMetrics;
/**
@ -34,11 +35,16 @@ public class testShareLink extends BaseTest {
loadUrl(url);
waitForText("Big Link"); // Waiting for page title to ensure the page is loaded
selectMenuItem("Share");
waitForText("Share via");
if (Build.VERSION.SDK_INT >= 14) {
// Check for our own sync in the submenu.
waitForText("Sync$");
} else {
waitForText("Share via");
}
// Get list of current avaliable share activities and verify them
shareOptions = getShareOptions();
ArrayList<String> displayedOptions = getSharePopupOption();
ArrayList<String> displayedOptions = getShareOptionsList();
for (String option:shareOptions) {
// Verify if the option is present in the list of displayed share options
mAsserter.ok(optionDisplayed(option, displayedOptions), "Share option found", option);
@ -147,6 +153,26 @@ public class testShareLink extends BaseTest {
return displayedOptions;
}
public ArrayList<String> getShareSubMenuOption() {
ArrayList<String> displayedOptions = new ArrayList();
ListView shareMenu = getDisplayedShareList();
for (int i = 0; i < shareMenu.getAdapter().getCount();i++) {
View shareItem = shareMenu.getAdapter().getView(i, null, null);
if (shareItem instanceof android.widget.TextView) {
displayedOptions.add(((android.widget.TextView)shareItem).getText().toString());
}
}
return displayedOptions;
}
public ArrayList<String> getShareOptionsList() {
if (Build.VERSION.SDK_INT >= 14) {
return getShareSubMenuOption();
} else {
return getSharePopupOption();
}
}
private boolean optionDisplayed(String shareOption, ArrayList<String> displayedOptions) {
for (String displayedOption: displayedOptions) {
if (shareOption.equals(displayedOption)) {