BasicFieldColorViewTest.java 文件源码

java
阅读 43 收藏 0 点赞 0 评论 0

项目:Blockly 作者:
@Test
public void testPopupWindowChangeColor() {
    mFieldColorView.performClick();
    final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow();
    final View popupWindowContentView = popupWindow.getContentView();
    assertThat(popupWindowContentView).isNotNull();

    // Reset color before test.
    mFieldColor.setColor(0);
    assertThat(mFieldColor.getColor()).isEqualTo(0);

    // Simulate click on the color panel.
    popupWindowContentView.onTouchEvent(
            MotionEvent.obtain(0 /* downTime */, 0 /* eventTime */, MotionEvent.ACTION_DOWN,
                    0f /* x */, 0f /* y */, 0 /* metaState */));

    // Verify both field and field view background have been set to correct color.
    final int expectedColour = 0xffffff;
    assertThat(mFieldColor.getColor())
            .isEqualTo(expectedColour);  // setColour() masks out alpha.
    assertThat(((ColorDrawable) mFieldColorView.getBackground()).getColor())
            .isEqualTo(BasicFieldColorView.ALPHA_OPAQUE | expectedColour);

    // Popup window should have disappeared.
    assertThat(popupWindow.isShowing()).isFalse();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号