Update settings tests to use new constructor.

Bug: 36571359
Test: m RunSettingsRoboTests
Change-Id: Id8a722fa7627e83d3ed4840128cfca0cb03289d2
This commit is contained in:
Amin Shaikh
2017-03-24 15:48:06 -07:00
parent 510a1a696a
commit 42cee74e6b
4 changed files with 27 additions and 7 deletions

View File

@@ -23,13 +23,20 @@ public final class NetworkScorerAppData implements Parcelable {
* wifi networks automatically" feature.
*/
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,
String recommendationServiceLabel, ComponentName enableUseOpenWifiActivity) {
String recommendationServiceLabel, ComponentName enableUseOpenWifiActivity,
String networkAvailableNotificationChannelId) {
this.packageUid = packageUid;
this.mRecommendationService = recommendationServiceComp;
this.mRecommendationServiceLabel = recommendationServiceLabel;
this.mEnableUseOpenWifiActivity = enableUseOpenWifiActivity;
this.mNetworkAvailableNotificationChannelId = networkAvailableNotificationChannelId;
}
protected NetworkScorerAppData(Parcel in) {
@@ -37,6 +44,7 @@ public final class NetworkScorerAppData implements Parcelable {
mRecommendationService = ComponentName.readFromParcel(in);
mRecommendationServiceLabel = in.readString();
mEnableUseOpenWifiActivity = ComponentName.readFromParcel(in);
mNetworkAvailableNotificationChannelId = in.readString();
}
@Override
@@ -45,6 +53,7 @@ public final class NetworkScorerAppData implements Parcelable {
ComponentName.writeToParcel(mRecommendationService, dest);
dest.writeString(mRecommendationServiceLabel);
ComponentName.writeToParcel(mEnableUseOpenWifiActivity, dest);
dest.writeString(mNetworkAvailableNotificationChannelId);
}
@Override
@@ -83,6 +92,11 @@ public final class NetworkScorerAppData implements Parcelable {
return mRecommendationServiceLabel;
}
@Nullable
public String getNetworkAvailableNotificationChannelId() {
return mNetworkAvailableNotificationChannelId;
}
@Override
public String toString() {
return "NetworkScorerAppData{" +
@@ -90,6 +104,8 @@ public final class NetworkScorerAppData implements Parcelable {
", mRecommendationService=" + mRecommendationService +
", mRecommendationServiceLabel=" + mRecommendationServiceLabel +
", mEnableUseOpenWifiActivity=" + mEnableUseOpenWifiActivity +
", mNetworkAvailableNotificationChannelId=" +
mNetworkAvailableNotificationChannelId +
'}';
}
@@ -101,12 +117,14 @@ public final class NetworkScorerAppData implements Parcelable {
return packageUid == that.packageUid &&
Objects.equals(mRecommendationService, that.mRecommendationService) &&
Objects.equals(mRecommendationServiceLabel, that.mRecommendationServiceLabel) &&
Objects.equals(mEnableUseOpenWifiActivity, that.mEnableUseOpenWifiActivity);
Objects.equals(mEnableUseOpenWifiActivity, that.mEnableUseOpenWifiActivity) &&
Objects.equals(mNetworkAvailableNotificationChannelId,
that.mNetworkAvailableNotificationChannelId);
}
@Override
public int hashCode() {
return Objects.hash(packageUid, mRecommendationService, mRecommendationServiceLabel,
mEnableUseOpenWifiActivity);
mEnableUseOpenWifiActivity, mNetworkAvailableNotificationChannelId);
}
}

View File

@@ -68,7 +68,8 @@ public class NetworkScorerPickerPreferenceControllerTest {
Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 1);
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
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);
Preference preference = mock(Preference.class);

View File

@@ -118,7 +118,8 @@ public class NetworkScorerPickerTest {
public void testUpdateCandidates_validScorer() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE_1, TEST_SCORER_CLASS_1);
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(
Lists.newArrayList(scorerAppData));
when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);

View File

@@ -56,9 +56,9 @@ import org.robolectric.annotation.Config;
public class UseOpenWifiPreferenceControllerTest {
private static ComponentName ENABLE_ACTIVITY_COMPONENT = new ComponentName("package", "activityClass");
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 =
new NetworkScorerAppData(0, null, null, null);
new NetworkScorerAppData(0, null, null, null, null);
@Mock private Lifecycle mLifecycle;
@Mock private Fragment mFragment;