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)); }
@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); }
@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(ReactTextShadowNode.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(); }
@Test public void testTextDecorationLineLineThroughApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"), JavaOnlyMap.of(ReactTextShadowNode.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(); }
@Test public void testTextDecorationLineUnderlineLineThroughApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"), JavaOnlyMap.of(ReactTextShadowNode.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(); }
@Test public void testNativeAnimatedEventDoNotUpdate() { int viewTag = 1000; createSimpleAnimatedViewWithOpacity(viewTag, 0d); mNativeAnimatedNodesManager.addAnimatedEventToView(viewTag, "otherEvent", JavaOnlyMap.of( "animatedValueTag", 1, "nativeEventPath", JavaOnlyArray.of("contentOffset", "y"))); mNativeAnimatedNodesManager.addAnimatedEventToView(999, "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(0); }
/** * 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); }
@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(ReactTextShadowNode.PROP_TEXT, "New text")); uiManager.onBatchComplete(); executePendingFrameCallbacks(); assertThat(textView.getText().toString()).isEqualTo("New text"); }
@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); }
public final void updateView(UIImplementation uiImplementation) { if (mConnectedViewTag == -1) { throw new IllegalStateException("Node has not been attached to a view"); } JavaOnlyMap propsMap = new JavaOnlyMap(); for (Map.Entry<String, Integer> entry : mPropMapping.entrySet()) { @Nullable AnimatedNode node = mNativeAnimatedNodesManager.getNodeById(entry.getValue()); if (node == null) { throw new IllegalArgumentException("Mapped property node does not exists"); } else if (node instanceof StyleAnimatedNode) { ((StyleAnimatedNode) node).collectViewUpdates(propsMap); } else if (node instanceof ValueAnimatedNode) { propsMap.putDouble(entry.getKey(), ((ValueAnimatedNode) node).getValue()); } else { throw new IllegalArgumentException("Unsupported type of node used in property node " + node.getClass()); } } // TODO: Reuse propsMap and stylesDiffMap objects - note that in subsequent animation steps // for a given node most of the time we will be creating the same set of props (just with // different values). We can take advantage on that and optimize the way we allocate property // maps (we also know that updating view props doesn't retain a reference to the styles object). uiImplementation.synchronouslyUpdateViewOnUIThread( mConnectedViewTag, new ReactStylesDiffMap(propsMap)); }
@Test public void testTextDecorationLineUnderlineApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"), JavaOnlyMap.of(ReactTextShadowNode.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); }
@Test public void shouldDeleteDbEntry() throws Exception { String tableName = "testTable"; ReadableMap readableMap = JavaOnlyMap.of("id", 1); AwaitablePromise<Integer> awaitablePromise = new AwaitablePromise<>(); when(sqLiteDatabase.delete(tableName, "id = ?", new String[] {"1"})).thenReturn(1); DeleteCommand deleteCommand = new DeleteCommand(reactContext, rnRecordSQLiteHelper); deleteCommand.delete(tableName, readableMap, awaitablePromise.promise()); Integer deleteCount = awaitablePromise.awaitResolve(); assertThat(deleteCount, is(1)); }
@Test public void shouldFindDbEntry() throws Exception { String tableName = "testTable"; ReadableMap readableMap = JavaOnlyMap.of("id", 1D); AwaitablePromise<JavaOnlyArray> awaitablePromise = new AwaitablePromise<>(); Cursor cursor = mockCursor(); when(sqLiteDatabase.rawQuery("SELECT * from " + tableName + " WHERE id = ? ;", new String[] { "1.0" })).thenReturn(cursor); FindCommand findCommand = new FindCommand(reactContext, rnRecordSQLiteHelper); findCommand.find(tableName, readableMap, awaitablePromise.promise()); JavaOnlyArray result = awaitablePromise.awaitResolve(); assertThat(result.size(), is(1)); assertThat(result.getMap(0).getString("name"), is("rob")); }
@Test public void shouldUpdateDbEntry() throws Exception { String tableName = "testTable"; ContentValues contentValues = new ContentValues(); contentValues.put("name", "rob"); contentValues.put("id", 1D); ReadableMap readableMap = JavaOnlyMap.of("id", 1D, "name", "rob"); AwaitablePromise<Integer> awaitablePromise = new AwaitablePromise<>(); when(sqLiteDatabase.update(tableName, contentValues, "id = ?", new String[] {"1.0"})).thenReturn(1); UpdateCommand updateCommand = new UpdateCommand(reactContext, rnRecordSQLiteHelper); updateCommand.update(tableName, readableMap, awaitablePromise.promise()); Integer updateCount = awaitablePromise.awaitResolve(); assertThat(updateCount, is(1)); }
@Test public void shouldSaveDbEntry() throws Exception { String tableName = "testTable"; ContentValues contentValues = new ContentValues(); contentValues.put("name", "rob"); AwaitablePromise<Double> awaitablePromise = new AwaitablePromise<>(); when(sqLiteDatabase.insert(tableName, null, contentValues)).thenReturn(1L); SaveCommand saveCommand = new SaveCommand(reactContext, rnRecordSQLiteHelper); saveCommand.save(tableName, JavaOnlyMap.of("name", "rob"), awaitablePromise.promise()); Double insertCount = awaitablePromise.awaitResolve(); assertThat(insertCount, is(1D)); }
/** * 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); }
@Test public void testCallbackPositive() { final JavaOnlyMap options = new JavaOnlyMap(); options.putString("buttonPositive", "OK"); final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); final AlertDialog dialog = (AlertDialog) getFragment().getDialog(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]); assertEquals(DialogInterface.BUTTON_POSITIVE, actionCallback.getArgs()[1]); }
@Test public void testPropsApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application); rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100)); int rootTag = uiManager.addMeasuredRootView(rootView); int textInputTag = rootTag + 1; final String hintStr = "placeholder text"; uiManager.createView( textInputTag, ReactTextInputManager.REACT_CLASS, rootTag, JavaOnlyMap.of( ViewProps.FONT_SIZE, 13.37, ViewProps.HEIGHT, 20.0, "placeholder", hintStr)); uiManager.manageChildren( rootTag, null, null, JavaOnlyArray.of(textInputTag), JavaOnlyArray.of(0), null); uiManager.onBatchComplete(); executePendingChoreographerCallbacks(); EditText editText = (EditText) rootView.getChildAt(0); assertThat(editText.getHint()).isEqualTo(hintStr); assertThat(editText.getTextSize()).isEqualTo((float) Math.ceil(13.37)); assertThat(editText.getHeight()).isEqualTo(20); }
@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]); }
@Test public void testBoldFontApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_WEIGHT, "bold"), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); CustomStyleSpan customStyleSpan = getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class); assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero(); assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isZero(); }
@Test public void testNumericBoldFontApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_WEIGHT, "500"), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); CustomStyleSpan customStyleSpan = getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class); assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero(); assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isZero(); }
@Test public void testItalicFontApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_STYLE, "italic"), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); CustomStyleSpan customStyleSpan = getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class); assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isNotZero(); assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isZero(); }
@Test public void testAnimationCallbackFinish() { createSimpleAnimatedViewWithOpacity(1000, 0d); JavaOnlyArray frames = JavaOnlyArray.of(0d, 1d); Callback animationCallback = mock(Callback.class); mNativeAnimatedNodesManager.startAnimatingNode( 1, 1, JavaOnlyMap.of("type", "frames", "frames", frames, "toValue", 1d), animationCallback); ArgumentCaptor<ReadableMap> callbackResponseCaptor = ArgumentCaptor.forClass(ReadableMap.class); reset(animationCallback); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verifyNoMoreInteractions(animationCallback); reset(animationCallback); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(animationCallback).invoke(callbackResponseCaptor.capture()); assertThat(callbackResponseCaptor.getValue().hasKey("finished")).isTrue(); assertThat(callbackResponseCaptor.getValue().getBoolean("finished")).isTrue(); reset(animationCallback); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verifyNoMoreInteractions(animationCallback); }
private ReactRootView createText( UIManagerModule uiManager, JavaOnlyMap textProps, JavaOnlyMap rawTextProps) { ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application); int rootTag = uiManager.addMeasuredRootView(rootView); int textTag = rootTag + 1; int rawTextTag = textTag + 1; uiManager.createView( textTag, ReactTextViewManager.REACT_CLASS, rootTag, textProps); uiManager.createView( rawTextTag, ReactRawTextManager.REACT_CLASS, rootTag, rawTextProps); 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; }
@Test public void testNormalFontStyleApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_STYLE, "normal"), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); CustomStyleSpan customStyleSpan = getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class); assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isZero(); }
@Test public void testRoundedCorners() { ReactImageManager viewManager = new ReactImageManager(); ReactImageView view = viewManager.createViewInstance(mThemeContext); viewManager.updateProperties( view, buildStyles("src", JavaOnlyArray.of(JavaOnlyMap.of("uri", "http://mysite.com/mypic.jpg")))); // We can't easily verify if rounded corner was honored or not, this tests simply verifies // we're not crashing.. viewManager.updateProperties(view, buildStyles("borderRadius", (double) 10)); viewManager.updateProperties(view, buildStyles("borderRadius", (double) 0)); viewManager.updateProperties(view, buildStyles("borderRadius", null)); }
@Test public void testFontFamilyBoldStyleApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_FAMILY, "sans-serif", ViewProps.FONT_WEIGHT, "bold"), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); CustomStyleSpan customStyleSpan = getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class); assertThat(customStyleSpan.getFontFamily()).isEqualTo("sans-serif"); assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isZero(); assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero(); }
@Test public void testFontFamilyItalicStyleApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_FAMILY, "sans-serif", ViewProps.FONT_STYLE, "italic"), JavaOnlyMap.of(ReactTextShadowNode.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).isZero(); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Test public void testMaxLinesApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.NUMBER_OF_LINES, 2), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); TextView textView = (TextView) rootView.getChildAt(0); assertThat(textView.getText().toString()).isEqualTo("test text"); assertThat(textView.getMaxLines()).isEqualTo(2); assertThat(textView.getEllipsize()).isEqualTo(TextUtils.TruncateAt.END); }
@Test public void testFramesAnimation() { createSimpleAnimatedViewWithOpacity(1000, 0d); JavaOnlyArray frames = JavaOnlyArray.of(0d, 0.2d, 0.4d, 0.6d, 0.8d, 1d); Callback animationCallback = mock(Callback.class); mNativeAnimatedNodesManager.startAnimatingNode( 1, 1, JavaOnlyMap.of("type", "frames", "frames", frames, "toValue", 1d), animationCallback); ArgumentCaptor<ReactStylesDiffMap> stylesCaptor = ArgumentCaptor.forClass(ReactStylesDiffMap.class); reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock).synchronouslyUpdateViewOnUIThread(eq(1000), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("opacity", Double.NaN)).isEqualTo(0); for (int i = 0; i < frames.size(); i++) { reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verify(mUIImplementationMock) .synchronouslyUpdateViewOnUIThread(eq(1000), stylesCaptor.capture()); assertThat(stylesCaptor.getValue().getDouble("opacity", Double.NaN)) .isEqualTo(frames.getDouble(i)); } reset(mUIImplementationMock); mNativeAnimatedNodesManager.runUpdates(nextFrameTime()); verifyNoMoreInteractions(mUIImplementationMock); }
@Test public void testBackgroundColorStyleApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.BACKGROUND_COLOR, Color.BLUE), JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text")); Drawable backgroundDrawable = ((TextView) rootView.getChildAt(0)).getBackground(); assertThat(((ReactViewBackgroundDrawable) backgroundDrawable).getColor()).isEqualTo(Color.BLUE); }
@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]); }