當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。