Skip to content

Commit

Permalink
Idk why it no work
Browse files Browse the repository at this point in the history
  • Loading branch information
Person8790 committed Nov 22, 2024
1 parent 8aaa5ff commit 6034219
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions flutter_app/lib/widgets/return_to_launch_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ class ReturnToLaunchTemplate extends StatefulWidget {
class ReturnToLaunchButton extends State<ReturnToLaunchTemplate> {
String buttonLabel = "Return to Launch";

void updateButton() {
setState(() {
buttonLabel = "Sent"; // Triggers a rebuild
});
}

// Returns a button that tells the drone to return to launch
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () async {
bool result = await widget.returnToLaunchCommand
.returnNoQueue(widget.systemID, widget.componentID);
if (result) {
buttonLabel = "Sent";
if (true) {
updateButton();
}
;
},
child: Text(buttonLabel));
}
Expand Down
12 changes: 9 additions & 3 deletions flutter_app/test/widget/return_to_launch_widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() {
// Waits for all frames and animations to settle
await tester.pumpAndSettle();
expect(find.byType(ElevatedButton), findsOneWidget);
expect(find.text("Return To Launch"), findsOneWidget);
expect(find.text("Return to Launch"), findsOneWidget);
});

testWidgets("Button sends MavLink command", (WidgetTester tester) async {
Expand All @@ -37,13 +37,19 @@ void main() {
body: ReturnToLaunchTemplate(
returnToLaunchCommand: command,
systemID: 1,
componentID: 0))));
componentID: 0,
key: UniqueKey()))));

await tester.pumpAndSettle();
expect(find.byType(ElevatedButton), findsOneWidget);

await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
expect(find.text("Sent"), findsOneWidget);
debugPrint((tester
.widget<ElevatedButton>(find.byType(ElevatedButton))
.child as Text)
.data);
expect(find.text("sent"), findsOneWidget);
});
});
}

0 comments on commit 6034219

Please sign in to comment.