Merge "Fixing incorrect method to launch mobile data plan app." into pi-dev
am: 27441a984a
Change-Id: I90e65a96e1ca6a101d6b120006822f7dedbd24bd
This commit is contained in:
@@ -187,7 +187,7 @@ public class DataUsageSummaryPreference extends Preference {
|
|||||||
updateCarrierInfo(carrierInfo);
|
updateCarrierInfo(carrierInfo);
|
||||||
if (mLaunchIntent != null) {
|
if (mLaunchIntent != null) {
|
||||||
launchButton.setOnClickListener((view) -> {
|
launchButton.setOnClickListener((view) -> {
|
||||||
getContext().sendBroadcast(mLaunchIntent);
|
getContext().startActivity(mLaunchIntent);
|
||||||
});
|
});
|
||||||
launchButton.setVisibility(View.VISIBLE);
|
launchButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -26,6 +26,7 @@ import android.graphics.Typeface;
|
|||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -400,6 +401,31 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
assertThat(mDataRemaining.getText()).isEqualTo("");
|
assertThat(mDataRemaining.getText()).isEqualTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetAppIntent_toMdpApp_intentCorrect() {
|
||||||
|
final Activity activity = Robolectric.setupActivity(Activity.class);
|
||||||
|
final Intent intent = new Intent(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
|
||||||
|
intent.setPackage("test-owner.example.com");
|
||||||
|
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 42);
|
||||||
|
|
||||||
|
mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
|
||||||
|
intent);
|
||||||
|
|
||||||
|
bindViewHolder();
|
||||||
|
assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mLaunchButton.getText())
|
||||||
|
.isEqualTo(mContext.getString(R.string.launch_mdp_app_text));
|
||||||
|
|
||||||
|
mLaunchButton.callOnClick();
|
||||||
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
|
Intent startedIntent = shadowActivity.getNextStartedActivity();
|
||||||
|
assertThat(startedIntent.getAction())
|
||||||
|
.isEqualTo(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
|
||||||
|
assertThat(startedIntent.getPackage()).isEqualTo("test-owner.example.com");
|
||||||
|
assertThat(startedIntent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, -1))
|
||||||
|
.isEqualTo(42);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetWifiMode_withUsageInfo_dataUsageShown() {
|
public void testSetWifiMode_withUsageInfo_dataUsageShown() {
|
||||||
final int daysLeft = 3;
|
final int daysLeft = 3;
|
||||||
|
Reference in New Issue
Block a user