Exemplo n.º 1
0
  @Test
  public void test_measuredDimensionCustomView() {
    // View provides its own onMeasure implementation
    TestView2 view2 = new TestView2(new Activity());

    assertThat(view2.getHeight(), equalTo(0));
    assertThat(view2.getWidth(), equalTo(0));
    assertThat(view2.getMeasuredHeight(), equalTo(0));
    assertThat(view2.getMeasuredWidth(), equalTo(0));

    view2.measure(
        MeasureSpec.makeMeasureSpec(1000, MeasureSpec.AT_MOST),
        MeasureSpec.makeMeasureSpec(600, MeasureSpec.AT_MOST));

    assertThat(view2.getHeight(), equalTo(0));
    assertThat(view2.getWidth(), equalTo(0));
    assertThat(view2.getMeasuredHeight(), equalTo(400));
    assertThat(view2.getMeasuredWidth(), equalTo(800));
  }