summaryrefslogtreecommitdiff
path: root/tests/NullHomeTest/src
diff options
context:
space:
mode:
authorIsaac Chen <ycchen@google.com>2020-05-15 16:34:44 +0800
committerIsaac Chen <ycchen@google.com>2020-05-19 10:59:30 +0800
commit498e571c9ce9cda53a1d7f7c97f5222b09cb9a8d (patch)
tree59f2bd7eaade58965842622bdbb63f42f58621c3 /tests/NullHomeTest/src
parent5bc026a72d77cf436107e5092dee4dd84d5e5041 (diff)
Add a test to check unusual home activities
Framework's SystemUserHome and Shell's NullHome activities have no real Home function and should only be used in bootable CSI products. They should not exist or be enabled on normal products. This test can help to find if they exist in the system without needing to find them via Settings manually. Bug: 149307007 Bug: 149780604 Bug: 154723738 Test: # On aosp_crosshatch with Shell's NullHome activity $ atest NullHomeTest ... arm64-v8a NullHomeTest ---------------------- com.android.test.nullhome (1 Test) [1/1] com.android.test.nullhome.NullHomeTest#checkNullHome: FAILED (127ms) # On aosp_crosshatch without Shell's NullHome activity $ atest NullHomeTest ... arm64-v8a NullHomeTest ---------------------- com.android.test.nullhome (1 Test) [1/1] com.android.test.nullhome.NullHomeTest#checkNullHome: PASSED (2ms) Change-Id: I6f190ae33fc9e724adc0e53d07107e9a1ae0291f Merged-In: I6f190ae33fc9e724adc0e53d07107e9a1ae0291f (cherry picked from commit c8607a3a5bf97905179388fec4533c0068209abe)
Diffstat (limited to 'tests/NullHomeTest/src')
-rw-r--r--tests/NullHomeTest/src/com/android/test/nullhome/NullHomeTest.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/NullHomeTest/src/com/android/test/nullhome/NullHomeTest.java b/tests/NullHomeTest/src/com/android/test/nullhome/NullHomeTest.java
new file mode 100644
index 000000000000..1d77cdc51187
--- /dev/null
+++ b/tests/NullHomeTest/src/com/android/test/nullhome/NullHomeTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2020 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.test.nullhome;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.support.test.InstrumentationRegistry;
+import android.util.Log;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/*
+ * Check if NullHome/SystemUserHome activity does not exist/is disabled.
+ *
+ * SystemUserHome is only enabled in bootable CSI (csi_x86, csi_arm64)
+ * products and should not be enabled in other products.
+ *
+ * Shell's NullHome is empty and caused issues in sevaral manual GUI tests
+ * that try to select/use it, and should be removed.
+ *
+ * Settings' FallbackHome is fine because it's specially handled by Settings.
+ *
+ */
+
+@RunWith(JUnit4.class)
+public class NullHomeTest {
+ private static final String TAG = "NullHomeTest";
+ private Context mContext;
+ private PackageManager mPm;
+
+ @Before
+ public void before() {
+ Log.d(TAG, "beforeClass()");
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
+ mPm = mContext.getPackageManager();
+ }
+
+ @Test
+ public void checkNullHome() {
+ final List<ResolveInfo> homeActivities = new ArrayList<>();
+
+ mPm.getHomeActivities(homeActivities);
+ for (ResolveInfo activity : homeActivities) {
+ Log.d(TAG, "Home activity: " + activity.activityInfo.packageName);
+ Assert.assertNotEquals(activity.activityInfo.packageName,
+ "com.android.internal.app.SystemUserHomeActivity");
+ Assert.assertNotEquals(activity.activityInfo.packageName,
+ "com.android.shell");
+ }
+ }
+}