Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix lints #419

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ExpectEnvironmentText extends Action {
/// Called when it executes the action in a flow file.
@override
Future<bool> execute(Tester tester) async {
if (!await ExpectVisible(
text: "Environment: (Development|Staging|Production|None){1}",
if (!await const ExpectVisible(
text: 'Environment: (Development|Staging|Production|None){1}',
).execute(tester)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion example/actions/expect_environment_text/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
fluttium: ^0.1.0-dev.1
flutter:
sdk: flutter
fluttium: ^0.1.0-dev.1
2 changes: 1 addition & 1 deletion example/lib/simple_menu/view/simple_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _SimpleMenuPageState extends State<SimpleMenuPage> {
child: Row(
children: [Text('Menu Item 1')],
),
)
),
],
context: context,
position: _getRelativeRect(widgetKey),
Expand Down
2 changes: 1 addition & 1 deletion packages/fluttium/lib/src/actions/clear_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ClearText extends Action {
SystemChannels.textInput.codec.encodeMethodCall(
const MethodCall('TextInputClient.performSelectors', [
-1,
['deleteBackward:']
['deleteBackward:'],
]),
),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/fluttium/lib/src/actions/swipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:fluttium/src/actions/scroll.dart';
/// ```
/// {@endtemplate}
class Swipe extends Scroll {
/// {@template swipe}
/// {@macro swipe}
Swipe({
required super.within,
required super.until,
Expand Down
4 changes: 2 additions & 2 deletions packages/fluttium/lib/src/registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Registry {
timeout: timeout,
),
aliases: const [
Alias(['in'], #within)
Alias(['in'], #within),
],
),
'swipe': ActionRegistration(
Expand All @@ -57,7 +57,7 @@ class Registry {
timeout: timeout,
),
aliases: const [
Alias(['in'], #within)
Alias(['in'], #within),
],
),
};
Expand Down
14 changes: 7 additions & 7 deletions packages/fluttium/lib/src/tester.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Tester {

final Registry _registry;

SemanticsOwner get _semanticsOwner => _binding.pipelineOwner.semanticsOwner!;
SemanticsOwner? get _semanticsOwner =>
RendererBinding.instance.rootPipelineOwner.semanticsOwner;
nohli marked this conversation as resolved.
Show resolved Hide resolved

/// The current screen's media query information.
MediaQueryData get mediaQuery =>
Expand Down Expand Up @@ -103,23 +104,23 @@ class Tester {
///
/// The [text] can be a [String] that can also be used as a [RegExp].
Future<SemanticsNode?> find(String text, {Duration? timeout}) async {
var nodes = _findNodes(_semanticsOwner.rootSemanticsNode!, text);
var nodes = _findNodes(_semanticsOwner?.rootSemanticsNode, text);
nohli marked this conversation as resolved.
Show resolved Hide resolved

final end = clock.now().add(timeout ?? const Duration(seconds: 10));
while (nodes.isEmpty) {
await pump();
if (clock.now().isAfter(end)) {
return null;
}
nodes = _findNodes(_semanticsOwner.rootSemanticsNode!, text);
nodes = _findNodes(_semanticsOwner?.rootSemanticsNode, text);
nohli marked this conversation as resolved.
Show resolved Hide resolved
}

return nodes.first;
}

List<SemanticsNode> _findNodes(SemanticsNode node, String text) {
List<SemanticsNode> _findNodes(SemanticsNode? node, String text) {
final nodes = <SemanticsNode>[];
node.visitChildren((n) {
node?.visitChildren((n) {
// Add all descendants that match the pattern.
if (!n.mergeAllDescendantsIntoThisNode) {
nodes.addAll(_findNodes(n, text));
Expand Down Expand Up @@ -169,8 +170,7 @@ class Tester {

/// Wait for the semantics tree to be fully build.
Future<void> ready() async {
while (_binding.pipelineOwner.semanticsOwner == null ||
_binding.pipelineOwner.semanticsOwner!.rootSemanticsNode == null) {
while (_semanticsOwner?.rootSemanticsNode == null) {
nohli marked this conversation as resolved.
Show resolved Hide resolved
await _binding.endOfFrame;
}
nohli marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Matcher get isDeleteBackward {
'method': 'TextInputClient.performSelectors',
'args': [
-1,
['deleteBackward:']
['deleteBackward:'],
],
});

Expand Down
2 changes: 1 addition & 1 deletion packages/fluttium/test/helpers/matchers/is_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Matcher isText(String text) {
TextEditingValue(
text: text,
selection: TextSelection.collapsed(offset: text.length),
).toJSON()
).toJSON(),
],
});

Expand Down
6 changes: 3 additions & 3 deletions packages/fluttium/test/src/registry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ void main() {
'action',
_TestActionWithArguments.new,
aliases: [
Alias(['withKey'], #key)
Alias(['withKey'], #key),
],
);

expect(registry.actions.containsKey('action'), isTrue);
expect(
registry.actions['action']!.aliases,
equals([
Alias(['withKey'], #key)
Alias(['withKey'], #key),
]),
);
});
Expand Down Expand Up @@ -130,7 +130,7 @@ void main() {
'action',
_TestActionWithArguments.new,
aliases: [
Alias(['withKey'], #key)
Alias(['withKey'], #key),
],
);

Expand Down
19 changes: 14 additions & 5 deletions packages/fluttium/test/src/tester_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class _MockRegistry extends Mock implements Registry {}

class _MockChannelBuffers extends Mock implements ChannelBuffers {}

class _MockPipelineOwner extends Mock implements PipelineOwner {}
class _MockPipelineOwner extends Mock implements PipelineOwner {
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return super.toString();
}
}

class _MockSemanticsOwner extends Mock implements SemanticsOwner {}

Expand Down Expand Up @@ -302,7 +307,8 @@ void main() {
semanticsOwner = _MockSemanticsOwner();

final pipelineOwner = _MockPipelineOwner();
when(() => binding.pipelineOwner).thenReturn(pipelineOwner);
when(() => RendererBinding.instance.rootPipelineOwner)
nohli marked this conversation as resolved.
Show resolved Hide resolved
.thenReturn(pipelineOwner);
when(() => pipelineOwner.semanticsOwner).thenReturn(semanticsOwner);

rootNode = MockSemanticsNode();
Expand Down Expand Up @@ -488,7 +494,8 @@ void main() {
semanticsOwner = _MockSemanticsOwner();

final pipelineOwner = _MockPipelineOwner();
when(() => binding.pipelineOwner).thenReturn(pipelineOwner);
when(() => RendererBinding.instance.rootPipelineOwner)
nohli marked this conversation as resolved.
Show resolved Hide resolved
.thenReturn(pipelineOwner);
when(() => pipelineOwner.semanticsOwner).thenReturn(semanticsOwner);

rootNode = MockSemanticsNode();
Expand All @@ -498,7 +505,8 @@ void main() {
test('resolve when ready', () {
expect(tester.ready(), completes);

verify(() => binding.pipelineOwner.semanticsOwner).called(equals(2));
verify(() => RendererBinding.instance.rootPipelineOwner.semanticsOwner)
nohli marked this conversation as resolved.
Show resolved Hide resolved
.called(equals(2));
verify(() => semanticsOwner.rootSemanticsNode).called(equals(1));
});

Expand All @@ -510,7 +518,8 @@ void main() {

expect(tester.ready(), completes);

verify(() => binding.pipelineOwner.semanticsOwner).called(equals(2));
verify(() => RendererBinding.instance.rootPipelineOwner.semanticsOwner)
nohli marked this conversation as resolved.
Show resolved Hide resolved
.called(equals(2));
verify(() => semanticsOwner.rootSemanticsNode).called(equals(1));
verify(() => binding.endOfFrame).called(equals(1));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,9 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
fileStep.copyWith(
status: StepStatus.done,
files: {
'file.txt': [1, 2, 3]
'file.txt': [1, 2, 3],
},
)
),
]);
await Future<void>.delayed(Duration.zero);

Expand Down Expand Up @@ -834,7 +834,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.running),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand All @@ -845,7 +845,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.failed),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand Down Expand Up @@ -911,7 +911,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.running),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand All @@ -923,7 +923,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.done),
step3.copyWith(status: StepStatus.done)
step3.copyWith(status: StepStatus.done),
]);
await Future<void>.delayed(Duration.zero);

Expand Down Expand Up @@ -970,7 +970,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.running),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand All @@ -982,7 +982,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.failed),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand Down Expand Up @@ -1087,7 +1087,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.running),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand Down Expand Up @@ -1132,7 +1132,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.running),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand All @@ -1143,7 +1143,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
stepStateController.add([
step1.copyWith(status: StepStatus.done),
step2.copyWith(status: StepStatus.failed),
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand Down Expand Up @@ -1235,11 +1235,11 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
step1.copyWith(
status: StepStatus.done,
files: {
'test_file': [1, 2, 3]
'test_file': [1, 2, 3],
},
),
step2,
step3
step3,
]);
await Future<void>.delayed(Duration.zero);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Some output
'b': {
'd': 5,
'e': 6,
'f': [7, 8, 9]
'f': [7, 8, 9],
},
'c': 4,
}),
Expand Down
Loading
Loading