本文整理匯總了Java中org.robolectric.shadows.ShadowApplication.Wrapper方法的典型用法代碼示例。如果您正苦於以下問題:Java ShadowApplication.Wrapper方法的具體用法?Java ShadowApplication.Wrapper怎麽用?Java ShadowApplication.Wrapper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.robolectric.shadows.ShadowApplication
的用法示例。
在下文中一共展示了ShadowApplication.Wrapper方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldRegisterHardwareTriggerListener
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void shouldRegisterHardwareTriggerListener() {
HardwareTriggerService hardwareTriggerService = new HardwareTriggerService();
hardwareTriggerService.onCreate();
hardwareTriggerService.onBind(null);
ShadowApplication shadowApplication = shadowOf(Robolectric.application);
List<ShadowApplication.Wrapper> registeredReceivers = shadowApplication.getRegisteredReceivers();
ShadowApplication.Wrapper hardwareReceiverWrapper = null;
for (ShadowApplication.Wrapper registeredReceiver : registeredReceivers) {
if (registeredReceiver.getBroadcastReceiver().getClass().equals(HardwareTriggerReceiver.class)) {
hardwareReceiverWrapper = registeredReceiver;
}
}
assertNotNull(hardwareReceiverWrapper);
IntentFilter intentFilter = hardwareReceiverWrapper.getIntentFilter();
assertEquals(Intent.ACTION_SCREEN_ON, intentFilter.getAction(0));
assertEquals(Intent.ACTION_SCREEN_OFF, intentFilter.getAction(1));
}
示例2: testBroadcastReceiverRegistered
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void testBroadcastReceiverRegistered() {
List<ShadowApplication.Wrapper> registeredReceivers = ShadowApplication.getInstance().getRegisteredReceivers();
assertFalse(registeredReceivers.isEmpty());
boolean receiverFound = false;
for (ShadowApplication.Wrapper wrapper : registeredReceivers) {
if (!receiverFound)
receiverFound = IncomingSmsReceiver.class.getSimpleName().equals(
wrapper.broadcastReceiver.getClass().getSimpleName());
}
// False if not found
Assert.assertTrue(receiverFound);
}
示例3: registersReceiverForDeviceRegistered
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void registersReceiverForDeviceRegistered() throws Exception {
List<ShadowApplication.Wrapper> registeredReceivers = ShadowApplication.getInstance().getRegisteredReceivers();
Assert.assertEquals(false, registeredReceivers.isEmpty());
Intent intent = new Intent(ElloPreferences.REGISTRATION_COMPLETE);
ShadowApplication shadowApplication = ShadowApplication.getInstance();
assertTrue("is registered for REGISTRATION_COMPLETE", shadowApplication.hasReceiverForIntent(intent));
}
示例4: registersReceiverForPushNotifications
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void registersReceiverForPushNotifications() throws Exception {
List<ShadowApplication.Wrapper> registeredReceivers = ShadowApplication.getInstance().getRegisteredReceivers();
Assert.assertEquals(false, registeredReceivers.isEmpty());
Intent intent = new Intent(ElloPreferences.PUSH_RECEIVED);
ShadowApplication shadowApplication = ShadowApplication.getInstance();
assertTrue("is registered for PUSH_RECEIVED", shadowApplication.hasReceiverForIntent(intent));
}
示例5: testReceiverRegistered
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void testReceiverRegistered() {
List<ShadowApplication.Wrapper> registeredList = ShadowApplication.getInstance().getRegisteredReceivers();
assertFalse(registeredList.isEmpty());
boolean found = false;
for(ShadowApplication.Wrapper wrapper : registeredList) {
if(wrapper.broadcastReceiver.getClass().getSimpleName().equals(LaunchAnalyzerReceiver.class.getSimpleName())) {
found = true;
break;
}
}
assertTrue(found);
}
示例6: givenTheApplicationIsConfiguredThenTheBootBroadcastReceiverIsRegistered
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void givenTheApplicationIsConfiguredThenTheBootBroadcastReceiverIsRegistered() {
List<ShadowApplication.Wrapper> registeredReceivers = Shadows.shadowOf(RuntimeEnvironment.application).getRegisteredReceivers();
assertFalse(registeredReceivers.isEmpty());
assertTrue(isBootBroadcastReceiverRegistered(registeredReceivers));
}
示例7: isBootBroadcastReceiverRegistered
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
private boolean isBootBroadcastReceiverRegistered(List<ShadowApplication.Wrapper> registeredReceivers) {
boolean receiverFound = false;
for (ShadowApplication.Wrapper wrapper : registeredReceivers) {
if (!receiverFound)
receiverFound = BootBroadcastReceiver.class.getSimpleName().equals(
wrapper.broadcastReceiver.getClass().getSimpleName());
}
return receiverFound;
}
示例8: broadcastIntent
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
private void broadcastIntent(final Intent intent) {
final List<ShadowApplication.Wrapper> wrappers = Robolectric.getShadowApplication().getRegisteredReceivers();
for (final ShadowApplication.Wrapper wrapper : wrappers) {
wrapper.broadcastReceiver.onReceive(context, intent);
}
}
示例9: shouldRegisterReceiversFromTheManifest
import org.robolectric.shadows.ShadowApplication; //導入方法依賴的package包/類
@Test
public void shouldRegisterReceiversFromTheManifest() throws Exception {
AndroidManifest appManifest = newConfig("TestAndroidManifestWithReceivers.xml");
Application application = defaultTestLifecycle.createApplication(null, appManifest);
shadowOf(application).bind(appManifest, null);
List<ShadowApplication.Wrapper> receivers = shadowOf(application).getRegisteredReceivers();
assertThat(receivers.size()).isEqualTo(6);
assertTrue(receivers.get(0).intentFilter.matchAction("org.robolectric.ACTION1"));
}