當前位置: 首頁>>代碼示例>>Java>>正文


Java ShadowApplication.Wrapper方法代碼示例

本文整理匯總了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));
}
 
開發者ID:PanicInitiative,項目名稱:PanicButton,代碼行數:23,代碼來源:HardwareTriggerServiceTest.java

示例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);
}
 
開發者ID:gabrielaradu,項目名稱:SpySms,代碼行數:16,代碼來源:SmsUnitTest.java

示例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));
}
 
開發者ID:ello,項目名稱:ello-android,代碼行數:10,代碼來源:MainActivityTest.java

示例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));
}
 
開發者ID:ello,項目名稱:ello-android,代碼行數:11,代碼來源:MainActivityTest.java

示例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);
}
 
開發者ID:weexteam,項目名稱:weex-analyzer-android,代碼行數:14,代碼來源:LaunchAnalyzerReceiverTest.java

示例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));
}
 
開發者ID:jameskbride,項目名稱:grocery-reminder,代碼行數:8,代碼來源:BootBroadcastReceiverTest.java

示例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;
}
 
開發者ID:jameskbride,項目名稱:grocery-reminder,代碼行數:10,代碼來源:BootBroadcastReceiverTest.java

示例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);
    }
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:8,代碼來源:MoPubViewTest.java

示例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"));
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:11,代碼來源:DefaultTestLifecycleTest.java


注:本文中的org.robolectric.shadows.ShadowApplication.Wrapper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。