mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-14 09:54:27 +08:00
Add:创建 flutter go web 版
This commit is contained in:
71
packages/flutter_web/test/widgets/flex_test.dart
Normal file
71
packages/flutter_web/test/widgets/flex_test.dart
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright 2015 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_web/material.dart';
|
||||
import 'package:flutter_web/rendering.dart';
|
||||
|
||||
import 'package:flutter_web_test/flutter_web_test.dart';
|
||||
|
||||
void main() {
|
||||
group('$Row', () {
|
||||
testWidgets('renders Row with 2 text spans', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(flex: 1, child: TestSizedBoxWithElement.expand()),
|
||||
Expanded(flex: 1, child: TestSizedBoxWithElement.expand()),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
final boxes = tester.renderObjectList(find.byType(Expanded)).toList();
|
||||
RenderBox first = boxes[0];
|
||||
expect(first.size, const Size(400.0, 600.0));
|
||||
expect(
|
||||
(first.parentData as FlexParentData).offset, const Offset(0.0, 0.0));
|
||||
|
||||
RenderBox second = boxes[1];
|
||||
expect(second.size, const Size(400.0, 600.0));
|
||||
expect((second.parentData as FlexParentData).offset,
|
||||
const Offset(400.0, 0.0));
|
||||
|
||||
expectCurrentHtml('''
|
||||
<clip style="overflow: hidden"><clip-i></clip-i></clip>
|
||||
<clip style="overflow: hidden"><clip-i></clip-i></clip>
|
||||
''');
|
||||
});
|
||||
});
|
||||
|
||||
group('$Column', () {
|
||||
testWidgets('renders Column with 2 text spans',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(flex: 1, child: TestSizedBoxWithElement.expand()),
|
||||
Expanded(flex: 1, child: TestSizedBoxWithElement.expand()),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
final boxes = tester.renderObjectList(find.byType(Expanded)).toList();
|
||||
RenderBox first = boxes[0];
|
||||
expect(first.size, const Size(800.0, 300.0));
|
||||
expect(
|
||||
(first.parentData as FlexParentData).offset, const Offset(0.0, 0.0));
|
||||
|
||||
RenderBox second = boxes[1];
|
||||
expect(second.size, const Size(800.0, 300.0));
|
||||
expect((second.parentData as FlexParentData).offset,
|
||||
const Offset(0.0, 300.0));
|
||||
|
||||
expectCurrentHtml('''
|
||||
<clip style="overflow: hidden"><clip-i></clip-i></clip>
|
||||
<clip style="overflow: hidden"><clip-i></clip-i></clip>
|
||||
''');
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user