DO NOT MERGE - Merge build QP1A.190711.019 into stage-aosp-master

Bug: 139893257
Change-Id: I54b340294458df6016b7893838e1b0f6e61daf11
This commit is contained in:
Xin Li
2019-08-23 06:45:17 +00:00
12 changed files with 142 additions and 25 deletions

View File

@@ -163,7 +163,7 @@ public class MasterClearTest {
verify(context).startActivity(intent.capture());
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
.isFalse();
.isTrue();
}
@Test

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
import android.os.SystemProperties;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class RegulatoryInfoDisplayActivityTest {
private static final String SKU_PROP_KEY = "ro.boot.hardware.sku";
private static final String COO_PROP_KEY = "ro.boot.hardware.coo";
private RegulatoryInfoDisplayActivity mRegulatoryInfoDisplayActivity;
@Before
public void setUp() {
mRegulatoryInfoDisplayActivity = Robolectric.buildActivity(
RegulatoryInfoDisplayActivity.class).create().get();
}
@Test
public void getResourceId_noSkuProperty_shouldReturnDefaultLabel() {
SystemProperties.set(SKU_PROP_KEY, "");
final int expectedResId = getResourceId("regulatory_info");
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
}
@Test
public void getResourceId_noCooProperty_shouldReturnSkuLabel() {
SystemProperties.set(SKU_PROP_KEY, "sku");
SystemProperties.set(COO_PROP_KEY, "");
final int expectedResId = getResourceId("regulatory_info_sku");
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
}
@Test
public void getResourceId_hasSkuAndCooProperties_shouldReturnCooLabel() {
SystemProperties.set(SKU_PROP_KEY, "sku1");
SystemProperties.set(COO_PROP_KEY, "coo");
final int expectedResId = getResourceId("regulatory_info_sku1_coo");
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
}
@Test
public void getResourceId_noCorrespondingCooLabel_shouldReturnSkuLabel() {
SystemProperties.set(SKU_PROP_KEY, "sku");
SystemProperties.set(COO_PROP_KEY, "unknown");
final int expectedResId = getResourceId("regulatory_info_sku");
assertThat(mRegulatoryInfoDisplayActivity.getResourceId()).isEqualTo(expectedResId);
}
private int getResourceId(String resourceName) {
return mRegulatoryInfoDisplayActivity.getResources().getIdentifier(resourceName, "drawable",
mRegulatoryInfoDisplayActivity.getPackageName());
}
}

View File

@@ -56,8 +56,7 @@ public class GameDriverAppPreferenceControllerTest {
private static final int DEFAULT = 0;
private static final int GAME_DRIVER = 1;
private static final int PRERELEASE_DRIVER = 2;
private static final int SYSTEM = 3;
private static final int SYSTEM = 2;
private static final String TEST_APP_NAME = "testApp";
private static final String TEST_PKG_NAME = "testPkg";
@@ -80,6 +79,7 @@ public class GameDriverAppPreferenceControllerTest {
private GameDriverAppPreferenceController mController;
private CharSequence[] mValueList;
private String mDialogTitle;
private String mPreferencePrereleaseDriver;
@Before
public void setUp() {
@@ -89,6 +89,8 @@ public class GameDriverAppPreferenceControllerTest {
mValueList =
mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
mPreferencePrereleaseDriver =
mContext.getResources().getString(R.string.game_driver_app_preference_prerelease_driver);
}
@Test
@@ -207,9 +209,7 @@ public class GameDriverAppPreferenceControllerTest {
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
assertThat(preference.getEntries()).isEqualTo(mValueList);
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
assertThat(preference.getEntry()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
assertThat(preference.getValue()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
assertThat(preference.getSummary()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
assertThat(preference.getSummary()).isEqualTo(mPreferencePrereleaseDriver);
}
@Test