Fix the Google Keyboard helper testing strategy
* No explicit open or close methods
* Fix the Google Keyboard package
* Blind sleep to reduce flakiness
Change-Id: Ica69253af690b414833bce2738aa6219375c09e3
diff --git a/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java b/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java
index a2036a8..3e5b5e1 100644
--- a/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java
+++ b/libraries/first-party-app-helpers/handheld/google-keyboard-app-helper/src/android/platform/test/helpers/GoogleKeyboardHelperImpl.java
@@ -94,7 +94,17 @@
*/
@Override
public void open() {
- Log.w(TAG, "No method defined to open Google Keyboard. (no-op)");
+ throw new UnsupportedOperationException(
+ "There is no explicit open method for the Google Keyboard");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void exit() {
+ throw new UnsupportedOperationException(
+ "There is no explicit close method for the Google Keyboard");
}
/**
@@ -102,7 +112,7 @@
*/
@Override
public String getPackage() {
- return UI_PACKAGE_NAME;
+ return "com.google.android.inputmethod.latin";
}
/**
diff --git a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java b/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java
index 62fc374..a4d73da 100644
--- a/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java
+++ b/tests/functional/app-helper/src/android/platform/test/helpers/tests/GoogleKeyboardHelperTest.java
@@ -16,9 +16,12 @@
package android.platform.test.helpers.tests;
+import android.app.Instrumentation;
+import android.os.SystemClock;
import android.platform.test.helpers.GoogleKeyboardHelperImpl;
import android.platform.test.helpers.IStandardAppHelper;
import android.support.test.InstrumentationRegistry;
+import android.support.test.uiautomator.UiDevice;
import org.junit.After;
import org.junit.Before;
@@ -30,9 +33,12 @@
public class GoogleKeyboardHelperTest extends BaseHelperTest {
private GoogleKeyboardHelperImpl mHelper;
+ private UiDevice mDevice;
public GoogleKeyboardHelperTest () {
- mHelper = new GoogleKeyboardHelperImpl(InstrumentationRegistry.getInstrumentation());
+ Instrumentation instr = InstrumentationRegistry.getInstrumentation();
+ mHelper = new GoogleKeyboardHelperImpl(instr);
+ mDevice = UiDevice.getInstance(instr);
}
@Override
@@ -40,24 +46,23 @@
return mHelper;
}
- @Before
- public void before() {
- mHelper.open();
- }
-
@After
public void after() {
- mHelper.exit();
+ mDevice.pressHome();
}
@Test
public void testDismissInitialDialogs() {
+ // Sleep reduces flakiness after clearing state
+ SystemClock.sleep(5000);
mHelper.dismissInitialDialogs();
}
@Test
- @Ignore("Not critical test functionality.")
+ @Ignore("Flaky, and not critical test functionality.")
public void testWaitForKeyboard_False() {
+ // Sleep reduces flakiness after clearing state
+ SystemClock.sleep(5000);
mHelper.dismissInitialDialogs();
mHelper.exit();
Assert.assertFalse("Method didn't return false waiting for the keyboard",
@@ -65,16 +70,20 @@
}
@Test
- @Ignore("Not critical test functionality.")
+ @Ignore("Flaky, and not critical test functionality.")
public void testWaitForKeyboard_True() {
+ // Sleep reduces flakiness after clearing state
+ SystemClock.sleep(5000);
mHelper.dismissInitialDialogs();
Assert.assertTrue("Method didn't return true waiting for the keyboard",
mHelper.waitForKeyboard(2500));
}
@Test
- @Ignore("Not critical test functionality.")
+ @Ignore("Flaky, and not critical test functionality.")
public void testTypeText() {
+ // Sleep reduces flakiness after clearing state
+ SystemClock.sleep(5000);
mHelper.dismissInitialDialogs();
mHelper.waitForKeyboard(2500);
mHelper.typeText("abcd efgh", 250);