@Test public void testMergeConstants() { ViewManager managerX = mock(ViewManager.class); when(managerX.getExportedCustomDirectEventTypeConstants()).thenReturn(MapBuilder.of( "onTwirl", MapBuilder.of( "registrationName", "onTwirl", "keyToOverride", "valueX", "mapToMerge", MapBuilder.of("keyToOverride", "innerValueX", "anotherKey", "valueX")))); ViewManager managerY = mock(ViewManager.class); when(managerY.getExportedCustomDirectEventTypeConstants()).thenReturn(MapBuilder.of( "onTwirl", MapBuilder.of( "extraKey", "extraValue", "keyToOverride", "valueY", "mapToMerge", MapBuilder.of("keyToOverride", "innerValueY", "extraKey", "valueY")))); List<ViewManager> viewManagers = Arrays.asList(managerX, managerY); UIManagerModule uiManagerModule = new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0); Map<String, Object> constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl"); Map twirlMap = (Map) valueAtPath(constants, CUSTOM_DIRECT_EVENT_TYPES, "onTwirl"); assertThat(twirlMap) .contains(MapEntry.entry("registrationName", "onTwirl")) .contains(MapEntry.entry("keyToOverride", "valueY")) .contains(MapEntry.entry("extraKey", "extraValue")) .containsKey("mapToMerge"); Map mapToMerge = (Map) valueAtPath(twirlMap, "mapToMerge"); assertThat(mapToMerge) .contains(MapEntry.entry("keyToOverride", "innerValueY")) .contains(MapEntry.entry("anotherKey", "valueX")) .contains(MapEntry.entry("extraKey", "valueY")); }
public static Map<String, Object> getConstants() { HashMap<String, Object> constants = new HashMap<String, Object>(); constants.put( "UIView", MapBuilder.of( "ContentMode", MapBuilder.of( "ScaleAspectFit", ImageView.ScaleType.FIT_CENTER.ordinal(), "ScaleAspectFill", ImageView.ScaleType.CENTER_CROP.ordinal(), "ScaleAspectCenter", ImageView.ScaleType.CENTER_INSIDE.ordinal()))); constants.put( "StyleConstants", MapBuilder.of( "PointerEventsValues", MapBuilder.of( "none", PointerEvents.NONE.ordinal(), "boxNone", PointerEvents.BOX_NONE.ordinal(), "boxOnly", PointerEvents.BOX_ONLY.ordinal(), "unspecified", PointerEvents.AUTO.ordinal()))); constants.put( "PopupMenu", MapBuilder.of( ACTION_DISMISSED, ACTION_DISMISSED, ACTION_ITEM_SELECTED, ACTION_ITEM_SELECTED)); constants.put( "AccessibilityEventTypes", MapBuilder.of( "typeWindowStateChanged", AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "typeViewClicked", AccessibilityEvent.TYPE_VIEW_CLICKED)); return constants; }
UIManagerModuleConstants { public static Map<String, Object> getConstants() { HashMap<String, Object> constants = new HashMap<String, Object>(); constants.put( "UIView", MapBuilder.of( "ContentMode", MapBuilder.of( "ScaleAspectFit", ImageView.ScaleType.FIT_CENTER.ordinal(), "ScaleAspectFill", ImageView.ScaleType.CENTER_CROP.ordinal(), "ScaleAspectCenter", ImageView.ScaleType.CENTER_INSIDE.ordinal()))); constants.put( "StyleConstants", MapBuilder.of( "PointerEventsValues", MapBuilder.of( "none", PointerEvents.NONE.ordinal(), "boxNone", PointerEvents.BOX_NONE.ordinal(), "boxOnly", PointerEvents.BOX_ONLY.ordinal(), "unspecified", PointerEvents.AUTO.ordinal()))); constants.put( "PopupMenu", MapBuilder.of( ACTION_DISMISSED, ACTION_DISMISSED, ACTION_ITEM_SELECTED, ACTION_ITEM_SELECTED)); constants.put( "AccessibilityEventTypes", MapBuilder.of( "typeWindowStateChanged", AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "typeViewClicked", AccessibilityEvent.TYPE_VIEW_CLICKED)); return constants; } }
UIManagerModuleConstants { public static Map<String, Object> getConstants() { HashMap<String, Object> constants = new HashMap<String, Object>(); constants.put( "UIView", MapBuilder.of( "ContentMode", MapBuilder.of( "ScaleAspectFit", ImageView.ScaleType.FIT_CENTER.ordinal(), "ScaleAspectFill", ImageView.ScaleType.CENTER_CROP.ordinal(), "ScaleAspectCenter", ImageView.ScaleType.CENTER_INSIDE.ordinal()))); constants.put( "StyleConstants", MapBuilder.of( "PointerEventsValues", MapBuilder.of( "none", PointerEvents.NONE.ordinal(), "boxNone", PointerEvents.BOX_NONE.ordinal(), "boxOnly", PointerEvents.BOX_ONLY.ordinal(), "unspecified", PointerEvents.AUTO.ordinal()))); constants.put( "PopupMenu", MapBuilder.of( ACTION_DISMISSED, ACTION_DISMISSED, ACTION_ITEM_SELECTED, ACTION_ITEM_SELECTED)); constants.put( "AccessibilityEventTypes", MapBuilder.of( "typeWindowStateChanged", AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "typeViewClicked", AccessibilityEvent.TYPE_VIEW_CLICKED)); return constants; }  }
UIManagerModuleConstants { public static Map<String, Object> getConstants() { HashMap<String, Object> constants = new HashMap<String, Object>(); constants.put( "UIView", MapBuilder.of( "ContentMode", MapBuilder.of( "ScaleAspectFit", ImageView.ScaleType.FIT_CENTER.ordinal(), "ScaleAspectFill", ImageView.ScaleType.CENTER_CROP.ordinal(), "ScaleAspectCenter", ImageView.ScaleType.CENTER_INSIDE.ordinal()))); constants.put( "StyleConstants", MapBuilder.of( "PointerEventsValues", MapBuilder.of( "none", PointerEvents.NONE.ordinal(), "boxNone", PointerEvents.BOX_NONE.ordinal(), "boxOnly", PointerEvents.BOX_ONLY.ordinal(), "unspecified", PointerEvents.AUTO.ordinal()))); constants.put( "PopupMenu", MapBuilder.of( ACTION_DISMISSED, ACTION_DISMISSED, ACTION_ITEM_SELECTED, ACTION_ITEM_SELECTED)); constants.put( "AccessibilityEventTypes", MapBuilder.of( "typeWindowStateChanged", AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "typeViewClicked", AccessibilityEvent.TYPE_VIEW_CLICKED)); return constants; }  static Map<String, Object> getConstants(); }
UIManagerModuleConstants { public static Map<String, Object> getConstants() { HashMap<String, Object> constants = new HashMap<String, Object>(); constants.put( "UIView", MapBuilder.of( "ContentMode", MapBuilder.of( "ScaleAspectFit", ImageView.ScaleType.FIT_CENTER.ordinal(), "ScaleAspectFill", ImageView.ScaleType.CENTER_CROP.ordinal(), "ScaleAspectCenter", ImageView.ScaleType.CENTER_INSIDE.ordinal()))); constants.put( "StyleConstants", MapBuilder.of( "PointerEventsValues", MapBuilder.of( "none", PointerEvents.NONE.ordinal(), "boxNone", PointerEvents.BOX_NONE.ordinal(), "boxOnly", PointerEvents.BOX_ONLY.ordinal(), "unspecified", PointerEvents.AUTO.ordinal()))); constants.put( "PopupMenu", MapBuilder.of( ACTION_DISMISSED, ACTION_DISMISSED, ACTION_ITEM_SELECTED, ACTION_ITEM_SELECTED)); constants.put( "AccessibilityEventTypes", MapBuilder.of( "typeWindowStateChanged", AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, "typeViewClicked", AccessibilityEvent.TYPE_VIEW_CLICKED)); return constants; }  static Map<String, Object> getConstants(); static final String ACTION_DISMISSED; static final String ACTION_ITEM_SELECTED; }