Merge "Update screen bounds calculation for SpectatioUiUtil" into main
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoStatusBarHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoStatusBarHelper.java
index e1ce259..dfacd66 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoStatusBarHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoStatusBarHelper.java
@@ -283,4 +283,18 @@
* <p>Checks if sound settings page title is present
*/
boolean hasSoundSettingsPageTitle();
+
+ /**
+ * Setup expectations: None
+ *
+ * <p>Get the current time Zone
+ */
+ String getCurrentTimeZone();
+
+ /**
+ * Setup expectations: None
+ *
+ * <p>Get the Device current time Zone
+ */
+ String getDeviceCurrentTimeZone();
}
diff --git a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
index bbf12bf..ca2dd00 100644
--- a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
+++ b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
@@ -74,7 +74,8 @@
"NIGHT_MODE_COMMAND": "dumpsys activity service com.android.car/.CarService day-night-mode night",
"DAY_MODE_COMMAND": "dumpsys activity service com.android.car/.CarService day-night-mode day",
"OPEN_SYSTEM_UI": "am crash com.android.systemui",
- "OPEN_CAR_UI": "am crash com.android.car"
+ "OPEN_CAR_UI": "am crash com.android.car",
+ "DATE_COMMAND": "date"
},
"UI_ELEMENTS": {
"MAKE_CALL": {
diff --git a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
index 36248ad..28cadc3 100644
--- a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
+++ b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
@@ -556,6 +556,7 @@
public static final String CONNECTED_WIFI = "CONNECTED_WIFI";
public static final String FORGET_WIFI = "FORGET_WIFI";
public static final String CLOCK_TIME = "CLOCK_TIME";
+ public static final String DATE_COMMAND = "DATE_COMMAND";
// Quick Controls
public static final String HOME_BLUETOOTH_BUTTON = "HOME_BLUETOOTH_BUTTON";
diff --git a/libraries/automotive-helpers/status-bar-helper/src/android/platform/helpers/StatusBarHelperImpl.java b/libraries/automotive-helpers/status-bar-helper/src/android/platform/helpers/StatusBarHelperImpl.java
index eaf9c22..77f48c5 100644
--- a/libraries/automotive-helpers/status-bar-helper/src/android/platform/helpers/StatusBarHelperImpl.java
+++ b/libraries/automotive-helpers/status-bar-helper/src/android/platform/helpers/StatusBarHelperImpl.java
@@ -25,6 +25,7 @@
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import java.util.TimeZone;
/** Helper file for status bar tests */
public class StatusBarHelperImpl extends AbstractStandardAppHelper implements IAutoStatusBarHelper {
@@ -426,6 +427,24 @@
}
@Override
+ public String getCurrentTimeZone() {
+ TimeZone currentTimeInZone = TimeZone.getDefault();
+ String currentTimeZoneId = currentTimeInZone.getID();
+ return currentTimeZoneId;
+ }
+
+ @Override
+ public String getDeviceCurrentTimeZone() {
+ String deviceCurrentDateTime =
+ getSpectatioUiUtil()
+ .executeShellCommand(
+ getCommandFromConfig(AutomotiveConfigConstants.DATE_COMMAND));
+ String[] dateTime = deviceCurrentDateTime.split(" ");
+ String deviceCurrentTimeZone = dateTime[dateTime.length - 2];
+ return deviceCurrentTimeZone;
+ }
+
+ @Override
public boolean changeToDayMode() {
String dayModeResult =
getSpectatioUiUtil()
diff --git a/libraries/flicker/src/android/tools/flicker/config/desktopmode/Components.kt b/libraries/flicker/src/android/tools/flicker/config/desktopmode/Components.kt
index eba258e..bad7595 100644
--- a/libraries/flicker/src/android/tools/flicker/config/desktopmode/Components.kt
+++ b/libraries/flicker/src/android/tools/flicker/config/desktopmode/Components.kt
@@ -76,6 +76,12 @@
associatedTransition.changes.first { it.transitMode == TransitionType.OPEN }
FullComponentIdMatcher(change.windowId, change.layerId)
}
+ ScenarioId("MINIMIZE_APP"),
+ ScenarioId("MINIMIZE_LAST_APP") -> {
+ val change =
+ associatedTransition.changes.first { it.transitMode == TransitionType.TO_BACK }
+ FullComponentIdMatcher(change.windowId, change.layerId)
+ }
ScenarioId("CORNER_RESIZE"),
ScenarioId("CORNER_RESIZE_TO_MINIMUM_SIZE"),
ScenarioId("CORNER_RESIZE_TO_MAXIMUM_SIZE"),
diff --git a/libraries/flicker/utils/src/android/tools/traces/wm/TransitionType.kt b/libraries/flicker/utils/src/android/tools/traces/wm/TransitionType.kt
index 3c1df47..3c24b21 100644
--- a/libraries/flicker/utils/src/android/tools/traces/wm/TransitionType.kt
+++ b/libraries/flicker/utils/src/android/tools/traces/wm/TransitionType.kt
@@ -53,7 +53,9 @@
TASK_FRAGMENT_DRAG_RESIZE(FIRST_CUSTOM.value + 17),
SPLIT_PASSTHROUGH(FIRST_CUSTOM.value + 18),
CLEANUP_PIP_EXIT(FIRST_CUSTOM.value + 19),
- MINIMIZE(FIRST_CUSTOM.value + 20);
+ MINIMIZE(FIRST_CUSTOM.value + 20),
+ START_RECENTS_TRANSITION(FIRST_CUSTOM.value + 21),
+ END_RECENTS_TRANSITION(FIRST_CUSTOM.value + 22);
companion object {
fun fromInt(value: Int) = entries.first { it.value == value }
diff --git a/libraries/runner/Android.bp b/libraries/runner/Android.bp
index 9302719..280ad08 100644
--- a/libraries/runner/Android.bp
+++ b/libraries/runner/Android.bp
@@ -22,15 +22,33 @@
manifest: "AndroidManifest.xml",
platform_apis: true,
min_sdk_version: "Tiramisu",
- lint: { test: true },
+ lint: {
+ test: true,
+ },
optimize: {
- enabled: false
+ enabled: false,
},
srcs: [
"src/main/java/**/*.java",
],
libs: [
- "Robolectric_all-target_upstream",
+ "Robolectric_all-target_upstream",
],
- static_libs: [ ],
+ static_libs: [],
+}
+
+android_test {
+ name: "platform-parametric-runner-lib-test",
+ team: "trendy_team_test_infrastructure",
+ srcs: [
+ "src/test/java/**/*.java",
+ "src/test/java/**/*.kt",
+ ],
+ static_libs: [
+ "platform-parametric-runner-lib",
+ ],
+
+ sdk_version: "current",
+
+ test_suites: ["general-tests"],
}
diff --git a/libraries/runner/TEST_MAPPING b/libraries/runner/TEST_MAPPING
new file mode 100644
index 0000000..da11d1a
--- /dev/null
+++ b/libraries/runner/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "postsubmit": [
+ {
+ "name": "platform-parametric-runner-lib-test"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/libraries/runner/src/androidTest/java/platform/test/runner/parameterized/ClassRuleCountTest.kt b/libraries/runner/src/androidTest/java/platform/test/runner/parameterized/ClassRuleCountTest.kt
new file mode 100644
index 0000000..ed05668
--- /dev/null
+++ b/libraries/runner/src/androidTest/java/platform/test/runner/parameterized/ClassRuleCountTest.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2024 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 platform.test.runner.parameterized
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.ClassRule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+
+@RunWith(ParameterizedAndroidJunit4::class)
+class ClassRuleCountTest(private val i: Int) {
+ companion object {
+ var howManyApplications = 0
+
+ @JvmStatic
+ @get:ClassRule
+ val countApplicationsRule = TestRule { base, _ ->
+ howManyApplications++
+ base
+ }
+
+ @JvmStatic
+ @Parameters(name = "N = {0}")
+ fun data(): List<Array<Any>> {
+ return listOf(arrayOf(0), arrayOf(1))
+ }
+ }
+
+ @Test
+ fun equalityWorks() {
+ assertThat(i).isEqualTo(i)
+ assertThat(howManyApplications).isEqualTo(1)
+ }
+}
diff --git a/libraries/runner/src/main/java/platform/test/runner/parameterized/AndroidParameterizedRunner.java b/libraries/runner/src/main/java/platform/test/runner/parameterized/AndroidParameterizedRunner.java
index f5d53cd..526124f 100644
--- a/libraries/runner/src/main/java/platform/test/runner/parameterized/AndroidParameterizedRunner.java
+++ b/libraries/runner/src/main/java/platform/test/runner/parameterized/AndroidParameterizedRunner.java
@@ -18,9 +18,11 @@
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
+import org.junit.rules.TestRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
+import java.util.Collections;
import java.util.List;
/** Parameterized runner for Android instrumentation. */
@@ -67,4 +69,11 @@
protected Object createTest() throws Exception {
return mDelegate.createTestInstance(getTestClass());
}
+
+ @Override
+ protected List<TestRule> classRules() {
+ // We are already running ClassRules at the top class level, don't run them again
+ // on each parameter (b/377890695)
+ return Collections.emptyList();
+ }
}
diff --git a/tests/automotive/functional/settings/Android.bp b/tests/automotive/functional/settings/Android.bp
index af115fd..27e1e77 100644
--- a/tests/automotive/functional/settings/Android.bp
+++ b/tests/automotive/functional/settings/Android.bp
@@ -24,6 +24,7 @@
"androidx.test.runner",
"androidx.test.rules",
"automotive-settings-app-helper",
+ "automotive-status-bar-helper",
"automotive-utility-helper",
"app-helpers-auto-interfaces",
"hamcrest-library",
diff --git a/tests/automotive/functional/statusbar/src/android/platform/tests/CurrentDateTimeTest.java b/tests/automotive/functional/statusbar/src/android/platform/tests/CurrentDateTimeTest.java
new file mode 100644
index 0000000..ff2b393
--- /dev/null
+++ b/tests/automotive/functional/statusbar/src/android/platform/tests/CurrentDateTimeTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2023 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 android.platform.tests;
+
+import static junit.framework.Assert.assertEquals;
+
+import android.platform.helpers.HelperAccessor;
+import android.platform.helpers.IAutoStatusBarHelper;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class CurrentDateTimeTest {
+
+ private HelperAccessor<IAutoStatusBarHelper> mStatusBarHelper;
+
+ public CurrentDateTimeTest() {
+ mStatusBarHelper = new HelperAccessor<>(IAutoStatusBarHelper.class);
+ }
+
+ @Test
+ public void testCurrentTime() {
+ assertEquals(
+ "Current local Time",
+ mStatusBarHelper.get().getClockTime(),
+ mStatusBarHelper
+ .get()
+ .getCurrentTimeWithTimeZone(mStatusBarHelper.get().getCurrentTimeZone()));
+ }
+
+ @Test
+ public void testCurrentTimeZone() {
+ assertEquals(
+ "Current local Time Zone",
+ mStatusBarHelper.get().getCurrentTimeZone(),
+ mStatusBarHelper.get().getDeviceCurrentTimeZone());
+ }
+}