mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Oct 12 10:12am * implicit_semantics_test.dart passes * refactoring * works in nice * minor rename * more doc comments * to be explicit check better * fix test * ++ * ++ * semantics_9_test (BlockSemantics) and implicit_semantics_test are passing * doc updates * tiny refactor * fix static errors in tests * fix gesture detector * ++ * ++ * geometry * ++ * remove noGeometry * revert test * + * all tests but scrolling/clipping pass * clipping works * scrolling halfway * sliver tests pass * ALL TESTS PASS * SemanticsNode changed * docs and tiny fixes * card test * more doc comments * remove missed print * more tests * make test pass on Linux * remove changes to intellij proj file * review comments
95 lines
3.3 KiB
Dart
95 lines
3.3 KiB
Dart
// 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/foundation.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'rendering_tester.dart';
|
|
|
|
void main() {
|
|
test('RenderFittedBox paint', () {
|
|
bool painted;
|
|
RenderFittedBox makeFittedBox() {
|
|
return new RenderFittedBox(
|
|
child: new RenderCustomPaint(
|
|
painter: new TestCallbackPainter(
|
|
onPaint: () { painted = true; }
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
painted = false;
|
|
layout(makeFittedBox(), phase: EnginePhase.paint);
|
|
expect(painted, equals(true));
|
|
|
|
// The RenderFittedBox should not paint if it is empty.
|
|
painted = false;
|
|
layout(makeFittedBox(), constraints: new BoxConstraints.tight(Size.zero), phase: EnginePhase.paint);
|
|
expect(painted, equals(false));
|
|
});
|
|
|
|
test('RenderPhysicalModel compositing on Fuchsia', () {
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
|
|
|
|
final RenderPhysicalModel root = new RenderPhysicalModel(color: const Color(0xffff00ff));
|
|
layout(root, phase: EnginePhase.composite);
|
|
expect(root.needsCompositing, isFalse);
|
|
|
|
// On Fuchsia, the system compositor is responsible for drawing shadows
|
|
// for physical model layers with non-zero elevation.
|
|
root.elevation = 1.0;
|
|
pumpFrame(phase: EnginePhase.composite);
|
|
expect(root.needsCompositing, isTrue);
|
|
|
|
root.elevation = 0.0;
|
|
pumpFrame(phase: EnginePhase.composite);
|
|
expect(root.needsCompositing, isFalse);
|
|
|
|
debugDefaultTargetPlatformOverride = null;
|
|
});
|
|
|
|
test('RenderPhysicalModel compositing on non-Fuchsia', () {
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
|
|
|
final RenderPhysicalModel root = new RenderPhysicalModel(color: const Color(0xffff00ff));
|
|
layout(root, phase: EnginePhase.composite);
|
|
expect(root.needsCompositing, isFalse);
|
|
|
|
// On non-Fuchsia platforms, Flutter draws its own shadows.
|
|
root.elevation = 1.0;
|
|
pumpFrame(phase: EnginePhase.composite);
|
|
expect(root.needsCompositing, isFalse);
|
|
|
|
root.elevation = 0.0;
|
|
pumpFrame(phase: EnginePhase.composite);
|
|
expect(root.needsCompositing, isFalse);
|
|
|
|
debugDefaultTargetPlatformOverride = null;
|
|
});
|
|
|
|
test('RenderSemanticsGestureHandler adds/removes correct semantic actions', () {
|
|
final RenderSemanticsGestureHandler renderObj = new RenderSemanticsGestureHandler(
|
|
onTap: () {},
|
|
onHorizontalDragUpdate: (DragUpdateDetails details) {},
|
|
);
|
|
|
|
SemanticsConfiguration config = new SemanticsConfiguration();
|
|
renderObj.describeSemanticsConfiguration(config);
|
|
expect(config.getActionHandler(SemanticsAction.tap), isNotNull);
|
|
expect(config.getActionHandler(SemanticsAction.scrollLeft), isNotNull);
|
|
expect(config.getActionHandler(SemanticsAction.scrollRight), isNotNull);
|
|
|
|
config = new SemanticsConfiguration();
|
|
renderObj.validActions = <SemanticsAction>[SemanticsAction.tap, SemanticsAction.scrollLeft].toSet();
|
|
|
|
renderObj.describeSemanticsConfiguration(config);
|
|
expect(config.getActionHandler(SemanticsAction.tap), isNotNull);
|
|
expect(config.getActionHandler(SemanticsAction.scrollLeft), isNotNull);
|
|
expect(config.getActionHandler(SemanticsAction.scrollRight), isNull);
|
|
});
|
|
}
|