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

Unified Diff: android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java

Issue 2045303002: Update to Chromium //base at Chromium commit 3e81715e6d3a4324362635aea46ce1f1a163cca1. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/domokit/base@master
Patch Set: Created 4 years, 6 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 | « android/jni_generator/testNatives.golden ('k') | android/library_loader/library_loader_hooks.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java
diff --git a/android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java b/android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java
index d3441f7895fed53357bb427c05a25cb8cd42eac5..bf94233c6debcaaec92b90689711702b85ed1d28 100644
--- a/android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java
+++ b/android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java
@@ -13,6 +13,7 @@ import android.view.KeyEvent;
import junit.framework.Assert;
import org.chromium.base.BaseChromiumApplication.WindowFocusChangedListener;
+import org.chromium.base.test.shadows.ShadowMultiDex;
import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,9 +27,9 @@ import org.robolectric.util.ActivityController;
/** Unit tests for {@link BaseChromiumApplication}. */
@RunWith(LocalRobolectricTestRunner.class)
@Config(manifest = Config.NONE, application = BaseChromiumApplication.class,
- shadows = {BaseChromiumApplicationTest.TrackingShadowActivity.class})
+ shadows = {BaseChromiumApplicationTest.TrackingShadowActivity.class, ShadowMultiDex.class})
public class BaseChromiumApplicationTest {
-
+ /** Shadow that tracks calls to onWindowFocusChanged and dispatchKeyEvent. */
@Implements(Activity.class)
public static class TrackingShadowActivity extends ShadowActivity {
private int mWindowFocusCalls;
@@ -65,30 +66,4 @@ public class BaseChromiumApplicationTest {
// Also ensure that the original activity is forwarded the notification.
Assert.assertEquals(1, shadow.mWindowFocusCalls);
}
-
- @Test
- public void testDispatchKeyEvent() throws Exception {
- ActivityController<Activity> controller =
- Robolectric.buildActivity(Activity.class).create().start().visible();
- TrackingShadowActivity shadow =
- (TrackingShadowActivity) Robolectric.shadowOf(controller.get());
-
- final KeyEvent menuKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU);
-
- // Ensure that key events are forwarded.
- Assert.assertFalse(controller.get().getWindow().getCallback().dispatchKeyEvent(menuKey));
- // This gets called twice - once to see if the activity is swallowing it, and again to
- // dispatch it.
- Assert.assertEquals(2, shadow.mDispatchKeyEventCalls);
-
- // Ensure that our activity can swallow the event.
- shadow.mReturnValueForKeyDispatch = true;
- Assert.assertTrue(controller.get().getWindow().getCallback().dispatchKeyEvent(menuKey));
- Assert.assertEquals(3, shadow.mDispatchKeyEventCalls);
-
- // A non-enter key only dispatches once.
- Assert.assertTrue(controller.get().getWindow().getCallback().dispatchKeyEvent(
- new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SPACE)));
- Assert.assertEquals(4, shadow.mDispatchKeyEventCalls);
- }
}
« no previous file with comments | « android/jni_generator/testNatives.golden ('k') | android/library_loader/library_loader_hooks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698