本文整理汇总了Java中org.robolectric.shadow.api.Shadow类的典型用法代码示例。如果您正苦于以下问题:Java Shadow类的具体用法?Java Shadow怎么用?Java Shadow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Shadow类属于org.robolectric.shadow.api包,在下文中一共展示了Shadow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Before
public void setUp() {
NotificationManager notificationManager = (NotificationManager) RuntimeEnvironment.application
.getSystemService(Context.NOTIFICATION_SERVICE);
shadowManager = (UpdateShadowNotificationManager) Shadow.extract(notificationManager);
remoteViews = mock(RemoteViews.class);
viewId = 123;
notification = mock(Notification.class);
notificationId = 456;
notificationTag = "tag";
target =
new NotificationTarget(RuntimeEnvironment.application, 100 /*width*/, 100 /*height*/,
viewId, remoteViews, notification, notificationId, notificationTag);
}
示例2: testLoadResource_returnsFileDescriptor
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testLoadResource_returnsFileDescriptor() throws Exception {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) Shadow.extract(contentResolver);
AssetFileDescriptor assetFileDescriptor = mock(AssetFileDescriptor.class);
ParcelFileDescriptor parcelFileDescriptor = mock(ParcelFileDescriptor.class);
when(assetFileDescriptor.getParcelFileDescriptor()).thenReturn(parcelFileDescriptor);
shadow.registerFileDescriptor(uri, assetFileDescriptor);
FileDescriptorLocalUriFetcher fetcher =
new FileDescriptorLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onDataReady(eq(parcelFileDescriptor));
}
示例3: setUp
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Before
public void setUp() {
NotificationManager notificationManager =
(NotificationManager)
RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE);
shadowManager = Shadow.extract(notificationManager);
remoteViews = mock(RemoteViews.class);
viewId = 123;
notification = mock(Notification.class);
notificationId = 456;
notificationTag = "tag";
target =
new NotificationTarget(RuntimeEnvironment.application, 100 /*width*/, 100 /*height*/,
viewId, remoteViews, notification, notificationId, notificationTag);
}
示例4: testLoadResource_returnsFileDescriptor
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testLoadResource_returnsFileDescriptor() throws Exception {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = Shadow.extract(contentResolver);
AssetFileDescriptor assetFileDescriptor = mock(AssetFileDescriptor.class);
ParcelFileDescriptor parcelFileDescriptor = mock(ParcelFileDescriptor.class);
when(assetFileDescriptor.getParcelFileDescriptor()).thenReturn(parcelFileDescriptor);
shadow.registerFileDescriptor(uri, assetFileDescriptor);
FileDescriptorLocalUriFetcher fetcher =
new FileDescriptorLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onDataReady(eq(parcelFileDescriptor));
}
示例5: testLoadResource_withNullFileDescriptor_callsLoadFailed
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testLoadResource_withNullFileDescriptor_callsLoadFailed() {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = Shadow.extract(contentResolver);
shadow.registerFileDescriptor(uri, null /*fileDescriptor*/);
FileDescriptorLocalUriFetcher fetcher =
new FileDescriptorLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
示例6: animations
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void animations() {
ScaleAnimation animation = new ScaleAnimation(1f, 0f, 1f, 0f);
AnimationViewBehavior behavior = new AnimationViewBehavior.Builder()
.dependsOn(firstView.getId(), SimpleViewBehavior.DEPEND_TYPE_Y)
.targetValue(100)
.animation(animation)
.build();
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(320, 200);
params.setBehavior(behavior);
secondView.setLayoutParams(params);
ShadowAnimation shadowAnimation = Shadow.extract(animation);
firstView.setY(50);
coordinatorLayout.requestLayout();
assertEquals(500L, shadowAnimation.getLastTimeGetTransform());
firstView.setY(100);
coordinatorLayout.requestLayout();
assertEquals(1000L, shadowAnimation.getLastTimeGetTransform());
}
示例7: setUp
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Before
public void setUp() {
sdkVersion = Build.VERSION.SDK_INT;
MockitoAnnotations.initMocks(this);
view = new View(RuntimeEnvironment.application);
target = new TestViewTarget(view);
shadowView = Shadow.extract(view);
shadowObserver = Shadow.extract(view.getViewTreeObserver());
}
示例8: setUp
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Before
public void setUp() {
shadowManager = (UpdateShadowAppWidgetManager) Shadow
.extract(AppWidgetManager.getInstance(RuntimeEnvironment.application));
viewId = 1234;
views = mock(RemoteViews.class);
}
示例9: testShouldDrawFirstFrameBeforeAnyFrameRead
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testShouldDrawFirstFrameBeforeAnyFrameRead() {
Canvas canvas = new Canvas();
drawable.draw(canvas);
BitmapTrackingShadowCanvas shadowCanvas =
(BitmapTrackingShadowCanvas) Shadow.extract(canvas);
assertThat(shadowCanvas.getDrawnBitmaps()).containsExactly(firstFrame);
}
示例10: testLoadResource_returnsInputStream
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testLoadResource_returnsInputStream() throws Exception {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) Shadow.extract(contentResolver);
shadow.registerInputStream(uri, new ByteArrayInputStream(new byte[0]));
StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onDataReady(isNotNull(InputStream.class));
}
示例11: testLoadResource_withNullInputStream_callsLoadFailed
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testLoadResource_withNullInputStream_callsLoadFailed() {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) Shadow.extract(contentResolver);
shadow.registerInputStream(uri, null /*inputStream*/);
StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.LOW, callback);
verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
示例12: testLoadResource_withNullFileDescriptor_callsLoadFailed
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testLoadResource_withNullFileDescriptor_callsLoadFailed() {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) Shadow.extract(contentResolver);
shadow.registerFileDescriptor(uri, null /*fileDescriptor*/);
FileDescriptorLocalUriFetcher fetcher =
new FileDescriptorLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
示例13: testByteArrayPoolSize_withLowRamDevice_isHalfTheSpecifiedBytes
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testByteArrayPoolSize_withLowRamDevice_isHalfTheSpecifiedBytes() {
LowRamActivityManager activityManager =
(LowRamActivityManager) Shadow.extract(harness.activityManager);
Util.setSdkVersionInt(19);
activityManager.setMemoryClass(getLargeEnoughMemoryClass());
activityManager.setIsLowRam(true);
int byteArrayPoolSize = harness.getCalculator().getArrayPoolSizeInBytes();
assertThat(byteArrayPoolSize).isEqualTo(harness.byteArrayPoolSizeBytes / 2);
}
示例14: setUp
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Before
public void setUp() {
sdkVersion = Build.VERSION.SDK_INT;
MockitoAnnotations.initMocks(this);
view = new View(RuntimeEnvironment.application);
target = new TestViewTarget(view);
attachStateTarget = new AttachStateTarget(view);
shadowView = Shadow.extract(view);
shadowObserver = Shadow.extract(view.getViewTreeObserver());
}
示例15: testShouldDrawFirstFrameBeforeAnyFrameRead
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testShouldDrawFirstFrameBeforeAnyFrameRead() {
Canvas canvas = new Canvas();
drawable.draw(canvas);
BitmapTrackingShadowCanvas shadowCanvas = Shadow.extract(canvas);
assertThat(shadowCanvas.getDrawnBitmaps()).containsExactly(firstFrame);
}