rough first cut of integration tests
This commit is contained in:
parent
cde82ed7b3
commit
f503be6a0d
|
@ -5,11 +5,13 @@
|
|||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import 'package:flutter_app/main.dart' as app;
|
||||
import 'package:flutter_app/main_test.dart' as app;
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
@ -17,21 +19,35 @@ void main() {
|
|||
}
|
||||
|
||||
void _testMain() {
|
||||
testWidgets('New profile pane smoke test', (WidgetTester tester) async {
|
||||
testWidgets('Blocked message rejection test', (WidgetTester tester) async {
|
||||
final String testerProfile = "mr roboto";
|
||||
final String blockedProfile = "rudey";
|
||||
|
||||
// start the app and render a few frames
|
||||
app.main();
|
||||
await tester.pump(); await tester.pump(); await tester.pump();
|
||||
//await tester.pumpAndSettle();
|
||||
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
//await tester.pumpAndSettle(Duration(seconds: 3), EnginePhase.sendSemanticsUpdate, Duration(seconds: 30));
|
||||
for (var i = 0; i < 30; i++) {
|
||||
print("$i pump");
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
// log in to a profile with a blocked contact
|
||||
await tester.tap(find.text(testerProfile));
|
||||
await tester.pump(); await tester.pump(); await tester.pump();
|
||||
expect(find.byIcon(Icons.block), findsOneWidget);
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
// expect(find.text('0'), findsNothing);
|
||||
expect(find.byKey(Key('addprofile')), findsOneWidget);
|
||||
// use the debug control to inject a message from the contact
|
||||
await tester.tap(find.byIcon(Icons.bug_report));
|
||||
await tester.pump(); await tester.pump(); await tester.pump();
|
||||
|
||||
|
||||
// screenshot test
|
||||
print(Directory.current);
|
||||
//Directory.current = "/home/erinn/AndroidStudioProjects/flwtch/integration_test";
|
||||
await expectLater(find.byKey(Key('app')), matchesGoldenFile('blockedcontact.png'));
|
||||
// any active message badges?
|
||||
expect(find.text('1'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
|
@ -80,6 +80,7 @@ class FlwtchState extends State<Flwtch> {
|
|||
Provider.of<Settings>(context).initPackageInfo();
|
||||
return Consumer<Settings>(
|
||||
builder: (context, opaque, child) => MaterialApp(
|
||||
key: Key('app'),
|
||||
locale: Provider.of<Settings>(context).locale,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app/errorHandler.dart';
|
||||
import 'package:flutter_app/settings.dart';
|
||||
import 'licenses.dart';
|
||||
import 'main.dart';
|
||||
import 'opaque.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:glob/glob.dart';
|
||||
import 'package:glob/list_local_fs.dart';
|
||||
|
||||
var globalSettings = Settings(Locale("en", ''), Opaque.dark);
|
||||
var globalErrorHandler = ErrorHandler();
|
||||
|
||||
void main() {
|
||||
LicenseRegistry.addLicense(() => licenses());
|
||||
DiskAssetBundle.loadGlob(['profiles/*.png']).then((assetBundle) {
|
||||
runApp(DefaultAssetBundle(
|
||||
bundle: assetBundle,
|
||||
child: Flwtch(),
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
class DiskAssetBundle extends CachingAssetBundle {
|
||||
static const _assetManifestDotJson = 'AssetManifest.json';
|
||||
|
||||
/// Creates a [DiskAssetBundle] by loading [globs] of assets under `assets/`.
|
||||
static Future<AssetBundle> loadGlob(
|
||||
Iterable<String> globs, {
|
||||
String from = 'assets',
|
||||
}) async {
|
||||
final cache = <String, ByteData>{};
|
||||
for (final pattern in globs) {
|
||||
await for (final path in Glob(pattern).list(root: from)) {
|
||||
if (path is File) {
|
||||
final bytes = await (path as File).readAsBytes() as Uint8List;
|
||||
cache[path.path] = ByteData.view(bytes.buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
final manifest = <String, List<String>>{};
|
||||
cache.forEach((key, _) {
|
||||
manifest[key] = [key];
|
||||
});
|
||||
|
||||
cache[_assetManifestDotJson] = ByteData.view(
|
||||
Uint8List.fromList(jsonEncode(manifest).codeUnits).buffer,
|
||||
);
|
||||
|
||||
return DiskAssetBundle._(cache);
|
||||
}
|
||||
|
||||
final Map<String, ByteData> _cache;
|
||||
|
||||
DiskAssetBundle._(this._cache);
|
||||
|
||||
@override
|
||||
Future<ByteData> load(String key) async {
|
||||
return _cache[key];
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app/widgets/contactrow.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../main.dart';
|
||||
import 'addcontactview.dart';
|
||||
import '../model.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
@ -23,6 +24,10 @@ class _ContactsViewState extends State<ContactsView> {
|
|||
icon: Icon(Icons.copy),
|
||||
onPressed: _copyOnion,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.bug_report),
|
||||
onPressed: _debugFakeMessage,
|
||||
)
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
|
@ -63,4 +68,8 @@ class _ContactsViewState extends State<ContactsView> {
|
|||
// Find the Scaffold in the widget tree and use it to show a SnackBar.
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
void _debugFakeMessage() {
|
||||
Provider.of<ProfileInfoState>(context, listen:false).contactList.getContact("44pknjvf4ju46nbuyn5getuayb6dj6z6zoppl56syn7pmscptoahlaid").unreadMessages++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,11 +93,12 @@ class _MessageViewState extends State<MessageView> {
|
|||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: ctrlrCompose,
|
||||
focusNode: focusNode,
|
||||
textInputAction: TextInputAction.send,
|
||||
onSubmitted: _sendMessage,
|
||||
child: TextField(
|
||||
key: Key('txtCompose'),
|
||||
controller: ctrlrCompose,
|
||||
focusNode: focusNode,
|
||||
textInputAction: TextInputAction.send,
|
||||
onSubmitted: _sendMessage,
|
||||
)),
|
||||
SizedBox(
|
||||
width: 90,
|
||||
|
|
|
@ -115,6 +115,13 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
glob:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: glob
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -35,6 +35,7 @@ dependencies:
|
|||
ffi: ^1.0.0
|
||||
path_provider: ^2.0.0
|
||||
|
||||
glob: any
|
||||
# todo: flutter_driver causes version conflict. eg https://github.com/flutter/flutter/issues/44829
|
||||
# testing-related deps
|
||||
integration_test: ^1.0.0
|
||||
|
|
|
@ -125,8 +125,10 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
|
||||
// empty string
|
||||
formKey.currentState.validate();
|
||||
formKey.currentState.validate(); //(ctrlr1.clear() doesn't trigger validate like keypress does)
|
||||
await tester.pumpAndSettle();
|
||||
await expectLater(find.byWidget(testHarness), matchesGoldenFile(file('form_final')));
|
||||
expect(find.text(strFail1), findsOneWidget);
|
||||
expect(find.text(strFail2), findsNothing);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue