1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.enterprise;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.provider.SearchIndexableResource;
22 
23 import com.android.settings.R;
24 import com.android.settings.widget.PreferenceCategoryController;
25 import com.android.settingslib.core.AbstractPreferenceController;
26 
27 import java.util.List;
28 
29 public abstract class AbsBasePrivacySettingsPreference {
30 
verifyEnterpriseSearchIndexableResources( List<SearchIndexableResource> searchIndexableResources)31     protected void verifyEnterpriseSearchIndexableResources(
32             List<SearchIndexableResource> searchIndexableResources) {
33         assertThat(searchIndexableResources).isNotEmpty();
34         assertThat(searchIndexableResources.size()).isEqualTo(1);
35         assertThat(searchIndexableResources.get(0).xmlResId)
36                 .isEqualTo(R.xml.enterprise_privacy_settings);
37     }
38 
verifyEnterprisePreferenceControllers( List<AbstractPreferenceController> controllers)39     protected void verifyEnterprisePreferenceControllers(
40             List<AbstractPreferenceController> controllers) {
41         assertThat(controllers).isNotNull();
42         assertThat(controllers.size()).isEqualTo(17);
43         int position = 0;
44         assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
45         assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
46         assertThat(controllers.get(position++)).isInstanceOf(
47                 SecurityLogsPreferenceController.class);
48         assertThat(controllers.get(position++)).isInstanceOf(
49                 EnterpriseInstalledPackagesPreferenceController.class);
50         assertThat(controllers.get(position++)).isInstanceOf(
51                 AdminGrantedLocationPermissionsPreferenceController.class);
52         assertThat(controllers.get(position++)).isInstanceOf(
53                 AdminGrantedMicrophonePermissionPreferenceController.class);
54         assertThat(controllers.get(position++)).isInstanceOf(
55                 AdminGrantedCameraPermissionPreferenceController.class);
56         assertThat(controllers.get(position++)).isInstanceOf(
57                 EnterpriseSetDefaultAppsPreferenceController.class);
58         assertThat(controllers.get(position++)).isInstanceOf(
59                 AlwaysOnVpnCurrentUserPreferenceController.class);
60         assertThat(controllers.get(position++)).isInstanceOf(
61                 AlwaysOnVpnManagedProfilePreferenceController.class);
62         assertThat(controllers.get(position++)).isInstanceOf(ImePreferenceController.class);
63         assertThat(controllers.get(position++)).isInstanceOf(
64                 GlobalHttpProxyPreferenceController.class);
65         assertThat(controllers.get(position++)).isInstanceOf(
66                 CaCertsCurrentUserPreferenceController.class);
67         assertThat(controllers.get(position++)).isInstanceOf(
68                 CaCertsManagedProfilePreferenceController.class);
69         assertThat(controllers.get(position++)).isInstanceOf(
70                 PreferenceCategoryController.class);
71         assertThat(controllers.get(position++)).isInstanceOf(
72                 FailedPasswordWipeCurrentUserPreferenceController.class);
73         assertThat(controllers.get(position)).isInstanceOf(
74                 FailedPasswordWipeManagedProfilePreferenceController.class);
75     }
76 
verifyFinancedSearchIndexableResources( List<SearchIndexableResource> searchIndexableResources)77     protected void verifyFinancedSearchIndexableResources(
78             List<SearchIndexableResource> searchIndexableResources) {
79         assertThat(searchIndexableResources).isNotEmpty();
80         assertThat(searchIndexableResources.size()).isEqualTo(1);
81         assertThat(searchIndexableResources.get(0).xmlResId)
82                 .isEqualTo(R.xml.financed_privacy_settings);
83     }
84 
verifyFinancedPreferenceControllers( List<AbstractPreferenceController> controllers)85     protected void verifyFinancedPreferenceControllers(
86             List<AbstractPreferenceController> controllers) {
87         assertThat(controllers).isEmpty();
88     }
89 }
90