Bug 701076: Minor updates to robotium tests to improve reliability of text entry; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Thu, 22 Dec 2011 09:09:50 -0500
changeset 83255 b84f3d11305814346dfb6f75fa40c4d854e00f91
parent 83254 65f3838752d8df85d52974369ddf36ff0c2944ac
child 83256 44412b34781d69ac3d326ec892b616c2846e4ae3
push id21744
push userbmo@edmorley.co.uk
push dateFri, 23 Dec 2011 23:56:40 +0000
treeherdermozilla-central@ede336ccaed0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs701076
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 701076: Minor updates to robotium tests to improve reliability of text entry; r=jmaher
mobile/android/base/tests/testAwesomebar.java.in
mobile/android/base/tests/testBookmark.java.in
mobile/android/base/tests/testLoad.java.in
mobile/android/base/tests/testNewTab.java.in
mobile/android/base/tests/testPan.java.in
--- a/mobile/android/base/tests/testAwesomebar.java.in
+++ b/mobile/android/base/tests/testAwesomebar.java.in
@@ -62,24 +62,25 @@ public class testAwesomebar extends Acti
     driver = new FennecNativeDriver(activity, solo);
     actions = new FennecNativeActions(activity, solo, getInstrumentation());
     driver.setLogFile((String)config.get("logfile"));
   }
 
   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();
     //Calculate where we should be dragging.
     int midX = driver.getGeckoLeft() + driver.getGeckoWidth()/2;
     int midY = driver.getGeckoTop() + driver.getGeckoHeight()/2;
     int endY = driver.getGeckoTop() + driver.getGeckoHeight()/10;
     for(int i = 0; i < 10; i++) {
@@ -87,17 +88,18 @@ public class testAwesomebar extends Acti
       try {
         Thread.sleep(200);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
     //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	
   public void tearDown() throws Exception {	
     try	{
       solo.finalize();	
     }catch (Throwable e){	
       e.printStackTrace();	
--- a/mobile/android/base/tests/testBookmark.java.in
+++ b/mobile/android/base/tests/testBookmark.java.in
@@ -62,40 +62,47 @@ public class testBookmark extends Activi
     driver = new FennecNativeDriver(activity, solo);
     actions = new FennecNativeActions(activity, solo, getInstrumentation());
     driver.setLogFile((String)config.get("logfile"));
   } 	
 
   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?");
   }
   
   @Override	
   public void tearDown() throws Exception {	
     try	{
--- a/mobile/android/base/tests/testLoad.java.in
+++ b/mobile/android/base/tests/testLoad.java.in
@@ -62,30 +62,35 @@ public class testLoad extends ActivityIn
     driver = new FennecNativeDriver(activity, solo);
     actions = new FennecNativeActions(activity, solo, getInstrumentation());
     driver.setLogFile((String)config.get("logfile"));
   } 	
 
   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	
   public void tearDown() throws Exception {	
     try	{
       solo.finalize();	
     }catch (Throwable e){	
       e.printStackTrace();	
--- a/mobile/android/base/tests/testNewTab.java.in
+++ b/mobile/android/base/tests/testNewTab.java.in
@@ -62,44 +62,48 @@ public class testNewTab extends Activity
     driver = new FennecNativeDriver(activity, solo);
     actions = new FennecNativeActions(activity, solo, getInstrumentation());
     driver.setLogFile((String)config.get("logfile"));
   }
 
   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();
     Element addTab = driver.findElement("add_tab");
 
     //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");
 
   }
 
   @Override	
   public void tearDown() throws Exception {	
     try	{
       solo.finalize();	
     }catch (Throwable e){	
--- a/mobile/android/base/tests/testPan.java.in
+++ b/mobile/android/base/tests/testPan.java.in
@@ -63,21 +63,23 @@ public class testPan extends ActivityIns
     solo = new Solo(getInstrumentation(), getActivity());
     driver = new FennecNativeDriver(activity, solo);
     actions = new FennecNativeActions(activity, solo, getInstrumentation());
     driver.setLogFile((String)config.get("logfile"));
   }
 
   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");
 
     actions.sendSpecialKey(Actions.SpecialKey.ENTER);
     actions.waitForGeckoEvent("DOMContentLoaded");
     driver.setupScrollHandling();
 
     // Setup scrolling coordinates.