Populate Enterprise Privacy Settings page - batch 1

This CL adds the first batch of items to the Privacy Settings page.
These are all the items that fall into the "What types of
information can your organization see?" category and do not require
deeper Framework changes. Further batches are to come in separate
CLs.

Test: make RunSettingsRoboTests
Bug: 32692748
Change-Id: I460093bc45ed0e5baab2a5cdf9833e654d436cc9
This commit is contained in:
Bartosz Fabianowski
2016-11-18 00:09:52 +01:00
parent d12b97f9e3
commit 62b96811c1
18 changed files with 415 additions and 24 deletions

View File

@@ -0,0 +1,99 @@
/*
* Copyright (C) 2016 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.applications;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.UserManager;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.ApplicationTestUtils;
import com.android.settings.testutils.shadow.ShadowUserManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import java.util.Arrays;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import org.robolectric.shadows.ShadowApplication;
/**
* Tests for {@link ApplicationFeatureProviderImpl}.
*/
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
shadows = {ShadowUserManager.class})
public final class ApplicationFeatureProviderImplTest {
private final int MAIN_USER_ID = 0;
private final int MANAGED_PROFILE_ID = 10;
private @Mock UserManager mUserManager;
private @Mock Context mContext;
private @Mock PackageManagerWrapper mPackageManager;
private ApplicationFeatureProvider mProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mProvider = new ApplicationFeatureProviderImpl(mContext, mPackageManager);
}
@Test
public void testCalculateNumberOfInstalledApps() {
final Integer[] numberOfInstalledApps = new Integer[1];
numberOfInstalledApps[0] = null;
when(mUserManager.getUsers(true)).thenReturn(Arrays.asList(
new UserInfo(MAIN_USER_ID, "main", UserInfo.FLAG_ADMIN),
new UserInfo(MANAGED_PROFILE_ID, "managed profile", 0)));
when(mPackageManager.getInstalledApplicationsAsUser(PackageManager.GET_DISABLED_COMPONENTS
| PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS
| PackageManager.GET_UNINSTALLED_PACKAGES,
MAIN_USER_ID)).thenReturn(Arrays.asList(
ApplicationTestUtils.buildInfo(MAIN_USER_ID, "app1", 0 /* flags */)));
when(mPackageManager.getInstalledApplicationsAsUser(PackageManager.GET_DISABLED_COMPONENTS
| PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS,
MANAGED_PROFILE_ID)).thenReturn(Arrays.asList(
ApplicationTestUtils.buildInfo(MANAGED_PROFILE_ID, "app2", 0 /* flags */)));
mProvider.calculateNumberOfInstalledApps(
new ApplicationFeatureProvider.NumberOfInstalledAppsCallback() {
@Override
public void onNumberOfInstalledAppsResult(int num) {
numberOfInstalledApps[0] = num;
}
});
ShadowApplication.runBackgroundTasks();
assertThat(numberOfInstalledApps[0]).isEqualTo(2);
}
}