• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ShadowLocationManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.robolectric.shadows.ShadowLocationManager的典型用法代码示例。如果您正苦于以下问题:Java ShadowLocationManager类的具体用法?Java ShadowLocationManager怎么用?Java ShadowLocationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ShadowLocationManager类属于org.robolectric.shadows包,在下文中一共展示了ShadowLocationManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: disableLocationCollection_whenLocationServiceHasMostRecentLocation_shouldNotIncludeLocationInUrl

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void disableLocationCollection_whenLocationServiceHasMostRecentLocation_shouldNotIncludeLocationInUrl() {
    MoPub.setLocationAwareness(MoPub.LocationAwareness.DISABLED);
    subject = new NativeUrlGenerator(context);

    // Mock out the LocationManager's last known location.
    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));
    Location locationFromSdk = new Location("");
    locationFromSdk.setLatitude(37);
    locationFromSdk.setLongitude(-122);
    locationFromSdk.setAccuracy(5.0f);
    locationFromSdk.setTime(2000);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, locationFromSdk);

    String requestString = generateMinimumUrlString();
    assertThat(getParameterFromRequestUrl(requestString, "ll")).isNullOrEmpty();
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:19,代码来源:NativeUrlGeneratorTest.java


示例2: generateAdUrl_whenLocationServiceGpsProviderHasMostRecentLocation_shouldUseLocationServiceValue

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void generateAdUrl_whenLocationServiceGpsProviderHasMostRecentLocation_shouldUseLocationServiceValue() {
    Location locationFromDeveloper = new Location("");
    locationFromDeveloper.setLatitude(42);
    locationFromDeveloper.setLongitude(-42);
    locationFromDeveloper.setAccuracy(3.5f);
    locationFromDeveloper.setTime(1000);

    // Mock out the LocationManager's last known location to be more recent than the
    // developer-supplied location.
    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));
    Location locationFromSdk = new Location("");
    locationFromSdk.setLatitude(37);
    locationFromSdk.setLongitude(-122);
    locationFromSdk.setAccuracy(5.0f);
    locationFromSdk.setTime(2000);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, locationFromSdk);

    String adUrl = subject.withLocation(locationFromDeveloper)
            .generateUrlString("ads.mopub.com");
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isEqualTo("37.0,-122.0");
    assertThat(getParameterFromRequestUrl(adUrl, "lla")).isEqualTo("5");
    assertThat(getParameterFromRequestUrl(adUrl, "llsdk")).isEqualTo("1");
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:26,代码来源:WebViewAdUrlGeneratorTest.java


示例3: Location

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void generateAdUrl_whenDeveloperSuppliesMoreRecentLocationThanLocationService_shouldUseDeveloperSuppliedLocation() {
    Location locationFromDeveloper = new Location("");
    locationFromDeveloper.setLatitude(42);
    locationFromDeveloper.setLongitude(-42);
    locationFromDeveloper.setAccuracy(3.5f);
    locationFromDeveloper.setTime(1000);

    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));

    // Mock out the LocationManager's last known location to be older than the
    // developer-supplied location.
    Location olderLocation = new Location("");
    olderLocation.setLatitude(40);
    olderLocation.setLongitude(-105);
    olderLocation.setAccuracy(8.0f);
    olderLocation.setTime(500);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, olderLocation);

    String adUrl = subject.withLocation(locationFromDeveloper)
            .generateUrlString("ads.mopub.com");
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isEqualTo("42.0,-42.0");
    assertThat(getParameterFromRequestUrl(adUrl, "lla")).isEqualTo("3");
    assertThat(getParameterFromRequestUrl(adUrl, "llsdk")).isEmpty();
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:27,代码来源:WebViewAdUrlGeneratorTest.java


