Skip to content

Commit

Permalink
[lint] fixing lints in test_integration post rebase over stage 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tiholic committed Nov 18, 2020
1 parent 6dac5ea commit fd96591
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:ably_flutter_integration_test/test/test_widget_abstract.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'test_widget_abstract.dart';

class AppKeyProvisionTest extends TestWidget {
AppKeyProvisionTest(TestDispatcherState dispatcher) : super(dispatcher);
const AppKeyProvisionTest(TestDispatcherState dispatcher) : super(dispatcher);

@override
TestWidgetState<TestWidget> createState() => _AppKeyProvisionTestState();
Expand Down
4 changes: 2 additions & 2 deletions test_integration/lib/test/platform_and_ably_version_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:ably_flutter_integration_test/test/test_widget_abstract.dart';
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart' as ably;

import '../test_dispatcher.dart';
import 'test_widget_abstract.dart';

class PlatformAndAblyVersionTest extends TestWidget {
PlatformAndAblyVersionTest(TestDispatcherState dispatcher)
const PlatformAndAblyVersionTest(TestDispatcherState dispatcher)
: super(dispatcher);

@override
Expand Down
20 changes: 8 additions & 12 deletions test_integration/lib/test/realtime_events_test.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:ably_flutter_integration_test/test/test_widget_abstract.dart';
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'test_widget_abstract.dart';

class RealtimeEventsTest extends TestWidget {
RealtimeEventsTest(TestDispatcherState dispatcher) : super(dispatcher);
const RealtimeEventsTest(TestDispatcherState dispatcher) : super(dispatcher);

@override
TestWidgetState<TestWidget> createState() => RealtimeEventsTestState();
Expand Down Expand Up @@ -46,7 +46,7 @@ class RealtimeEventsTestState extends TestWidgetState<RealtimeEventsTest> {
await realtime.connect();
widget.dispatcher.reportLog({'after realtime.connect': ''});

final channel = await realtime.channels.get('events-test');
final channel = realtime.channels.get('events-test');
void recordChannelState() =>
channelStates.add(enumValueToString(channel.state));

Expand Down Expand Up @@ -75,7 +75,7 @@ class RealtimeEventsTestState extends TestWidgetState<RealtimeEventsTest> {
await realtime.close();
await Future.delayed(Duration.zero);
while (realtime.connection.state != ConnectionState.closed) {
await Future.delayed(Duration(seconds: 2));
await Future.delayed(const Duration(seconds: 2));
}
recordChannelState(); // channel: detached
recordConnectionState(); // connection: closed
Expand All @@ -91,26 +91,22 @@ class RealtimeEventsTestState extends TestWidgetState<RealtimeEventsTest> {
});
}

Map<String, dynamic> channelEventToJson(ChannelStateChange e) {
return {
Map<String, dynamic> channelEventToJson(ChannelStateChange e) => {
'event': enumValueToString(e.event),
'current': enumValueToString(e.current),
'previous': enumValueToString(e.previous),
'reason': e.reason.toString(),
'resumed': e.resumed,
};
}

Map<String, dynamic> connectionEventToJson(ConnectionStateChange e) {
return {
Map<String, dynamic> connectionEventToJson(ConnectionStateChange e) => {
'event': enumValueToString(e.event),
'current': enumValueToString(e.current),
'previous': enumValueToString(e.previous),
'reason': e.reason.toString(),
'retryIn': e.retryIn,
};
}
}

String enumValueToString(dynamic value) =>
String enumValueToString(Object value) =>
value.toString().substring(value.toString().indexOf('.') + 1);
12 changes: 6 additions & 6 deletions test_integration/lib/test/realtime_publish_test.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:ably_flutter_integration_test/test/test_widget_abstract.dart';
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'test_widget_abstract.dart';

class RealtimePublishTest extends TestWidget {
RealtimePublishTest(TestDispatcherState dispatcher) : super(dispatcher);
const RealtimePublishTest(TestDispatcherState dispatcher) : super(dispatcher);

@override
TestWidgetState<TestWidget> createState() => RealtimePublishTestState();
Expand Down Expand Up @@ -35,7 +35,7 @@ class RealtimePublishTestState extends TestWidgetState<RealtimePublishTest> {
}

Future<void> realtimeMessagesPublishUtil(Realtime realtime) async {
final name = 'Hello';
const name = 'Hello';
final messageData = [
null, //null
'Ably', //string
Expand All @@ -52,10 +52,10 @@ Future<void> realtimeMessagesPublishUtil(Realtime realtime) async {
] //list of map
];

final channel = await realtime.channels.get('test');
final channel = realtime.channels.get('test');
await channel.publish(); //publish without name and data
await channel.publish(data: messageData[1]); //publish without name
for (var data in messageData) {
for (final data in messageData) {
await channel.publish(name: name, data: data);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'realtime_publish_test.dart';
import 'test_widget_abstract.dart';

Expand Down
4 changes: 2 additions & 2 deletions test_integration/lib/test/realtime_subscribe.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:ably_flutter_integration_test/test/test_widget_abstract.dart';
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'test_widget_abstract.dart';

class RealtimeSubscribeTest extends TestWidget {
const RealtimeSubscribeTest(TestDispatcherState dispatcher)
Expand Down
10 changes: 5 additions & 5 deletions test_integration/lib/test/rest_publish_test.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:ably_flutter_integration_test/test/test_widget_abstract.dart';
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'test_widget_abstract.dart';

class RestPublishTest extends TestWidget {
RestPublishTest(TestDispatcherState dispatcher) : super(dispatcher);
const RestPublishTest(TestDispatcherState dispatcher) : super(dispatcher);

@override
TestWidgetState<TestWidget> createState() => RestPublishTestState();
Expand Down Expand Up @@ -35,7 +35,7 @@ class RestPublishTestState extends TestWidgetState<RestPublishTest> {
}

Future<void> restMessagesPublishUtil(Rest rest) async {
final name = 'Hello';
const name = 'Hello';
final messageData = [
null, //null
'Ably', //string
Expand All @@ -48,7 +48,7 @@ Future<void> restMessagesPublishUtil(Rest rest) async {
final channel = rest.channels.get('test');
await channel.publish(); //publish without name and data
await channel.publish(data: messageData[1]); //publish without name
for(var data in messageData){
for(final data in messageData){
await channel.publish(name: name, data: data);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:ably_flutter_integration_test/test/rest_publish_test.dart';
import 'package:ably_flutter_plugin/ably_flutter_plugin.dart';
import 'package:flutter/widgets.dart';

import '../test_dispatcher.dart';
import 'appkey_provision_helper.dart';
import 'app_key_provision_helper.dart';
import 'rest_publish_test.dart';

class RestPublishWithAuthCallbackTest extends StatefulWidget {
final TestDispatcherState dispatcher;
Expand All @@ -30,7 +30,7 @@ class RestPublishWithAuthCallbackTestState
options: ClientOptions()
..clientId = 'someClientId'
..logLevel = LogLevel.verbose
..authCallback = ((TokenParams params) async {
..authCallback = ((params) async {
authCallbackInvoked = true;
return TokenRequest.fromMap(await getTokenRequest());
}));
Expand Down
23 changes: 11 additions & 12 deletions test_integration/lib/test/test_factory.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import 'package:ably_flutter_integration_test/test/appkey_provision_test.dart';
import 'package:ably_flutter_integration_test/test/platform_and_ably_version_test.dart';
import 'package:ably_flutter_integration_test/test/realtime_events_test.dart';
import 'package:ably_flutter_integration_test/test/realtime_publish_test.dart';
import 'package:ably_flutter_integration_test/test/realtime_publish_with_auth_callback_test.dart';
import 'package:ably_flutter_integration_test/test/realtime_subscribe.dart';
import 'package:ably_flutter_integration_test/test/rest_publish_test.dart';
import 'package:ably_flutter_integration_test/test/rest_publish_with_auth_callback_test.dart';
import 'package:ably_flutter_integration_test/test/test_helper_flutter_error_test.dart';
import 'package:ably_flutter_integration_test/test/test_helper_unhandled_exception_test.dart';
import 'package:ably_flutter_integration_test/test_dispatcher.dart';

import '../test_dispatcher.dart';
import 'app_key_provision_test.dart';
import 'platform_and_ably_version_test.dart';
import 'realtime_events_test.dart';
import 'realtime_publish_test.dart';
import 'realtime_publish_with_auth_callback_test.dart';
import 'realtime_subscribe.dart';
import 'rest_publish_test.dart';
import 'rest_publish_with_auth_callback_test.dart';
import 'test_helper_flutter_error_test.dart';
import 'test_helper_unhandled_exception_test.dart';
import 'test_names.dart';

final testFactory = <String, TestFactory>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestHelperFlutterErrorTestState
extends State<TestHelperFlutterErrorTest> {
@override
Widget build(BuildContext context) {
FlutterError.reportError(FlutterErrorDetails(
FlutterError.reportError(const FlutterErrorDetails(
exception: 'Should become a FlutterError response'));
return Container();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class TestHelperUnhandledExceptionTest extends StatefulWidget {

TestHelperUnhandledExceptionTest(this.dispatcher, {Key key})
: super(key: key) {
// ignore: only_throw_errors
throw 'Unhandled exception';
}

Expand Down
10 changes: 5 additions & 5 deletions test_integration/lib/test_dispatcher.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//ignore_for_file: avoid_print
import 'dart:async';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -60,14 +61,14 @@ class TestDispatcherState extends State<TestDispatcher> {
return _responseCompleter.future;
}

Null _unhandledTestExceptionAndFlutterErrorHandler(
void _unhandledTestExceptionAndFlutterErrorHandler(
Map<String, String> errorMessage) =>
reportTestCompletion({TestControlMessage.errorKey: errorMessage});

final _log = <dynamic>[];

/// Collect log messages.to be sent with the response at the end of the test.
void reportLog(dynamic log) => _log.add(log);
void reportLog(Object log) => _log.add(log);

/// Create a response to a message from the driver reporting the test result.
void reportTestCompletion(Map<String, dynamic> data) {
Expand All @@ -92,13 +93,12 @@ class TestDispatcherState extends State<TestDispatcher> {
///
/// widget.dispatcher.timeout(const Duration(seconds: 3));
///
void timeout(Duration duration) async {
void timeout(Duration duration) =>
unawaited(_responseCompleter.future.timeout(duration, onTimeout: () {
reportTestCompletion(
{TestControlMessage.errorKey: 'Timed out after $duration'});
return null;
}));
}

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -165,7 +165,7 @@ class TestDispatcherState extends State<TestDispatcher> {
/// Used to wire app unhandled exceptions and Flutter errors to be reported back
/// to the test driver.
class ErrorHandler {
Null Function(Map<String, String> message) callback;
void Function(Map<String, String> message) callback;

void onFlutterError(FlutterErrorDetails details) {
if (callback == null) {
Expand Down
2 changes: 1 addition & 1 deletion test_integration/test_driver/basic_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'tests_abstract.dart';
import 'tests_config.dart';

void main() => runTests(groupName: TestGroup.BasicTests);
void main() => runTests(groupName: TestGroup.basicTests);
2 changes: 1 addition & 1 deletion test_integration/test_driver/realtime_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'tests_abstract.dart';
import 'tests_config.dart';

void main() => runTests(groupName: TestGroup.Realtime);
void main() => runTests(groupName: TestGroup.realtime);
2 changes: 1 addition & 1 deletion test_integration/test_driver/rest_publish_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'tests_abstract.dart';
import 'tests_config.dart';

void main() => runTests(groupName: TestGroup.Rest);
void main() => runTests(groupName: TestGroup.rest);
2 changes: 1 addition & 1 deletion test_integration/test_driver/test_helper_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'tests_abstract.dart';
import 'tests_config.dart';

void main() => runTests(groupName: TestGroup.HelperTests);
void main() => runTests(groupName: TestGroup.helperTests);
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//ignore_for_file: avoid_print
import 'package:ably_flutter_integration_test/driver_data_handler.dart';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';


Future testPlatformAndAblyVersion(FlutterDriver driver) async {
final data = {'message': 'foo'};
final message =
TestControlMessage(TestName.platformAndAblyVersion, payload: data);
TestControlMessage(TestName.platformAndAblyVersion, payload: data);

final response = await getTestResponse(driver, message);

Expand All @@ -21,22 +21,20 @@ Future testPlatformAndAblyVersion(FlutterDriver driver) async {
Future testDemoDependencies(FlutterDriver driver) async {
final data = {'message': 'foo'};
final message =
TestControlMessage(TestName.appKeyProvisioning, payload: data);
TestControlMessage(TestName.appKeyProvisioning, payload: data);

final response = await getTestResponse(driver, message);

print("response.payload ${response.payload}");
print('response.payload ${response.payload}');

expect(response.testName, message.testName);

expect(response.payload['appKey'], isA<String>());
expect(response.payload['appKey'], isNotEmpty);


print('response.payload:: ${response.payload}');


var tokenRequest = response.payload['tokenRequest'];
final tokenRequest = response.payload['tokenRequest'];

expect(tokenRequest['keyName'], isA<String>());
expect(tokenRequest['keyName'], isNotEmpty);
Expand All @@ -47,7 +45,7 @@ Future testDemoDependencies(FlutterDriver driver) async {
expect(tokenRequest['mac'], isA<String>());
expect(tokenRequest['mac'], isNotEmpty);

expect(tokenRequest['timestamp'], isA<int>());;
expect(tokenRequest['timestamp'], isA<int>());

expect(tokenRequest['ttl'], isA<int>());
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

Future testShouldReportUnhandledException(FlutterDriver driver) async {
final message = TestControlMessage(TestName.testHelperUnhandledExceptionTest);
const message = TestControlMessage(TestName.testHelperUnhandledExceptionTest);

final response = await getTestResponse(driver, message);

Expand All @@ -16,7 +16,7 @@ Future testShouldReportUnhandledException(FlutterDriver driver) async {
// FlutterError seems to break the test app
// and needs to be run last
Future testShouldReportFlutterError(FlutterDriver driver) async {
final message = TestControlMessage(TestName.testHelperFlutterErrorTest);
const message = TestControlMessage(TestName.testHelperFlutterErrorTest);

final response = await getTestResponse(driver, message);

Expand Down
Loading

0 comments on commit fd96591

Please sign in to comment.