From 2badd4efea32402fd4760147dbf05a021883f0d5 Mon Sep 17 00:00:00 2001 From: Corey Wu Date: Sat, 11 May 2019 20:42:10 -0700 Subject: [PATCH] Add Flipper plugin for Navigation Summary: The main goal is to update visitation id for our targeted tabs requirements (https://fb.quip.com/2jZiA97DTATi). In doing so, we want an easier way to debug whether everything is working as expected. I've been meaning to add something like this for a while since it's a pain to explain what the visitation id and HSM look like as you navigate the app, so this should help the other teams who're using visitation id as well. Will probably also start adding navigation events and any other data that we feel is useful. Run: ``` fbsource/xplat/sonar/scripts/facebook/create-plugin.py Navigation --android ``` Then clean a few things up and fix lints. Differential Revision: D14759995 fbshipit-source-id: 066dcbf70eed7056f995053cc9ba80dcbbafdb03 --- .../NavigationFlipperPluginTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 android/src/test/java/com/facebook/flipper/plugins/navigation/NavigationFlipperPluginTest.java diff --git a/android/src/test/java/com/facebook/flipper/plugins/navigation/NavigationFlipperPluginTest.java b/android/src/test/java/com/facebook/flipper/plugins/navigation/NavigationFlipperPluginTest.java new file mode 100644 index 000000000..35654c9b4 --- /dev/null +++ b/android/src/test/java/com/facebook/flipper/plugins/navigation/NavigationFlipperPluginTest.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. + * + */ +package com.facebook.flipper.plugins.navigation; + +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.MatcherAssert.assertThat; + +import com.facebook.flipper.core.FlipperObject; +import com.facebook.flipper.testing.FlipperConnectionMock; +import com.facebook.flipper.testing.FlipperResponderMock; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; + +@RunWith(RobolectricTestRunner.class) +public class NavigationFlipperPluginTest { + + @Test + public void greetingTest() throws Exception { + final NavigationFlipperPlugin plugin = new NavigationFlipperPlugin(); + final FlipperConnectionMock connection = new FlipperConnectionMock(); + final FlipperResponderMock responder = new FlipperResponderMock(); + + plugin.onConnect(connection); + connection.receivers.get("greet").onReceive(null, responder); + + assertThat( + responder.successes, hasItem(new FlipperObject.Builder().put("greeting", "Hello").build())); + } +}