Codota Logo
ShadowNetworkInfo.setConnectionStatus
Code IndexAdd Codota to your IDE (free)

How to use
setConnectionStatus
method
in
org.robolectric.shadows.ShadowNetworkInfo

Best Java code snippets using org.robolectric.shadows.ShadowNetworkInfo.setConnectionStatus (Showing top 14 results out of 315)

  • Common ways to obtain ShadowNetworkInfo
private void myMethod () {
ShadowNetworkInfo s =
  • Codota IconObject instance;(ShadowNetworkInfo) Shadow.extract(instance)
  • Smart code suggestions by Codota
}
origin: robolectric/robolectric

/**
 * Sets up the return value of {@link #isConnectedOrConnecting()}, {@link #isConnected()}, and
 * {@link #getState()}. If the input is true, state will be {@link NetworkInfo.State#CONNECTED},
 * else it will be {@link NetworkInfo.State#DISCONNECTED}.
 *
 * @param isConnected the value that {@link #isConnectedOrConnecting()} and {@link #isConnected()}
 *     will return.
 * @deprecated use {@link #setConnectionStatus(NetworkInfo.State)} instead
 */
@Deprecated
public void setConnectionStatus(boolean isConnected) {
 setConnectionStatus(isConnected ? NetworkInfo.State.CONNECTED : NetworkInfo.State.DISCONNECTED);
}
origin: robolectric/robolectric

@Test
public void getActiveNetworkInfo_shouldReturnTrueCorrectly() {
 shadowOfActiveNetworkInfo.setConnectionStatus(NetworkInfo.State.CONNECTED);
 assertThat(connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting()).isTrue();
 assertThat(connectivityManager.getActiveNetworkInfo().isConnected()).isTrue();
 shadowOfActiveNetworkInfo.setConnectionStatus(NetworkInfo.State.CONNECTING);
 assertThat(connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting()).isTrue();
 assertThat(connectivityManager.getActiveNetworkInfo().isConnected()).isFalse();
 shadowOfActiveNetworkInfo.setConnectionStatus(NetworkInfo.State.DISCONNECTED);
 assertThat(connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting()).isFalse();
 assertThat(connectivityManager.getActiveNetworkInfo().isConnected()).isFalse();
}
origin: robolectric/robolectric

/** Allows developers to create a {@link NetworkInfo} instance for testing. */
public static NetworkInfo newInstance(
  NetworkInfo.DetailedState detailedState,
  int type,
  int subType,
  boolean isAvailable,
  NetworkInfo.State state) {
 NetworkInfo networkInfo = Shadow.newInstanceOf(NetworkInfo.class);
 final ShadowNetworkInfo info = Shadow.extract(networkInfo);
 info.setConnectionType(type);
 info.setSubType(subType);
 info.setDetailedState(detailedState);
 info.setAvailableStatus(isAvailable);
 info.setConnectionStatus(state);
 return networkInfo;
}
origin: firebase/firebase-jobdispatcher-android

@Test
public void testAreConstraintsSatisfied_anyNetworkRequired_satisfied() {
 JobInvocation job =
   jobBuilder.setConstraints(Constraint.uncompact(Constraint.ON_ANY_NETWORK)).build();
 shadowNetworkInfo.setConnectionStatus(/* isConnected= */ true);
 assertThat(constraintChecker.areConstraintsSatisfied(job)).isTrue();
}
origin: firebase/firebase-jobdispatcher-android

@Test
public void testAreConstraintsSatisfied_anyNetworkRequired_unsatisfied_notConnected() {
 JobInvocation job =
   jobBuilder.setConstraints(Constraint.uncompact(Constraint.ON_ANY_NETWORK)).build();
 shadowNetworkInfo.setConnectionStatus(/* isConnected= */ false);
 assertThat(constraintChecker.areConstraintsSatisfied(job)).isFalse();
}
origin: firebase/firebase-jobdispatcher-android

@Test
public void
  testAreConstraintsSatisfied_unmeteredNetworkRequired_unsatisfied_networkDisconnected() {
 JobInvocation job =
   jobBuilder.setConstraints(Constraint.uncompact(Constraint.ON_UNMETERED_NETWORK)).build();
 shadowNetworkInfo.setConnectionStatus(/* isConnected= */ false);
 setNetworkMetered(false);
 assertThat(constraintChecker.areConstraintsSatisfied(job)).isFalse();
}
origin: firebase/firebase-jobdispatcher-android

 @Test
 public void
   testAreConstraintsSatisfied_anyNetworkRequired_satisfied_includesNonNetworkConstraints() {
  JobInvocation job =
    jobBuilder
      .setConstraints(
        Constraint.uncompact(
          Constraint.DEVICE_IDLE
            | Constraint.DEVICE_CHARGING
            | Constraint.ON_ANY_NETWORK))
      .build();
  shadowNetworkInfo.setConnectionStatus(/* isConnected= */ true);

  assertThat(constraintChecker.areConstraintsSatisfied(job)).isTrue();
 }
}
origin: firebase/firebase-jobdispatcher-android

