### Question:
BorderDrawable extends Drawable { @Override public int getOpacity() { return mShader != null ? PixelFormat.OPAQUE : WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(CSSShorthand.EDGE edge, float width); void setBorderRadius(CORNER position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); @NonNull float[] getBorderInnerRadius(RectF borderBox); void setBorderColor(CSSShorthand.EDGE edge, int color); void setBorderStyle(CSSShorthand.EDGE edge, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); static final int BORDER_TOP_LEFT_RADIUS; static final int BORDER_TOP_RIGHT_RADIUS; static final int BORDER_BOTTOM_RIGHT_RADIUS; static final int BORDER_BOTTOM_LEFT_RADIUS; static final int BORDER_RADIUS_ALL; }### Answer:
@Test public void testGetOpacity() throws Exception { BorderDrawable opaque = new BorderDrawable(); opaque.setColor(Color.GREEN); assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE)); BorderDrawable transparent = new BorderDrawable(); transparent.setColor(WXResourceUtils.getColor("#00ff0000")); assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT)); BorderDrawable half = new BorderDrawable(); half.setColor(WXResourceUtils.getColor("#aaff0000")); assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT)); BorderDrawable changeAlpha = new BorderDrawable(); changeAlpha.setColor(Color.RED); changeAlpha.setAlpha(15); assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT)); }