Skip to content

Commit

Permalink
Merge branch 'master' into kotlin-finder
Browse files Browse the repository at this point in the history
  • Loading branch information
truongsinh committed Aug 26, 2019
2 parents 1e696d7 + 1aace44 commit 0ef4251
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 117 deletions.
2 changes: 1 addition & 1 deletion driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"appium",
"flutter"
],
"version": "0.0.17",
"version": "0.0.18",
"author": "TruongSinh Tran-Nguyen <[email protected]>",
"license": "MIT",
"repository": {
Expand Down
217 changes: 101 additions & 116 deletions example/flutter_app_under_test/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,132 +1,117 @@
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:hello_world/stream.dart';

part 'main.g.dart';

void main() {
enableFlutterDriverExtension();
init();
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Counter App',
home: MyHomePage(title: 'Counter App Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
@widget
Widget myApp() => MaterialApp(
title: 'Counter App',
home: MyHomePage(title: 'Counter App Home Page'),
);

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Tooltip(
message: 'counter_tooltip',
child: Text(
'$_counter',
@widget
Widget myHomePage(BuildContext context, {String title}) => Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Tooltip(
message: 'counter_tooltip',
child: StreamBuilder<int>(
stream: counterStream,
builder: (context, snapshot) {
return Text(
'${snapshot.data}',
key: Key('counter'),
style: Theme.of(context).textTheme.display1,
semanticsLabel: 'counter_semantic',
),
),
FlatButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: SecondPage(),
),
)),
);
},
child: Text(
'Go to next route',
key: Key('next_route_key'),
),
),
],
),
),
floatingActionButton: FloatingActionButton(
// Provide a Key to this button. This allows finding this
// specific button inside the test suite, and tapping it.
key: Key('increment'),
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}

class SecondPage extends StatelessWidget {
@override
Widget build(BuildContext context) => ListView(
padding: const EdgeInsets.all(8.0),
children: <Widget>[
Container(
height: 100,
color: Colors.amber[600],
child: const Center(child: Text('This is 2nd route')),
),
Container(
height: 200,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 500,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
);
}
),
Container(
height: 1000,
color: Colors.amber[100],
child: const Center(child: Text('Entry D')),
),
Container(
height: 1000,
color: Colors.amber[100],
child: const Center(
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Sample Input',
),
)),
),
FlatButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: SecondPage(),
),
)),
);
},
child: Text(
'Go to next route',
key: Key('next_route_key'),
),
],
);
}
),
],
),
),
floatingActionButton: FloatingActionButton(
// Provide a Key to this button. This allows finding this
// specific button inside the test suite, and tapping it.
key: Key('increment'),
onPressed: () => plusClickSink.add(null),
tooltip: 'Increment',
child: Icon(Icons.add),
),
);

@widget
Widget secondPage() => ListView(
padding: const EdgeInsets.all(8.0),
children: <Widget>[
Container(
height: 100,
color: Colors.amber[600],
child: const Center(child: Text('This is 2nd route')),
),
Container(
height: 200,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 500,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
),
Container(
height: 1000,
color: Colors.amber[100],
child: const Center(child: Text('Entry D')),
),
Container(
height: 1000,
color: Colors.amber[100],
child: const Center(
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Sample Input',
),
)),
),
],
);
30 changes: 30 additions & 0 deletions example/flutter_app_under_test/lib/main.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions example/flutter_app_under_test/lib/stream.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'dart:async' show StreamSink;

import 'package:rxdart/rxdart.dart'
show BehaviorSubject;

final counterSubject = new BehaviorSubject<int>.seeded(0);
final counterStream = counterSubject.stream;

final plusClickSubject = new BehaviorSubject<void>();
final StreamSink plusClickSink = plusClickSubject;

void init() {
plusClickSubject.stream.withLatestFrom<int, int>(
counterSubject,
(_, a) => a + 1,
).pipe(counterSubject);
}
14 changes: 14 additions & 0 deletions example/flutter_app_under_test/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
functional_widget_annotation:
dependency: "direct main"
description:
name: functional_widget_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.1"
glob:
dependency: transitive
description:
Expand Down Expand Up @@ -266,6 +273,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.1+1"
shelf:
dependency: transitive
description:
Expand Down
5 changes: 5 additions & 0 deletions example/flutter_app_under_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ environment:
sdk: ">=2.1.0 <3.0.0"

dependencies:
functional_widget_annotation: ^0.5.0
rxdart: 0.22.1+1
flutter:
sdk: flutter

Expand All @@ -18,3 +20,6 @@ dev_dependencies:

flutter:
uses-material-design: true

builders:
functional_widget: ^0.6.0

0 comments on commit 0ef4251

Please sign in to comment.