summaryrefslogtreecommitdiff
path: root/media/tests
diff options
context:
space:
mode:
author Vadim Caen <caen@google.com> 2025-02-26 16:49:12 +0100
committer Vadim Caen <caen@google.com> 2025-03-21 16:13:33 +0100
commit73b1415205ea371cc943528e12b5ba3ce3573e14 (patch)
tree35acdc992ad1ccd92db2faed5eb960bf9a93c40e /media/tests
parent34f9f07edf00f62d54803c60a5c30af678e33195 (diff)
Builder pattern for MediaProjectionConfig
Introduce a builder pattern for MediaProjectionConfig, allowing more flexibility for the type of configuration need by the requesting application, in preparation for the content sharing option in a follow-up CL. Also adding some documentation fix and moving readding the CTS in presubmit. Test: atest CtsMediaProjectionTestCases:MediaProjectionConfigTest Flag: com.android.media.projection.flags.app_content_sharing Bug: 398757866 Change-Id: I0e048c47605fe06bf49e032f387d4009750e5f02
Diffstat (limited to 'media/tests')
-rw-r--r--media/tests/projection/Android.bp1
-rw-r--r--media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java32
2 files changed, 32 insertions, 1 deletions
diff --git a/media/tests/projection/Android.bp b/media/tests/projection/Android.bp
index 48621e4e2094..37726898824b 100644
--- a/media/tests/projection/Android.bp
+++ b/media/tests/projection/Android.bp
@@ -26,6 +26,7 @@ android_test {
"androidx.test.runner",
"androidx.test.rules",
"androidx.test.ext.junit",
+ "flag-junit",
"frameworks-base-testutils",
"mockito-target-extended-minus-junit4",
"platform-test-annotations",
diff --git a/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java b/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java
index 2820606958b7..bc0eae1a3ec7 100644
--- a/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java
+++ b/media/tests/projection/src/android/media/projection/MediaProjectionConfigTest.java
@@ -18,22 +18,31 @@ package android.media.projection;
import static android.media.projection.MediaProjectionConfig.CAPTURE_REGION_FIXED_DISPLAY;
import static android.media.projection.MediaProjectionConfig.CAPTURE_REGION_USER_CHOICE;
+import static android.media.projection.MediaProjectionConfig.PROJECTION_SOURCE_DISPLAY;
+import static android.media.projection.MediaProjectionConfig.DEFAULT_PROJECTION_SOURCES;
import static android.view.Display.DEFAULT_DISPLAY;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.platform.test.annotations.Presubmit;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import com.android.media.projection.flags.Flags;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests for the {@link MediaProjectionConfig} class.
- *
+ * <p>
* Build/Install/Run:
* atest MediaProjectionTests:MediaProjectionConfigTest
*/
@@ -41,6 +50,11 @@ import org.junit.runner.RunWith;
@Presubmit
@RunWith(AndroidJUnit4.class)
public class MediaProjectionConfigTest {
+
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule =
+ DeviceFlagsValueProvider.createCheckFlagsRule();
+
private static final MediaProjectionConfig DISPLAY_CONFIG =
MediaProjectionConfig.createConfigForDefaultDisplay();
private static final MediaProjectionConfig USERS_CHOICE_CONFIG =
@@ -57,17 +71,33 @@ public class MediaProjectionConfigTest {
}
@Test
+ @RequiresFlagsDisabled(Flags.FLAG_APP_CONTENT_SHARING)
public void testCreateDisplayConfig() {
assertThat(DISPLAY_CONFIG.getRegionToCapture()).isEqualTo(CAPTURE_REGION_FIXED_DISPLAY);
assertThat(DISPLAY_CONFIG.getDisplayToCapture()).isEqualTo(DEFAULT_DISPLAY);
}
@Test
+ @RequiresFlagsDisabled(Flags.FLAG_APP_CONTENT_SHARING)
public void testCreateUsersChoiceConfig() {
assertThat(USERS_CHOICE_CONFIG.getRegionToCapture()).isEqualTo(CAPTURE_REGION_USER_CHOICE);
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_APP_CONTENT_SHARING)
+ public void testDefaultProjectionSources() {
+ assertThat(USERS_CHOICE_CONFIG.getProjectionSources())
+ .isEqualTo(DEFAULT_PROJECTION_SOURCES);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_APP_CONTENT_SHARING)
+ public void testCreateDisplayConfigProjectionSource() {
+ assertThat(DISPLAY_CONFIG.getProjectionSources()).isEqualTo(PROJECTION_SOURCE_DISPLAY);
+ assertThat(DISPLAY_CONFIG.getDisplayToCapture()).isEqualTo(DEFAULT_DISPLAY);
+ }
+
+ @Test
public void testEquals() {
assertThat(MediaProjectionConfig.createConfigForUserChoice()).isEqualTo(
USERS_CHOICE_CONFIG);