From 5b5aa254574e4e34957cb76b668b2bdfcbfaf3fb Mon Sep 17 00:00:00 2001 From: mattsarett Date: Thu, 18 May 2017 13:07:45 -0400 Subject: [PATCH] Add manual test for color space rendering behavior (#10000) * Add manual test for color space rendering behavior * Remove unneeded assets * Add test for color demo * Drag up to scroll down --- dev/manual_tests/lib/color_testing_demo.dart | 95 +++++++++++++++++++ .../test/color_testing_demo_test.dart | 22 +++++ 2 files changed, 117 insertions(+) create mode 100644 dev/manual_tests/lib/color_testing_demo.dart create mode 100644 dev/manual_tests/test/color_testing_demo_test.dart diff --git a/dev/manual_tests/lib/color_testing_demo.dart b/dev/manual_tests/lib/color_testing_demo.dart new file mode 100644 index 00000000000..6e3b7da1547 --- /dev/null +++ b/dev/manual_tests/lib/color_testing_demo.dart @@ -0,0 +1,95 @@ +// Copyright 2017 The Chromium 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:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +class ColorTestingDemo extends StatelessWidget { + const ColorTestingDemo({ Key key }) : super(key: key); + + static const String routeName = '/color_demo'; + + @override + Widget build(BuildContext context) => new ColorDemoHome(); +} + +const double _kPageMaxWidth = 500.0; + +class ColorDemoHome extends StatelessWidget { + @override + Widget build(BuildContext context) { + return new Scaffold( + appBar: new AppBar(title: const Text('Color Demo')), + body: new ListView( + padding: const EdgeInsets.all(5.0), + children: [ + new Image.network('https://flutter.github.io/assets-for-api-docs/tests/colors/gbr.png'), + new Image.network('https://flutter.github.io/assets-for-api-docs/tests/colors/tf.png'), + new Image.network('https://flutter.github.io/assets-for-api-docs/tests/colors/wide-gamut.png'), + const GradientRow(leftColor: const Color(0xFFFF0000), rightColor: const Color(0xFF00FF00)), + const GradientRow(leftColor: const Color(0xFF0000FF), rightColor: const Color(0xFFFFFF00)), + const GradientRow(leftColor: const Color(0xFFFF0000), rightColor: const Color(0xFF0000FF)), + const GradientRow(leftColor: const Color(0xFF00FF00), rightColor: const Color(0xFFFFFF00)), + const GradientRow(leftColor: const Color(0xFF0000FF), rightColor: const Color(0xFF00FF00)), + const GradientRow(leftColor: const Color(0xFFFF0000), rightColor: const Color(0xFFFFFF00)), + + // For the following pairs, the blend result should match the opaque color. + const ColorRow(color: const Color(0xFFBCBCBC)), + const ColorRow(color: const Color(0x80000000)), + + const ColorRow(color: const Color(0xFFFFBCBC)), + const ColorRow(color: const Color(0x80FF0000)), + + const ColorRow(color: const Color(0xFFBCFFBC)), + const ColorRow(color: const Color(0x8000FF00)), + + const ColorRow(color: const Color(0xFFBCBCFF)), + const ColorRow(color: const Color(0x800000FF)), + ], + ), + ); + } +} + +class GradientRow extends StatelessWidget { + const GradientRow({ Key key, this.rightColor, this.leftColor }) : super(key: key); + + final Color leftColor; + final Color rightColor; + + @override + Widget build(BuildContext context) { + return new Container( + height: 100.0, + decoration: new BoxDecoration( + gradient: new LinearGradient( + begin: FractionalOffset.topLeft, + end: FractionalOffset.bottomRight, + colors: [ leftColor, rightColor ], + ), + ), + ); + } +} + +class ColorRow extends StatelessWidget { + const ColorRow({ Key key, this.color }) : super(key: key); + + final Color color; + + @override + Widget build(BuildContext context) { + return new Container( + height: 100.0, + color: color, + ); + } +} + +void main() { + runApp(new MaterialApp( + title: 'Color Testing Demo', + home: new ColorDemoHome(), + )); +} diff --git a/dev/manual_tests/test/color_testing_demo_test.dart b/dev/manual_tests/test/color_testing_demo_test.dart new file mode 100644 index 00000000000..f7cb3973bb3 --- /dev/null +++ b/dev/manual_tests/test/color_testing_demo_test.dart @@ -0,0 +1,22 @@ +// Copyright 2017 The Chromium 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:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import '../lib/color_testing_demo.dart' as color_testing_demo; + +void main() { + testWidgets("Color testing demo smoke test", (WidgetTester tester) async { + color_testing_demo.main(); // builds the app and schedules a frame but doesn't trigger one + await tester.pump(); // see https://github.com/flutter/flutter/issues/1865 + await tester.pump(); // triggers a frame + + await tester.dragFrom(const Offset(0.0, 500.0), const Offset(0.0, 0.0)); // scrolls down + await tester.pump(); + + await tester.dragFrom(const Offset(0.0, 500.0), const Offset(0.0, 0.0)); // scrolls down + await tester.pump(); + }); +}