com.facebook.react.bridge.JavaOnlyMap Java Examples
The following examples show how to use
com.facebook.react.bridge.JavaOnlyMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DialogModuleTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testAllOptions() { final JavaOnlyMap options = new JavaOnlyMap(); options.putString("title", "Title"); options.putString("message", "Message"); options.putString("buttonPositive", "OK"); options.putString("buttonNegative", "Cancel"); options.putString("buttonNeutral", "Later"); options.putBoolean("cancelable", false); mDialogModule.showAlert(options, null, null); final AlertFragment fragment = getFragment(); assertNotNull("Fragment was not displayed", fragment); assertEquals(false, fragment.isCancelable()); final AlertDialog dialog = (AlertDialog) fragment.getDialog(); assertEquals("OK", dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText().toString()); assertEquals("Cancel", dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText().toString()); assertEquals("Later", dialog.getButton(DialogInterface.BUTTON_NEUTRAL).getText().toString()); }
Example #2
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testTextDecorationLineLineThroughApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); TextView textView = (TextView) rootView.getChildAt(0); Spanned text = (Spanned) textView.getText(); UnderlineSpan[] underlineSpans = text.getSpans(0, text.length(), UnderlineSpan.class); StrikethroughSpan strikeThroughSpan = getSingleSpan(textView, StrikethroughSpan.class); assertThat(underlineSpans).hasSize(0); assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue(); }
Example #3
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testTextDecorationLineUnderlineApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); TextView textView = (TextView) rootView.getChildAt(0); Spanned text = (Spanned) textView.getText(); UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class); StrikethroughSpan[] strikeThroughSpans = text.getSpans(0, text.length(), StrikethroughSpan.class); assertThat(underlineSpan instanceof UnderlineSpan).isTrue(); assertThat(strikeThroughSpans).hasSize(0); }
Example #4
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testFontFamilyBoldItalicStyleApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of( ViewProps.FONT_FAMILY, "sans-serif", ViewProps.FONT_WEIGHT, "500", ViewProps.FONT_STYLE, "italic"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); CustomStyleSpan customStyleSpan = getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class); assertThat(customStyleSpan.getFontFamily()).isEqualTo("sans-serif"); assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isNotZero(); assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero(); }
Example #5
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testTextDecorationLineUnderlineLineThroughApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); UnderlineSpan underlineSpan = getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class); StrikethroughSpan strikeThroughSpan = getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class); assertThat(underlineSpan instanceof UnderlineSpan).isTrue(); assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue(); }
Example #6
Source File: KeychainModuleTests.java From react-native-keychain with MIT License | 6 votes |
@Test @Config(sdk = Build.VERSION_CODES.P) public void testGetSecurityLevel_NoBiometry_api28() throws Exception { // GIVE: final ReactApplicationContext context = getRNContext(); final KeychainModule module = new KeychainModule(context); final Promise mockPromise = mock(Promise.class); // WHEN: final JavaOnlyMap options = new JavaOnlyMap(); options.putString(Maps.ACCESS_CONTROL, AccessControl.DEVICE_PASSCODE); module.getSecurityLevel(options, mockPromise); // THEN: verify(mockPromise).resolve(SecurityLevel.SECURE_HARDWARE.name()); }
Example #7
Source File: BlobModuleTest.java From react-native-GPay with MIT License | 6 votes |
@Before public void prepareModules() throws Exception { PowerMockito.mockStatic(Arguments.class); Mockito.when(Arguments.createMap()).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return new JavaOnlyMap(); } }); mBytes = new byte[120]; new Random().nextBytes(mBytes); mBlobModule = new BlobModule(ReactTestHelper.createCatalystContextForTest()); mBlobId = mBlobModule.store(mBytes); }
Example #8
Source File: UIManagerModuleTest.java From react-native-GPay with MIT License | 6 votes |
/** * Makes sure replaceExistingNonRootView by replacing a view with a new view that has a background * color set. */ @Test public void testReplaceExistingNonRootView() { UIManagerModule uiManager = getUIManagerModule(); TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager); int newViewTag = 1234; uiManager.createView( newViewTag, ReactViewManager.REACT_CLASS, hierarchy.rootView, JavaOnlyMap.of("backgroundColor", Color.RED)); uiManager.replaceExistingNonRootView(hierarchy.view2, newViewTag); uiManager.onBatchComplete(); executePendingFrameCallbacks(); assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(4); assertThat(hierarchy.nativeRootView.getChildAt(2)).isInstanceOf(ReactViewGroup.class); ReactViewGroup view = (ReactViewGroup) hierarchy.nativeRootView.getChildAt(2); assertThat(view.getBackgroundColor()).isEqualTo(Color.RED); }
Example #9
Source File: UIManagerModuleTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testUpdateSimpleHierarchy() { UIManagerModule uiManager = getUIManagerModule(); ViewGroup rootView = createSimpleTextHierarchy(uiManager, "Some text"); TextView textView = (TextView) rootView.getChildAt(0); int rawTextTag = 3; uiManager.updateView( rawTextTag, ReactRawTextManager.REACT_CLASS, JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "New text")); uiManager.onBatchComplete(); executePendingFrameCallbacks(); assertThat(textView.getText().toString()).isEqualTo("New text"); }
Example #10
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testNativeAnimatedEventDoUpdate() { int viewTag = 1000; createSimpleAnimatedViewWithOpacity(viewTag, 0d); mNativeAnimatedNodesManager.addAnimatedEventToView(viewTag, "topScroll", JavaOnlyMap.of( "animatedValueTag", 1, "nativeEventPath", JavaOnlyArray.of("contentOffset", "y"))); mNativeAnimatedNodesManager.onEventDispatch(createScrollEvent(viewTag, 10)); ArgumentCaptor<ReactStylesDiffMap> stylesCaptor = ArgumentCaptor.forClass(ReactStylesDiffMap.class); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock).synchronouslyUpdateViewOnUIThread(eq(viewTag), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("opacity", Double.NaN)).isEqualTo(10); }
Example #11
Source File: KeychainModuleTests.java From react-native-keychain with MIT License | 6 votes |
@Test @Config(sdk = Build.VERSION_CODES.P) public void testGetSecurityLevel_NoBiometry_NoSecuredHardware_api28() throws Exception { // GIVE: final ReactApplicationContext context = getRNContext(); final KeychainModule module = new KeychainModule(context); final Promise mockPromise = mock(Promise.class); // set key info - software method provider.configuration.put("isInsideSecureHardware", false); // WHEN: final JavaOnlyMap options = new JavaOnlyMap(); options.putString(Maps.ACCESS_CONTROL, AccessControl.DEVICE_PASSCODE); module.getSecurityLevel(options, mockPromise); // THEN: // expected AesCbc usage assertThat(provider.mocks.get("KeyGenerator"), notNullValue()); assertThat(provider.mocks.get("KeyGenerator").get("AES"), notNullValue()); assertThat(provider.mocks.get("KeyPairGenerator"), notNullValue()); assertThat(provider.mocks.get("KeyPairGenerator").get("RSA"), notNullValue()); verify(mockPromise).resolve(SecurityLevel.SECURE_SOFTWARE.name()); }
Example #12
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testNodeValueListenerIfNotListening() { int nodeId = 1; createSimpleAnimatedViewWithOpacity(1000, 0d); JavaOnlyArray frames = JavaOnlyArray.of(0d, 0.2d, 0.4d, 0.6d, 0.8d, 1d); Callback animationCallback = mock(Callback.class); AnimatedNodeValueListener valueListener = mock(AnimatedNodeValueListener.class); mNativeAnimatedNodesManager.startListeningToAnimatedNodeValue(nodeId, valueListener); mNativeAnimatedNodesManager.startAnimatingNode( 1, nodeId, JavaOnlyMap.of("type", "frames", "frames", frames, "toValue", 1d), animationCallback); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(valueListener).onValueUpdate(eq(0d)); mNativeAnimatedNodesManager.stopListeningToAnimatedNodeValue(nodeId); reset(valueListener); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verifyNoMoreInteractions(valueListener); }
Example #13
Source File: ReactTextInputPropertyTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testSelection() { ReactEditText view = mManager.createViewInstance(mThemedContext); view.setText("Need some text to select something..."); mManager.updateProperties(view, buildStyles()); assertThat(view.getSelectionStart()).isEqualTo(0); assertThat(view.getSelectionEnd()).isEqualTo(0); JavaOnlyMap selection = JavaOnlyMap.of("start", 5, "end", 10); mManager.updateProperties(view, buildStyles("selection", selection)); assertThat(view.getSelectionStart()).isEqualTo(5); assertThat(view.getSelectionEnd()).isEqualTo(10); mManager.updateProperties(view, buildStyles("selection", null)); assertThat(view.getSelectionStart()).isEqualTo(5); assertThat(view.getSelectionEnd()).isEqualTo(10); }
Example #14
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testUnderdampedSpringAnimation() { performSpringAnimationTestWithConfig( JavaOnlyMap.of( "type", "spring", "stiffness", 230.2d, "damping", 22d, "mass", 1d, "initialVelocity", 0d, "toValue", 1d, "restSpeedThreshold", 0.001d, "restDisplacementThreshold", 0.001d, "overshootClamping", false ), false ); }
Example #15
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testCriticallyDampedSpringAnimation() { performSpringAnimationTestWithConfig( JavaOnlyMap.of( "type", "spring", "stiffness", 1000d, "damping", 500d, "mass", 3.0d, "initialVelocity", 0d, "toValue", 1d, "restSpeedThreshold", 0.001d, "restDisplacementThreshold", 0.001d, "overshootClamping", false ), true ); }
Example #16
Source File: JSONParserTest.java From react-native-navigation with MIT License | 6 votes |
@Test public void parsesArrays() throws Exception { JavaOnlyArray input = new JavaOnlyArray(); input.pushString("Hello"); input.pushInt(123); input.pushDouble(123.456); input.pushBoolean(true); input.pushArray(new JavaOnlyArray()); input.pushMap(new JavaOnlyMap()); input.pushNull(); JSONArray result = new JSONParser().parse(input); assertThat(result.length()).isEqualTo(6); assertThat(result.get(0)).isEqualTo("Hello"); assertThat(result.get(1)).isEqualTo(123); assertThat(result.get(2)).isEqualTo(123.456); assertThat(result.get(3)).isEqualTo(true); assertThat(result.getJSONArray(4).length()).isZero(); assertThat(result.getJSONObject(5).keys()).isEmpty(); }
Example #17
Source File: RNInstabugReactnativeModuleTest.java From Instabug-React-Native with MIT License | 6 votes |
@Test public void givenCallback$getAllUserAttributes_whenQuery_thenShouldCallNativeApiAndInvokeCallback() { // given PowerMockito.mockStatic(Instabug.class); PowerMockito.mockStatic(Arguments.class); Callback callback = mock(Callback.class); // when HashMap<String, String> userAttributes = new HashMap<>(); userAttributes.put("email", "[email protected]"); PowerMockito.when(Arguments.createMap()).thenReturn(new JavaOnlyMap()); PowerMockito.when(Instabug.getAllUserAttributes()).thenReturn(userAttributes); rnModule.getAllUserAttributes(callback); // then PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Instabug.getAllUserAttributes(); WritableMap expectedMap = new JavaOnlyMap(); expectedMap.putString("email", "[email protected]"); verify(callback).invoke(expectedMap); }
Example #18
Source File: TransformAnimatedNode.java From react-native-GPay with MIT License | 6 votes |
public void collectViewUpdates(JavaOnlyMap propsMap) { List<JavaOnlyMap> transforms = new ArrayList<>(mTransformConfigs.size()); for (TransformConfig transformConfig : mTransformConfigs) { double value; if (transformConfig instanceof AnimatedTransformConfig) { int nodeTag = ((AnimatedTransformConfig) transformConfig).mNodeTag; AnimatedNode node = mNativeAnimatedNodesManager.getNodeById(nodeTag); if (node == null) { throw new IllegalArgumentException("Mapped style node does not exists"); } else if (node instanceof ValueAnimatedNode) { value = ((ValueAnimatedNode) node).getValue(); } else { throw new IllegalArgumentException("Unsupported type of node used as a transform child " + "node " + node.getClass()); } } else { value = ((StaticTransformConfig) transformConfig).mValue; } transforms.add(JavaOnlyMap.of(transformConfig.mProperty, value)); } propsMap.putArray("transform", JavaOnlyArray.from(transforms)); }
Example #19
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 5 votes |
private Event createScrollEvent(final int tag, final double value) { return new Event(tag) { @Override public String getEventName() { return "topScroll"; } @Override public void dispatch(RCTEventEmitter rctEventEmitter) { rctEventEmitter.receiveEvent(tag, "topScroll", JavaOnlyMap.of( "contentOffset", JavaOnlyMap.of("y", value))); } }; }
Example #20
Source File: UIManagerModuleTest.java From react-native-GPay with MIT License | 5 votes |
/** * Assuming no other views have been created, the root view will have tag 1, Text tag 2, and * RawText tag 3. */ private ViewGroup createSimpleTextHierarchy(UIManagerModule uiManager, String text) { ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application.getApplicationContext()); int rootTag = uiManager.addRootView(rootView); int textTag = rootTag + 1; int rawTextTag = textTag + 1; uiManager.createView( textTag, ReactTextViewManager.REACT_CLASS, rootTag, JavaOnlyMap.of("collapsable", false)); uiManager.createView( rawTextTag, ReactRawTextManager.REACT_CLASS, rootTag, JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, text, "collapsable", false)); uiManager.manageChildren( textTag, null, null, JavaOnlyArray.of(rawTextTag), JavaOnlyArray.of(0), null); uiManager.manageChildren( rootTag, null, null, JavaOnlyArray.of(textTag), JavaOnlyArray.of(0), null); uiManager.onBatchComplete(); executePendingFrameCallbacks(); return rootView; }
Example #21
Source File: ReactPropAnnotationSetterTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testMapSetter() { ReadableMap map = new JavaOnlyMap(); mViewManager.updateProperties(null, buildStyles("mapProp", map)); verify(mUpdatesReceiverMock).onMapSetterCalled(map); verifyNoMoreInteractions(mUpdatesReceiverMock); reset(mUpdatesReceiverMock); mViewManager.updateProperties(null, buildStyles("mapProp", null)); verify(mUpdatesReceiverMock).onMapSetterCalled(null); verifyNoMoreInteractions(mUpdatesReceiverMock); reset(mUpdatesReceiverMock); }
Example #22
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 5 votes |
/** * Generates a simple animated nodes graph and attaches the props node to a given {@param viewTag} * Parameter {@param opacity} is used as a initial value for the "opacity" attribute. * * Nodes are connected as follows (nodes IDs in parens): * ValueNode(1) -> StyleNode(2) -> PropNode(3) */ private void createSimpleAnimatedViewWithOpacity(int viewTag, double opacity) { mNativeAnimatedNodesManager.createAnimatedNode( 1, JavaOnlyMap.of("type", "value", "value", opacity, "offset", 0d)); mNativeAnimatedNodesManager.createAnimatedNode( 2, JavaOnlyMap.of("type", "style", "style", JavaOnlyMap.of("opacity", 1))); mNativeAnimatedNodesManager.createAnimatedNode( 3, JavaOnlyMap.of("type", "props", "props", JavaOnlyMap.of("style", 2))); mNativeAnimatedNodesManager.connectAnimatedNodes(1, 2); mNativeAnimatedNodesManager.connectAnimatedNodes(2, 3); mNativeAnimatedNodesManager.connectAnimatedNodeToView(3, viewTag); }
Example #23
Source File: DialogModuleTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testCallbackNeutral() { final JavaOnlyMap options = new JavaOnlyMap(); options.putString("buttonNeutral", "Later"); final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); final AlertDialog dialog = (AlertDialog) getFragment().getDialog(); dialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]); assertEquals(DialogInterface.BUTTON_NEUTRAL, actionCallback.getArgs()[1]); }
Example #24
Source File: BlobModuleTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testCreateFromParts() { String id = UUID.randomUUID().toString(); JavaOnlyMap blobData = new JavaOnlyMap(); blobData.putString("blobId", mBlobId); blobData.putInt("offset", 0); blobData.putInt("size", mBytes.length); JavaOnlyMap blob = new JavaOnlyMap(); blob.putMap("data", blobData); blob.putString("type", "blob"); String stringData = "i \u2665 dogs"; byte[] stringBytes = stringData.getBytes(Charset.forName("UTF-8")); JavaOnlyMap string = new JavaOnlyMap(); string.putString("data", stringData); string.putString("type", "string"); JavaOnlyArray parts = new JavaOnlyArray(); parts.pushMap(blob); parts.pushMap(string); mBlobModule.createFromParts(parts, id); int resultSize = mBytes.length + stringBytes.length; byte[] result = mBlobModule.resolve(id, 0, resultSize); ByteBuffer buffer = ByteBuffer.allocate(resultSize); buffer.put(mBytes); buffer.put(stringBytes); assertArrayEquals(result, buffer.array()); }
Example #25
Source File: BlobModuleTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testResolveMap() { JavaOnlyMap blob = new JavaOnlyMap(); blob.putString("blobId", mBlobId); blob.putInt("offset", 0); blob.putInt("size", mBytes.length); assertArrayEquals(mBytes, mBlobModule.resolve(blob)); }
Example #26
Source File: ShareModuleTest.java From react-native-GPay with MIT License | 5 votes |
@Before public void prepareModules() throws Exception { PowerMockito.mockStatic(Arguments.class); Mockito.when(Arguments.createMap()).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return new JavaOnlyMap(); } }); mShareModule = new ShareModule(ReactTestHelper.createCatalystContextForTest()); }
Example #27
Source File: KeychainModuleTests.java From react-native-keychain with MIT License | 5 votes |
@Test @Config(sdk = Build.VERSION_CODES.P) public void testDowngradeBiometricToAes_api28() throws Exception { // GIVEN: final ReactApplicationContext context = getRNContext(); final KeychainModule module = new KeychainModule(context); final PrefsStorage prefs = new PrefsStorage(context); final Cipher mockCipher = Mockito.mock(Cipher.class); final KeyStore mockKeyStore = Mockito.mock(KeyStore.class); final CipherStorage storage = module.getCipherStorageByName(KnownCiphers.RSA); final CipherStorage.EncryptionResult result = new CipherStorage.EncryptionResult(BYTES_USERNAME, BYTES_PASSWORD, storage); final Promise mockPromise = mock(Promise.class); final JavaOnlyMap options = new JavaOnlyMap(); options.putString(Maps.SERVICE, "dummy"); // store record done with RSA/Biometric cipher prefs.storeEncryptedEntry("dummy", result); assertThat(storage, instanceOf(CipherStorage.class)); ((CipherStorageBase)storage).setCipher(mockCipher).setKeyStore(mockKeyStore); when(mockKeyStore.getKey(eq("dummy"), isNull())).thenReturn(null); // return empty Key! // WHEN: module.getGenericPasswordForOptions(options, mockPromise); // THEN: ArgumentCaptor<Exception> exception = ArgumentCaptor.forClass(Exception.class); verify(mockPromise).reject(eq(Errors.E_CRYPTO_FAILED), exception.capture()); assertThat(exception.getValue(), instanceOf(CryptoFailedException.class)); assertThat(exception.getValue().getCause(), instanceOf(KeyStoreAccessException.class)); assertThat(exception.getValue().getMessage(), is("Wrapped error: Empty key extracted!")); }
Example #28
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 5 votes |
/** * Verifies that {@link NativeAnimatedNodesManager#runUpdates} updates the view correctly in case * when one of the addition input nodes has started animating while the other one has not. * * We expect that the output of the addition node will take the starting value of the second input * node even though the node hasn't been connected to an active animation driver. */ @Test public void testViewReceiveUpdatesIfOneOfAnimationHasntStarted() { createAnimatedGraphWithAdditionNode(50, 100d, 1000d); // Start animating only the first addition input node Callback animationCallback = mock(Callback.class); JavaOnlyArray frames = JavaOnlyArray.of(0d, 1d); mNativeAnimatedNodesManager.startAnimatingNode( 1, 1, JavaOnlyMap.of("type", "frames", "frames", frames, "toValue", 101d), animationCallback); ArgumentCaptor<ReactStylesDiffMap> stylesCaptor = ArgumentCaptor.forClass(ReactStylesDiffMap.class); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock).synchronouslyUpdateViewOnUIThread(eq(50), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("translateX", Double.NaN)).isEqualTo(1100d); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock) .synchronouslyUpdateViewOnUIThread(eq(50), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("translateX", Double.NaN)).isEqualTo(1101d); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verifyNoMoreInteractions(mUIImplementationMock); }
Example #29
Source File: DialogModuleTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testCallbackDismiss() { final JavaOnlyMap options = new JavaOnlyMap(); final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); getFragment().getDialog().dismiss(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_DISMISSED, actionCallback.getArgs()[0]); }
Example #30
Source File: NativeAnimatedNodeTraversalTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testAdditionNode() { createAnimatedGraphWithAdditionNode(50, 100d, 1000d); Callback animationCallback = mock(Callback.class); JavaOnlyArray frames = JavaOnlyArray.of(0d, 1d); mNativeAnimatedNodesManager.startAnimatingNode( 1, 1, JavaOnlyMap.of("type", "frames", "frames", frames, "toValue", 101d), animationCallback); mNativeAnimatedNodesManager.startAnimatingNode( 2, 2, JavaOnlyMap.of("type", "frames", "frames", frames, "toValue", 1010d), animationCallback); ArgumentCaptor<ReactStylesDiffMap> stylesCaptor = ArgumentCaptor.forClass(ReactStylesDiffMap.class); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock).synchronouslyUpdateViewOnUIThread(eq(50), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("translateX", Double.NaN)).isEqualTo(1100d); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock) .synchronouslyUpdateViewOnUIThread(eq(50), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("translateX", Double.NaN)).isEqualTo(1111d); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verifyNoMoreInteractions(mUIImplementationMock); }