本文整理了Java中org.robolectric.annotation.Config.<init>()
方法的一些代码示例,展示了Config.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.<init>()
方法的具体详情如下:
包路径:org.robolectric.annotation.Config
类名称:Config
方法名:<init>
暂无
代码示例来源:origin: square/leakcanary
@RunWith(RobolectricTestRunner.class)
@Config(application = TestExampleApplication.class)
public class SampleTest {
@Test public void testTheThing() throws Exception {
ActivityController<MainActivity> controller =
Robolectric.buildActivity(MainActivity.class).create().start().resume().visible();
controller.get().findViewById(R.id.async_work).performClick();
controller.stop();
controller.destroy();
}
}
代码示例来源:origin: bumptech/glide
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
public class FixedPreloadSizeProviderTest {
// containsExactly doesn't need a return value check.
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testReturnsGivenSize() {
int width = 500;
int height = 1234;
FixedPreloadSizeProvider<Object> provider = new FixedPreloadSizeProvider<>(width, height);
int[] size = provider.getPreloadSize(new Object(), 0, 0);
assertThat(size).asList().containsExactly(width, height);
}
}
代码示例来源:origin: bumptech/glide
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
public class BitmapDrawableTranscoderTest {
private BitmapDrawableTranscoder transcoder;
@Before
public void setUp() {
transcoder = new BitmapDrawableTranscoder(RuntimeEnvironment.application.getResources());
}
@Test
public void testReturnsBitmapDrawableResourceContainingGivenBitmap() {
Bitmap expected = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Resource<Bitmap> resource = mockResource();
when(resource.get()).thenReturn(expected);
Resource<BitmapDrawable> transcoded = transcoder.transcode(resource, new Options());
assertEquals(expected, transcoded.get().getBitmap());
}
}
代码示例来源:origin: bumptech/glide
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 18)
public class BitmapImageViewTargetTest {
private ImageView view;
private BitmapImageViewTarget target;
@Before
public void setUp() {
view = new ImageView(RuntimeEnvironment.application);
target = new BitmapImageViewTarget(view);
}
@Test
public void testSetsBitmapOnViewInSetResource() {
Bitmap bitmap = Bitmap.createBitmap(100, 75, Bitmap.Config.RGB_565);
target.setResource(bitmap);
assertEquals(bitmap, ((BitmapDrawable) view.getDrawable()).getBitmap());
}
}
代码示例来源:origin: bumptech/glide
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class HttpGlideUrlLoaderTest {
private HttpGlideUrlLoader loader;
private GlideUrl model;
@SuppressWarnings("unchecked")
@Before
public void setUp() {
loader = new HttpGlideUrlLoader();
model = mock(GlideUrl.class);
}
@Test
public void testReturnsValidFetcher() {
DataFetcher<InputStream> result =
Preconditions.checkNotNull(loader.buildLoadData(model, 100, 100, new Options())).fetcher;
assertThat(result).isInstanceOf(HttpUrlFetcher.class);
}
}
代码示例来源:origin: bumptech/glide
@Test @Config(sdk = 19)
public void testAsksBitmapPoolForArgb8888IfInConfigIsNull() {
bitmap.setConfig(null);
centerCrop.transform(context, resource, 10, 10);
verify(pool).get(anyInt(), anyInt(), eq(Bitmap.Config.ARGB_8888));
verify(pool, never()).get(anyInt(), anyInt(), (Bitmap.Config) isNull());
}
代码示例来源:origin: airbnb/lottie-android
@RunWith(RobolectricTestRunner.class)
@Config
@Ignore
public class BaseTest {
}
代码示例来源:origin: bumptech/glide
@Test @Config(sdk = 19)
public void testCenterCropHandlesBitmapsWithNullConfigs() {
Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
toTransform.setConfig(null);
Bitmap transformed = TransformationUtils.centerCrop(bitmapPool, toTransform, 50, 50);
assertEquals(Bitmap.Config.ARGB_8888, transformed.getConfig());
}
代码示例来源:origin: bumptech/glide
@Test @Config(sdk = 19)
public void testFitCenterHandlesBitmapsWithNullConfigs() {
Bitmap toFit = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
toFit.setConfig(null);
Bitmap transformed = TransformationUtils.fitCenter(bitmapPool, toFit, 50, 50);
assertEquals(Bitmap.Config.ARGB_8888, transformed.getConfig());
}
代码示例来源:origin: bumptech/glide
@Test @Config(sdk = 19)
public void testRotateImageExifHandlesBitmapsWithNullConfigs() {
Bitmap toRotate = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
toRotate.setConfig(null);
Bitmap rotated = TransformationUtils.rotateImageExif(bitmapPool, toRotate,
ExifInterface.ORIENTATION_ROTATE_180);
assertEquals(Bitmap.Config.ARGB_8888, rotated.getConfig());
}
代码示例来源:origin: robolectric/robolectric
@Test @Config(qualifiers = "de")
public void getQuantityString() throws Exception {
assertThat(resources.getQuantityString(R.plurals.minute, 2)).isEqualTo(
resources.getString(R.string.minute_plural));
}
代码示例来源:origin: google/ExoPlayer
@Config(sdk = 21)
@Test
public void testSupportsFormatAtApi21() {
// From API 21, tunneling is supported.
assertThat(audioRenderer.supportsFormat(FORMAT))
.isEqualTo(ADAPTIVE_NOT_SEAMLESS | TUNNELING_SUPPORTED | FORMAT_HANDLED);
}
代码示例来源:origin: google/ExoPlayer
@Config(sdk = 27)
@Test
public void testAdjustRequestDataV27() {
// Request should be unchanged.
assertThat(ClearKeyUtil.adjustRequestData(KEY_REQUEST)).isEqualTo(KEY_REQUEST);
}
代码示例来源:origin: google/ExoPlayer
@Config(sdk = 19)
@Test
public void testSupportsFormatAtApi19() {
assertThat(audioRenderer.supportsFormat(FORMAT))
.isEqualTo(ADAPTIVE_NOT_SEAMLESS | TUNNELING_NOT_SUPPORTED | FORMAT_HANDLED);
}
代码示例来源:origin: google/ExoPlayer
@Config(sdk = 27)
@Test
public void testAdjustResponseDataV27() {
// Response should be unchanged.
assertThat(ClearKeyUtil.adjustResponseData(SINGLE_KEY_RESPONSE)).isEqualTo(SINGLE_KEY_RESPONSE);
}
代码示例来源:origin: bumptech/glide
@Test @Config(sdk = 19)
public void testBitmapsWithAllowedNullConfigsAreAllowed() {
pool = new LruBitmapPool(100, strategy, Collections.<Bitmap.Config>singleton(null));
Bitmap bitmap = createMutableBitmap();
bitmap.setConfig(null);
pool.put(bitmap);
assertEquals(1, strategy.numPuts);
}
代码示例来源:origin: square/picasso
@Config(sdk = 16) // This test fails on 23 so restore the default level.
@Test public void cancelExistingRequestWithRemoteViewTarget() {
int layoutId = 0;
int viewId = 1;
RemoteViews remoteViews = new RemoteViews("packageName", layoutId);
RemoteViewsTarget target = new RemoteViewsTarget(remoteViews, viewId);
Action action = mockAction(URI_KEY_1, URI_1, target);
picasso.enqueueAndSubmit(action);
assertThat(picasso.targetToAction).hasSize(1);
picasso.cancelRequest(remoteViews, viewId);
assertThat(picasso.targetToAction).isEmpty();
verify(action).cancel();
verify(dispatcher).dispatchCancel(action);
}
代码示例来源:origin: square/picasso
@Config(sdk = 18)
@Test public void simpleResizeOnJbMr2UsesWebP() {
Request input = new Request.Builder(IMAGE_URI).resize(50, 50).build();
Request output = transformer.transformRequest(input);
assertThat(output).isNotSameAs(input);
assertThat(output.hasSize()).isFalse();
String expected = Thumbor.create(HOST)
.buildImage(IMAGE)
.resize(50, 50)
.filter(format(ImageFormat.WEBP))
.toUrl();
assertThat(output.uri.toString()).isEqualTo(expected);
}
代码示例来源:origin: bumptech/glide
@Test
@Config(shadows = {CustomShadowBitmap.class})
public void testFirstFrameMustClearBeforeDrawingWhenLastFrameIsDisposalNone() throws IOException {
byte[] data = TestUtil.resourceToBytes(getClass(), "transparent_disposal_none.gif");
GifHeaderParser headerParser = new GifHeaderParser();
headerParser.setData(data);
GifHeader header = headerParser.parseHeader();
GifDecoder decoder = new StandardGifDecoder(provider);
decoder.setData(header, data);
decoder.advance();
Bitmap firstFrame = decoder.getNextFrame();
decoder.advance();
decoder.getNextFrame();
decoder.advance();
Bitmap firstFrameTwice = decoder.getNextFrame();
assertTrue(Arrays.equals((((CustomShadowBitmap) shadowOf(firstFrame))).getPixels(),
(((CustomShadowBitmap) shadowOf(firstFrameTwice))).getPixels()));
}
代码示例来源:origin: bumptech/glide
@Test
@Config(shadows = {CustomShadowBitmap.class})
public void testFirstFrameMustClearBeforeDrawingWhenLastFrameIsDisposalBackground()
throws IOException {
byte[] data = TestUtil.resourceToBytes(getClass(), "transparent_disposal_background.gif");
GifHeaderParser headerParser = new GifHeaderParser();
headerParser.setData(data);
GifHeader header = headerParser.parseHeader();
GifDecoder decoder = new StandardGifDecoder(provider);
decoder.setData(header, data);
decoder.advance();
Bitmap firstFrame = decoder.getNextFrame();
decoder.advance();
decoder.getNextFrame();
decoder.advance();
Bitmap firstFrameTwice = decoder.getNextFrame();
assertTrue(Arrays.equals((((CustomShadowBitmap) shadowOf(firstFrame))).getPixels(),
(((CustomShadowBitmap) shadowOf(firstFrameTwice))).getPixels()));
}
内容来源于网络,如有侵权,请联系作者删除!