Search in sources :

Example 1 with NetworkScoreManager

use of android.net.NetworkScoreManager in project robolectric by robolectric.

the class ShadowNetworkScoreManagerTest method testGetActiveScorerPackage.

@Test
@Config(minSdk = LOLLIPOP)
public void testGetActiveScorerPackage() {
    Context context = ApplicationProvider.getApplicationContext();
    NetworkScoreManager networkScoreManager = (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
    String testPackage = "com.package.test";
    networkScoreManager.setActiveScorer(testPackage);
    assertThat(networkScoreManager.getActiveScorerPackage()).isEqualTo(testPackage);
}
Also used : Context(android.content.Context) NetworkScoreManager(android.net.NetworkScoreManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 2 with NetworkScoreManager

use of android.net.NetworkScoreManager in project robolectric by robolectric.

the class ShadowNetworkScoreManagerTest method testIsScoringEnabled.

@Test
@Config(minSdk = LOLLIPOP)
public void testIsScoringEnabled() {
    Context context = ApplicationProvider.getApplicationContext();
    NetworkScoreManager networkScoreManager = (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
    networkScoreManager.disableScoring();
    ShadowNetworkScoreManager m = Shadow.extract(networkScoreManager);
    assertThat(m.isScoringEnabled()).isFalse();
}
Also used : Context(android.content.Context) NetworkScoreManager(android.net.NetworkScoreManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Context (android.content.Context)2 NetworkScoreManager (android.net.NetworkScoreManager)2 Test (org.junit.Test)2 Config (org.robolectric.annotation.Config)2