Skip to content

Instantly share code, notes, and snippets.

@Pyozer
Last active June 19, 2019 10:18
Show Gist options
  • Select an option

  • Save Pyozer/3d3830ea74c7d069dc5f91b5e3f6641b to your computer and use it in GitHub Desktop.

Select an option

Save Pyozer/3d3830ea74c7d069dc5f91b5e3f6641b to your computer and use it in GitHub Desktop.
SplashScreen codes, one that is not working and another that's works.
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
void main() {
group('Testing app', () {
FlutterDriver driver;
// Connect to the Flutter driver before running any tests.
setUpAll(() async {
driver = await FlutterDriver.connect();
});
// Close the connection to the driver after the tests have completed.
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
Future<void> tap(SerializableFinder finder) async {
await driver.waitFor(finder);
await driver.tap(finder);
}
// This test is working
test('Check flutter driver health', () async {
Health health = await driver.checkHealth();
expect(health.status, HealthStatus.ok);
});
// This test is working
test('Test onboarding', () async {
await tap(find.text("Skip"));
await tap(find.text("Done"));
});
// This test is not working if there is the Align widget
test('Test splashscreen', () async {
await driver.waitFor(find.text("Loading"));
});
// This test is not working, but I think it's same issue as the splashscreen
test('Click on site ESCP Europe - République', () async {
await Future.delayed(const Duration(seconds: 10));
await tap(find.text("ESCP Europe - République"));
});
// This test is working
test('Test to like multiple times a site', () async {
for (var i = 0; i < 100; i++) {
await tap(find.byType("FavButton"));
await Future.delayed(Duration(milliseconds: 300));
}
});
// This test is working
test('Test booking', () async {
await tap(find.text("Book"));
await tap(find.text("Group study rooms"));
await tap(find.byValueKey("bookRes750"));
await tap(find.byValueKey("booking_email"));
await driver.enterText("jeancharles.msse@gmail.com");
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: Alignment.center,
children: [
SplashScreenLogo(),
SafeArea(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snap) {
if (!snap.hasData) return Text("");
return Text(
'${snap.data.version} (${snap.data.buildNumber})',
textAlign: TextAlign.end,
style: const TextStyle(color: Colors.black26),
);
},
),
const Expanded(child: SizedBox.shrink()),
Text(
"Loading",
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18.0),
),
const SizedBox(height: 24.0),
_isLoading
? const SizedBox.shrink()
: Center(child: RetryButton(onPress: _initAllData)),
],
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: LinearProgressIndicator(value: _isLoading ? null : 0),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: Alignment.center,
children: [
SplashScreenLogo(),
SafeArea(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snap) {
if (!snap.hasData) return Text("");
return Text(
'${snap.data.version} (${snap.data.buildNumber})',
textAlign: TextAlign.end,
style: const TextStyle(color: Colors.black26),
);
},
),
const Expanded(child: SizedBox.shrink()),
Text(
"Loading",
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18.0),
),
const SizedBox(height: 24.0),
_isLoading
? const SizedBox.shrink()
: Center(child: RetryButton(onPress: _initAllData)),
],
),
),
),
/*
If Align widget is remove, or LinearProgressIndicator is replaced by a Container, it's working
Align(
alignment: Alignment.bottomCenter,
child: Container(height: 20.0, color: Colors.red),
),
*/
],
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment