Exemplo n.º 1
0
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      method = "inflate",
      args = {
        android.content.res.Resources.class,
        org.xmlpull.v1.XmlPullParser.class,
        android.util.AttributeSet.class
      })
  @ToBeFixed(
      bug = "1386429",
      explanation =
          "no getter can not be tested,"
              + " and there should not be a NullPointerException thrown out.")
  public void testInflate() {
    Drawable d = mContext.getResources().getDrawable(R.drawable.pass);
    InsetDrawable insetDrawable = new InsetDrawable(d, 0);

    Resources r = mContext.getResources();
    XmlPullParser parser = r.getXml(R.layout.framelayout_layout);
    AttributeSet attrs = Xml.asAttributeSet(parser);

    try {
      insetDrawable.inflate(r, parser, attrs);
      fail("There should be a XmlPullParserException thrown out.");
    } catch (XmlPullParserException e) {
      // expected, test success
    } catch (IOException e) {
      fail("There should not be an IOException thrown out.");
    }

    // input null as params
    try {
      insetDrawable.inflate(null, null, null);
      fail("There should be a NullPointerException thrown out.");
    } catch (XmlPullParserException e) {
      fail("There should not be a XmlPullParserException thrown out.");
    } catch (IOException e) {
      fail("There should not be an IOException thrown out.");
    } catch (NullPointerException e) {
      // expected, test success
    }
  }