Fix and clean up scenario app for Android (#22540)
@ -46,7 +46,7 @@ The test is run on a x86 emulator. To run the test locally, you must create an e
|
||||
|
||||
```
|
||||
hw.lcd.density = 480
|
||||
hw.lcd.height = 1920
|
||||
hw.lcd.height = 1680
|
||||
hw.lcd.width = 1080
|
||||
lcd.depth = 16
|
||||
```
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
package dev.flutter.scenariosui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -129,28 +127,6 @@ public class ScreenshotUtil {
|
||||
album = null;
|
||||
}
|
||||
|
||||
private static int getStatusBarHeight() {
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
// Resource name defined in
|
||||
// https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/dimens.xml#34
|
||||
final int resourceId =
|
||||
context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
int statusBarHeight = 0;
|
||||
if (resourceId > 0) {
|
||||
statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return statusBarHeight;
|
||||
}
|
||||
|
||||
private static int getActionBarHeight(Activity activity) {
|
||||
int actionBarHeight = 0;
|
||||
final android.content.res.TypedArray styledAttributes =
|
||||
activity.getTheme().obtainStyledAttributes(new int[] {android.R.attr.actionBarSize});
|
||||
actionBarHeight = (int) styledAttributes.getDimension(0, 0);
|
||||
styledAttributes.recycle();
|
||||
return actionBarHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures a screenshot of {@code TestableFlutterActivity}.
|
||||
*
|
||||
@ -182,13 +158,7 @@ public class ScreenshotUtil {
|
||||
Bitmap bitmap =
|
||||
InstrumentationRegistry.getInstrumentation().getUiAutomation().takeScreenshot();
|
||||
// Remove the status and action bars from the screenshot capture.
|
||||
bitmap =
|
||||
Bitmap.createBitmap(
|
||||
bitmap,
|
||||
0,
|
||||
getStatusBarHeight(),
|
||||
bitmap.getWidth(),
|
||||
bitmap.getHeight() - getStatusBarHeight() - getActionBarHeight(activity));
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
|
||||
final String screenshotName = String.format("%s__%s", testClass, testName);
|
||||
// Write bitmap to the album.
|
||||
|
||||
@ -14,7 +14,8 @@
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/FullScreenScreenshot">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.intent.action.TEST_LOOP" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
@ -8,9 +8,11 @@
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<style name="FullScreenScreenshot">
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 39 KiB |
@ -39,7 +39,7 @@ fi
|
||||
|
||||
if [[ ! -d "$DEVICE_TOOLS" ]]; then
|
||||
echo "Directory $DEVICE_TOOLS not found."
|
||||
ehco "Second argument must specify the device out directory containing gen_snapshot (e.g. android_debug_unopt_x64)."
|
||||
echo "Second argument must specify the device out directory containing gen_snapshot (e.g. android_debug_unopt_x64)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -195,30 +195,30 @@
|
||||
|
||||
XCUIElement* platform_view1 = app.textViews[@"platform_view[0]"];
|
||||
XCTAssertTrue([platform_view1 waitForExistenceWithTimeout:1.0]);
|
||||
XCTAssertEqual(platform_view1.frame.origin.x, 25);
|
||||
XCTAssertEqual(platform_view1.frame.origin.x, 50);
|
||||
XCTAssertEqual(platform_view1.frame.origin.y, 325);
|
||||
XCTAssertEqual(platform_view1.frame.size.width, 250);
|
||||
XCTAssertEqual(platform_view1.frame.size.height, 250);
|
||||
|
||||
XCUIElement* platform_view2 = app.textViews[@"platform_view[1]"];
|
||||
XCTAssertTrue(platform_view2.exists);
|
||||
XCTAssertEqual(platform_view2.frame.origin.x, 25);
|
||||
XCTAssertEqual(platform_view2.frame.origin.x, 50);
|
||||
XCTAssertEqual(platform_view2.frame.origin.y, 25);
|
||||
XCTAssertEqual(platform_view2.frame.size.width, 250);
|
||||
XCTAssertEqual(platform_view2.frame.size.height, 250);
|
||||
|
||||
XCUIElement* overlay1 = app.otherElements[@"platform_view[0].overlay[0]"];
|
||||
XCTAssertTrue(overlay1.exists);
|
||||
XCTAssertEqual(overlay1.frame.origin.x, 25);
|
||||
XCTAssertEqual(overlay1.frame.origin.x, 50);
|
||||
XCTAssertEqual(overlay1.frame.origin.y, 325);
|
||||
XCTAssertEqual(overlay1.frame.size.width, 225);
|
||||
XCTAssertEqual(overlay1.frame.size.width, 200);
|
||||
XCTAssertEqual(overlay1.frame.size.height, 175);
|
||||
|
||||
XCUIElement* overlay2 = app.otherElements[@"platform_view[1].overlay[0]"];
|
||||
XCTAssertTrue(overlay2.exists);
|
||||
XCTAssertEqual(overlay2.frame.origin.x, 25);
|
||||
XCTAssertEqual(overlay2.frame.origin.x, 50);
|
||||
XCTAssertEqual(overlay2.frame.origin.y, 25);
|
||||
XCTAssertEqual(overlay2.frame.size.width, 225);
|
||||
XCTAssertEqual(overlay2.frame.size.width, 200);
|
||||
XCTAssertEqual(overlay2.frame.size.height, 250);
|
||||
}
|
||||
|
||||
|
||||
@ -46,8 +46,6 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, id);
|
||||
}
|
||||
}
|
||||
@ -70,8 +68,6 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
finishBuilderByAddingPlatformViewAndPicture(
|
||||
builder,
|
||||
id,
|
||||
@ -98,8 +94,6 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
finishBuilderByAddingPlatformViewAndPicture(
|
||||
builder,
|
||||
id,
|
||||
@ -126,8 +120,6 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario with _BasePla
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
_addPlatformViewToScene(builder, id, 500, 500);
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(recorder);
|
||||
@ -167,8 +159,6 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario wit
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
_addPlatformViewToScene(builder, id, 500, 500);
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(recorder);
|
||||
@ -217,8 +207,6 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
builder.pushOffset(0, 600);
|
||||
_addPlatformViewToScene(builder, firstId, 500, 500);
|
||||
builder.pop();
|
||||
@ -259,8 +247,6 @@ class PlatformViewMaxOverlaysScenario extends Scenario with _BasePlatformViewSce
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
_addPlatformViewToScene(builder, id, 500, 500);
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(recorder);
|
||||
@ -314,8 +300,6 @@ class MultiPlatformViewScenario extends Scenario with _BasePlatformViewScenarioM
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
builder.pushOffset(0, 600);
|
||||
_addPlatformViewToScene(builder, firstId, 500, 500);
|
||||
builder.pop();
|
||||
@ -357,13 +341,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
||||
void _firstFrame() {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
builder.pushOffset(0, 600);
|
||||
builder.pushOffset(50, 600);
|
||||
_addPlatformViewToScene(builder, firstId, 500, 500);
|
||||
builder.pop();
|
||||
|
||||
builder.pushOffset(50, 0);
|
||||
_addPlatformViewToScene(builder, secondId, 500, 500);
|
||||
builder.pop();
|
||||
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(recorder);
|
||||
@ -374,7 +358,6 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
||||
final Picture picture = recorder.endRecording();
|
||||
builder.addPicture(const Offset(0, 0), picture);
|
||||
|
||||
builder.pop();
|
||||
final Scene scene = builder.build();
|
||||
window.render(scene);
|
||||
scene.dispose();
|
||||
@ -383,13 +366,12 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
|
||||
void _secondFrame() {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
builder.pushOffset(0, 600);
|
||||
_addPlatformViewToScene(builder, firstId, 500, 500);
|
||||
builder.pop();
|
||||
|
||||
_addPlatformViewToScene(builder, secondId, 500, 500);
|
||||
|
||||
final Scene scene = builder.build();
|
||||
window.render(scene);
|
||||
scene.dispose();
|
||||
@ -430,9 +412,10 @@ class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenar
|
||||
|
||||
@override
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
builder.pushOffset(0, 0);
|
||||
builder.pushClipRect(const Rect.fromLTRB(100, 100, 400, 400));
|
||||
final SceneBuilder builder =
|
||||
SceneBuilder()
|
||||
..pushClipRect(const Rect.fromLTRB(100, 100, 400, 400));
|
||||
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, id);
|
||||
}
|
||||
}
|
||||
@ -446,8 +429,6 @@ class PlatformViewClipRRectScenario extends PlatformViewScenario {
|
||||
@override
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
builder.pushClipRRect(
|
||||
RRect.fromLTRBAndCorners(
|
||||
100,
|
||||
@ -471,18 +452,14 @@ class PlatformViewClipPathScenario extends PlatformViewScenario {
|
||||
|
||||
@override
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
|
||||
final Path path = Path()
|
||||
..moveTo(100, 100)
|
||||
..quadraticBezierTo(50, 250, 100, 400)
|
||||
..lineTo(350, 400)
|
||||
..cubicTo(400, 300, 300, 200, 350, 100)
|
||||
..close();
|
||||
builder.pushClipPath(path);
|
||||
|
||||
final SceneBuilder builder = SceneBuilder()..pushClipPath(path);
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, id);
|
||||
}
|
||||
}
|
||||
@ -495,15 +472,12 @@ class PlatformViewTransformScenario extends PlatformViewScenario {
|
||||
|
||||
@override
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
final Matrix4 matrix4 = Matrix4.identity()
|
||||
..rotateZ(1)
|
||||
..scale(0.5, 0.5, 1.0)
|
||||
..translate(1000.0, 100.0, 0.0);
|
||||
|
||||
builder.pushTransform(matrix4.storage);
|
||||
final SceneBuilder builder = SceneBuilder()..pushTransform(matrix4.storage);
|
||||
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, id);
|
||||
}
|
||||
@ -517,11 +491,7 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
|
||||
|
||||
@override
|
||||
void onBeginFrame(Duration duration) {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
builder.pushOpacity(150);
|
||||
|
||||
final SceneBuilder builder = SceneBuilder()..pushOpacity(150);
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, id);
|
||||
}
|
||||
}
|
||||
@ -600,15 +570,11 @@ class PlatformViewForTouchIOSScenario extends Scenario
|
||||
|
||||
void _firstFrame() {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(0, 0);
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, _viewId);
|
||||
}
|
||||
|
||||
void _secondFrame() {
|
||||
final SceneBuilder builder = SceneBuilder();
|
||||
|
||||
builder.pushOffset(5, 5);
|
||||
final SceneBuilder builder = SceneBuilder()..pushOffset(5, 5);
|
||||
finishBuilderByAddingPlatformViewAndPicture(builder, _viewId);
|
||||
}
|
||||
}
|
||||
|
||||