Skip to content

Commit ada245a

Browse files
author
Emmanuel Garcia
authored
Re-enable scenario tests on Android (flutter#33574)
1 parent 84c3012 commit ada245a

File tree

58 files changed

+722
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+722
-329
lines changed

.ci.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,24 @@ targets:
100100
timeout: 60
101101

102102
- name: Linux Android Emulator Tests
103-
bringup: true # Recipe issue https://github.com/flutter/flutter/issues/86427
104103
recipe: engine/scenarios
104+
enabled_branches:
105+
- main
106+
- master
105107
properties:
106108
dependencies: >-
107109
[
108-
{"dependency": "android_virtual_device", "version": "31"}
110+
{"dependency": "android_virtual_device", "version": "31"},
111+
{"dependency": "goldctl"}
109112
]
110113
upload_packages: "true"
111114
clobber: "true"
112115
timeout: 60
116+
runIf:
117+
- DEPS
118+
- .ci.yaml
119+
- testing/**
120+
- shell/platforms/android/**
113121

114122
- name: Linux Benchmarks
115123
enabled_branches:

shell/platform/android/android_context_gl_unittests.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ TEST(AndroidSurfaceGL, CreateSnapshopSurfaceWhenOnscreenSurfaceIsNull) {
164164
EXPECT_NE(android_surface->GetOnscreenSurface(), nullptr);
165165
}
166166

167-
TEST(AndroidContextGl, MSAAx4) {
167+
// TODO(https://github.com/flutter/flutter/issues/104463): Flaky test.
168+
TEST(AndroidContextGl, DISABLED_MSAAx4) {
168169
GrMockOptions main_context_options;
169170
sk_sp<GrDirectContext> main_context =
170171
GrDirectContext::MakeMock(&main_context_options);

shell/platform/android/external_view_embedder/external_view_embedder.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ void AndroidExternalViewEmbedder::SubmitFrame(
9898

9999
for (size_t i = 0; i < current_frame_view_count; i++) {
100100
int64_t view_id = composition_order_[i];
101+
if (picture_recorders_.at(view_id)->getRecordingCanvas() == nullptr) {
102+
continue;
103+
}
101104

102105
sk_sp<SkPicture> picture =
103106
picture_recorders_.at(view_id)->finishRecordingAsPicture();

testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/ScreenshotUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ private static class Connection {
3737
}
3838

3939
synchronized void writeFile(String name, byte[] fileContent) throws IOException {
40-
final ByteBuffer buffer = ByteBuffer.allocate(name.length() + fileContent.length + 4);
40+
final ByteBuffer buffer = ByteBuffer.allocate(name.length() + fileContent.length + 8);
41+
// See ScreenshotBlobTransformer#bind in screenshot_transformer.dart for consumer side.
4142
buffer.putInt(name.length());
43+
buffer.putInt(fileContent.length);
4244
buffer.put(name.getBytes());
4345
buffer.put(fileContent);
4446
final byte[] bytes = buffer.array();
@@ -118,6 +120,9 @@ public static void capture(@NonNull TestableFlutterActivity activity, @NonNull S
118120

119121
final Bitmap bitmap =
120122
InstrumentationRegistry.getInstrumentation().getUiAutomation().takeScreenshot();
123+
if (bitmap == null) {
124+
throw new RuntimeException("failed to capture screenshot");
125+
}
121126
final ByteArrayOutputStream out = new ByteArrayOutputStream();
122127
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
123128
ScreenshotUtil.writeFile(captureName, out.toByteArray());

testing/scenario_app/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
android:hardwareAccelerated="true"
1515
android:launchMode="singleTop"
1616
android:windowSoftInputMode="adjustResize"
17-
android:theme="@style/FullScreenScreenshot"
1817
android:exported="true">
1918
<intent-filter>
2019
<action android:name="com.google.intent.action.TEST_LOOP" />
@@ -32,7 +31,6 @@
3231
android:hardwareAccelerated="true"
3332
android:launchMode="singleTop"
3433
android:windowSoftInputMode="adjustResize"
35-
android:theme="@style/FullScreenScreenshot"
3634
android:exported="true">
3735
<intent-filter>
3836
<action android:name="android.intent.action.MAIN" />
@@ -45,7 +43,6 @@
4543
android:hardwareAccelerated="true"
4644
android:launchMode="singleTop"
4745
android:windowSoftInputMode="adjustResize"
48-
android:theme="@style/FullScreenScreenshot"
4946
android:exported="true">
5047
<intent-filter>
5148
<action android:name="android.intent.action.MAIN" />

testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/TestActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
import android.os.Bundle;
1313
import android.os.Handler;
1414
import android.os.Looper;
15+
import android.view.Window;
1516
import androidx.annotation.NonNull;
1617
import androidx.annotation.Nullable;
18+
import androidx.core.view.WindowCompat;
19+
import androidx.core.view.WindowInsetsCompat;
20+
import androidx.core.view.WindowInsetsControllerCompat;
1721
import io.flutter.Log;
1822
import io.flutter.embedding.engine.FlutterShellArgs;
1923
import io.flutter.embedding.engine.loader.FlutterLoader;
@@ -35,6 +39,8 @@ public abstract class TestActivity extends TestableFlutterActivity {
3539
@Override
3640
protected void onCreate(@Nullable Bundle savedInstanceState) {
3741
super.onCreate(savedInstanceState);
42+
hideSystemBars(getWindow());
43+
3844
final Intent launchIntent = getIntent();
3945
if ("com.google.intent.action.TEST_LOOP".equals(launchIntent.getAction())) {
4046
if (Build.VERSION.SDK_INT > 22) {
@@ -158,4 +164,12 @@ public void run() {
158164
}
159165
});
160166
}
167+
168+
private static void hideSystemBars(Window window) {
169+
final WindowInsetsControllerCompat insetController =
170+
WindowCompat.getInsetsController(window, window.getDecorView());
171+
insetController.setSystemBarsBehavior(
172+
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
173+
insetController.hide(WindowInsetsCompat.Type.systemBars());
174+
}
161175
}

testing/scenario_app/android/app/src/main/res/values/styles.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,4 @@
88
<item name="colorAccent">@color/colorAccent</item>
99
</style>
1010

11-
<style name="FullScreenScreenshot">
12-
<item name="android:windowNoTitle">true</item>
13-
<item name="android:windowActionBar">false</item>
14-
<item name="android:windowFullscreen">true</item>
15-
<item name="android:windowContentOverlay">@null</item>
16-
</style>
17-
1811
</resources>

0 commit comments

Comments
 (0)