Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testing/scenario_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,28 +127,6 @@ void flush() {
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}.
*
Expand Down Expand Up @@ -182,13 +158,7 @@ public Void call() {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion testing/scenario_app/compile_android_jit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,30 @@ - (void)testMultiplePlatformViewsWithOverlays {

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);
}

Expand Down
58 changes: 12 additions & 46 deletions testing/scenario_app/lib/src/platform_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to add 50 on x?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screenshot will explain it better, see before/after.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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,
Expand All @@ -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);
}
}
Expand All @@ -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);
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down