Java 类org.robolectric.shadows.ShadowBitmapFactory 实例源码

项目:Onosendai    文件:PictureResizeDialogTest.java   
@Test
public void itGeneratesLivePreview () throws Exception {
    this.alert.show();
    this.dlg.updateSummary();

    final TextView txtSummary = (TextView) this.shadowAlert.getView().findViewById(R.id.txtSummary);

    ShadowBitmapFactory.provideWidthAndHeightHints(this.attachment, 72, 72);
    // Note above does not actually have any effect,
    // since dimensions are read via BitmapFactory.decodeFileDescriptor().
    // 100x100 is ShadowBitmapFactory's default.
    final String expectedStatus = "100 x 100 (3.4 KB) --> 36 x 36 (69 B)";
    int n = 0;
    while (true) {
        if (expectedStatus.equals(txtSummary.getText().toString())) break;
        if (n > 5) fail("Expected '" + txtSummary.getText() + "' to be '" + expectedStatus + "' after " + n + " seconds.");
        n++;
        Thread.sleep(1000L);
    }

    // TODO assert img in UI is set.
}