@Test
public void testAreConstraintsSatisfied_unmeteredNetworkRequired_unsatisfied_networkMetered() {
 JobInvocation job =
   jobBuilder.setConstraints(Constraint.uncompact(Constraint.ON_UNMETERED_NETWORK)).build();
 shadowNetworkInfo.setConnectionStatus(/* isConnected= */ true);
 setNetworkMetered(true);
 assertThat(constraintChecker.areConstraintsSatisfied(job)).isFalse();
}
origin: firebase/firebase-jobdispatcher-android

@Test
public void testAreConstraintsSatisfied_unmeteredNetworkRequired_satisfied() {
 JobInvocation job =
   jobBuilder.setConstraints(Constraint.uncompact(Constraint.ON_UNMETERED_NETWORK)).build();
 shadowNetworkInfo.setConnectionStatus(/* isConnected= */ true);
 setNetworkMetered(false);
 assertThat(constraintChecker.areConstraintsSatisfied(job)).isTrue();
}
origin: org.robolectric/shadows-framework

/**
 * Sets up the return value of {@link #isConnectedOrConnecting()}, {@link #isConnected()}, and
 * {@link #getState()}. If the input is true, state will be {@link NetworkInfo.State#CONNECTED},
 * else it will be {@link NetworkInfo.State#DISCONNECTED}.
 *
 * @param isConnected the value that {@link #isConnectedOrConnecting()} and {@link #isConnected()}
 *     will return.
 * @deprecated use {@link #setConnectionStatus(NetworkInfo.State)} instead
 */
@Deprecated
public void setConnectionStatus(boolean isConnected) {
 setConnectionStatus(isConnected ? NetworkInfo.State.CONNECTED : NetworkInfo.State.DISCONNECTED);
}
origin: org.robolectric/shadows-core

public static NetworkInfo newInstance(NetworkInfo.DetailedState detailedState, int type, int subType, boolean isAvailable, boolean isConnected) {
 NetworkInfo networkInfo = Shadow.newInstanceOf(NetworkInfo.class);
 final ShadowNetworkInfo info = Shadows.shadowOf(networkInfo);
 info.setConnectionType(type);
 info.setSubType(subType);
 info.setDetailedState(detailedState);
 info.setAvailableStatus(isAvailable);
 info.setConnectionStatus(isConnected);
 return networkInfo;
}
origin: org.robolectric/framework

public static NetworkInfo newInstance(NetworkInfo.DetailedState detailedState, int type, int subType, boolean isAvailable, boolean isConnected) {
 NetworkInfo networkInfo = Shadow.newInstanceOf(NetworkInfo.class);
 final ShadowNetworkInfo info = Shadows.shadowOf(networkInfo);
 info.setConnectionType(type);
 info.setSubType(subType);
 info.setDetailedState(detailedState);
 info.setAvailableStatus(isAvailable);
 info.setConnectionStatus(isConnected);
 return networkInfo;
}
origin: org.robolectric/shadows-core-v23

public static NetworkInfo newInstance(NetworkInfo.DetailedState detailedState, int type, int subType, boolean isAvailable, boolean isConnected) {
 NetworkInfo networkInfo = Shadow.newInstanceOf(NetworkInfo.class);
 final ShadowNetworkInfo info = Shadows.shadowOf(networkInfo);
 info.setConnectionType(type);
 info.setSubType(subType);
 info.setDetailedState(detailedState);
 info.setAvailableStatus(isAvailable);
 info.setConnectionStatus(isConnected);
 return networkInfo;
}
origin: org.robolectric/shadows-framework

/** Allows developers to create a {@link NetworkInfo} instance for testing. */
public static NetworkInfo newInstance(
  NetworkInfo.DetailedState detailedState,
  int type,
  int subType,
  boolean isAvailable,
  NetworkInfo.State state) {
 NetworkInfo networkInfo = Shadow.newInstanceOf(NetworkInfo.class);
 final ShadowNetworkInfo info = Shadow.extract(networkInfo);
 info.setConnectionType(type);
 info.setSubType(subType);
 info.setDetailedState(detailedState);
 info.setAvailableStatus(isAvailable);
 info.setConnectionStatus(state);
 return networkInfo;
}
org.robolectric.shadowsShadowNetworkInfosetConnectionStatus

Javadoc

Sets up the return value of #getState().

Popular methods of ShadowNetworkInfo

  • newInstance
  • setConnectionType
    Non-Android accessor Sets up the return value of #getType().
  • setDetailedState
  • setAvailableStatus
    Non-Android accessor Sets up the return value of #isAvailable().
  • setSubType
  • isConnected
  • getType

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • onRequestPermissionsResult (Fragment)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now