Bug 910859 - Part 3: Add missing go button work around. r=lucasr
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 04 Dec 2013 18:32:53 -0800
changeset 168024 cedb942aa081be44a5919902ae0ed5630ac04d72
parent 168023 db9eae6662a0814221ed6f66552f0af15bc3ed7b
child 168025 a7c9340f5a340fc34323148d01559acceae41bcf
push id4703
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 20:24:19 +0000
treeherdermozilla-aurora@20af7fbd96c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs910859
milestone28.0a1
Bug 910859 - Part 3: Add missing go button work around. r=lucasr
mobile/android/base/tests/components/BaseComponent.java
mobile/android/base/tests/components/ToolbarComponent.java
--- a/mobile/android/base/tests/components/BaseComponent.java
+++ b/mobile/android/base/tests/components/BaseComponent.java
@@ -4,30 +4,34 @@
 
 package org.mozilla.gecko.tests.components;
 
 import org.mozilla.gecko.Actions;
 import org.mozilla.gecko.tests.UITestContext;
 
 import com.jayway.android.robotium.solo.Solo;
 
+import android.app.Activity;
+
 /**
  * A base class for constructing components - an abstraction over small bits of Firefox
  * functionality. For example, the Toolbar or the about:home screen could be considered a
  * component. Components should not need to know about each others existences and should be
  * combined via helpers. Helpers can also handle a series of actions taken on one component
  * (e.g. clicking the toolbar, entering a url, and waiting for page load).
  */
 public abstract class BaseComponent {
     private final UITestContext mTestContext;
+    protected final Activity mActivity;
     protected final Solo mSolo;
     protected final Actions mActions;
 
     public BaseComponent(final UITestContext testContext) {
         mTestContext = testContext;
+        mActivity = mTestContext.getActivity();
         mSolo = mTestContext.getSolo();
         mActions = mTestContext.getActions();
     }
 
     protected UITestContext getTestContext() {
         return mTestContext;
     }
 }
--- a/mobile/android/base/tests/components/ToolbarComponent.java
+++ b/mobile/android/base/tests/components/ToolbarComponent.java
@@ -1,21 +1,23 @@
 /* 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.tests.components;
 
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
 
+import org.mozilla.gecko.InputMethods;
 import org.mozilla.gecko.tests.helpers.*;
 import org.mozilla.gecko.tests.UITestContext;
 import org.mozilla.gecko.R;
 
 import com.jayway.android.robotium.solo.Condition;
+import com.jayway.android.robotium.solo.Solo;
 
 import android.view.View;
 import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.TextView;
 
 /**
  * A class representing any interactions that take place on the Toolbar.
@@ -125,17 +127,23 @@ public class ToolbarComponent extends Ba
     }
 
     public ToolbarComponent commitEditingMode() {
         assertIsEditing();
 
         WaitHelper.waitForPageLoad(new Runnable() {
             @Override
             public void run() {
-                mSolo.clickOnView(getGoButton());
+                if (InputMethods.shouldDisableUrlBarUpdate(mActivity)) {
+                    // Bug 945521 workaround: Some IMEs do not allow the go button
+                    // to be displayed in the toolbar so we hit enter instead.
+                    mSolo.sendKey(Solo.ENTER);
+                } else {
+                    mSolo.clickOnView(getGoButton());
+                }
             }
         });
         waitForNotEditing();
 
         return this;
     }
 
     public ToolbarComponent dismissEditingMode() {