Bug 701076: Minor updates to robotium tests to improve reliability of text entry; r=jmaher

This commit is contained in:
Geoff Brown 2011-12-22 09:09:50 -05:00
parent 6e117752cf
commit aaf8a4cf00
5 changed files with 34 additions and 14 deletions

View File

@ -67,14 +67,15 @@ public class testAwesomebar extends ActivityInstrumentationTestCase2 {
public void testAwesomebar() {
// TODO: find a better way to not hardcode this url
String url = "http://mochi.test:8888/tests/robocop/robocop.html";
actions.waitForGeckoEvent("Gecko:Ready");
Element awesomebar = driver.findElement("awesome_bar");
awesomebar.click();
Element urlbar = driver.findElement("awesomebar_text");
getInstrumentation().waitForIdleSync();
actions.sendKeys(url);
driver.is(url, urlbar.getText(), "Awesomebar URL Typed Properly");
//could also use: urlbar.clickSpecialKey(Element.SpecialKey.ENTER)
actions.sendKeys("\n");
driver.is(urlbar.getText(), url, "Awesomebar URL Typed Properly");
actions.sendSpecialKey(Actions.SpecialKey.ENTER);
//wait for screen to load
actions.waitForGeckoEvent("DOMContentLoaded");
driver.setupScrollHandling();
@ -92,7 +93,8 @@ public class testAwesomebar extends ActivityInstrumentationTestCase2 {
}
//Click the awesomebar again
awesomebar.click();
driver.is(url, urlbar.getText(), "Aweosmebar URL stayed the same");
getInstrumentation().waitForIdleSync();
driver.is(urlbar.getText(), url, "Aweosmebar URL stayed the same");
}
@Override

View File

@ -67,30 +67,37 @@ public class testBookmark extends ActivityInstrumentationTestCase2 {
public void testBookmark(){
// TODO: find a better way to not hardcode this url
String url = "http://mochi.test:8888/tests/robocop/robocop.html";
actions.waitForGeckoEvent("Gecko:Ready");
Element awesomebar = driver.findElement("awesome_bar");
awesomebar.click();
Element urlbar = driver.findElement("awesomebar_text");
getInstrumentation().waitForIdleSync();
actions.sendKeys(url);
driver.is(url, urlbar.getText(), "Awesomebar url typed properly");
driver.is(urlbar.getText(), url, "Awesomebar url typed properly");
//Click the top item in the list.
actions.sendSpecialKey(Actions.SpecialKey.DOWN);
actions.sendSpecialKey(Actions.SpecialKey.ENTER);
actions.waitForGeckoEvent("DOMContentLoaded");
getInstrumentation().waitForIdleSync();
awesomebar.click();
driver.is(url, urlbar.getText(),"Awesomebar URL still on");
driver.is(urlbar.getText(), url, "Awesomebar URL still on");
//Click the Top item in the history list.
getInstrumentation().waitForIdleSync();
actions.sendSpecialKey(Actions.SpecialKey.RIGHT);
actions.sendSpecialKey(Actions.SpecialKey.RIGHT);
getInstrumentation().waitForIdleSync();
actions.sendSpecialKey(Actions.SpecialKey.DOWN);
actions.sendSpecialKey(Actions.SpecialKey.DOWN);
actions.sendSpecialKey(Actions.SpecialKey.ENTER);
actions.waitForGeckoEvent("DOMContentLoaded");
getInstrumentation().waitForIdleSync();
awesomebar.click();
//Unfortunately, the item isn't constant so can't be tested.
//driver.is(url, urlbar.getText(),"Shouldn't this be the last url in the history?");

View File

@ -67,20 +67,25 @@ public class testLoad extends ActivityInstrumentationTestCase2 {
public void testLoad(){
// TODO: find a better way to not hardcode this url
String url = "http://mochi.test:8888/tests/robocop/robocop.html";
actions.waitForGeckoEvent("Gecko:Ready");
Element awesomebar = driver.findElement("awesome_bar");
awesomebar.click();
Element urlbar = driver.findElement("awesomebar_text");
getInstrumentation().waitForIdleSync();
actions.sendKeys(url);
driver.is(url, urlbar.getText(),"Awesomebar URL Correct");
getInstrumentation().waitForIdleSync();
driver.is(urlbar.getText(), url, "Awesomebar URL Correct");
//Select top item in the list.
actions.sendSpecialKey(Actions.SpecialKey.DOWN);
actions.sendKeys("\n");
actions.sendSpecialKey(Actions.SpecialKey.ENTER);
actions.waitForGeckoEvent("DOMContentLoaded");
awesomebar.click();
driver.is(url, urlbar.getText(), "Awesomebar URL is still correct");
getInstrumentation().waitForIdleSync();
driver.is(urlbar.getText(), url, "Awesomebar URL is still correct");
}
@Override

View File

@ -67,20 +67,22 @@ public class testNewTab extends ActivityInstrumentationTestCase2 {
public void testNewTab(){
// TODO: find a better way to not hardcode this url
String url = "http://mochi.test:8888/tests/robocop/robocop.html";
actions.waitForGeckoEvent("Gecko:Ready");
Element tabs = driver.findElement("tabs");
//Add one tab
tabs.click();
Element urlbar = driver.findElement("awesomebar_text");
getInstrumentation().waitForIdleSync();
actions.sendKeys(url);
driver.is(url, urlbar.getText(),"Awesomebar url is fine");
driver.is(urlbar.getText(), url, "Awesomebar url is fine");
actions.sendSpecialKey(Actions.SpecialKey.ENTER);
actions.waitForGeckoEvent("DOMContentLoaded");
try{Thread.sleep(5000);}catch(Throwable e){};
//See tab count
Element tabCount = driver.findElement("tabs_count");
driver.is("2", tabCount.getText(),"Number of tabs has increased");
driver.is(tabCount.getText(), "2", "Number of tabs has increased");
//Click tab list
tabs.click();
@ -88,13 +90,15 @@ public class testNewTab extends ActivityInstrumentationTestCase2 {
//Add another tab
addTab.click();
getInstrumentation().waitForIdleSync();
actions.sendKeys(url);
driver.is(url, urlbar.getText(),"URL is still fine");
getInstrumentation().waitForIdleSync();
driver.is(urlbar.getText(), url, "URL is still fine");
actions.sendSpecialKey(Actions.SpecialKey.ENTER);
actions.waitForGeckoEvent("DOMContentLoaded");
//Check tab count another time.
driver.is("3", tabCount.getText(),"Number of tabs has increased");
driver.is(tabCount.getText(), "3", "Number of tabs has increased");
}

View File

@ -68,11 +68,13 @@ public class testPan extends ActivityInstrumentationTestCase2 {
public void testPan() {
// TODO: find a better way to not hardcode this url
String url = "http://mochi.test:8888/tests/robocop/robocop.html";
String url = "http://mochi.test:8888/tests/robocop/pantest.html";
actions.waitForGeckoEvent("Gecko:Ready");
Element awesomebar = driver.findElement("awesome_bar");
awesomebar.click();
Element urlbar = driver.findElement("awesomebar_text");
getInstrumentation().waitForIdleSync();
actions.sendKeys(url);
driver.is(url, urlbar.getText(),"Asserting Awesomebar typing works");