@Test public void testNativeProps() { ViewManager mockViewManager = mock(ViewManager.class); List<ViewManager> viewManagers = Arrays.asList(mockViewManager); when(mockViewManager.getName()).thenReturn("SomeView"); when(mockViewManager.getNativeProps()) .thenReturn(MapBuilder.of("fooProp", "number")); UIManagerModule uiManagerModule = new UIManagerModule( mReactContext, viewManagers, mUIImplementationProvider, false); Map<String, Object> constants = uiManagerModule.getConstants(); assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp")) .isEqualTo("number"); }
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()))); DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics(); DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); constants.put( "Dimensions", MapBuilder.of( "windowPhysicalPixels", MapBuilder.of( "width", displayMetrics.widthPixels, "height", displayMetrics.heightPixels, "scale", displayMetrics.density, "fontScale", displayMetrics.scaledDensity, "densityDpi", displayMetrics.densityDpi), "screenPhysicalPixels", MapBuilder.of( "width", screenDisplayMetrics.widthPixels, "height", screenDisplayMetrics.heightPixels, "scale", screenDisplayMetrics.density, "fontScale", screenDisplayMetrics.scaledDensity, "densityDpi", screenDisplayMetrics.densityDpi))); 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()))); DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics(); DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); constants.put( "Dimensions", MapBuilder.of( "windowPhysicalPixels", MapBuilder.of( "width", displayMetrics.widthPixels, "height", displayMetrics.heightPixels, "scale", displayMetrics.density, "fontScale", displayMetrics.scaledDensity, "densityDpi", displayMetrics.densityDpi), "screenPhysicalPixels", MapBuilder.of( "width", screenDisplayMetrics.widthPixels, "height", screenDisplayMetrics.heightPixels, "scale", screenDisplayMetrics.density, "fontScale", screenDisplayMetrics.scaledDensity, "densityDpi", screenDisplayMetrics.densityDpi))); 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()))); DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics(); DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); constants.put( "Dimensions", MapBuilder.of( "windowPhysicalPixels", MapBuilder.of( "width", displayMetrics.widthPixels, "height", displayMetrics.heightPixels, "scale", displayMetrics.density, "fontScale", displayMetrics.scaledDensity, "densityDpi", displayMetrics.densityDpi), "screenPhysicalPixels", MapBuilder.of( "width", screenDisplayMetrics.widthPixels, "height", screenDisplayMetrics.heightPixels, "scale", screenDisplayMetrics.density, "fontScale", screenDisplayMetrics.scaledDensity, "densityDpi", screenDisplayMetrics.densityDpi))); 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()))); DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics(); DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); constants.put( "Dimensions", MapBuilder.of( "windowPhysicalPixels", MapBuilder.of( "width", displayMetrics.widthPixels, "height", displayMetrics.heightPixels, "scale", displayMetrics.density, "fontScale", displayMetrics.scaledDensity, "densityDpi", displayMetrics.densityDpi), "screenPhysicalPixels", MapBuilder.of( "width", screenDisplayMetrics.widthPixels, "height", screenDisplayMetrics.heightPixels, "scale", screenDisplayMetrics.density, "fontScale", screenDisplayMetrics.scaledDensity, "densityDpi", screenDisplayMetrics.densityDpi))); 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()))); DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics(); DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); constants.put( "Dimensions", MapBuilder.of( "windowPhysicalPixels", MapBuilder.of( "width", displayMetrics.widthPixels, "height", displayMetrics.heightPixels, "scale", displayMetrics.density, "fontScale", displayMetrics.scaledDensity, "densityDpi", displayMetrics.densityDpi), "screenPhysicalPixels", MapBuilder.of( "width", screenDisplayMetrics.widthPixels, "height", screenDisplayMetrics.heightPixels, "scale", screenDisplayMetrics.density, "fontScale", screenDisplayMetrics.scaledDensity, "densityDpi", screenDisplayMetrics.densityDpi))); 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; }