### Question:
NetworkStateTracker extends ConstraintTracker<NetworkState> { @Override public void startTracking() { if (isNetworkCallbackSupported()) { Log.d(TAG, "Registering network callback"); mConnectivityManager.registerDefaultNetworkCallback(mNetworkCallback); } else { Log.d(TAG, "Registering broadcast receiver"); mAppContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } } NetworkStateTracker(Context context); @Override NetworkState getInitialState(); @Override void startTracking(); @Override void stopTracking();  }### Answer:
@Test @SmallTest @SdkSuppress(minSdkVersion = 24) public void testStartTracking_afterApi24() { mTracker.startTracking(); verify(mMockConnectivityManager) .registerDefaultNetworkCallback(any(ConnectivityManager.NetworkCallback.class)); }
@Test @SmallTest @SdkSuppress(maxSdkVersion = 23) public void testStartTracking_beforeApi24() { mTracker.startTracking(); ArgumentCaptor<IntentFilter> argCaptor = ArgumentCaptor.forClass(IntentFilter.class); verify(mMockContext).registerReceiver(any(BroadcastReceiver.class), argCaptor.capture()); IntentFilter intentFilter = argCaptor.getValue(); assertThat(intentFilter.hasAction(ConnectivityManager.CONNECTIVITY_ACTION), is(true)); assertThat(intentFilter.countActions(), is(1)); }