Ejemplo n.º 1
0
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      method = "onBoundsChange",
      args = {android.graphics.Rect.class})
  @ToBeFixed(
      bug = "1371108",
      explanation = "There should not be a" + " NullPointerException thrown out.")
  public void testOnBoundsChange() {
    Drawable d = mContext.getResources().getDrawable(R.drawable.pass);
    MockInsetDrawable insetDrawable = new MockInsetDrawable(d, 5);

    Rect bounds = d.getBounds();
    assertEquals(0, bounds.left);
    assertEquals(0, bounds.top);
    assertEquals(0, bounds.right);
    assertEquals(0, bounds.bottom);

    Rect r = new Rect();
    insetDrawable.onBoundsChange(r);

    assertEquals(5, bounds.left);
    assertEquals(5, bounds.top);
    assertEquals(-5, bounds.right);
    assertEquals(-5, bounds.bottom);

    // input null as param
    try {
      insetDrawable.onBoundsChange(null);
      fail("There should be a NullPointerException thrown out.");
    } catch (NullPointerException e) {
      // expected, test success
    }
  }
Ejemplo n.º 2
0
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      method = "onStateChange",
      args = {int[].class})
  @ToBeFixed(bug = "", explanation = "The onStateChange will always return false.")
  public void testOnStateChange() {
    Drawable d = mContext.getResources().getDrawable(R.drawable.pass);
    MockInsetDrawable insetDrawable = new MockInsetDrawable(d, 10);

    Rect bounds = d.getBounds();
    assertEquals(0, bounds.left);
    assertEquals(0, bounds.top);
    assertEquals(0, bounds.right);
    assertEquals(0, bounds.bottom);

    int[] state = new int[] {1, 2, 3};
    assertFalse(insetDrawable.onStateChange(state));

    assertEquals(10, bounds.left);
    assertEquals(10, bounds.top);
    assertEquals(-10, bounds.right);
    assertEquals(-10, bounds.bottom);

    // input null as param
    insetDrawable.onStateChange(null);
    // expected, no Exception thrown out, test success
  }