Merge "Making AbstractDeviceProfileTest tnd FakeInvariantDeviceProfileTesto only run on CF_PHONE" into main
diff --git a/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt b/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
index dbafe79..2905d85 100644
--- a/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
+++ b/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
@@ -17,9 +17,12 @@
import android.content.Context
import android.content.res.Configuration
-import android.content.res.Resources
import android.graphics.Point
import android.graphics.Rect
+import android.platform.test.rule.AllowedDevices
+import android.platform.test.rule.DeviceProduct
+import android.platform.test.rule.IgnoreLimit
+import android.platform.test.rule.LimitDevicesRule
import android.util.DisplayMetrics
import android.view.Surface
import androidx.test.core.app.ApplicationProvider
@@ -32,7 +35,6 @@
import com.android.launcher3.util.rule.TestStabilityRule
import com.android.launcher3.util.window.CachedDisplayInfo
import com.android.launcher3.util.window.WindowManagerProxy
-import com.android.wm.shell.Flags
import com.google.common.truth.Truth
import java.io.BufferedReader
import java.io.File
@@ -52,6 +54,8 @@
*
* For an implementation that mocks InvariantDeviceProfile, use [FakeInvariantDeviceProfileTest]
*/
+@AllowedDevices(allowed = [DeviceProduct.CF_PHONE])
+@IgnoreLimit(ignoreLimit = BuildConfig.IS_STUDIO_BUILD)
abstract class AbstractDeviceProfileTest {
protected val testContext: Context = InstrumentationRegistry.getInstrumentation().context
protected lateinit var context: SandboxContext
@@ -59,15 +63,11 @@
private val displayController: DisplayController = mock()
private val windowManagerProxy: WindowManagerProxy = mock()
private val launcherPrefs: LauncherPrefs = mock()
- private val allowLeftRightSplitInPortrait: Boolean = initAllowLeftRightSplitInPortrait()
- fun initAllowLeftRightSplitInPortrait(): Boolean {
- val res = Resources.getSystem()
- val resId = res.getIdentifier("config_leftRightSplitInPortrait", "bool", "android")
- return Flags.enableLeftRightSplitInPortrait() && resId > 0 && res.getBoolean(resId)
- }
@Rule @JvmField val testStabilityRule = TestStabilityRule()
+ @Rule @JvmField val limitDevicesRule = LimitDevicesRule()
+
class DeviceSpec(
val naturalSize: Pair<Int, Int>,
var densityDpi: Int,
@@ -311,22 +311,6 @@
protected fun assertDump(dp: DeviceProfile, folderName: String, filename: String) {
val dump = dump(context!!, dp, "${folderName}_$filename.txt")
var expected = readDumpFromAssets(testContext, "$folderName/$filename.txt")
-
- // TODO(b/315230497): We don't currently have device-specific device profile dumps, so just
- // update the result before we do the comparison
- if (allowLeftRightSplitInPortrait) {
- val isLeftRightSplitInPortrait =
- when {
- allowLeftRightSplitInPortrait && dp.isTablet -> !dp.isLandscape
- else -> dp.isLandscape
- }
- expected =
- expected.replace(
- Regex("isLeftRightSplit:\\w+"),
- "isLeftRightSplit:$isLeftRightSplitInPortrait"
- )
- }
-
Truth.assertThat(dump).isEqualTo(expected)
}
diff --git a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
index 30b5663..251a401 100644
--- a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
+++ b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
@@ -18,6 +18,10 @@
import android.content.Context
import android.graphics.PointF
import android.graphics.Rect
+import android.platform.test.rule.AllowedDevices
+import android.platform.test.rule.DeviceProduct
+import android.platform.test.rule.IgnoreLimit
+import android.platform.test.rule.LimitDevicesRule
import android.util.SparseArray
import androidx.test.core.app.ApplicationProvider
import com.android.launcher3.DeviceProfile.DEFAULT_DIMENSION_PROVIDER
@@ -27,6 +31,7 @@
import java.io.PrintWriter
import java.io.StringWriter
import org.junit.Before
+import org.junit.Rule
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
@@ -37,6 +42,8 @@
*
* For an implementation that creates InvariantDeviceProfile, use [AbstractDeviceProfileTest]
*/
+@AllowedDevices(allowed = [DeviceProduct.CF_PHONE])
+@IgnoreLimit(ignoreLimit = BuildConfig.IS_STUDIO_BUILD)
abstract class FakeInvariantDeviceProfileTest {
protected var context: Context? = null
@@ -49,6 +56,8 @@
protected var isGestureMode: Boolean = true
protected var isTransientTaskbar: Boolean = true
+ @Rule @JvmField val limitDevicesRule = LimitDevicesRule()
+
@Before
fun setUp() {
context = ApplicationProvider.getApplicationContext()