mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
122 lines
4.0 KiB
Java
122 lines
4.0 KiB
Java
#filter substitution
|
|
package @ANDROID_PACKAGE_NAME@.tests;
|
|
|
|
import @ANDROID_PACKAGE_NAME@.*;
|
|
|
|
import android.app.Activity;
|
|
import android.view.View;
|
|
import android.widget.EditText;
|
|
|
|
/**
|
|
* Basic test of text editing within the AwesomeBar.
|
|
* - Enter some text, move the cursor around, and modifying some text.
|
|
* - Check that all AwesomeBar text is selected after switching AwesomeScreen tabs.
|
|
*/
|
|
public final class testInputAwesomeBar extends BaseTest {
|
|
private Activity mAwesomeBarActivity;
|
|
private Element mAwesomeBarTextElement;
|
|
private EditText mAwesomeBarEditText;
|
|
|
|
public void testInputAwesomeBar() {
|
|
blockForGeckoReady();
|
|
|
|
openAwesomeScreen();
|
|
assertAwesomeBarText("about:home");
|
|
|
|
mActions.sendKeys("ab");
|
|
assertAwesomeBarText("ab");
|
|
|
|
mActions.sendKeys("cd");
|
|
assertAwesomeBarText("abcd");
|
|
|
|
mActions.sendSpecialKey(Actions.SpecialKey.LEFT);
|
|
mActions.sendSpecialKey(Actions.SpecialKey.LEFT);
|
|
// Inserting "" should not do anything.
|
|
mActions.sendKeys("");
|
|
assertAwesomeBarText("abcd");
|
|
|
|
mActions.sendKeys("ef");
|
|
assertAwesomeBarText("abefcd");
|
|
|
|
mActions.sendSpecialKey(Actions.SpecialKey.RIGHT);
|
|
mActions.sendKeys("gh");
|
|
assertAwesomeBarText("abefcghd");
|
|
|
|
final EditText editText = mAwesomeBarEditText;
|
|
runOnUiThreadSync(new Runnable() { public void run() {
|
|
// Select "ef"
|
|
editText.setSelection(2);
|
|
}});
|
|
mActions.sendKeys("op");
|
|
assertAwesomeBarText("abopefcghd");
|
|
|
|
runOnUiThreadSync(new Runnable() { public void run() {
|
|
// Select "cg"
|
|
editText.setSelection(6,8);
|
|
}});
|
|
mActions.sendKeys("qr");
|
|
assertAwesomeBarText("abopefqrhd");
|
|
|
|
runOnUiThreadSync(new Runnable() { public void run() {
|
|
// Select "op"
|
|
editText.setSelection(4,2);
|
|
}});
|
|
mActions.sendKeys("st");
|
|
assertAwesomeBarText("abstefqrhd");
|
|
|
|
runOnUiThreadSync(new Runnable() { public void run() {
|
|
editText.selectAll();
|
|
}});
|
|
mActions.sendKeys("uv");
|
|
assertAwesomeBarText("uv");
|
|
|
|
// BACK key should close the VKB, so typing should no longer affect the AwesomeBar text.
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
|
|
|
// Wait for about:home page to load.
|
|
waitForText("Add-ons for your");
|
|
|
|
// AwesomeBar should have forgotten about "uv" text.
|
|
openAwesomeScreen();
|
|
assertAwesomeBarText("about:home");
|
|
|
|
// Switch tabs so address bar loses input focus.
|
|
mSolo.clickOnText("Top Sites");
|
|
mSolo.clickOnText("Bookmarks");
|
|
mSolo.clickOnText("History");
|
|
|
|
mSolo.clickOnView(mAwesomeBarEditText);
|
|
mActions.sendKeys("yz");
|
|
|
|
// FIXME BUG 855134: Clicking back to the AwesomeBar after the VKB has closed should
|
|
// select all URL text. Instead it deselects the URL text and positions the cursor.
|
|
String yz = getAwesomeBarText();
|
|
mAsserter.ok("yz".equals(yz) || "about:homeyz".equals(yz),
|
|
"Is AwesomeBar text \"yz\" or \"about:homeyz\"?", yz);
|
|
}
|
|
|
|
@Override
|
|
protected int getTestType() {
|
|
return TEST_MOCHITEST;
|
|
}
|
|
|
|
private void openAwesomeScreen() {
|
|
mAwesomeBarActivity = clickOnAwesomeBar();
|
|
mAwesomeBarTextElement = mDriver.findElement(mAwesomeBarActivity, "awesomebar_text");
|
|
int id = mAwesomeBarTextElement.getId();
|
|
mAwesomeBarEditText = (EditText) mAwesomeBarActivity.findViewById(id);
|
|
}
|
|
|
|
private String getAwesomeBarText() {
|
|
String elementText = mAwesomeBarTextElement.getText();
|
|
String editText = mAwesomeBarEditText.getText().toString();
|
|
mAsserter.is(editText, elementText, "Does AwesomeBar editText == elementText?");
|
|
return editText;
|
|
}
|
|
|
|
private void assertAwesomeBarText(String expectedText) {
|
|
String actualText = getAwesomeBarText();
|
|
mAsserter.is(actualText, expectedText, "Does AwesomeBar actualText == expectedText?");
|
|
}
|
|
}
|