This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add test for external textures on Android #26109
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
...io_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ExternalTextureTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package dev.flutter.scenariosui; | ||
|
||
import android.content.Intent; | ||
import android.graphics.Rect; | ||
import android.os.Build.VERSION_CODES; | ||
import androidx.test.filters.LargeTest; | ||
import androidx.test.filters.SdkSuppress; | ||
import androidx.test.rule.ActivityTestRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
import dev.flutter.scenarios.ExternalTextureFlutterActivity; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class ExternalTextureTests { | ||
private static final int SURFACE_WIDTH = 192; | ||
private static final int SURFACE_HEIGHT = 256; | ||
|
||
Intent intent; | ||
|
||
@Rule | ||
public ActivityTestRule<ExternalTextureFlutterActivity> activityRule = | ||
new ActivityTestRule<>( | ||
ExternalTextureFlutterActivity.class, | ||
/*initialTouchMode=*/ false, | ||
/*launchActivity=*/ false); | ||
|
||
@Before | ||
public void setUp() { | ||
intent = new Intent(Intent.ACTION_MAIN); | ||
} | ||
|
||
@Test | ||
public void testCanvasSurface() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "canvas"); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) | ||
public void testMediaSurface() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "media"); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) | ||
public void testRotatedMediaSurface_90() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "media"); | ||
intent.putExtra("rotation", 90); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) | ||
public void testRotatedMediaSurface_180() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "media"); | ||
intent.putExtra("rotation", 180); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.LOLLIPOP) | ||
public void testRotatedMediaSurface_270() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "media"); | ||
intent.putExtra("rotation", 270); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.M) | ||
public void testCroppedMediaSurface_bottomLeft() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "image"); | ||
intent.putExtra("crop", new Rect(0, 0, SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2)); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.M) | ||
public void testCroppedMediaSurface_topRight() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "image"); | ||
intent.putExtra( | ||
"crop", new Rect(SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2, SURFACE_WIDTH, SURFACE_HEIGHT)); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
|
||
@Test | ||
@SdkSuppress(minSdkVersion = VERSION_CODES.M) | ||
public void testCroppedRotatedMediaSurface_bottomLeft_90() throws Exception { | ||
intent.putExtra("scenario", "display_texture"); | ||
intent.putExtra("surface_renderer", "image"); | ||
intent.putExtra("crop", new Rect(0, 0, SURFACE_WIDTH / 2, SURFACE_HEIGHT / 2)); | ||
intent.putExtra("rotation", 90); | ||
ScreenshotUtil.capture(activityRule.launchActivity(intent)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems correct. I wonder if the issue is that only one activity can have this action. What happens if you remove the content of the outer
<intent-filter>
?