示例4: generateAdUrl_whenLocationServiceNetworkProviderHasMostRecentLocation_shouldUseLocationServiceValue

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void generateAdUrl_whenLocationServiceNetworkProviderHasMostRecentLocation_shouldUseLocationServiceValue() {
    Location locationFromDeveloper = new Location("");
    locationFromDeveloper.setLatitude(42);
    locationFromDeveloper.setLongitude(-42);
    locationFromDeveloper.setAccuracy(3.5f);
    locationFromDeveloper.setTime(1000);

    // Mock out the LocationManager's last known location to be more recent than the
    // developer-supplied location.
    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));
    Location locationFromSdk = new Location("");
    locationFromSdk.setLatitude(38);
    locationFromSdk.setLongitude(-123);
    locationFromSdk.setAccuracy(5.0f);
    locationFromSdk.setTime(2000);
    shadowLocationManager.setLastKnownLocation(LocationManager.NETWORK_PROVIDER,
            locationFromSdk);

    String adUrl = subject.withLocation(locationFromDeveloper)
            .generateUrlString("ads.mopub.com");
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isEqualTo("38.0,-123.0");
    assertThat(getParameterFromRequestUrl(adUrl, "lla")).isEqualTo("5");
    assertThat(getParameterFromRequestUrl(adUrl, "llsdk")).isEqualTo("1");
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:27,代码来源:WebViewAdUrlGeneratorTest.java


示例5: disableLocationCollection_whenLocationServiceHasMostRecentLocation_shouldNotIncludeLocationInUrl

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void disableLocationCollection_whenLocationServiceHasMostRecentLocation_shouldNotIncludeLocationInUrl() {
    MoPub.setLocationAwareness(MoPub.LocationAwareness.DISABLED);

    // Mock out the LocationManager's last known location.
    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));
    Location locationFromSdk = new Location("");
    locationFromSdk.setLatitude(37);
    locationFromSdk.setLongitude(-122);
    locationFromSdk.setAccuracy(5.0f);
    locationFromSdk.setTime(2000);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, locationFromSdk);

    String adUrl = generateMinimumUrlString();
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isNullOrEmpty();
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:18,代码来源:WebViewAdUrlGeneratorTest.java


示例6: generateUrlString_whenLocationServiceGpsProviderHasMostRecentLocation_shouldUseLocationServiceValue

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void generateUrlString_whenLocationServiceGpsProviderHasMostRecentLocation_shouldUseLocationServiceValue() {
    Location locationFromDeveloper = new Location("");
    locationFromDeveloper.setLatitude(42);
    locationFromDeveloper.setLongitude(-42);
    locationFromDeveloper.setAccuracy(3.5f);
    locationFromDeveloper.setTime(1000);

    // Mock out the LocationManager's last known location to be more recent than the
    // developer-supplied location.
    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));
    Location locationFromSdk = new Location("");
    locationFromSdk.setLatitude(37);
    locationFromSdk.setLongitude(-122);
    locationFromSdk.setAccuracy(5.0f);
    locationFromSdk.setTime(System.currentTimeMillis() - 555555);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, locationFromSdk);

    RequestParameters requestParameters = new RequestParameters.Builder()
            .location(locationFromDeveloper)
            .build();
    subject = new NativeUrlGenerator(context).withAdUnitId(AD_UNIT_ID);
    String adUrl = subject.withRequest(requestParameters)
            .generateUrlString("ads.mopub.com");
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isEqualTo("37.0,-122.0");
    assertThat(getParameterFromRequestUrl(adUrl, "lla")).isEqualTo("5");
    assertThat(getParameterFromRequestUrl(adUrl, "llsdk")).isEqualTo("1");
    // Only test to the full second (as there may be small differences)
    assertThat(getParameterFromRequestUrl(adUrl, "llf")).startsWith("555");
    assertThat(getParameterFromRequestUrl(adUrl, "llf").length()).isEqualTo(6);
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:33,代码来源:NativeUrlGeneratorTest.java


