本文整理汇总了Java中org.robolectric.shadow.api.Shadow类的典型用法代码示例。如果您正苦于以下问题:Java Shadow类的具体用法?Java Shadow怎么用?Java Shadow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Shadow类属于org.robolectric.shadow.api包,在下文中一共展示了Shadow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:NotificationTargetTest.java
示例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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:FileDescriptorLocalUriFetcherTest.java
示例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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:NotificationTargetTest.java
示例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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:FileDescriptorLocalUriFetcherTest.java
示例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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:FileDescriptorLocalUriFetcherTest.java
示例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());
}
开发者ID:zoonooz,项目名称:simple-view-behavior,代码行数:24,代码来源:AnimationViewBehaviorTest.java
示例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());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ViewTargetTest.java
示例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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:AppWidgetTargetTest.java
示例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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:GifDrawableTest.java
示例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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamLocalUriFetcherTest.java
示例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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:StreamLocalUriFetcherTest.java
示例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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:FileDescriptorLocalUriFetcherTest.java
示例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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:MemorySizeCalculatorTest.java
示例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());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:ViewTargetTest.java
示例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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:GifDrawableTest.java
示例16: 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 = 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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamLocalUriFetcherTest.java
示例17: 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 = 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));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:StreamLocalUriFetcherTest.java
示例18: testByteArrayPoolSize_withLowRamDevice_isHalfTheSpecifiedBytes
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testByteArrayPoolSize_withLowRamDevice_isHalfTheSpecifiedBytes() {
LowRamActivityManager activityManager = Shadow.extract(harness.activityManager);
Util.setSdkVersionInt(19);
activityManager.setMemoryClass(getLargeEnoughMemoryClass());
activityManager.setIsLowRam();
int byteArrayPoolSize = harness.getCalculator().getArrayPoolSizeInBytes();
assertThat(byteArrayPoolSize).isEqualTo(harness.byteArrayPoolSizeBytes / 2);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:MemorySizeCalculatorTest.java
示例19: newInstance
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
public static NetworkCapabilities newInstance(long networkCapabilities, long transportTypes,
int linkUpBandwidthKbps, int linkDownBandwidthKbps, String networkSpecifier,
int signalStrength) {
NetworkCapabilities nc = Shadow.newInstanceOf(NetworkCapabilities.class);
final ShadowNetworkCapabilities capabilities = Shadow.extract(nc);
capabilities.mNetworkCapabilities = networkCapabilities;
capabilities.mTransportTypes = transportTypes;
capabilities.mLinkUpBandwidthKbps = linkUpBandwidthKbps;
capabilities.mLinkDownBandwidthKbps = linkDownBandwidthKbps;
capabilities.mNetworkSpecifier = networkSpecifier;
capabilities.mSignalStrength = signalStrength;
return nc;
}
开发者ID:greyfoxit,项目名称:RxNetwork,代码行数:16,代码来源:ShadowNetworkCapabilities.java
示例20: testRegisterGCMStartsBroadcastManagerAndIntentService
import org.robolectric.shadow.api.Shadow; //导入依赖的package包/类
@Test
public void testRegisterGCMStartsBroadcastManagerAndIntentService() throws ManifestValidator.InvalidManifestException {
registration.registerGCM(context, "senderId", registrationListener);
Intent expectedIntent = new Intent(context, GCMRegistrationIntentService.class);
Intent startedIntent = shadowOf(RuntimeEnvironment.application).getNextStartedService();
assertThat(startedIntent.getComponent(), equalTo(expectedIntent.getComponent()));
Bundle extras = startedIntent.getExtras();
assertEquals("senderId", extras.getString("gcm_defaultSenderId"));
ShadowLocalBroadcastManager localBroadcastManager = (ShadowLocalBroadcastManager) Shadow.extract(LocalBroadcastManager.getInstance(context));
List<ShadowLocalBroadcastManager.Wrapper> receivers = localBroadcastManager.getRegisteredBroadcastReceivers();
assertEquals(1, receivers.size());
}
开发者ID:pusher,项目名称:pusher-websocket-android,代码行数:13,代码来源:PushNotificationRegistrationTest.java
注:本文中的org.robolectric.shadow.api.Shadow类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论