| // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file |
| // for details. 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:analysis_server/src/services/correction/assist.dart'; |
| import 'package:analyzer_plugin/utilities/assist/assist.dart'; |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| |
| import 'assist_processor.dart'; |
| |
| main() { |
| defineReflectiveSuite(() { |
| defineReflectiveTests(FlutterWrapCenterTest); |
| }); |
| } |
| |
| @reflectiveTest |
| class FlutterWrapCenterTest extends AssistProcessorTest { |
| @override |
| AssistKind get kind => DartAssistKind.FLUTTER_WRAP_CENTER; |
| |
| test_aroundCenter() async { |
| addFlutterPackage(); |
| await resolveTestUnit(''' |
| import 'package:flutter/widgets.dart'; |
| class FakeFlutter { |
| main() { |
| return /*caret*/Center(); |
| } |
| } |
| '''); |
| await assertNoAssist(); |
| } |
| |
| test_aroundContainer() async { |
| addFlutterPackage(); |
| await resolveTestUnit(''' |
| import 'package:flutter/widgets.dart'; |
| class FakeFlutter { |
| main() { |
| return /*caret*/Container(); |
| } |
| } |
| '''); |
| await assertHasAssist(''' |
| import 'package:flutter/widgets.dart'; |
| class FakeFlutter { |
| main() { |
| return Center(child: Container()); |
| } |
| } |
| '''); |
| } |
| |
| test_aroundNamedConstructor() async { |
| addFlutterPackage(); |
| await resolveTestUnit(''' |
| import 'package:flutter/widgets.dart'; |
| |
| class MyWidget extends StatelessWidget { |
| MyWidget.named(); |
| |
| Widget build(BuildContext context) => null; |
| } |
| |
| main() { |
| return MyWidget./*caret*/named(); |
| } |
| '''); |
| await assertHasAssist(''' |
| import 'package:flutter/widgets.dart'; |
| |
| class MyWidget extends StatelessWidget { |
| MyWidget.named(); |
| |
| Widget build(BuildContext context) => null; |
| } |
| |
| main() { |
| return Center(child: MyWidget.named()); |
| } |
| '''); |
| } |
| |
| test_assignment() async { |
| addFlutterPackage(); |
| await resolveTestUnit(''' |
| import 'package:flutter/widgets.dart'; |
| |
| main() { |
| Widget w; |
| w = /*caret*/Container(); |
| } |
| '''); |
| await assertHasAssist(''' |
| import 'package:flutter/widgets.dart'; |
| |
| main() { |
| Widget w; |
| w = Center(child: Container()); |
| } |
| '''); |
| } |
| |
| test_expressionFunctionBody() async { |
| addFlutterPackage(); |
| await resolveTestUnit(''' |
| import 'package:flutter/widgets.dart'; |
| class FakeFlutter { |
| main() => /*caret*/Container(); |
| } |
| '''); |
| await assertHasAssist(''' |
| import 'package:flutter/widgets.dart'; |
| class FakeFlutter { |
| main() => Center(child: Container()); |
| } |
| '''); |
| } |
| } |