[Settings] Code refactor
1. Fix comments 2. Split test case Bug: 147338143 Test: make RunSettingsRoboTests ROBOTEST_FILTER=DataUsageListTest Change-Id: I017a3ac8a716e69eb4d9c3e30e20363a215563a2
This commit is contained in:
@@ -96,7 +96,7 @@ public class BillingCyclePreference extends Preference
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of MobileDataEnabledListener.Client
|
* Implementation of {@code MobileDataEnabledListener.Client}
|
||||||
*/
|
*/
|
||||||
public void onMobileDataEnabledChange() {
|
public void onMobileDataEnabledChange() {
|
||||||
updateEnabled();
|
updateEnabled();
|
||||||
|
@@ -240,7 +240,7 @@ public class CellDataPreference extends CustomDialogPreferenceCompat
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of MobileDataEnabledListener.Client
|
* Implementation of {@code MobileDataEnabledListener.Client}
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void onMobileDataEnabledChange() {
|
public void onMobileDataEnabledChange() {
|
||||||
|
@@ -201,7 +201,6 @@ public class DataUsageList extends DataUsageBaseFragment
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
mUidDetailProvider.clearCache();
|
mUidDetailProvider.clearCache();
|
||||||
mUidDetailProvider = null;
|
mUidDetailProvider = null;
|
||||||
mDataStateListener.stop();
|
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
@@ -232,7 +231,7 @@ public class DataUsageList extends DataUsageBaseFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of MobileDataEnabledListener.Client
|
* Implementation of {@code MobileDataEnabledListener.Client}
|
||||||
*/
|
*/
|
||||||
public void onMobileDataEnabledChange() {
|
public void onMobileDataEnabledChange() {
|
||||||
updatePolicy();
|
updatePolicy();
|
||||||
|
@@ -78,7 +78,7 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
|
|||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
|
||||||
// enable ProxySubscriptionMgr with Lifecycle support for all controllers
|
// Enable ProxySubscriptionMgr with Lifecycle support for all controllers
|
||||||
// live within this fragment
|
// live within this fragment
|
||||||
mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(context);
|
mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(context);
|
||||||
mProxySubscriptionMgr.setLifecycle(getLifecycle());
|
mProxySubscriptionMgr.setLifecycle(getLifecycle());
|
||||||
|
@@ -25,12 +25,12 @@ public class MobileDataEnabledListener {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Client mClient;
|
private Client mClient;
|
||||||
private int mSubId;
|
private int mSubId;
|
||||||
/**
|
|
||||||
* There're 2 listeners both activated at the same time.
|
// There're 2 listeners both activated at the same time.
|
||||||
* For project that access MOBILE_DATA, only first listener is functional.
|
// For project that access MOBILE_DATA, only first listener is functional.
|
||||||
* For project that access "MOBILE_DATA + subId", first listener will be stopped when receiving
|
// For project that access "MOBILE_DATA + subId", first listener will be stopped when receiving
|
||||||
* any onChange from second listener.
|
// any onChange from second listener.
|
||||||
*/
|
|
||||||
private GlobalSettingsChangeListener mListener;
|
private GlobalSettingsChangeListener mListener;
|
||||||
private GlobalSettingsChangeListener mListenerForSubId;
|
private GlobalSettingsChangeListener mListenerForSubId;
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ public class DataUsageListTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resumePause_shouldListenUnlistenDataStateChange() {
|
public void resume_shouldListenDataStateChange() {
|
||||||
ReflectionHelpers.setField(
|
ReflectionHelpers.setField(
|
||||||
mDataUsageList, "mVisibilityLoggerMixin", mock(VisibilityLoggerMixin.class));
|
mDataUsageList, "mVisibilityLoggerMixin", mock(VisibilityLoggerMixin.class));
|
||||||
ReflectionHelpers.setField(
|
ReflectionHelpers.setField(
|
||||||
@@ -104,6 +104,17 @@ public class DataUsageListTest {
|
|||||||
verify(mMobileDataEnabledListener).start(anyInt());
|
verify(mMobileDataEnabledListener).start(anyInt());
|
||||||
|
|
||||||
mDataUsageList.onPause();
|
mDataUsageList.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void pause_shouldUnlistenDataStateChange() {
|
||||||
|
ReflectionHelpers.setField(
|
||||||
|
mDataUsageList, "mVisibilityLoggerMixin", mock(VisibilityLoggerMixin.class));
|
||||||
|
ReflectionHelpers.setField(
|
||||||
|
mDataUsageList, "mPreferenceManager", mock(PreferenceManager.class));
|
||||||
|
|
||||||
|
mDataUsageList.onResume();
|
||||||
|
mDataUsageList.onPause();
|
||||||
|
|
||||||
verify(mMobileDataEnabledListener).stop();
|
verify(mMobileDataEnabledListener).stop();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user