Skip to content
Snippets Groups Projects
Commit f7c638ef authored by Steffen Meschkat's avatar Steffen Meschkat Committed by CQ bot account: commit-bot@chromium.org
Browse files

[e2e] add end to end test for the terminal product

The test verifies that after reboot, the screen is not
black. It could be used for more than one product, but is configured
for now to test the terminal product.

The test is in the directory src/end_to_end_tests. The directory
src/ is organized by areas, but end to end tests by definition span
areas, so they get their own area under src.

That the test is added to the terminal product for now only makes it
build when the build configuration is terminal.*. It doesn't cause
the test to be executed by a CI/CQ builder of that product. That requires
that the builder is configured to pick up tests with the label assigned
to the test, e2e-terminal.

How to execute the test on a linux workstation:

  fx set terminal.astro
  fx build
  fx reboot -r
  fx pave -1
  FUCHSIA_IPV4_ADDR=$(buildtools/linux-x64/dev_finder list) \
  FUCHSIA_SSH_KEY=${PWD}/.ssh/pkey \
  FUCHSIA_TEST_OUTDIR=${PWD}/outdir \
  ./out/default/host_x64/screen_is_not_black_test

This is the output:

  00:00 +0: screen_is_not_black_test the startup screen is not black
  Target device: 192.168.1.231
  Try 0 at starting sl4f.
  Running over ssh: run fuchsia-pkg://fuchsia.com/sl4f#meta/sl4f.cmx
  SL4F has started.
  Saw a screen that is not black.
  Running over ssh: killall sl4f.cmx
  00:05 +1: All tests passed!

INTK-1031 #comment This change adds the test to run in the new builder.

Change-Id: I9bfe3055f12fd3dc58f94d57f82d15eadbb3137a
parent 1d2f41e6
No related branches found
No related tags found
No related merge requests found
......@@ -16,3 +16,16 @@ cache_package_labels += [
]
universe_package_labels += [ "//bundles:tools" ]
# TODO(IN-1097): Support a package server rather than building these
# into the image via preinstall+monolith.
cache_package_labels += [
"//garnet/packages/tools:sl4f",
]
# E2E Product Tests. They don't produce fuchsia packages, but host executables,
# and must just be included somewhere in the build configuration of the product.
universe_package_labels += [
"//src/end_to_end_tests/screen_is_not_black:test",
]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/dart/test.gni")
import("//build/testing/environments.gni")
dart_test("screen_is_not_black_test") {
sources = [
"screen_is_not_black_test.dart",
]
deps = [
"//sdk/testing/sl4f/client",
"//third_party/dart-pkg/pub/image",
"//third_party/dart-pkg/pub/matcher",
"//third_party/dart-pkg/pub/test",
]
_untagged_envs = [nuc_env, astro_env]
environments = []
foreach(env, _untagged_envs) {
if (!defined(env.tags)) {
env.tags = []
}
env.tags += ["e2e-terminal"]
environments += [env]
}
}
group("test") {
testonly = true
deps = [
":screen_is_not_black_test($host_toolchain)",
]
}
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
include: ../../../topaz/tools/analysis_options.yaml
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:test/test.dart';
import 'package:image/image.dart';
import 'package:sl4f/sl4f.dart' as sl4f;
int _ignoreAlpha(int pixel) => pixel & 0x00ffffff;
/// Returns true if [image] is all black.
bool _isAllBlack(Image image) =>
image.data.every((pixel) => _ignoreAlpha(pixel) == 0);
/// How many times to check the screen.
const _tries = 10;
/// How long to wait between screen checks.
const _delay = Duration(seconds: 10);
void main() {
sl4f.Sl4f sl4fDriver;
sl4f.Scenic scenicDriver;
setUp(() async {
sl4fDriver = sl4f.Sl4f.fromEnvironment();
await sl4fDriver.startServer();
scenicDriver = sl4f.Scenic(sl4fDriver);
});
tearDown(() async {
await sl4fDriver.stopServer();
sl4fDriver.close();
});
test('the startup screen is not black', () async {
for (var attempt = 0; attempt < _tries; attempt++) {
final screen = await scenicDriver.takeScreenshot(dumpName: 'screen');
if (!_isAllBlack(screen)) {
print('Saw a screen that is not black.');
return;
}
await Future.delayed(_delay);
}
fail('Screen was all black.');
},
// This is a large test that waits for the DUT to come up and to start
// rendering something.
timeout: Timeout.none);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment