Bug 942270 - Fix tests for quickshare. r=gbrown

This commit is contained in:
Wes Johnston 2014-03-26 10:18:01 -07:00
Родитель 1d56b0fe1e
Коммит ab67c195d5
6 изменённых файлов: 107 добавлений и 11 удалений

Просмотреть файл

@ -14,6 +14,30 @@
<application
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
<!-- Fake handlers to ensure that we have some share intents to show in our share handler list -->
<activity android:name="org.mozilla.gecko.RobocopShare1"
android:label="Robocop fake activity">
<intent-filter android:label="Fake robocop share handler 1">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
<activity android:name="org.mozilla.gecko.RobocopShare2"
android:label="Robocop fake activity 2">
<intent-filter android:label="Fake robocop share handler 2">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
</application>
</manifest>

Просмотреть файл

@ -26,6 +26,8 @@ _JAVA_HARNESS := \
FennecNativeDriver.java \
FennecNativeElement.java \
RoboCopException.java \
RobocopShare1.java \
RobocopShare2.java \
RobocopUtils.java \
PaintedSurface.java \
$(NULL)

Просмотреть файл

@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class RobocopShare1 extends FragmentActivity {
private static Bundle sArguments;
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
}
}

Просмотреть файл

@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class RobocopShare2 extends FragmentActivity {
private static Bundle sArguments;
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
}
}

Просмотреть файл

@ -29,7 +29,10 @@ abstract class ContentContextMenuTest extends PixelTest {
protected void verifyContextMenuItems(String[] items) {
// Test that the menu items are displayed
openWebContentContextMenu(items[0]);
if (!mSolo.searchText(items[0])) {
openWebContentContextMenu(items[0]); // Open the context menu if it is not already
}
for (String option:items) {
mAsserter.ok(mSolo.searchText(option), "Checking that the option: " + option + " is available", "The option is available");
}
@ -46,6 +49,24 @@ abstract class ContentContextMenuTest extends PixelTest {
verifyTabCount(expectedTabCount);
}
protected void verifyTabs(String[] items) {
if (!mSolo.searchText(items[0])) {
openWebContentContextMenu(items[0]);
}
for (String option:items) {
mAsserter.ok(mSolo.searchText(option), "Checking that the option: " + option + " is available", "The option is available");
}
}
protected void switchTabs(String tab) {
if (!mSolo.searchText(tab)) {
openWebContentContextMenu(tab);
}
mSolo.clickOnText(tab);
}
protected void verifyCopyOption(String copyOption, final String copiedText) {
if (!mSolo.searchText(copyOption)) {
openWebContentContextMenu(copyOption); // Open the context menu if it is not already
@ -65,10 +86,12 @@ abstract class ContentContextMenuTest extends PixelTest {
protected void verifyShareOption(String shareOption, String pageTitle) {
waitForText(pageTitle);
openWebContentContextMenu(shareOption);
waitForText(pageTitle); // Even if this fails, it won't assert
if (!mSolo.searchText(shareOption)) {
openWebContentContextMenu(shareOption); // Open the context menu if it is not already
}
mSolo.clickOnText(shareOption);
mAsserter.ok(waitForText("Share via"), "Checking that the share pop-up is displayed", "The pop-up has been displayed");
mAsserter.ok(waitForText(shareOption), "Checking that the share pop-up is displayed", "The pop-up has been displayed");
// Close the Share Link option menu and wait for the page to be focused again
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
@ -76,7 +99,9 @@ abstract class ContentContextMenuTest extends PixelTest {
}
protected void verifyBookmarkLinkOption(String bookmarkOption, String link) {
openWebContentContextMenu(bookmarkOption);
if (!mSolo.searchText(bookmarkOption)) {
openWebContentContextMenu(bookmarkOption); // Open the context menu if it is not already
}
mSolo.clickOnText(bookmarkOption);
mAsserter.ok(waitForText("Bookmark added"), "Waiting for the Bookmark added toaster notification", "The notification has been displayed");
mAsserter.ok(mDatabaseHelper.isBookmark(link), "Checking if the link has been added as a bookmark", "The link has been bookmarked");

Просмотреть файл

@ -8,7 +8,10 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
private static String PICTURE_PAGE_URL;
private static String BLANK_PAGE_URL;
private static final String PICTURE_PAGE_TITLE = "Picture Link";
private static final String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set Image As", "Save Image", "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
private static final String tabs [] = { "Image", "Link" };
private static final String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set Image As", "Save Image" };
private static final String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
private static final String linkTitle = "^Link$";
@Override
protected int getTestType() {
@ -24,13 +27,21 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
verifyPageTitle(PICTURE_PAGE_TITLE);
verifyContextMenuItems(photoMenuItems);
verifyTabs(tabs);
verifyCopyOption(photoMenuItems[0], "Firefox.jpg"); // Test the "Copy Image Location" option
verifyShareOption(photoMenuItems[1], PICTURE_PAGE_TITLE); // Test the "Share Image" option
openTabFromContextMenu(photoMenuItems[4],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one
openTabFromContextMenu(photoMenuItems[5],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
verifyCopyOption(photoMenuItems[6], BLANK_PAGE_URL); // Test the "Copy Link" option
verifyShareOption(photoMenuItems[7], PICTURE_PAGE_TITLE); // Test the "Share Link" option
verifyBookmarkLinkOption(photoMenuItems[8],BLANK_PAGE_URL); // Test the "Bookmark Link" option
switchTabs(linkTitle);
verifyContextMenuItems(linkMenuItems);
openTabFromContextMenu(linkMenuItems[0],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one
switchTabs(linkTitle);
openTabFromContextMenu(linkMenuItems[1],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
switchTabs(linkTitle);
verifyCopyOption(linkMenuItems[2], BLANK_PAGE_URL); // Test the "Copy Link" option
switchTabs(linkTitle);
verifyShareOption(linkMenuItems[3], PICTURE_PAGE_TITLE); // Test the "Share Link" option
switchTabs(linkTitle);
verifyBookmarkLinkOption(linkMenuItems[4],BLANK_PAGE_URL); // Test the "Bookmark Link" option
}
@Override