remove personal repo and replace with trivial example for smoke test (#28386)
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
// Copyright 2019 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:inject/inject.dart';
|
||||
|
||||
// This is a compile-time generated file and does not exist in source.
|
||||
import 'coffee_app.inject.dart' as generated; // ignore: uri_does_not_exist
|
||||
import 'src/coffee.dart';
|
||||
|
||||
@module
|
||||
class PourOverCoffeeModule {
|
||||
@provide
|
||||
@brandName
|
||||
String provideBrand() => 'Coffee by Flutter Inc.';
|
||||
|
||||
@provide
|
||||
@modelName
|
||||
String provideModel() => 'PourOverSupremeFiesta';
|
||||
|
||||
@provide
|
||||
@asynchronous
|
||||
Future<Heater> provideHeater() async => Stove();
|
||||
|
||||
@provide
|
||||
Pump providePump(Heater heater) => NoOpPump();
|
||||
}
|
||||
|
||||
class NoOpPump extends Pump {
|
||||
@override
|
||||
void pump() {
|
||||
print('nothing to pump...');
|
||||
}
|
||||
}
|
||||
|
||||
class Stove extends Heater {
|
||||
@override
|
||||
bool get isHot => _isHot;
|
||||
bool _isHot = false;
|
||||
|
||||
@override
|
||||
void off() {
|
||||
_isHot = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void on() {
|
||||
_isHot = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Injector(<Type>[PourOverCoffeeModule])
|
||||
abstract class CoffeeApp {
|
||||
static final Future<CoffeeApp> Function(PourOverCoffeeModule) create = generated.CoffeeApp$Injector.create;
|
||||
|
||||
@provide
|
||||
CoffeeMaker getCoffeeMaker();
|
||||
}
|
||||
@@ -4,18 +4,13 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
|
||||
import 'coffee_app.dart';
|
||||
import 'src/coffee.dart';
|
||||
import 'message.dart' as generated; // ignore: uri_does_not_exist
|
||||
|
||||
Future<void> main() async {
|
||||
enableFlutterDriverExtension();
|
||||
coffeeApp = await CoffeeApp.create(PourOverCoffeeModule());
|
||||
runApp(ExampleWidget());
|
||||
}
|
||||
|
||||
CoffeeApp coffeeApp;
|
||||
|
||||
class ExampleWidget extends StatefulWidget {
|
||||
@override
|
||||
_ExampleWidgetState createState() => _ExampleWidgetState();
|
||||
@@ -34,9 +29,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
||||
RaisedButton(
|
||||
child: const Text('Press Button, Get Coffee'),
|
||||
onPressed: () async {
|
||||
final CoffeeMaker coffeeMaker = coffeeApp.getCoffeeMaker();
|
||||
setState(() {
|
||||
_message = coffeeMaker.brew();
|
||||
_message = generated.message;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
1
dev/integration_tests/codegen/lib/message.spec
Normal file
1
dev/integration_tests/codegen/lib/message.spec
Normal file
@@ -0,0 +1 @@
|
||||
final String message = 'Thanks for using PourOverSupremeFiesta by Coffee by Flutter Inc.';
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2019 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:inject/inject.dart';
|
||||
|
||||
const Qualifier brandName = Qualifier(#brandName);
|
||||
const Qualifier modelName = Qualifier(#modelName);
|
||||
|
||||
class CoffeeMaker {
|
||||
@provide
|
||||
CoffeeMaker(this._heater, this._pump, this._brand, this._model);
|
||||
|
||||
final Heater _heater;
|
||||
final Pump _pump;
|
||||
|
||||
@modelName
|
||||
final String _model;
|
||||
|
||||
@brandName
|
||||
final String _brand;
|
||||
|
||||
String brew() {
|
||||
_heater.on();
|
||||
_pump.pump();
|
||||
print(' [_]P coffee! [_]P');
|
||||
final String message = 'Thanks for using $_model by $_brand';
|
||||
_heater.off();
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Heater {
|
||||
void on();
|
||||
void off();
|
||||
bool get isHot;
|
||||
}
|
||||
|
||||
abstract class Pump {
|
||||
void pump();
|
||||
}
|
||||
@@ -10,11 +10,6 @@ dependencies:
|
||||
sdk: flutter
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
# TODO(jonahwilliams): replace with pub version when everything is compatible
|
||||
inject:
|
||||
git:
|
||||
url: https://github.com/jonahwilliams/inject.dart
|
||||
path: package/inject
|
||||
|
||||
async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -76,11 +71,9 @@ dev_dependencies:
|
||||
yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
builders:
|
||||
# TODO(jonahwilliams): replace with pub version when everything is compatible
|
||||
inject_generator:
|
||||
git:
|
||||
url: https://github.com/jonahwilliams/inject.dart
|
||||
path: package/inject_generator
|
||||
# Note: path is relative from generated directory
|
||||
simple_codegen:
|
||||
path: ../../../simple_codegen
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
@@ -12,6 +12,10 @@ void main() {
|
||||
driver = await FlutterDriver.connect();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await driver.close();
|
||||
});
|
||||
|
||||
test('Can execute generated code', () async {
|
||||
const String button = 'Press Button, Get Coffee';
|
||||
await driver.tap(find.text(button));
|
||||
|
||||
Reference in New Issue
Block a user