Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/util/TranslateUtil.java

Issue 2908253002: Create automation test for the new translate infobar (Closed)
Patch Set: rename functions Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/android/javatests/src/org/chromium/chrome/test/util/InfoBarUtil.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/android/javatests/src/org/chromium/chrome/test/util/TranslateUtil.java
diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/TranslateUtil.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/TranslateUtil.java
index e64931ca367a5aa8039fa1fcfb76542eead4b7e8..fed5f4fd44c07dd86d2e024ff3b394ae2e0f9287 100644
--- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/TranslateUtil.java
+++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/TranslateUtil.java
@@ -16,10 +16,13 @@ import org.junit.Assert;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBar;
import org.chromium.chrome.browser.infobar.InfoBarCompactLayout;
+import org.chromium.chrome.browser.infobar.TranslateCompactInfoBar;
+import org.chromium.chrome.browser.infobar.translate.TranslateMenu;
import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.TestTouchUtils;
-
/**
* Utility functions for dealing with Translate InfoBars.
*/
@@ -73,6 +76,73 @@ public class TranslateUtil {
Assert.assertTrue(tabLayout instanceof TranslateTabLayout);
}
+ public static void assertHasAtLeastTwoLanguageTabs(TranslateCompactInfoBar infoBar) {
+ View content = infoBar.getView().findViewById(R.id.translate_infobar_content);
+ Assert.assertNotNull(content);
+
+ TranslateTabLayout tabLayout =
+ (TranslateTabLayout) content.findViewById(R.id.translate_infobar_tabs);
+ Assert.assertTrue(tabLayout.getTabCount() >= 2);
+ }
+
+ /**
+ * Checks if the menu button exists on the InfoBar.
+ * @return True if the View was found.
+ */
+ public static boolean hasMenuButton(InfoBar infoBar) {
+ return InfoBarUtil.findButton(infoBar, R.id.translate_infobar_menu_button, false);
+ }
+
+ /**
+ * Simulates clicking the menu button in the specified infobar.
+ * @return True if the View was found.
+ */
+ public static boolean clickMenuButton(InfoBar infoBar) {
+ return InfoBarUtil.findButton(infoBar, R.id.translate_infobar_menu_button, true);
+ }
+
+ /**
+ * Simulates clicking the menu button and check if overflow menu is shown.
+ */
+ public static void clickMenuButtonAndAssertMenuShown(final TranslateCompactInfoBar infoBar) {
+ clickMenuButton(infoBar);
+ CriteriaHelper.pollInstrumentationThread(new Criteria("Overflow menu did not show") {
+ @Override
+ public boolean isSatisfied() {
+ return infoBar.isShowingOverflowMenuForTesting();
+ }
+ });
+ }
+
+ /**
+ * Simulates clicking the 'More Language' menu item and check if language menu is shown.
+ */
+ public static void clickMoreLanguageButtonAndAssertLanguageMenuShown(
+ Instrumentation instrumentation, final TranslateCompactInfoBar infoBar) {
+ invokeOverflowMenuActionSync(
+ instrumentation, infoBar, TranslateMenu.ID_OVERFLOW_MORE_LANGUAGE);
+ CriteriaHelper.pollInstrumentationThread(new Criteria("Language menu did not show") {
+ @Override
+ public boolean isSatisfied() {
+ return infoBar.isShowingLanguageMenuForTesting();
+ }
+ });
+ }
+
+ /**
+ * Execute a particular menu item from the overflow menu.
+ * The item is executed even if it is disabled or not visible.
+ */
+ public static void invokeOverflowMenuActionSync(
+ Instrumentation instrumentation, final TranslateCompactInfoBar infoBar, final int id) {
+ instrumentation.runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ infoBar.onOverflowMenuItemClicked(id);
+ }
+ });
+ }
+
private static String findInfoBarText(View view) {
TextView text = (TextView) view.findViewById(R.id.infobar_message);
return text != null ? text.getText().toString() : null;
« no previous file with comments | « chrome/test/android/javatests/src/org/chromium/chrome/test/util/InfoBarUtil.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698