Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot committed Nov 12, 2024
1 parent a504319 commit e5e9d13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
24 changes: 18 additions & 6 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
Expand Down Expand Up @@ -43,7 +45,7 @@ void main() {
await tester.tap(devicesButton);
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAny);
await tester.pumpAndSettle(const Duration(seconds: 20));
await tester.pumpAndSettle();
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAtLeast(2));

Expand All @@ -65,10 +67,13 @@ void main() {

final portScanButton = find.byKey(WidgetKey.portScanButton.key);
await tester.tap(portScanButton);
await tester.pumpAndSettle();
await tester.pumpAndSettle(const Duration(seconds: 4));
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAny);
});

testWidgets('port scan returns open port for google.com', (tester) async {
testWidgets('port scan returns open port for popular domains',
(tester) async {
// Load app widget.
await tester.pumpWidget(const MyApp(true));
await tester.pumpAndSettle();
Expand All @@ -83,8 +88,15 @@ void main() {
await tester.tap(scanForOpenPortsButton);
await tester.pumpAndSettle();
expect(find.byType(AppBar), findsOne);

final googleChip = find.byKey(WidgetKey.googleChip.key);
final chips = [
WidgetKey.googleChip.key,
WidgetKey.amazonChip.key,
WidgetKey.appleChip.key,
WidgetKey.cloudflareChip.key,
WidgetKey.youtubeChip.key
];

final googleChip = find.byKey(chips[Random().nextInt(5)]);
await tester.tap(googleChip);
await tester.pumpAndSettle();

Expand All @@ -98,7 +110,7 @@ void main() {

final portScanButton = find.byKey(WidgetKey.portScanButton.key);
await tester.tap(portScanButton);
await tester.pumpAndSettle(const Duration(seconds: 20));
await tester.pumpAndSettle(const Duration(seconds: 4));
await tester.pump();
//TODO: not passing in github actions
expect(find.byType(AdaptiveListTile), findsAny);
Expand Down
15 changes: 0 additions & 15 deletions lib/pages/network_troubleshoot/port_scan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,6 @@ class _PortScanPageState extends State<PortScanPage>
return Scaffold(
appBar: AppBar(
title: const Text('Open Ports Scanner'),
actions: [
if (_completed)
const SizedBox()
else
Container(
margin: const EdgeInsets.only(right: 20.0),
child: CircularPercentIndicator(
radius: 10.0,
lineWidth: 2.5,
percent: _progress / 100,
backgroundColor: Colors.grey,
progressColor: Colors.white,
),
),
],
),
body: FutureBuilder<Map<String, Port>>(
future: PortDescLoader('assets/ports_lists.json').load(),
Expand Down

0 comments on commit e5e9d13

Please sign in to comment.