示例7: Location

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void generateUrlString_whenDeveloperSuppliesMoreRecentLocationThanLocationService_shouldUseDeveloperSuppliedLocation() {
    Location locationFromDeveloper = new Location("");
    locationFromDeveloper.setLatitude(42);
    locationFromDeveloper.setLongitude(-42);
    locationFromDeveloper.setAccuracy(3.5f);
    locationFromDeveloper.setTime(System.currentTimeMillis() - 777777);

    ShadowLocationManager shadowLocationManager = Robolectric.shadowOf(
            (LocationManager) application.getSystemService(Context.LOCATION_SERVICE));

    // Mock out the LocationManager's last known location to be older than the
    // developer-supplied location.
    Location olderLocation = new Location("");
    olderLocation.setLatitude(40);
    olderLocation.setLongitude(-105);
    olderLocation.setAccuracy(8.0f);
    olderLocation.setTime(System.currentTimeMillis() - 888888);
    shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, olderLocation);

    RequestParameters requestParameters = new RequestParameters.Builder()
            .location(locationFromDeveloper)
            .build();
    subject = new NativeUrlGenerator(context).withAdUnitId(AD_UNIT_ID);
    String adUrl = subject.withRequest(requestParameters)
            .generateUrlString("ads.mopub.com");
    assertThat(getParameterFromRequestUrl(adUrl, "ll")).isEqualTo("42.0,-42.0");
    assertThat(getParameterFromRequestUrl(adUrl, "lla")).isEqualTo("3");
    assertThat(getParameterFromRequestUrl(adUrl, "llsdk")).isEmpty();
    // Only test to the full second (as there may be small differences)
    assertThat(getParameterFromRequestUrl(adUrl, "llf")).startsWith("777");
    assertThat(getParameterFromRequestUrl(adUrl, "llf").length()).isEqualTo(6);
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:34,代码来源:NativeUrlGeneratorTest.java


示例8: shouldReturnTheLatestLocation

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Ignore
@Test
public void shouldReturnTheLatestLocation() {
    LocationManager locationManager = (LocationManager)
            RuntimeEnvironment.application.getSystemService(Context.LOCATION_SERVICE);
    ShadowLocationManager shadowLocationManager = Shadows.shadowOf(locationManager);
    Location expectedLocation = location(LocationManager.GPS_PROVIDER, 12.0, 20.0);

    shadowLocationManager.simulateLocation(expectedLocation);
    // -- todo
    assertEquals(expectedLocation.getLatitude(), skyLinesApp.lastLat);
    assertEquals(expectedLocation.getLongitude(), skyLinesApp.lastLon);

    //assertEquals(expectedLocation, actualLocation);
}
 
开发者ID:ubx,项目名称:SkyLinesTracker,代码行数:16,代码来源:MainActivityGPSTest.java


示例9: onResume_shouldCheckIfConnectedBeforeConnectingAgain

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void onResume_shouldCheckIfConnectedBeforeConnectingAgain() throws Exception {
    ShadowLocationManager shadowLocationManager = shadowOf(getLocationManager());
    List<android.location.LocationListener>
            listeners = shadowLocationManager.getRequestLocationUpdateListeners();
    for (android.location.LocationListener listener : listeners) {
        shadowLocationManager.removeUpdates(listener);
    }

    activity.locationClient.connect();
    activity.onResume();
    assertThat(shadowLocationManager.getRequestLocationUpdateListeners()).hasSize(2);
}
 
开发者ID:mapzen,项目名称:open,代码行数:14,代码来源:BaseActivityTest.java


示例10: onRoutePreviewEvent_shouldDisplayGPSPromptIfNotEnabled

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
@Test
public void onRoutePreviewEvent_shouldDisplayGPSPromptIfNotEnabled() throws Exception {
    ShadowLocationManager manager = shadowOf(getLocationManager());
    manager.setProviderEnabled(LocationManager.GPS_PROVIDER, false);
    activity.onRoutePreviewEvent(new RoutePreviewEvent(getTestSimpleFeature()));
    assertThat(activity.getSupportFragmentManager()).hasFragmentWithTag("gps_dialog");
}
 
开发者ID:mapzen,项目名称:open,代码行数:8,代码来源:BaseActivityTest.java


示例11: shadowOf

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
public static ShadowLocationManager shadowOf(LocationManager instance) {
  return (ShadowLocationManager) shadowOf_(instance);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java


示例12: initLastKnownLocation

import org.robolectric.shadows.ShadowLocationManager; //导入依赖的package包/类
public static void initLastKnownLocation() {
    LocationManager locationManager = (LocationManager)
            application.getSystemService(LOCATION_SERVICE);
    ShadowLocationManager shadowLocationManager = shadowOf(locationManager);
    shadowLocationManager.setLastKnownLocation(GPS_PROVIDER, new Location(GPS_PROVIDER));
}
 
开发者ID:mapzen,项目名称:open,代码行数:7,代码来源:TestHelper.java



注:本文中的org.robolectric.shadows.ShadowLocationManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSSimpleTypeDefinition类代码示例发布时间:2022-05-23
下一篇:
Java MarathonException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap