mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877659 - Robocop: Find a way to check if the vkb is opened and close it without using a BACK action. r=jmaher
This commit is contained in:
parent
0c63fa228c
commit
26f36aaddf
@ -18,7 +18,9 @@ import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import java.io.File;
|
||||
@ -472,6 +474,27 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
mAsserter.is(tabCountInt, expectedTabCount, "The correct number of tabs are opened");
|
||||
}
|
||||
|
||||
// Used to perform clicks on pop-up buttons without having to close the virtual keyboard
|
||||
public void clickOnButton(String label) {
|
||||
final Button button = mSolo.getButton(label);
|
||||
try {
|
||||
runTestOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
button.performClick();
|
||||
}
|
||||
});
|
||||
} catch (Throwable throwable) {
|
||||
mAsserter.ok(false, "Unable to click the button","Was unable to click button ");
|
||||
}
|
||||
}
|
||||
|
||||
// Used to hide/show the virtual keyboard
|
||||
public void toggleVKB() {
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
|
||||
}
|
||||
|
||||
protected boolean isBookmark(String[] bookmarks, String aValue) {
|
||||
for (int i = 0; i < bookmarks.length; i++) {
|
||||
if (bookmarks[i].equals(aValue))
|
||||
@ -673,7 +696,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
mActions.sendKeys(addedText);
|
||||
mSolo.clickOnText("OK");
|
||||
waitForText("Bookmark updated");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
|
||||
toggleVKB(); // close the VKB
|
||||
}
|
||||
|
||||
public boolean checkBookmarkEdit(int bookmarkIndex, String addedText, ListView list) {
|
||||
@ -689,22 +712,16 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
mSolo.clickOnText("Edit");
|
||||
waitForText("Edit Bookmark");
|
||||
|
||||
// If the OS is not Gingerbread the vkb will be opened so we need to close it in order to press the "Cancel" button
|
||||
// XXX: This is not true on all devices, but is true on our current automation test machines...
|
||||
if (!(mDevice.version.equals("2.x"))) {
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
|
||||
}
|
||||
|
||||
// Check if the new text was added
|
||||
if (mSolo.searchText(addedText)) {
|
||||
mSolo.clickOnText("Cancel");
|
||||
clickOnButton("Cancel");
|
||||
waitForText("about:home");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
|
||||
toggleVKB(); // close the VKB
|
||||
return true;
|
||||
} else {
|
||||
mSolo.clickOnText("Cancel");
|
||||
clickOnButton("Cancel");
|
||||
waitForText("about:home");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // close the VKB
|
||||
toggleVKB(); // close the VKB
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -51,12 +51,7 @@ public class testAddSearchEngine extends BaseTest {
|
||||
// Add the search engine
|
||||
mSolo.clickOnText("Add Search Engine");
|
||||
waitForText("Cancel");
|
||||
if (mDevice.type.equals("tablet")) {
|
||||
// On tablets, the vkb is opened when the popup is triggered so we need to close it in order to click the OK button
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
waitForText("OK"); // Make sure the OK button is visible
|
||||
}
|
||||
mSolo.clickOnButton("OK");
|
||||
clickOnButton("OK");
|
||||
mAsserter.ok(!mSolo.searchText("Add Search Engine"), "Adding the search engine", "The add search engine pop-up has been closed");
|
||||
|
||||
// Check that the number of search results has increased
|
||||
|
@ -118,7 +118,7 @@ public class testMasterPassword extends PixelTest {
|
||||
mSolo.waitForText("^Use master password$");
|
||||
mSolo.clickOnText("^Use master password$");
|
||||
mAsserter.ok(mSolo.waitForText("^Create Master Password$"), "Checking if the password is disabled", "The password is disabled");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the VKB
|
||||
toggleVKB(); // Close the VKB
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the Master Password menu
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ public class testMasterPassword extends PixelTest {
|
||||
public void closeTabletKeyboard() {
|
||||
if (dev.type.equals("tablet")) {
|
||||
mSolo.sleep(1500);
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the keyboard for tablets
|
||||
toggleVKB();// Close the keyboard for tablets
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user