Update settings tests to use new constructor.
Bug: 36571359 Test: m RunSettingsRoboTests Change-Id: Id8a722fa7627e83d3ed4840128cfca0cb03289d2
This commit is contained in:
@@ -23,13 +23,20 @@ public final class NetworkScorerAppData implements Parcelable {
|
|||||||
* wifi networks automatically" feature.
|
* wifi networks automatically" feature.
|
||||||
*/
|
*/
|
||||||
private final ComponentName mEnableUseOpenWifiActivity;
|
private final ComponentName mEnableUseOpenWifiActivity;
|
||||||
|
/**
|
||||||
|
* The {@link android.app.NotificationChannel} ID used by {@link #mRecommendationService} to
|
||||||
|
* post open network notifications.
|
||||||
|
*/
|
||||||
|
private final String mNetworkAvailableNotificationChannelId;
|
||||||
|
|
||||||
public NetworkScorerAppData(int packageUid, ComponentName recommendationServiceComp,
|
public NetworkScorerAppData(int packageUid, ComponentName recommendationServiceComp,
|
||||||
String recommendationServiceLabel, ComponentName enableUseOpenWifiActivity) {
|
String recommendationServiceLabel, ComponentName enableUseOpenWifiActivity,
|
||||||
|
String networkAvailableNotificationChannelId) {
|
||||||
this.packageUid = packageUid;
|
this.packageUid = packageUid;
|
||||||
this.mRecommendationService = recommendationServiceComp;
|
this.mRecommendationService = recommendationServiceComp;
|
||||||
this.mRecommendationServiceLabel = recommendationServiceLabel;
|
this.mRecommendationServiceLabel = recommendationServiceLabel;
|
||||||
this.mEnableUseOpenWifiActivity = enableUseOpenWifiActivity;
|
this.mEnableUseOpenWifiActivity = enableUseOpenWifiActivity;
|
||||||
|
this.mNetworkAvailableNotificationChannelId = networkAvailableNotificationChannelId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NetworkScorerAppData(Parcel in) {
|
protected NetworkScorerAppData(Parcel in) {
|
||||||
@@ -37,6 +44,7 @@ public final class NetworkScorerAppData implements Parcelable {
|
|||||||
mRecommendationService = ComponentName.readFromParcel(in);
|
mRecommendationService = ComponentName.readFromParcel(in);
|
||||||
mRecommendationServiceLabel = in.readString();
|
mRecommendationServiceLabel = in.readString();
|
||||||
mEnableUseOpenWifiActivity = ComponentName.readFromParcel(in);
|
mEnableUseOpenWifiActivity = ComponentName.readFromParcel(in);
|
||||||
|
mNetworkAvailableNotificationChannelId = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,6 +53,7 @@ public final class NetworkScorerAppData implements Parcelable {
|
|||||||
ComponentName.writeToParcel(mRecommendationService, dest);
|
ComponentName.writeToParcel(mRecommendationService, dest);
|
||||||
dest.writeString(mRecommendationServiceLabel);
|
dest.writeString(mRecommendationServiceLabel);
|
||||||
ComponentName.writeToParcel(mEnableUseOpenWifiActivity, dest);
|
ComponentName.writeToParcel(mEnableUseOpenWifiActivity, dest);
|
||||||
|
dest.writeString(mNetworkAvailableNotificationChannelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -83,6 +92,11 @@ public final class NetworkScorerAppData implements Parcelable {
|
|||||||
return mRecommendationServiceLabel;
|
return mRecommendationServiceLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getNetworkAvailableNotificationChannelId() {
|
||||||
|
return mNetworkAvailableNotificationChannelId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "NetworkScorerAppData{" +
|
return "NetworkScorerAppData{" +
|
||||||
@@ -90,6 +104,8 @@ public final class NetworkScorerAppData implements Parcelable {
|
|||||||
", mRecommendationService=" + mRecommendationService +
|
", mRecommendationService=" + mRecommendationService +
|
||||||
", mRecommendationServiceLabel=" + mRecommendationServiceLabel +
|
", mRecommendationServiceLabel=" + mRecommendationServiceLabel +
|
||||||
", mEnableUseOpenWifiActivity=" + mEnableUseOpenWifiActivity +
|
", mEnableUseOpenWifiActivity=" + mEnableUseOpenWifiActivity +
|
||||||
|
", mNetworkAvailableNotificationChannelId=" +
|
||||||
|
mNetworkAvailableNotificationChannelId +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,12 +117,14 @@ public final class NetworkScorerAppData implements Parcelable {
|
|||||||
return packageUid == that.packageUid &&
|
return packageUid == that.packageUid &&
|
||||||
Objects.equals(mRecommendationService, that.mRecommendationService) &&
|
Objects.equals(mRecommendationService, that.mRecommendationService) &&
|
||||||
Objects.equals(mRecommendationServiceLabel, that.mRecommendationServiceLabel) &&
|
Objects.equals(mRecommendationServiceLabel, that.mRecommendationServiceLabel) &&
|
||||||
Objects.equals(mEnableUseOpenWifiActivity, that.mEnableUseOpenWifiActivity);
|
Objects.equals(mEnableUseOpenWifiActivity, that.mEnableUseOpenWifiActivity) &&
|
||||||
|
Objects.equals(mNetworkAvailableNotificationChannelId,
|
||||||
|
that.mNetworkAvailableNotificationChannelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(packageUid, mRecommendationService, mRecommendationServiceLabel,
|
return Objects.hash(packageUid, mRecommendationService, mRecommendationServiceLabel,
|
||||||
mEnableUseOpenWifiActivity);
|
mEnableUseOpenWifiActivity, mNetworkAvailableNotificationChannelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,8 @@ public class NetworkScorerPickerPreferenceControllerTest {
|
|||||||
Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 1);
|
Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 1);
|
||||||
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
|
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
|
||||||
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(
|
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(
|
||||||
0, scorer, TEST_SCORER_LABEL, null /* enableUseOpenWifiActivity */);
|
0, scorer, TEST_SCORER_LABEL, null /* enableUseOpenWifiActivity */,
|
||||||
|
null /* networkAvailableNotificationChannelId */);
|
||||||
when(mNetworkScorer.getActiveScorer()).thenReturn(scorerAppData);
|
when(mNetworkScorer.getActiveScorer()).thenReturn(scorerAppData);
|
||||||
Preference preference = mock(Preference.class);
|
Preference preference = mock(Preference.class);
|
||||||
|
|
||||||
|
@@ -118,7 +118,8 @@ public class NetworkScorerPickerTest {
|
|||||||
public void testUpdateCandidates_validScorer() {
|
public void testUpdateCandidates_validScorer() {
|
||||||
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE_1, TEST_SCORER_CLASS_1);
|
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE_1, TEST_SCORER_CLASS_1);
|
||||||
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(
|
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(
|
||||||
0, scorer, TEST_SCORER_LABEL_1, null /* enableUseOpenWifiActivity */);
|
0, scorer, TEST_SCORER_LABEL_1, null /* enableUseOpenWifiActivity */,
|
||||||
|
null /* networkAvailableNotificationChannelId */);
|
||||||
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(
|
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(
|
||||||
Lists.newArrayList(scorerAppData));
|
Lists.newArrayList(scorerAppData));
|
||||||
when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);
|
when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);
|
||||||
|
@@ -56,9 +56,9 @@ import org.robolectric.annotation.Config;
|
|||||||
public class UseOpenWifiPreferenceControllerTest {
|
public class UseOpenWifiPreferenceControllerTest {
|
||||||
private static ComponentName ENABLE_ACTIVITY_COMPONENT = new ComponentName("package", "activityClass");
|
private static ComponentName ENABLE_ACTIVITY_COMPONENT = new ComponentName("package", "activityClass");
|
||||||
private static NetworkScorerAppData APP_DATA =
|
private static NetworkScorerAppData APP_DATA =
|
||||||
new NetworkScorerAppData(0, null, null, ENABLE_ACTIVITY_COMPONENT);
|
new NetworkScorerAppData(0, null, null, ENABLE_ACTIVITY_COMPONENT, null);
|
||||||
private static NetworkScorerAppData APP_DATA_NO_ACTIVITY =
|
private static NetworkScorerAppData APP_DATA_NO_ACTIVITY =
|
||||||
new NetworkScorerAppData(0, null, null, null);
|
new NetworkScorerAppData(0, null, null, null, null);
|
||||||
|
|
||||||
@Mock private Lifecycle mLifecycle;
|
@Mock private Lifecycle mLifecycle;
|
||||||
@Mock private Fragment mFragment;
|
@Mock private Fragment mFragment;
|
||||||
|
Reference in New Issue
Block a user