From 4411fd40e86338c8e7afe9959be705fba21d21bc Mon Sep 17 00:00:00 2001 From: vivek Date: Mon, 21 Apr 2014 13:27:00 +0200 Subject: [PATCH] Bug 997996 - Make ToolbarComponent.dismissEditingMode use the cancel editing mode button. r=mcomella --- .../tests/components/ToolbarComponent.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/mobile/android/base/tests/components/ToolbarComponent.java b/mobile/android/base/tests/components/ToolbarComponent.java index 1df3eab3f04..dd8043e6e0b 100644 --- a/mobile/android/base/tests/components/ToolbarComponent.java +++ b/mobile/android/base/tests/components/ToolbarComponent.java @@ -86,6 +86,13 @@ public class ToolbarComponent extends BaseComponent { return (ImageButton) getToolbarView().findViewById(R.id.forward); } + /** + * Returns the View for the edit cancel button in the browser toolbar. + */ + private ImageButton getEditCancelButton() { + return (ImageButton) getToolbarView().findViewById(R.id.edit_cancel); + } + private CharSequence getTitle() { return getTitleHelper(true); } @@ -145,14 +152,19 @@ public class ToolbarComponent extends BaseComponent { public ToolbarComponent dismissEditingMode() { assertIsEditing(); - if (getUrlEditText().isInputMethodTarget()) { - // Drop the soft keyboard. - // TODO: Solo.hideSoftKeyboard() does not clear focus, causing unexpected - // behavior, but we may want to use it over goBack(). - mSolo.goBack(); - } + // Cancel Button not implemeneted in tablet. + if (DeviceHelper.isTablet()) { + if (getUrlEditText().isInputMethodTarget()) { + // Drop the soft keyboard. + // TODO: Solo.hideSoftKeyboard() does not clear focus, causing unexpected + // behavior, but we may want to use it over goBack(). + mSolo.goBack(); + } - mSolo.goBack(); + mSolo.goBack(); + } else { + mSolo.clickOnView(getEditCancelButton()); + } waitForNotEditing();