当前位置: 首页>>代码示例>>Java>>正文


Java Config类代码示例

本文整理汇总了Java中org.robolectric.annotation.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Config类属于org.robolectric.annotation包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRecyclesTransformedResourceAfterWritingIfTransformedResourceIsDifferent

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testRecyclesTransformedResourceAfterWritingIfTransformedResourceIsDifferent() {
  when(decoder.getFrameCount()).thenReturn(1);
  Bitmap expected = Bitmap.createBitmap(100, 200, Bitmap.Config.RGB_565);
  when(transformedResource.get()).thenReturn(expected);
  when(frameTransformation.transform(anyContext(), eq(frameResource), anyInt(), anyInt()))
      .thenReturn(transformedResource);

  when(gifEncoder.start(any(OutputStream.class))).thenReturn(true);

  encoder.encode(resource, file, options);

  InOrder order = inOrder(transformedResource, gifEncoder);
  order.verify(gifEncoder).addFrame(eq(expected));
  order.verify(transformedResource).recycle();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ReEncodingGifResourceEncoderTest.java

示例2: getManifestFactory

import org.robolectric.annotation.Config; //导入依赖的package包/类
/**
 * Detects which build system is in use and returns the appropriate ManifestFactory implementation.
 *
 * Custom TestRunner subclasses may wish to override this method to provide alternate configuration.
 *
 * @param config Specification of the SDK version, manifest file, package name, etc.
 */
private ManifestFactory getManifestFactory(Config config) {
    Properties buildSystemApiProperties = getBuildSystemApiProperties();
    if (buildSystemApiProperties != null) {
        return new DefaultManifestFactory(buildSystemApiProperties);
    }

    Class<?> buildConstants = config.constants();
    //noinspection ConstantConditions
    if (BuckManifestFactory.isBuck()) {
        return new BuckManifestFactory();
    } else if (buildConstants != Void.class) {
        return new GradleManifestFactory();
    } else {
        return new MavenManifestFactory();
    }
}
 
开发者ID:bangarharshit,项目名称:Oleaster,代码行数:24,代码来源:RoboOleaster.java

示例3: startFromFirstFrame_withPendingFrame_clearsPendingFrame

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void startFromFirstFrame_withPendingFrame_clearsPendingFrame() {
  loader = createGifFrameLoader(/*handler=*/ null);
  DelayTarget loaded = mock(DelayTarget.class);
  when(loaded.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));
  loader.onFrameReady(loaded);
  loader.unsubscribe(callback);

  DelayTarget nextFrame = mock(DelayTarget.class);
  Bitmap expected = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
  when(nextFrame.getResource())
      .thenReturn(expected);
  loader.onFrameReady(nextFrame);

  loader.setNextStartFromFirstFrame();
  verify(requestManager).clear(nextFrame);

  loader.subscribe(callback);
  verify(callback, times(1)).onFrameReady();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:GifFrameLoaderTest.java

示例4: testCenterCropSetsOutBitmapToNotHaveAlphaIfInBitmapDoesNotHaveAlphaAndOutBitmapIsReused

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void
testCenterCropSetsOutBitmapToNotHaveAlphaIfInBitmapDoesNotHaveAlphaAndOutBitmapIsReused() {
  Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

  Bitmap toReuse = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
  reset(bitmapPool);
  when(bitmapPool.get(eq(50), eq(50), eq(Bitmap.Config.ARGB_8888))).thenReturn(toReuse);

  toReuse.setHasAlpha(true);
  toTransform.setHasAlpha(false);

  Bitmap result = TransformationUtils.centerCrop(bitmapPool, toTransform, toReuse.getWidth(),
      toReuse.getHeight());

  assertEquals(toReuse, result);
  assertFalse(result.hasAlpha());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:TransformationUtilsTest.java

示例5: testFitCenterSetsOutBitmapToNotHaveAlphaIfInBitmapDoesNotHaveAlphaAndOutBitmapIsReused

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void
testFitCenterSetsOutBitmapToNotHaveAlphaIfInBitmapDoesNotHaveAlphaAndOutBitmapIsReused() {
  Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

  Bitmap toReuse = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
  reset(bitmapPool);
  when(bitmapPool.get(eq(toReuse.getWidth()), eq(toReuse.getHeight()), eq(toReuse.getConfig())))
      .thenReturn(toReuse);

  toReuse.setHasAlpha(true);
  toTransform.setHasAlpha(false);

  Bitmap result = TransformationUtils.fitCenter(bitmapPool, toTransform, toReuse.getWidth(),
      toReuse.getHeight());

  assertEquals(toReuse, result);
  assertFalse(result.hasAlpha());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:TransformationUtilsTest.java

示例6: testOnFrameReadyClearsPreviousFrame

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testOnFrameReadyClearsPreviousFrame() {
  // Force the loader to create a real Handler.
  loader = createGifFrameLoader(null);

  DelayTarget previous = mock(DelayTarget.class);
  Request previousRequest = mock(Request.class);
  when(previous.getRequest()).thenReturn(previousRequest);
  when(previous.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));

  DelayTarget current = mock(DelayTarget.class);
  when(current.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
  loader.onFrameReady(previous);
  loader.onFrameReady(current);

  verify(requestManager).clear(eq(previous));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:GifFrameLoaderTest.java

示例7: testReturnsBitmapWithExactlyGivenDimensionsIfBitmapIsLargerThanTarget

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testReturnsBitmapWithExactlyGivenDimensionsIfBitmapIsLargerThanTarget() {
  int expectedWidth = 75;
  int expectedHeight = 74;

  for (int[] dimens : new int[][] { new int[] { 800, 200 }, new int[] { 450, 100 },
      new int[] { 78, 78 } }) {
    Bitmap toTransform = Bitmap.createBitmap(dimens[0], dimens[1], Bitmap.Config.ARGB_4444);
    when(resource.get()).thenReturn(toTransform);

    Resource<Bitmap> result =
        centerCrop.transform(context, resource, expectedWidth, expectedHeight);
    Bitmap transformed = result.get();
    assertEquals(expectedWidth, transformed.getWidth());
    assertEquals(expectedHeight, transformed.getHeight());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:CenterCropTest.java

示例8: testCenterCropSetsOutBitmapToHaveAlphaIfInBitmapHasAlphaAndOutBitmapIsReused

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testCenterCropSetsOutBitmapToHaveAlphaIfInBitmapHasAlphaAndOutBitmapIsReused() {
  Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

  Bitmap toReuse = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
  reset(bitmapPool);
  when(bitmapPool.get(eq(50), eq(50), eq(Bitmap.Config.ARGB_8888)))
      .thenReturn(toReuse);

  toReuse.setHasAlpha(false);
  toTransform.setHasAlpha(true);

  Bitmap result = TransformationUtils.centerCrop(bitmapPool, toTransform, toReuse.getWidth(),
      toReuse.getHeight());

  assertEquals(toReuse, result);
  assertTrue(result.hasAlpha());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:TransformationUtilsTest.java

示例9: onFrameReady_whenNotRunning_clearsOldFrameOnStart

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void onFrameReady_whenNotRunning_clearsOldFrameOnStart() {
  loader = createGifFrameLoader(/*handler=*/ null);
  DelayTarget loaded = mock(DelayTarget.class);
  when(loaded.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));
  loader.onFrameReady(loaded);
  loader.unsubscribe(callback);

  DelayTarget nextFrame = mock(DelayTarget.class);
  when(nextFrame.getResource())
      .thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));
  loader.onFrameReady(nextFrame);

  loader.subscribe(callback);
  verify(requestManager).clear(loaded);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:GifFrameLoaderTest.java

示例10: testReturnsNewResourceWhenBitmapTransformed

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testReturnsNewResourceWhenBitmapTransformed() {
  final Bitmap transformed = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_4444);
  BitmapTransformation transformation = new BitmapTransformation() {
    @Override
    public void updateDiskCacheKey(MessageDigest messageDigest) { }

    @Override
    protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap bitmap, int outWidth,
        int outHeight) {
      return transformed;
    }
  };

  Resource<Bitmap> resource = mockResource(1, 2);
  assertNotSame(resource, transformation.transform(context, resource, 100, 100));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BitmapTransformationTest.java

示例11: testReturnsNewResourceIfTransformationDoesTransform

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testReturnsNewResourceIfTransformationDoesTransform() {
  int outWidth = 999;
  int outHeight = 555;

  Bitmap transformedBitmap = Bitmap.createBitmap(outWidth, outHeight, Bitmap.Config.RGB_565);
  Resource<Bitmap> transformedBitmapResource = Util.mockResource();
  when(transformedBitmapResource.get()).thenReturn(transformedBitmap);
  when(wrapped.transform(anyContext(), Util.<Bitmap>anyResource(), eq(outWidth), eq(outHeight)))
      .thenReturn(transformedBitmapResource);

  Resource<BitmapDrawable> transformed =
      transformation.transform(context, drawableResourceToTransform, outWidth, outHeight);

  assertThat(transformed.get().getBitmap()).isEqualTo(transformedBitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:BitmapDrawableTransformationTest.java

示例12: getAppManifest

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Override
protected AndroidManifest getAppManifest(Config config) {

    final String manifestPath = PathResolver.resolveAndroidManifestPath();
    final String resourcesPath = PathResolver.resolveResPath();
    final String assetsPath = PathResolver.resolveAssetsPath();

    AndroidManifest manifest = new AndroidManifest(
            Fs.fileFromPath(manifestPath),
            Fs.fileFromPath(resourcesPath),
            Fs.fileFromPath(assetsPath)) {
        @Override
        public int getTargetSdkVersion() {
            return TARGET_SDK_VERSION;
        }

        @Override
        public int getMinSdkVersion() {
            return MIN_SDK_VERSION;
        }
    };

    return manifest;
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:25,代码来源:ApplicationRobolectricTestRunner.java

示例13: testAddsBitmapsToMemoryCacheIfMemoryCacheHasEnoughSpaceRemaining

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testAddsBitmapsToMemoryCacheIfMemoryCacheHasEnoughSpaceRemaining() {
  Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  when(cache.getMaxSize()).thenReturn(Util.getBitmapByteSize(bitmap));

  PreFillType size =
      new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
          .build();
  Map<PreFillType, Integer> allocationOrder = new HashMap<>();
  allocationOrder.put(size, 1);

  getHandler(allocationOrder).run();

  verify(cache).put(any(Key.class), anyResource());
  verify(pool, never()).put(any(Bitmap.class));
  // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
  // assertThat(addedBitmaps).containsExactly(bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BitmapPreFillRunnerTest.java

示例14: testWritesTransformedBitmaps

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testWritesTransformedBitmaps() {
  final Bitmap frame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  when(decoder.getFrameCount()).thenReturn(1);
  when(decoder.getNextFrame()).thenReturn(frame);

  when(gifEncoder.start(any(OutputStream.class))).thenReturn(true);

  int expectedWidth = 123;
  int expectedHeight = 456;
  when(gifDrawable.getIntrinsicWidth()).thenReturn(expectedWidth);
  when(gifDrawable.getIntrinsicHeight()).thenReturn(expectedHeight);

  Bitmap transformedFrame = Bitmap.createBitmap(200, 200, Bitmap.Config.RGB_565);
  when(transformedResource.get()).thenReturn(transformedFrame);
  when(frameTransformation.transform(
      anyContext(), eq(frameResource), eq(expectedWidth), eq(expectedHeight)))
      .thenReturn(transformedResource);
  when(gifDrawable.getFrameTransformation()).thenReturn(frameTransformation);

  encoder.encode(resource, file, options);

  verify(gifEncoder).addFrame(eq(transformedFrame));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:ReEncodingGifResourceEncoderTest.java

示例15: testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap

import org.robolectric.annotation.Config; //导入依赖的package包/类
@Test
public void testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap() {
  Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  when(cache.getMaxSize()).thenReturn(Util.getBitmapByteSize(bitmap) / 2);

  PreFillType size =
      new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
          .build();
  Map<PreFillType, Integer> allocationOrder = new HashMap<>();
  allocationOrder.put(size, 1);

  getHandler(allocationOrder).run();

  verify(cache, never()).put(any(Key.class), anyResource());
  // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
  //verify(pool).put(eq(bitmap));
  //assertThat(addedBitmaps).containsExactly(bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BitmapPreFillRunnerTest.java


注:本文中的org.robolectric.annotation.Config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。