Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27441a98 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixing incorrect method to launch mobile data plan app." into pi-dev

parents e898c758 d4c79736
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class DataUsageSummaryPreference extends Preference {
            updateCarrierInfo(carrierInfo);
            if (mLaunchIntent != null) {
                launchButton.setOnClickListener((view) -> {
                    getContext().sendBroadcast(mLaunchIntent);
                    getContext().startActivity(mLaunchIntent);
                });
                launchButton.setVisibility(View.VISIBLE);
            } else {
+26 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Typeface;
import android.net.NetworkTemplate;
import android.os.Bundle;
import android.support.v7.preference.PreferenceViewHolder;
import android.telephony.SubscriptionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -400,6 +401,31 @@ public class DataUsageSummaryPreferenceTest {
        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
    public void testSetWifiMode_withUsageInfo_dataUsageShown() {
        final int daysLeft = 3;