package com.android.settings.applications;
+import static com.android.settings.widget.EntityHeaderController.ActionType;
+
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
-import static com.android.settings.widget.EntityHeaderController.ActionType;
-
public abstract class AppInfoWithHeader extends AppInfoBase {
private boolean mCreated;
final Preference pref = EntityHeaderController
.newInstance(activity, this, null /* header */)
.setRecyclerView(getListView(), getLifecycle())
- .setIcon(IconDrawableFactory.newInstance(activity)
+ .setIcon(IconDrawableFactory.newInstance(getContext())
.getBadgedIcon(mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
private AccountRestrictionHelper mHelper;
private UserManager mUserManager;
private PackageManager mPm;
- private boolean mCellBroadcastAppLinkEnabled;
public EmergencyBroadcastPreferenceController(Context context, String prefKey) {
this(context, new AccountRestrictionHelper(context), prefKey);
mHelper = helper;
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
mPm = mContext.getPackageManager();
- // Enable link to CMAS app settings depending on the value in config.xml.
- mCellBroadcastAppLinkEnabled = isCellBroadcastAppLinkEnabled();
}
@Override
@Override
public boolean isAvailable() {
- return mUserManager.isAdminUser() && mCellBroadcastAppLinkEnabled
+ return mUserManager.isAdminUser() && isCellBroadcastAppLinkEnabled()
&& !mHelper.hasBaseUserRestriction(
UserManager.DISALLOW_CONFIG_CELL_BROADCASTS, UserHandle.myUserId());
}
private boolean isCellBroadcastAppLinkEnabled() {
+ // Enable link to CMAS app settings depending on the value in config.xml.
boolean enabled = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_cellBroadcastAppLinks);
if (enabled) {
package com.android.settings.applications;
-import android.content.Context;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
import android.os.UserManager;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.notification.EmergencyBroadcastPreferenceController;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.XmlTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.util.ReflectionHelpers;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
import java.util.List;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppAndNotificationDashboardFragmentTest {
@Test
+ @Config(shadows = {ShadowEmergencyBroadcastPreferenceController.class})
public void testNonIndexableKeys_existInXmlLayout() {
final Context context = spy(RuntimeEnvironment.application);
UserManager manager = mock(UserManager.class);
assertThat(keys).containsAllIn(niks);
}
+
+ @Implements(EmergencyBroadcastPreferenceController.class)
+ public static class ShadowEmergencyBroadcastPreferenceController {
+
+ @Implementation
+ public boolean isAvailable() {
+ return true;
+ }
+ }
}
package com.android.settings.applications;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowEntityHeaderController.class)
public class AppInfoWithHeaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
import android.content.Context;
import android.support.v7.preference.Preference;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
import org.junit.Before;
import org.junit.Test;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import com.android.settings.R;
-import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
-
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppStorageSizesControllerTest {
private static final String COMPUTING = "Computing…";
private static final String INVALID_SIZE = "Couldn’t compute package size.";
mController.setResult(result);
mController.updateUi(mContext);
- assertThat(mAppPreference.getSummary()).isEqualTo("1.00 B");
- assertThat(mCachePreference.getSummary()).isEqualTo("10.00 B");
- assertThat(mDataPreference.getSummary()).isEqualTo("90.00 B");
+ assertThat(mAppPreference.getSummary()).isEqualTo("1 B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("10 B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("90 B");
assertThat(mTotalPreference.getSummary()).isEqualTo("101 B");
}
mController.setCacheCleared(true);
mController.updateUi(mContext);
- assertThat(mAppPreference.getSummary()).isEqualTo("1.00 B");
- assertThat(mCachePreference.getSummary()).isEqualTo("0.00 B");
- assertThat(mDataPreference.getSummary()).isEqualTo("90.00 B");
- assertThat(mTotalPreference.getSummary()).isEqualTo("91.00 B");
+ assertThat(mAppPreference.getSummary()).isEqualTo("1 B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("0 B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("90 B");
+ assertThat(mTotalPreference.getSummary()).isEqualTo("91 B");
}
@Test
mController.setDataCleared(true);
mController.updateUi(mContext);
- assertThat(mAppPreference.getSummary()).isEqualTo("1.00 B");
- assertThat(mCachePreference.getSummary()).isEqualTo("0.00 B");
- assertThat(mDataPreference.getSummary()).isEqualTo("0.00 B");
- assertThat(mTotalPreference.getSummary()).isEqualTo("1.00 B");
+ assertThat(mAppPreference.getSummary()).isEqualTo("1 B");
+ assertThat(mCachePreference.getSummary()).isEqualTo("0 B");
+ assertThat(mDataPreference.getSummary()).isEqualTo("0 B");
+ assertThat(mTotalPreference.getSummary()).isEqualTo("1 B");
}
}
package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.anyDouble;
import static org.mockito.Matchers.anyInt;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
- manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
- shadows = InstalledAppDetailsTest.ShadowUtils.class
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION_O,
+ shadows = InstalledAppDetailsTest.ShadowUtils.class
)
public final class InstalledAppDetailsTest {
when(stats.getTotalBytes()).thenReturn(1L);
assertThat(InstalledAppDetails.getStorageSummary(context, stats, true))
- .isEqualTo("1.00 B used in external storage");
+ .isEqualTo("1 B used in external storage");
}
@Test
when(stats.getTotalBytes()).thenReturn(1L);
assertThat(InstalledAppDetails.getStorageSummary(context, stats, false))
- .isEqualTo("1.00 B used in internal storage");
+ .isEqualTo("1 B used in internal storage");
}
@Test